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

Common.MatDefs.Terrain.AdvancedPBRTerrain.j3md Maven / Gradle / Ivy

There is a newer version: 3.7.0-stable
Show newest version
// NOTE: Doesn't support OpenGL1
MaterialDef Advanced PBR Terrain {

    MaterialParameters {

    
        Boolean UseVertexColorsAsSunIntensity //set true to make the vertex color's R channel how exposed a vertex is to the sun
        Float StaticSunIntensity              //used for setting the sun exposure value for a whole material
                                             //these are usually generated at run time or setup in a level editor per-geometry, so that models indoors can have the DirectionalLight dimmed accordingly.

        Boolean BrightenIndoorShadows  //set true if shadows are enabled and indoor areas without full sun exposure are too dark compared to when shadows are turned off in settings

  
        TextureArray AlbedoTextureArray
        TextureArray NormalParallaxTextureArray -LINEAR
        TextureArray MetallicRoughnessAoEiTextureArray -LINEAR



        Int AfflictionSplatScale : 8
        Float AfflictionRoughnessValue : 1.0
        Float AfflictionMetallicValue : 0.0
        Float AfflictionEmissiveValue : 0.0   //note that this is simplified into one value, rather than 2 with power and intensity like the regular pbr values.


     // affliction texture splatting & desaturation functionality
        Boolean UseTriplanarAfflictionMapping

        Texture2D AfflictionAlphaMap

        Texture2D SplatAlbedoMap  -LINEAR
        Texture2D SplatNormalMap  -LINEAR
        Texture2D SplatRoughnessMetallicMap -LINEAR
        Texture2D SplatEmissiveMap -LINEAR

        Color AfflictionEmissiveColor : 0.0 0.0 0.0 0.0

        Float SplatNoiseVar


        Int AfflictionMode_0 : 1
        Int AfflictionMode_1 : 1
        Int AfflictionMode_2 : 1
        Int AfflictionMode_3 : 1
        Int AfflictionMode_4 : 1
        Int AfflictionMode_5 : 1
        Int AfflictionMode_6 : 1
        Int AfflictionMode_7 : 1
        Int AfflictionMode_8 : 1
        Int AfflictionMode_9 : 1
        Int AfflictionMode_10 : 1
        Int AfflictionMode_11 : 1

        Color EmissiveColor_0 : 0.0 0.0 0.0 0.0
        Color EmissiveColor_1 : 0.0 0.0 0.0 0.0
        Color EmissiveColor_2 : 0.0 0.0 0.0 0.0
        Color EmissiveColor_3 : 0.0 0.0 0.0 0.0
        Color EmissiveColor_4 : 0.0 0.0 0.0 0.0
        Color EmissiveColor_5 : 0.0 0.0 0.0 0.0
        Color EmissiveColor_6 : 0.0 0.0 0.0 0.0
        Color EmissiveColor_7 : 0.0 0.0 0.0 0.0
        Color EmissiveColor_8 : 0.0 0.0 0.0 0.0
        Color EmissiveColor_9 : 0.0 0.0 0.0 0.0
        Color EmissiveColor_10 : 0.0 0.0 0.0 0.0
        Color EmissiveColor_11 : 0.0 0.0 0.0 0.0

        Float Roughness_0 : 0.0
        Float Roughness_1 : 0.0
        Float Roughness_2 : 0.0
        Float Roughness_3 : 0.0
        Float Roughness_4 : 0.0
        Float Roughness_5 : 0.0
        Float Roughness_6 : 0.0
        Float Roughness_7 : 0.0
        Float Roughness_8 : 0.0
        Float Roughness_9 : 0.0
        Float Roughness_10 : 0.0
        Float Roughness_11 : 0.0

        Float Metallic_0 : 0.0
        Float Metallic_1 : 0.0
        Float Metallic_2 : 0.0
        Float Metallic_3 : 0.0
        Float Metallic_4 : 0.0
        Float Metallic_5 : 0.0
        Float Metallic_6 : 0.0
        Float Metallic_7 : 0.0
        Float Metallic_8 : 0.0
        Float Metallic_9 : 0.0
        Float Metallic_10 : 0.0
        Float Metallic_11 : 0.0

        Int AlbedoMap_0
        Int AlbedoMap_1
        Int AlbedoMap_2
        Int AlbedoMap_3
        Int AlbedoMap_4
        Int AlbedoMap_5
        Int AlbedoMap_6
        Int AlbedoMap_7
        Int AlbedoMap_8
        Int AlbedoMap_9
        Int AlbedoMap_10
        Int AlbedoMap_11


        Float AlbedoMap_0_scale : 1
        Float AlbedoMap_1_scale : 1
        Float AlbedoMap_2_scale : 1
        Float AlbedoMap_3_scale : 1
        Float AlbedoMap_4_scale : 1
        Float AlbedoMap_5_scale : 1
        Float AlbedoMap_6_scale : 1
        Float AlbedoMap_7_scale : 1
        Float AlbedoMap_8_scale : 1
        Float AlbedoMap_9_scale : 1
        Float AlbedoMap_10_scale : 1
        Float AlbedoMap_11_scale : 1


        Int NormalMap_0
        Int NormalMap_1
        Int NormalMap_2
        Int NormalMap_3
        Int NormalMap_4
        Int NormalMap_5
        Int NormalMap_6
        Int NormalMap_7
        Int NormalMap_8
        Int NormalMap_9
        Int NormalMap_10
        Int NormalMap_11


        Int MetallicRoughnessMap_0
        Int MetallicRoughnessMap_1
        Int MetallicRoughnessMap_2
        Int MetallicRoughnessMap_3
        Int MetallicRoughnessMap_4
        Int MetallicRoughnessMap_5
        Int MetallicRoughnessMap_6
        Int MetallicRoughnessMap_7
        Int MetallicRoughnessMap_8
        Int MetallicRoughnessMap_9 
        Int MetallicRoughnessMap_10
        Int MetallicRoughnessMap_11


        Float ParallaxHeight_0
        Float ParallaxHeight_1
        Float ParallaxHeight_2
        Float ParallaxHeight_3
        Float ParallaxHeight_4
        Float ParallaxHeight_5
        Float ParallaxHeight_6
        Float ParallaxHeight_7
        Float ParallaxHeight_8
        Float ParallaxHeight_9
        Float ParallaxHeight_10
        Float ParallaxHeight_11



        // debug the final value of the selected layer as a color output            
        Int DebugValuesMode

            // Layers:
            //   0 - albedo (un-shaded)
            //   1 - normals
            //   2 - roughness
            //   3 - metallic
            //   4 - ao
            //   5  - emissive


        // use tri-planar mapping
        Boolean useTriPlanarMapping

        // Texture that specifies alpha values
        Texture2D AlphaMap -LINEAR
        Texture2D AlphaMap_1 -LINEAR
        Texture2D AlphaMap_2 -LINEAR

        Boolean UseSpecGloss
        Texture2D SpecularMap
        Texture2D GlossinessMap
        Texture2D SpecularGlossinessMap
        Color Specular : 1.0 1.0 1.0 1.0
        Float Glossiness : 1.0

        Vector4 ProbeData

        // Prefiltered Env Map for indirect specular lighting
        TextureCubeMap PrefEnvMap -LINEAR
        
        // Irradiance map for indirect diffuse lighting
        TextureCubeMap IrradianceMap -LINEAR

        //integrate BRDF map for indirect Lighting
        Texture2D IntegrateBRDF -LINEAR


        //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

        //For Vertex Color
        Boolean UseVertexColor

        Boolean BackfaceShadows : false

        Boolean UseFog
        Color FogColor
        Vector2 LinearFog
        Float ExpFog
        Float ExpSqFog

        // Alpha threshold for fragment discarding
        Float AlphaDiscardThreshold (AlphaTestFallOff)
    }

    Technique {

        LightMode SinglePassAndImageBased

        VertexShader  GLSL150:   Common/MatDefs/Terrain/PBRTerrain.vert
        FragmentShader GLSL150: Common/MatDefs/Terrain/AdvancedPBRTerrain.frag

        WorldParameters {
            WorldViewProjectionMatrix
            CameraPosition
            WorldMatrix
            WorldNormalMatrix
            ViewProjectionMatrix
            ViewMatrix
            Time

        }

        Defines {
                
            AFFLICTIONTEXTURE : AfflictionAlphaMap
            AFFLICTIONALBEDOMAP: SplatAlbedoMap 
            AFFLICTIONNORMALMAP : SplatNormalMap 
            AFFLICTIONROUGHNESSMETALLICMAP : SplatRoughnessMetallicMap
            AFFLICTIONEMISSIVEMAP : SplatEmissiveMap
            USE_SPLAT_NOISE : SplatNoiseVar

            TRI_PLANAR_MAPPING : useTriPlanarMapping

            DISCARD_ALPHA : AlphaDiscardThreshold

            ALPHAMAP : AlphaMap
            ALPHAMAP_1 : AlphaMap_1
            ALPHAMAP_2 : AlphaMap_2

            USE_FOG : UseFog
            FOG_LINEAR : LinearFog
            FOG_EXP : ExpFog
            FOG_EXPSQ : ExpSqFog

            ALBEDOMAP_0 : AlbedoMap_0
            ALBEDOMAP_1 : AlbedoMap_1
            ALBEDOMAP_2 : AlbedoMap_2
            ALBEDOMAP_3 : AlbedoMap_3
            ALBEDOMAP_4 : AlbedoMap_4
            ALBEDOMAP_5 : AlbedoMap_5
            ALBEDOMAP_6 : AlbedoMap_6
            ALBEDOMAP_7 : AlbedoMap_7
            ALBEDOMAP_8 : AlbedoMap_8
            ALBEDOMAP_9 : AlbedoMap_9
            ALBEDOMAP_10 : AlbedoMap_10
            ALBEDOMAP_11 : AlbedoMap_11

            NORMALMAP_0 : NormalMap_0
            NORMALMAP_1 : NormalMap_1
            NORMALMAP_2 : NormalMap_2
            NORMALMAP_3 : NormalMap_3
            NORMALMAP_4 : NormalMap_4
            NORMALMAP_5 : NormalMap_5
            NORMALMAP_6 : NormalMap_6
            NORMALMAP_7 : NormalMap_7
            NORMALMAP_8 : NormalMap_8
            NORMALMAP_9 : NormalMap_9
            NORMALMAP_10 : NormalMap_10
            NORMALMAP_11 : NormalMap_11

            METALLICROUGHNESSMAP_0 : MetallicRoughnessMap_0
            METALLICROUGHNESSMAP_1 : MetallicRoughnessMap_1
            METALLICROUGHNESSMAP_2 : MetallicRoughnessMap_2
            METALLICROUGHNESSMAP_3 : MetallicRoughnessMap_3
            METALLICROUGHNESSMAP_4 : MetallicRoughnessMap_4
            METALLICROUGHNESSMAP_5 : MetallicRoughnessMap_5
            METALLICROUGHNESSMAP_6 : MetallicRoughnessMap_6
            METALLICROUGHNESSMAP_7 : MetallicRoughnessMap_7
            METALLICROUGHNESSMAP_8 : MetallicRoughnessMap_8
            METALLICROUGHNESSMAP_9 : MetallicRoughnessMap_9
            METALLICROUGHNESSMAP_10 : MetallicRoughnessMap_10
            METALLICROUGHNESSMAP_11 : MetallicRoughnessMap_11

            DEBUG_VALUES_MODE : DebugValuesMode



        }
    }


    Technique PreShadow {

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

        WorldParameters {
            WorldViewProjectionMatrix
            WorldViewMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

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

        ForcedRenderState {
            FaceCull Off
            DepthTest On
            DepthWrite On
            PolyOffset 5 3
            ColorWrite Off
        }

    }


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

        WorldParameters {
            WorldViewProjectionMatrix
            WorldMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        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
        }

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

    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy