Class TechniqueDef

java.lang.Object
com.jme3.material.TechniqueDef
All Implemented Interfaces:
Savable, Cloneable

public class TechniqueDef extends Object implements Savable, Cloneable
Describes a technique definition.
  • Field Details

    • SAVABLE_VERSION

      public static final int SAVABLE_VERSION
      Version #1: Separate shader language for each shader source.
      See Also:
    • DEFAULT_TECHNIQUE_NAME

      public static final String 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

      public TechniqueDef(String name, int sortId)
      Creates a new technique definition.

      Used internally by the J3M/J3MD loader.

      Parameters:
      name - The name of the technique
      sortId - 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

      public String getName()
      Returns the name of this technique as specified in the J3MD file. Default techniques have the name DEFAULT_TECHNIQUE_NAME.
      Returns:
      the name of this technique
    • getLightMode

      public TechniqueDef.LightMode getLightMode()
      Returns the light mode.
      Returns:
      the light mode.
      See Also:
    • setLightMode

      public void setLightMode(TechniqueDef.LightMode lightMode)
      Set the light mode
      Parameters:
      lightMode - the light mode
      See Also:
    • setLogic

      public void setLogic(TechniqueDefLogic logic)
    • getLogic

      public TechniqueDefLogic getLogic()
    • getShadowMode

      public TechniqueDef.ShadowMode getShadowMode()
      Returns the shadow mode.
      Returns:
      the shadow mode.
    • setShadowMode

      public void setShadowMode(TechniqueDef.ShadowMode shadowMode)
      Set the shadow mode.
      Parameters:
      shadowMode - the shadow mode.
      See Also:
    • getRenderState

      public RenderState getRenderState()
      Returns the render state that this technique is using
      Returns:
      the render state that this technique is using
      See Also:
    • setRenderState

      public void setRenderState(RenderState renderState)
      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

      public EnumSet<Caps> getRequiredCaps()
      Gets the renderer 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 shader
      fragmentShader - The name of the fragment shader
      vertLanguage - The vertex shader language
      fragLanguage - The fragment shader language
    • setShaderPrologue

      public void setShaderPrologue(String shaderPrologue)
      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

      public String getShaderPrologue()
      Returns:
      the shader prologue which is prepended to every shader.
    • getShaderParamDefine

      public String getShaderParamDefine(String paramName)
      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

      public Integer getShaderParamDefineId(String paramName)
      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

      public VarType getDefineIdType(int defineId)
      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

      public void addShaderParamDefine(String paramName, VarType paramType, String defineName)
      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

      public int addShaderUnmappedDefine(String defineName, VarType defineType)
      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 create
      defineType - the type for the new define
      Returns:
      The define ID of the created define
    • getDefineNames

      public String[] 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

      public VarType[] 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

      public DefineList 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

      public Shader getShader(AssetManager assetManager, EnumSet<Caps> rendererCaps, DefineList defines)
    • 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 stage
      shaderLanguages - EnumMap containing all shader languages for this stage
    • getFragmentShaderName

      public String 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

      public String 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

      public String getFragmentShaderLanguage()
      Returns the language of the fragment shader used in this technique.
      Returns:
      the name of the language (such as "GLSL100")
    • getVertexShaderLanguage

      public String getVertexShaderLanguage()
      Returns the language of the vertex shader used in this technique.
      Returns:
      the name of the language (such as "GLSL100")
    • getShaderProgramLanguage

      public String getShaderProgramLanguage(Shader.ShaderType shaderType)
      Returns the language for each shader program
      Parameters:
      shaderType - Fragment/Vertex/etcetera
      Returns:
      the name of the language
    • getShaderProgramName

      public String getShaderProgramName(Shader.ShaderType shaderType)
      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

      public boolean addWorldParam(String name)
      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

      public RenderState getForcedRenderState()
    • setForcedRenderState

      public void setForcedRenderState(RenderState forcedRenderState)
    • getWorldBindings

      public List<UniformBinding> getWorldBindings()
      Returns a list of world parameters that are used by this technique definition.
      Returns:
      The list of world parameters
    • write

      public void write(JmeExporter ex) throws IOException
      Specified by:
      write in interface Savable
      Throws:
      IOException
    • read

      public void read(JmeImporter im) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException
    • getShaderNodes

      public List<ShaderNode> getShaderNodes()
    • setShaderNodes

      public void setShaderNodes(List<ShaderNode> shaderNodes)
    • getShaderProgramNames

      public EnumMap<Shader.ShaderType,String> getShaderProgramNames()
      Returns the Enum containing the ShaderProgramNames;
      Returns:
      the pre-existing EnumMap
    • getShaderProgramLanguages

      public EnumMap<Shader.ShaderType,String> getShaderProgramLanguages()
      Returns the Enum containing the ShaderProgramLanguages;
      Returns:
      the pre-existing EnumMap
    • getShaderGenerationInfo

      public ShaderGenerationInfo getShaderGenerationInfo()
    • setShaderGenerationInfo

      public void setShaderGenerationInfo(ShaderGenerationInfo shaderGenerationInfo)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getLightSpace

      public TechniqueDef.LightSpace getLightSpace()
      Returns the space in which the light data should be passed to the shader.
      Returns:
      the light space
    • setLightSpace

      public void setLightSpace(TechniqueDef.LightSpace lightSpace)
      Sets the space in which the light data should be passed to the shader.
      Parameters:
      lightSpace - the light space
    • clone

      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException