Package com.jme3.shader
Class Glsl150ShaderGenerator
java.lang.Object
com.jme3.shader.ShaderGenerator
com.jme3.shader.Glsl100ShaderGenerator
com.jme3.shader.Glsl150ShaderGenerator
- Direct Known Subclasses:
Glsl300ShaderGenerator
This shader Generator can generate Vertex and Fragment shaders from
ShaderNodes for GLSL 1.5
-
Field Summary
Fields inherited from class com.jme3.shader.Glsl100ShaderGenerator
inPosTmpFields inherited from class com.jme3.shader.ShaderGenerator
assetManager, indent, NAME_SPACE_GLOBAL, NAME_SPACE_MAT_PARAM, NAME_SPACE_VERTEX_ATTRIBUTE, NAME_SPACE_WORLD_PARAM, techniqueDef -
Constructor Summary
ConstructorsConstructorDescriptionGlsl150ShaderGenerator(AssetManager assetManager) Creates a Glsl150ShaderGenerator -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddeclareAttribute(StringBuilder source, ShaderNodeVariable var) Declares an attributeprotected voiddeclareVarying(StringBuilder source, ShaderNodeVariable var, boolean input) Declares a varyingprotected voidgenerateEndOfMainSection(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) Generates the end of the shader main section.protected voidgenerateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) generates the start of the shader main section.protected voidgenerateUniforms(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) generates the uniforms declaration for a shader of the given type.protected Stringreturns the language + version of the shader should be something like "GLSL100" for glsl 1.0 "GLSL150" for glsl 1.5.protected voidinitVariable(StringBuilder source, ShaderNodeVariable var, String initValue) Append a variable initialization to the codeMethods inherited from class com.jme3.shader.Glsl100ShaderGenerator
appendIndent, appendOutput, comment, declareGlobalPosition, declareVariable, declareVariable, declareVariable, declareVariable, declareVariable, endCondition, fixInPositionType, generateAttributes, generateDeclarativeSection, generateNodeMainSection, generateUniforms, generateVaryings, getAppendableNameSpace, indent, isVarying, isWorldOrMaterialParam, map, replace, replaceVariableName, startCondition, unIndent, updateDefinesNameMethods inherited from class com.jme3.shader.ShaderGenerator
appendNodeDeclarationAndMain, buildShader, findShaderIndexFromVersion, generateDeclarationAndMainBody, generateShader, initialize
-
Constructor Details
-
Glsl150ShaderGenerator
Creates a Glsl150ShaderGenerator- Parameters:
assetManager- the assetmanager
-
-
Method Details
-
getLanguageAndVersion
Description copied from class:ShaderGeneratorreturns the language + version of the shader should be something like "GLSL100" for glsl 1.0 "GLSL150" for glsl 1.5.- Overrides:
getLanguageAndVersionin classGlsl100ShaderGenerator- Parameters:
type- the shader type for which the version should be returned.- Returns:
- the shaderLanguage and version.
-
declareAttribute
Declares an attribute in glsl 1.5 attributes are prefixed with the "in" keyword and not the "attribute" keyword- Overrides:
declareAttributein classGlsl100ShaderGenerator- Parameters:
source- the StringBuilder to usevar- the variable to declare as an attribute
-
declareVarying
Declares a varying 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)- Overrides:
declareVaryingin classGlsl100ShaderGenerator- Parameters:
source- the StringBuilder to usevar- the variable to declare as a varyinginput- a boolean set to true if the varying is an input. This in not used in this implementation, but can be used in overriding implementations.
-
generateUniforms
protected void generateUniforms(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) Description copied from class:ShaderGeneratorgenerates the uniforms declaration for a shader of the given type.- Overrides:
generateUniformsin classGlsl100ShaderGenerator- Parameters:
source- the source StringBuilder to append generated code.info- the ShaderGenerationInfo.type- the shader type the uniforms have to be generated for.
-
generateStartOfMainSection
protected void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) generates the start of the shader main section. this method is responsible of appending the "void main(){" in the shader and declaring all global outputs of the shader Shader outputs are declared and initialized inside the main section Fragment shader outputs are declared before the "void main(){" with the "out" keyword. After the "void main(){", the vertex output are declared and initialized and the fragment outputs are declared.- Overrides:
generateStartOfMainSectionin classGlsl100ShaderGenerator- Parameters:
source- the StringBuilder to append generated code.info- the ShaderGenerationInfo.type- the shader type the section has to be generated for.
-
generateEndOfMainSection
protected void generateEndOfMainSection(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) Generates the end of the shader main section. This method is responsible for appending the last "}" in the shader and mapping all global outputs of the shader. outputs are assigned to built in glsl output. then the main section is closed This code accounts for multi render target and correctly output to gl_FragData if several output are declared for the fragment shader only vertex shader output are mapped here, since fragment shader outputs must have been mapped in the main section.- Overrides:
generateEndOfMainSectionin classGlsl100ShaderGenerator- Parameters:
source- the StringBuilder to append generated code.info- the ShaderGenerationInfo.type- the shader type the section has to be generated for.
-
initVariable
Append a variable initialization to the code- Parameters:
source- the StringBuilder to usevar- the variable to initializeinitValue- the init value to assign to the variable
-