@@ -2,29 +2,19 @@ uniform sampler2D texture_lightMap;
2
2
uniform sampler2D texture_dirLightMap;
3
3
4
4
void addLightMap() {
5
-
6
5
vec3 color = $texture2DSAMPLE(texture_lightMap, $UV).$CH;
7
- vec4 dir = texture2D (texture_dirLightMap, $UV);
8
-
9
- if (dot (dir.xyz,vec3 (1.0 )) < 0.00001 ) {
6
+ vec3 dir = texture2D (texture_dirLightMap, $UV).xyz;
7
+ if (dot (dir, vec3 (1.0 )) < 0.00001 ) {
10
8
dDiffuseLight += color;
11
- return ;
12
- }
13
-
14
- dLightDirNormW = normalize (dir.xyz * 2.0 - vec3 (1.0 ));
9
+ } else {
10
+ dLightDirNormW = normalize (dir * 2.0 - vec3 (1.0 ));
15
11
16
- float vlight = saturate(dot (dLightDirNormW, - dVertexNormalW));
17
- float flight = saturate(dot (dLightDirNormW, - dNormalW));
18
- float nlight = (flight / max (vlight,0.01 )) * 0.5 ;
12
+ float vlight = saturate(dot (dLightDirNormW, - dVertexNormalW));
13
+ float flight = saturate(dot (dLightDirNormW, - dNormalW));
14
+ float nlight = (flight / max (vlight, 0.01 )) * 0.5 ;
19
15
20
- dDiffuseLight += color * nlight * 2.0 ;
21
- }
22
-
23
- void addDirLightMap() {
24
- vec4 dir = texture2D (texture_dirLightMap, $UV);
25
- if (dot (dir.xyz,vec3 (1.0 )) < 0.00001 ) return ;
26
- vec3 color = $texture2DSAMPLE(texture_lightMap, $UV).$CH;
16
+ dDiffuseLight += color * nlight * 2.0 ;
17
+ }
27
18
28
- dLightDirNormW = normalize (dir.xyz * 2.0 - vec3 (1.0 ));
29
- dSpecularLight += vec3 (getLightSpecular()) * color;
19
+ dSpecularLight += color * getLightSpecular();
30
20
}
0 commit comments