Package com.jme3.material
Class TechniqueDef
java.lang.Object
com.jme3.material.TechniqueDef
Describes a technique definition.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Describes light rendering mode.static enum
Define in what space the light data should be sent to the shader.static enum
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default technique name.static final int
Version #1: Separate shader language for each shader source. -
Constructor Summary
ModifierConstructorDescriptionprotected
Serialization only.TechniqueDef
(String name, int sortId) Creates a new technique definition. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addShaderParamDefine
(String paramName, VarType paramType, String defineName) Adds a define linked to a material parameter.int
addShaderUnmappedDefine
(String defineName, VarType defineType) Add an unmapped define which can only be set by define ID.boolean
addWorldParam
(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 capabilities
that 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.int
Returns 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.float
returns the weight of the technique defReturns a list of world parameters that are used by this technique definition.boolean
Returns true if this technique should not be used to render.boolean
Returns true if this technique uses Shader Nodes, false otherwise.void
read
(JmeImporter im) void
setForcedRenderState
(RenderState forcedRenderState) void
setLightMode
(TechniqueDef.LightMode lightMode) Set the light modevoid
setLightSpace
(TechniqueDef.LightSpace lightSpace) Sets the space in which the light data should be passed to the shader.void
setLogic
(TechniqueDefLogic logic) void
setNoRender
(boolean noRender) Sets if this technique should not be used to render.void
setRenderState
(RenderState renderState) Sets the render state that this technique is using.void
setShaderFile
(String vertexShader, String fragmentShader, String vertLanguage, String fragLanguage) Sets the shaders that this technique definition will use.void
setShaderFile
(EnumMap<Shader.ShaderType, String> shaderNames, EnumMap<Shader.ShaderType, String> shaderLanguages) Sets the shaders that this technique definition will use.void
setShaderGenerationInfo
(ShaderGenerationInfo shaderGenerationInfo) void
setShaderNodes
(List<ShaderNode> shaderNodes) void
setShaderPrologue
(String shaderPrologue) Set a string which is prepended to every shader used by this technique.void
setShadowMode
(TechniqueDef.ShadowMode shadowMode) Set the shadow mode.toString()
void
write
(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 capabilities
that 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
1
if 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:
write
in interfaceSavable
- Throws:
IOException
-
read
- Specified by:
read
in 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:
clone
in classObject
- Throws:
CloneNotSupportedException
-