Package com.jme3.material
Class TechniqueDef
java.lang.Object
com.jme3.material.TechniqueDef
Describes a technique definition.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDescribes light rendering mode.static enumDefine in what space the light data should be sent to the shader.static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default technique name.static final intVersion #1: Separate shader language for each shader source. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSerialization only.TechniqueDef(String name, int sortId) Creates a new technique definition. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddShaderParamDefine(String paramName, VarType paramType, String defineName) Adds a define linked to a material parameter.intaddShaderUnmappedDefine(String defineName, VarType defineType) Add an unmapped define which can only be set by define ID.booleanaddWorldParam(String name) Adds a new world parameter by the given name.clone()Create a define list with the size matching the number of defines on this technique.getDefineIdType(int defineId) Get the type of a particular define.String[]Get the names of all defines declared on this technique definition.VarType[]Get the types of all defines declared on this technique definition.Returns the language of the fragment shader used in this technique.Returns the name of the fragment shader used by the technique, or null if no fragment shader is specified.Returns the light mode.Returns the space in which the light data should be passed to the shader.getLogic()getName()Returns the name of this technique as specified in the J3MD file.Returns the render state that this technique is usingGets therenderer capabilitiesthat are required by this technique.getShader(AssetManager assetManager, EnumSet<Caps> rendererCaps, DefineList defines) getShaderParamDefine(String paramName) Returns the define name which the given material parameter influences.getShaderParamDefineId(String paramName) Get the define ID for a given material parameter.getShaderProgramLanguage(Shader.ShaderType shaderType) Returns the language for each shader programReturns the Enum containing the ShaderProgramLanguages;getShaderProgramName(Shader.ShaderType shaderType) Returns the name for each shader programReturns the Enum containing the ShaderProgramNames;Returns the shadow mode.intReturns the language of the vertex shader used in this technique.Returns the name of the vertex shader used by the technique, or null if no vertex shader is specified.floatreturns the weight of the technique defReturns a list of world parameters that are used by this technique definition.booleanReturns true if this technique should not be used to render.booleanReturns true if this technique uses Shader Nodes, false otherwise.voidread(JmeImporter im) voidsetForcedRenderState(RenderState forcedRenderState) voidsetLightMode(TechniqueDef.LightMode lightMode) Set the light modevoidsetLightSpace(TechniqueDef.LightSpace lightSpace) Sets the space in which the light data should be passed to the shader.voidsetLogic(TechniqueDefLogic logic) voidsetNoRender(boolean noRender) Sets if this technique should not be used to render.voidsetRenderState(RenderState renderState) Sets the render state that this technique is using.voidsetShaderFile(String vertexShader, String fragmentShader, String vertLanguage, String fragLanguage) Sets the shaders that this technique definition will use.voidsetShaderFile(EnumMap<Shader.ShaderType, String> shaderNames, EnumMap<Shader.ShaderType, String> shaderLanguages) Sets the shaders that this technique definition will use.voidsetShaderGenerationInfo(ShaderGenerationInfo shaderGenerationInfo) voidsetShaderNodes(List<ShaderNode> shaderNodes) voidsetShaderPrologue(String shaderPrologue) Set a string which is prepended to every shader used by this technique.voidsetShadowMode(TechniqueDef.ShadowMode shadowMode) Set the shadow mode.toString()voidwrite(JmeExporter ex)
-
Field Details
-
SAVABLE_VERSION
public static final int SAVABLE_VERSIONVersion #1: Separate shader language for each shader source.- See Also:
-
DEFAULT_TECHNIQUE_NAME
The default technique name. The technique with this name is selected if no specific technique is requested by the user. Currently set to "Default".- See Also:
-
-
Constructor Details
-
TechniqueDef
Creates a new technique definition.Used internally by the J3M/J3MD loader.
- Parameters:
name- The name of the techniquesortId- a unique ID for sorting
-
TechniqueDef
protected TechniqueDef()Serialization only. Do not use.
-
-
Method Details
-
getSortId
public int getSortId()- Returns:
- A unique sort ID. No other technique definition can have the same ID.
-
getName
Returns the name of this technique as specified in the J3MD file. Default techniques have the nameDEFAULT_TECHNIQUE_NAME.- Returns:
- the name of this technique
-
getLightMode
Returns the light mode.- Returns:
- the light mode.
- See Also:
-
setLightMode
Set the light mode- Parameters:
lightMode- the light mode- See Also:
-
setLogic
-
getLogic
-
getShadowMode
Returns the shadow mode.- Returns:
- the shadow mode.
-
setShadowMode
Set the shadow mode.- Parameters:
shadowMode- the shadow mode.- See Also:
-
getRenderState
Returns the render state that this technique is using- Returns:
- the render state that this technique is using
- See Also:
-
setRenderState
Sets the render state that this technique is using.- Parameters:
renderState- the render state that this technique is using.- See Also:
-
setNoRender
public void setNoRender(boolean noRender) Sets if this technique should not be used to render.- Parameters:
noRender- not render or render ?- See Also:
-
isNoRender
public boolean isNoRender()Returns true if this technique should not be used to render. (e.g. to not render a material with default technique)- Returns:
- true if this technique should not be rendered, false otherwise.
-
isUsingShaderNodes
public boolean isUsingShaderNodes()Returns true if this technique uses Shader Nodes, false otherwise.- Returns:
- true if this technique uses Shader Nodes, false otherwise.
-
getRequiredCaps
Gets therenderer capabilitiesthat are required by this technique.- Returns:
- the required renderer capabilities
-
setShaderFile
public void setShaderFile(String vertexShader, String fragmentShader, String vertLanguage, String fragLanguage) Sets the shaders that this technique definition will use.- Parameters:
vertexShader- The name of the vertex shaderfragmentShader- The name of the fragment shadervertLanguage- The vertex shader languagefragLanguage- The fragment shader language
-
setShaderPrologue
Set a string which is prepended to every shader used by this technique. Typically this is used for preset defines.- Parameters:
shaderPrologue- The prologue to append before the technique's shaders.
-
getShaderPrologue
- Returns:
- the shader prologue which is prepended to every shader.
-
getShaderParamDefine
Returns the define name which the given material parameter influences.- Parameters:
paramName- The parameter name to look up- Returns:
- The define name
- See Also:
-
getShaderParamDefineId
Get the define ID for a given material parameter.- Parameters:
paramName- The parameter name to look up- Returns:
- The define ID, or null if not found.
-
getDefineIdType
Get the type of a particular define.- Parameters:
defineId- The define ID to lookup.- Returns:
- The type of the define, or null if not found.
-
addShaderParamDefine
Adds a define linked to a material parameter.Any time the material parameter on the parent material is altered, the appropriate define on the technique will be modified as well. When set, the material parameter will be mapped to an integer define, typically
1if it is set, unless it is an integer or a float, in which case it will be converted into an integer.- Parameters:
paramName- The name of the material parameter to link to.paramType- The type of the material parameter to link to.defineName- The name of the define parameter, e.g. USE_LIGHTING
-
addShaderUnmappedDefine
Add an unmapped define which can only be set by define ID. Unmapped defines are used by technique renderers to configure the shader internally before rendering.- Parameters:
defineName- The define name to createdefineType- the type for the new define- Returns:
- The define ID of the created define
-
getDefineNames
Get the names of all defines declared on this technique definition. The defines are returned in order of declaration.- Returns:
- the names of all defines declared.
-
getDefineTypes
Get the types of all defines declared on this technique definition. The types are returned in order of declaration.- Returns:
- the types of all defines declared.
-
createDefineList
Create a define list with the size matching the number of defines on this technique.- Returns:
- a define list with the size matching the number of defines on this technique.
-
getShader
-
setShaderFile
public void setShaderFile(EnumMap<Shader.ShaderType, String> shaderNames, EnumMap<Shader.ShaderType, String> shaderLanguages) Sets the shaders that this technique definition will use.- Parameters:
shaderNames- EnumMap containing all shader names for this stageshaderLanguages- EnumMap containing all shader languages for this stage
-
getFragmentShaderName
Returns the name of the fragment shader used by the technique, or null if no fragment shader is specified.- Returns:
- the name of the fragment shader to be used.
-
getVertexShaderName
Returns the name of the vertex shader used by the technique, or null if no vertex shader is specified.- Returns:
- the name of the vertex shader to be used.
-
getFragmentShaderLanguage
Returns the language of the fragment shader used in this technique.- Returns:
- the name of the language (such as "GLSL100")
-
getVertexShaderLanguage
Returns the language of the vertex shader used in this technique.- Returns:
- the name of the language (such as "GLSL100")
-
getShaderProgramLanguage
Returns the language for each shader program- Parameters:
shaderType- Fragment/Vertex/etcetera- Returns:
- the name of the language
-
getShaderProgramName
Returns the name for each shader program- Parameters:
shaderType- Fragment/Vertex/etcetera- Returns:
- the name of the program
-
getWeight
public float getWeight()returns the weight of the technique def- Returns:
- the weight
-
addWorldParam
Adds a new world parameter by the given name.- Parameters:
name- The world parameter to add.- Returns:
- True if the world parameter name was found and added to the list of world parameters, false otherwise.
-
getForcedRenderState
-
setForcedRenderState
-
getWorldBindings
Returns a list of world parameters that are used by this technique definition.- Returns:
- The list of world parameters
-
write
- Specified by:
writein interfaceSavable- Throws:
IOException
-
read
- Specified by:
readin interfaceSavable- Throws:
IOException
-
getShaderNodes
-
setShaderNodes
-
getShaderProgramNames
Returns the Enum containing the ShaderProgramNames;- Returns:
- the pre-existing EnumMap
-
getShaderProgramLanguages
Returns the Enum containing the ShaderProgramLanguages;- Returns:
- the pre-existing EnumMap
-
getShaderGenerationInfo
-
setShaderGenerationInfo
-
toString
-
getLightSpace
Returns the space in which the light data should be passed to the shader.- Returns:
- the light space
-
setLightSpace
Sets the space in which the light data should be passed to the shader.- Parameters:
lightSpace- the light space
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-