/** * Called by the object manager to reset all object IDs. This causes * the shader to be reuploaded to the GPU incase the display was restarted. */ @Override public void resetObject() { this.id = -1; for (ShaderSource source : shaderSourceList){ source.resetObject(); } setUpdateNeeded(); }
@Override protected void generateUniforms(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { generateCompatibilityDefines(source, type); super.generateUniforms(source, info, type); }
/** * replaces a variable name in a shaderNode source code by prefixing it * with its nameSpace and "_" if needed. * @param nodeSource the source to modify * @param var the variable to replace * @return the modified source */ protected String replaceVariableName(String nodeSource, ShaderNodeVariable var) { String namePrefix = getAppendableNameSpace(var); String newName = namePrefix + var.getName(); nodeSource = replace(nodeSource, var, newName); return nodeSource; }
private void clearUniformsSetByCurrent(Shader shader) { ListMap<String, Uniform> uniforms = shader.getUniformMap(); int size = uniforms.size(); for (int i = 0; i < size; i++) { Uniform u = uniforms.getValue(i); u.clearSetByCurrentMaterial(); } }
/** * declares a variable, embed in a conditional block if needed * @param source the StringBuilder to use * @param var the variable to declare * @param appendNameSpace true to append the nameSpace + "_" */ protected void declareVariable(StringBuilder source, ShaderNodeVariable var, boolean appendNameSpace) { declareVariable(source, var, appendNameSpace, null); }
public void set(int id, int val) { rangeCheck(id); isSet |= (1L << id); values[id] = val; }
/** * Set the timer that should be used to query the time based * {@link UniformBinding}s for material world parameters. * * @param timer The timer to query time world parameters */ public void setTimer(Timer timer) { uniformBindingManager.setTimer(timer); }
/** * Internal use only. Sets the world matrix to use for future * rendering. This has no effect unless objects are rendered manually * using {@link Material#render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager) }. * Using {@link #renderGeometry(com.jme3.scene.Geometry) } will * override this value. * * @param mat The world matrix to set */ public void setWorldMatrix(Matrix4f mat) { uniformBindingManager.setWorldMatrix(mat); }
/** * {@inheritDoc} in glsl 1.5 varying are prefixed with the "in" or "out" * keyword and not the "varying" keyword. * * "in" is used for Fragment shader (maybe Geometry shader later) "out" is * used for Vertex shader (maybe Geometry shader later) */ @Override protected void declareVarying(StringBuilder source, ShaderNodeVariable var, boolean input) { declareVariable(source, var, true, input ? "in" : "out"); }
/** * Internal use only. * Updates the given list of uniforms with {@link UniformBinding uniform bindings} * based on the current world state. */ public void updateUniformBindings(Shader shader) { uniformBindingManager.updateUniformBindings(shader); }
@Override public void resetObject() { this.id = -1; setUpdateNeeded(); }
/** * declares a variable, embed in a conditional block if needed. the namespace is appended with "_" * @param source the StringBuilder to use * @param var the variable to declare */ protected void declareVariable(StringBuilder source, ShaderNodeVariable var) { declareVariable(source, var, true, null); }
public void unset(int id) { rangeCheck(id); isSet &= ~(1L << id); values[id] = 0; }
/** * declares a variable, embed in a conditional block if needed. the namespace is appended with "_" * @param source the StringBuilder to use * @param var the variable to declare * @param value the initialization value to assign the variable */ protected void declareVariable(StringBuilder source, ShaderNodeVariable var, String value) { declareVariable(source, var, value, true, null); }
/** * Declares an attribute * @param source the StringBuilder to use * @param var the variable to declare as an attribute */ protected void declareAttribute(StringBuilder source, ShaderNodeVariable var) { declareVariable(source, var, false, "attribute"); }
/** * Declares a varying * @param source the StringBuilder to use * @param var the variable to declare as a varying * @param input a boolean set to true if the this varying is an input. * this in not used in this implementation but can be used in overriding * implementation */ protected void declareVarying(StringBuilder source, ShaderNodeVariable var, boolean input) { declareVariable(source, var, true, "varying"); }