private void writeWorldParams(TechniqueDef techniqueDef, OutputStreamWriter out) throws IOException { out.write(" WorldParameters {\n"); for (UniformBinding uniformBinding : techniqueDef.getWorldBindings()) { out.write(" "); out.write(uniformBinding.toString()); out.write("\n"); } out.write(" }\n\n"); }
public void addUniformBinding(UniformBinding binding){ String uniformName = "g_" + binding.name(); Uniform uniform = uniforms.get(uniformName); if (uniform == null) { uniform = new Uniform(); uniform.name = uniformName; uniform.binding = binding; uniforms.put(uniformName, uniform); boundUniforms.add(uniform); } }
/** * Adds a new world parameter by the given name. * * @param name The world parameter to add. * @return True if the world parameter name was found and added * to the list of world parameters, false otherwise. */ public boolean addWorldParam(String name) { try { worldBinds.add(UniformBinding.valueOf(name)); return true; } catch (IllegalArgumentException ex) { return false; } }
/** * updates the right variable of the given mapping from a UniformBinding (a * WorldParam) it checks if the uniform hasn't already been loaded, add it * to the maps if not. * * @param param the WorldParam UniformBinding * @param mapping the mapping * @param map the map of uniforms to search into * @return true if the param was added to the map */ protected boolean updateRightFromUniforms(UniformBinding param, VariableMapping mapping, Map<String, DeclaredVariable> map) { ShaderNodeVariable right = mapping.getRightVariable(); String name = param.toString(); DeclaredVariable dv = map.get(name); if (dv == null) { right.setType(param.getGlslType()); right.setName(name); right.setPrefix("g_"); dv = new DeclaredVariable(right); map.put(right.getName(), dv); dv.addNode(shaderNode); mapping.setRightVariable(right); return true; } dv.addNode(shaderNode); mapping.setRightVariable(dv.var); return false; }
@Override public int hashCode() { int hash = 5; hash = 31 * hash + (this.value != null ? this.value.hashCode() : 0); hash = 31 * hash + (this.varType != null ? this.varType.hashCode() : 0); hash = 31 * hash + (this.binding != null ? this.binding.hashCode() : 0); return hash; }
/** * updates the right variable of the given mapping from a UniformBinding (a * WorldParam) it checks if the uniform hasn't already been loaded, add it * to the maps if not. * * @param param the WorldParam UniformBinding * @param mapping the mapping * @param map the map of uniforms to search into * @return true if the param was added to the map */ protected boolean updateRightFromUniforms(UniformBinding param, VariableMapping mapping, Map<String, DeclaredVariable> map) { ShaderNodeVariable right = mapping.getRightVariable(); String name = param.toString(); DeclaredVariable dv = map.get(name); if (dv == null) { right.setType(param.getGlslType()); right.setName(name); right.setPrefix("g_"); dv = new DeclaredVariable(right); map.put(right.getName(), dv); dv.addNode(shaderNode); mapping.setRightVariable(right); return true; } dv.addNode(shaderNode); mapping.setRightVariable(dv.var); return false; }
@Override public int hashCode() { int hash = 5; hash = 31 * hash + (this.value != null ? this.value.hashCode() : 0); hash = 31 * hash + (this.varType != null ? this.varType.hashCode() : 0); hash = 31 * hash + (this.binding != null ? this.binding.hashCode() : 0); return hash; }
/** * finds an UniformBinding representing a WorldParam from the techniqueDef * * @param varName the name of the WorldParam * @return the corresponding UniformBinding to the WorldParam */ protected UniformBinding findWorldParam(String varName) { for (UniformBinding worldParam : techniqueDef.getWorldBindings()) { if (varName.equals(worldParam.toString())) { return worldParam; } } return null; }
public void addUniformBinding(UniformBinding binding){ String uniformName = "g_" + binding.name(); Uniform uniform = uniforms.get(uniformName); if (uniform == null) { uniform = new Uniform(); uniform.name = uniformName; uniform.binding = binding; uniforms.put(uniformName, uniform); boundUniforms.add(uniform); } }
/** * Adds a new world parameter by the given name. * * @param name The world parameter to add. * @return True if the world parameter name was found and added * to the list of world parameters, false otherwise. */ public boolean addWorldParam(String name) { try { worldBinds.add(UniformBinding.valueOf(name)); return true; } catch (IllegalArgumentException ex) { return false; } }
private void writeWorldParams(TechniqueDef techniqueDef, OutputStreamWriter out) throws IOException { out.write(" WorldParameters {\n"); for (UniformBinding uniformBinding : techniqueDef.getWorldBindings()) { out.write(" "); out.write(uniformBinding.toString()); out.write("\n"); } out.write(" }\n\n"); }
private void loadShader(AssetManager manager) { // recompute define list DefineList allDefines = new DefineList(); allDefines.addFrom(def.getShaderPresetDefines()); allDefines.addFrom(defines); ShaderKey key = new ShaderKey(def.getVertexShaderName(), def.getFragmentShaderName(), allDefines, def.getShaderLanguage()); shader = manager.loadShader(key); if (shader == null) { logger.warning("Failed to reload shader!"); return; } // refresh the uniform links //owner.updateUniformLinks(); // register the world bound uniforms worldBindUniforms.clear(); for (UniformBinding binding : def.getWorldBindings()) { Uniform uniform = shader.getUniform("g_" + binding.name()); uniform.setBinding(binding); if (uniform != null) { worldBindUniforms.add(uniform); } } needReload = false; }
/** * Adds a new world parameter by the given name. * * @param name The world parameter to add. * @return True if the world parameter name was found and added * to the list of world parameters, false otherwise. */ public boolean addWorldParam(String name) { if (worldBinds == null){ worldBinds = new ArrayList<UniformBinding>(); } try { worldBinds.add( UniformBinding.valueOf(name) ); return true; } catch (IllegalArgumentException ex){ return false; } }
/** * finds an UniformBinding representing a WorldParam from the techniqueDef * * @param varName the name of the WorldParam * @return the corresponding UniformBinding to the WorldParam */ protected UniformBinding findWorldParam(String varName) { for (UniformBinding worldParam : techniqueDef.getWorldBindings()) { if (varName.equals(worldParam.toString())) { return worldParam; } } return null; }