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
inPosTmp
Fields 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
ConstructorDescriptionGlsl150ShaderGenerator
(AssetManager assetManager) Creates a Glsl150ShaderGenerator -
Method Summary
Modifier and TypeMethodDescriptionprotected void
declareAttribute
(StringBuilder source, ShaderNodeVariable var) Declares an attributeprotected void
declareVarying
(StringBuilder source, ShaderNodeVariable var, boolean input) Declares a varyingprotected void
generateEndOfMainSection
(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) Generates the end of the shader main section.protected void
generateStartOfMainSection
(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) generates the start of the shader main section.protected void
generateUniforms
(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) generates the uniforms declaration for a shader of the given type.protected String
returns the language + version of the shader should be something like "GLSL100" for glsl 1.0 "GLSL150" for glsl 1.5.protected void
initVariable
(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, updateDefinesName
Methods 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:ShaderGenerator
returns the language + version of the shader should be something like "GLSL100" for glsl 1.0 "GLSL150" for glsl 1.5.- Overrides:
getLanguageAndVersion
in 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:
declareAttribute
in 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:
declareVarying
in 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:ShaderGenerator
generates the uniforms declaration for a shader of the given type.- Overrides:
generateUniforms
in 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:
generateStartOfMainSection
in 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:
generateEndOfMainSection
in 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
-