aboutsummaryrefslogtreecommitdiff
path: root/engine/src/core-data/Common/MatDefs/Light/Lighting.j3md
blob: 95042b7c19dc1a8e1f131fb47de61659a74d4343 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
MaterialDef Phong Lighting {

    MaterialParameters {

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

        // Use more efficent algorithms to improve performance
        Boolean LowQuality

        // Improve quality at the cost of performance
        Boolean HighQuality

        // Output alpha from the diffuse map
        Boolean UseAlpha

        // Apha threshold for fragment discarding
        Float AlphaDiscardThreshold

        // Normal map is in BC5/ATI2n/LATC/3Dc compression format
        Boolean LATC

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

        // Activate shading along the tangent, instead of the normal
        // Requires tangent data to be available on the model.
        Boolean VTangent

        // Use minnaert diffuse instead of lambert
        Boolean Minnaert

        // Use ward specular instead of phong
        Boolean WardIso

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

        // Ambient color
        Color Ambient (MaterialAmbient)

        // Diffuse color
        Color Diffuse (MaterialDiffuse)

        // Specular color
        Color Specular (MaterialSpecular)

        // Specular power/shininess
        Float Shininess (MaterialShininess) : 1

        // Diffuse map
        Texture2D DiffuseMap

        // Normal map
        Texture2D NormalMap

        // Specular/gloss map
        Texture2D SpecularMap

        // Parallax/height map
        Texture2D ParallaxMap

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

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

    Technique {

        LightMode MultiPass

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

        WorldParameters {
            WorldViewProjectionMatrix
            NormalMatrix
            WorldViewMatrix
            ViewMatrix
            CameraPosition
            WorldMatrix
        }

        Defines {
            LATC : LATC
            VERTEX_COLOR : UseVertexColor
            VERTEX_LIGHTING : VertexLighting
            ATTENUATION : Attenuation
            MATERIAL_COLORS : UseMaterialColors
            V_TANGENT : VTangent
            MINNAERT  : Minnaert
            WARDISO   : WardIso
            LOW_QUALITY : LowQuality
            HQ_ATTENUATION : HighQuality

            DIFFUSEMAP : DiffuseMap
            NORMALMAP : NormalMap
            SPECULARMAP : SpecularMap
            PARALLAXMAP : ParallaxMap
            NORMALMAP_PARALLAX : PackedNormalParallax
            STEEP_PARALLAX : SteepParallax
            ALPHAMAP : AlphaMap
            COLORRAMP : ColorRamp
            LIGHTMAP : LightMap
            SEPARATE_TEXCOORD : SeparateTexCoord

            USE_REFLECTION : EnvMap
            SPHERE_MAP : SphereMap
        }
    }

    Technique PreShadow {

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

        WorldParameters {
            WorldViewProjectionMatrix
            WorldViewMatrix
        }

        Defines {
            DIFFUSEMAP_ALPHA : DiffuseMap
        }

        RenderState {
            FaceCull Off
            DepthTest On
            DepthWrite On
            PolyOffset 5 0
            ColorWrite Off
        }

    }

  Technique PreNormalPass {

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

        WorldParameters {
            WorldViewProjectionMatrix
            WorldViewMatrix
            NormalMatrix
        }

        Defines {
            DIFFUSEMAP_ALPHA : DiffuseMap
        }

        RenderState {

        }

    }

    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
            V_TANGENT : VTangent
            MINNAERT  : Minnaert
            WARDISO   : WardIso

            DIFFUSEMAP : DiffuseMap
            NORMALMAP : NormalMap
            SPECULARMAP : SpecularMap
            PARALLAXMAP : ParallaxMap
        }
    }

    Technique FixedFunc {
        LightMode FixedPipeline
    }

    Technique Glow {

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

        WorldParameters {
            WorldViewProjectionMatrix
        }

        Defines {
            HAS_GLOWMAP : GlowMap
            HAS_GLOWCOLOR : GlowColor
        }
    }

}