All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gine.jme3-plugins.3.7.0-beta1.source-code.example.j3md Maven / Gradle / Ivy

There is a newer version: 3.7.0-stable
Show newest version
MaterialDef Example Lighting {

    MaterialParameters {

        // Compute vertex lighting in the shader
        // For better performance
        Boolean VertexLighting

        // Alpha threshold for fragment discarding
        Float AlphaDiscardThreshold

        // Use the provided ambient, diffuse, and specular colors
        Boolean UseMaterialColors

        // Use vertex color as an additional diffuse color.
        Boolean UseVertexColor

        // Ambient color
        Color Ambient

        // Diffuse color
        Color Diffuse

        // Specular color
        Color Specular

        // Specular power/shininess
        Float Shininess : 1

        // Diffuse map
        Texture2D DiffuseMap

        // Normal map
        Texture2D NormalMap -LINEAR

        // Specular/gloss map
        Texture2D SpecularMap

        // Parallax/height map
        Texture2D ParallaxMap -LINEAR

        //Set to true is parallax map is stored in the alpha channel of the normal map
        Boolean PackedNormalParallax

        //Sets the relief height for parallax mapping
        Float ParallaxHeight : 0.05

        //Set to true to activate Steep Parallax mapping
        Boolean SteepParallax

        // Texture that specifies alpha values
        Texture2D AlphaMap -LINEAR

        // Color ramp, will map diffuse and specular values through it.
        Texture2D ColorRamp

        // Texture of the glowing parts of the material
        Texture2D GlowMap

        // Set to Use Lightmap
        Texture2D LightMap

        // Set to use TexCoord2 for the lightmap sampling
        Boolean SeparateTexCoord

        // The glow color of the object
        Color GlowColor

        // Parameters for fresnel
        // X = bias
        // Y = scale
        // Z = power
        Vector3 FresnelParams

        // Env Map for reflection
        TextureCubeMap EnvMap

        // the env map is a spheremap and not a cube map
        Boolean EnvMapAsSphereMap

        //shadows
         Int FilterMode
        Boolean HardwareShadows

        Texture2D ShadowMap0
        Texture2D ShadowMap1
        Texture2D ShadowMap2
        Texture2D ShadowMap3
        //pointLights
        Texture2D ShadowMap4
        Texture2D ShadowMap5

        Float ShadowIntensity
        Vector4 Splits
        Vector2 FadeInfo

        Matrix4 LightViewProjectionMatrix0
        Matrix4 LightViewProjectionMatrix1
        Matrix4 LightViewProjectionMatrix2
        Matrix4 LightViewProjectionMatrix3
        //pointLight
        Matrix4 LightViewProjectionMatrix4
        Matrix4 LightViewProjectionMatrix5
        Vector3 LightPos
        Vector3 LightDir

        Float PCFEdge
        Float ShadowMapSize

        // For hardware skinning
        Int NumberOfBones
        Matrix4Array BoneMatrices

        //For instancing
        Boolean UseInstancing

        Boolean BackfaceShadows : false

        Color Color
    }

    Technique ShaderNodeTechnique {
        WorldParameters {
            WorldViewProjectionMatrix
        }
        VertexShaderNodes {
            ShaderNode CommonVert {
                Condition: (LightMap || SeparateTexCoord) && (!Color || ShadowMapSize)
                Definition : CommonVert : Common/MatDefs/ShaderNodes/Common/CommonVert.j3sn
                InputMappings {
                    worldViewProjectionMatrix = WorldParam.WorldViewProjectionMatrix
                    modelPosition = Global.position.xyz: BackfaceShadows
                }
                OutputMappings {
                    Global.position = projPosition
                }
            }
        }
        FragmentShaderNodes {
            ShaderNode ColorMult {
                Definition : ColorMult : Common/MatDefs/ShaderNodes/Basic/ColorMult.j3sn
                InputMappings {
                    color1 = MatParam.Color
                    color2 = Global.color
                }
                OutputMappings {
                    Global.color = outColor
                }
            }
        }
    }

    Technique {
        LightMode SinglePass

        ShadowMode InPass

        VertexShader GLSL100:   Common/MatDefs/Light/SPLighting.vert
        FragmentShader GLSL100: Common/MatDefs/Light/SPLighting.frag

        WorldParameters {
            WorldViewProjectionMatrix
            NormalMatrix
            WorldViewMatrix
            ViewMatrix
            CameraPosition
            WorldMatrix
            ViewProjectionMatrix
        }

        Defines {
            VERTEX_COLOR : UseVertexColor
            VERTEX_LIGHTING : VertexLighting
            MATERIAL_COLORS : UseMaterialColors
            DIFFUSEMAP : DiffuseMap
            NORMALMAP : NormalMap
            SPECULARMAP : SpecularMap
            PARALLAXMAP : ParallaxMap
            NORMALMAP_PARALLAX : PackedNormalParallax
            STEEP_PARALLAX : SteepParallax
            ALPHAMAP : AlphaMap
            COLORRAMP : ColorRamp
            LIGHTMAP : LightMap
            SEPARATE_TEXCOORD : SeparateTexCoord
            DISCARD_ALPHA : AlphaDiscardThreshold
            USE_REFLECTION : EnvMap
            SPHERE_MAP : EnvMapAsSphereMap
            NUM_BONES : NumberOfBones
            INSTANCING : UseInstancing
        }
    }

    Technique {

        LightMode MultiPass

        ShadowMode PostPass

        VertexShader GLSL100:   Common/MatDefs/Light/Lighting.vert
        FragmentShader GLSL100: Common/MatDefs/Light/Lighting.frag

        WorldParameters {
            WorldViewProjectionMatrix
            NormalMatrix
            WorldViewMatrix
            ViewMatrix
            CameraPosition
            WorldMatrix
            ViewProjectionMatrix
        }

        Defines {
            VERTEX_COLOR : UseVertexColor
            VERTEX_LIGHTING : VertexLighting
            MATERIAL_COLORS : UseMaterialColors
            DIFFUSEMAP : DiffuseMap
            NORMALMAP : NormalMap
            SPECULARMAP : SpecularMap
            PARALLAXMAP : ParallaxMap
            NORMALMAP_PARALLAX : PackedNormalParallax
            STEEP_PARALLAX : SteepParallax
            ALPHAMAP : AlphaMap
            COLORRAMP : ColorRamp
            LIGHTMAP : LightMap
            SEPARATE_TEXCOORD : SeparateTexCoord
            DISCARD_ALPHA : AlphaDiscardThreshold
            USE_REFLECTION : EnvMap
            SPHERE_MAP : EnvMapAsSphereMap
            NUM_BONES : NumberOfBones
            INSTANCING : UseInstancing
        }
    }



    Technique PreShadow {

        VertexShader GLSL100 :   Common/MatDefs/Shadow/PreShadow.vert
        FragmentShader GLSL100 : Common/MatDefs/Shadow/PreShadow.frag

        WorldParameters {
            WorldViewProjectionMatrix
            WorldViewMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            DISCARD_ALPHA : AlphaDiscardThreshold
            NUM_BONES : NumberOfBones
            INSTANCING : UseInstancing
        }

    }


    Technique PostShadow {
        VertexShader GLSL150:   Common/MatDefs/Shadow/PostShadow.vert
        FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadow.frag

        WorldParameters {
            WorldViewProjectionMatrix
            WorldMatrix
            ViewProjectionMatrix
            ViewMatrix
            NormalMatrix
        }

        Defines {
            HARDWARE_SHADOWS : HardwareShadows
            FILTER_MODE : FilterMode
            PCFEDGE : PCFEdge
            DISCARD_ALPHA : AlphaDiscardThreshold
            SHADOWMAP_SIZE : ShadowMapSize
            FADE : FadeInfo
            PSSM : Splits
            POINTLIGHT : LightViewProjectionMatrix5
            NUM_BONES : NumberOfBones
            INSTANCING : UseInstancing
            BACKFACE_SHADOWS: BackfaceShadows
        }

        RenderState {
            Blend Alpha
            DepthWrite Off
            PolyOffset -0.1 0
            Wireframe On
            FaceCull Back
            DepthWrite On
            DepthTest On
            BlendEquation ReverseSubtract
            BlendEquationAlpha InheritColor
            ColorWrite Off
            DepthFunc GreaterOrEqual
            LineWidth 3.0
        }

        ForcedRenderState {
            Blend Modulate
            DepthWrite Off
            PolyOffset -0.1 0
        }
    }

    Technique PostShadow{
        VertexShader GLSL100:   Common/MatDefs/Shadow/PostShadow.vert
        FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadow.frag

        WorldParameters {
            WorldViewProjectionMatrix
            WorldMatrix
            ViewProjectionMatrix
            ViewMatrix
            NormalMatrix
        }

        Defines {
            HARDWARE_SHADOWS : HardwareShadows
            FILTER_MODE : FilterMode
            PCFEDGE : PCFEdge
            DISCARD_ALPHA : AlphaDiscardThreshold
            SHADOWMAP_SIZE : ShadowMapSize
            FADE : FadeInfo
            PSSM : Splits
            POINTLIGHT : LightViewProjectionMatrix5
            NUM_BONES : NumberOfBones
            INSTANCING : UseInstancing
        }

        ForcedRenderState {
            Blend Modulate
            DepthWrite Off
            PolyOffset -0.1 0
        }
    }

  Technique PreNormalPass {

        VertexShader GLSL100 :   Common/MatDefs/SSAO/normal.vert
        FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag

        WorldParameters {
            WorldViewProjectionMatrix
            WorldViewMatrix
            NormalMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            DIFFUSEMAP_ALPHA : DiffuseMap
            NUM_BONES : NumberOfBones
            INSTANCING : UseInstancing
        }

    }


    Technique PreNormalPassDerivative {

        VertexShader GLSL100 :   Common/MatDefs/MSSAO/normal.vert
        FragmentShader GLSL100 : Common/MatDefs/MSSAO/normal.frag

        WorldParameters {
            WorldViewProjectionMatrix
            WorldViewMatrix
            NormalMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            DIFFUSEMAP_ALPHA : DiffuseMap
            NUM_BONES : NumberOfBones
            INSTANCING : UseInstancing
        }

    }

    Technique GBuf {

        VertexShader GLSL100:   Common/MatDefs/Light/GBuf.vert
        FragmentShader GLSL100: Common/MatDefs/Light/GBuf.frag

        WorldParameters {
            WorldViewProjectionMatrix
            NormalMatrix
            WorldViewMatrix
            WorldMatrix
        }

        Defines {
            VERTEX_COLOR : UseVertexColor
            MATERIAL_COLORS : UseMaterialColors
            DIFFUSEMAP : DiffuseMap
            NORMALMAP : NormalMap
            SPECULARMAP : SpecularMap
            PARALLAXMAP : ParallaxMap
        }
    }

    Technique Glow {

        VertexShader GLSL100:   Common/MatDefs/Misc/Unshaded.vert
        FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag

        WorldParameters {
            WorldViewProjectionMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            NEED_TEXCOORD1
            HAS_GLOWMAP : GlowMap
            HAS_GLOWCOLOR : GlowColor

            NUM_BONES : NumberOfBones
            INSTANCING : UseInstancing
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy