Skip to content

Commit 71a5707

Browse files
committed
bikeshedding: unify a bit the lining in glsl
1 parent 1419ca6 commit 71a5707

6 files changed

Lines changed: 14 additions & 23 deletions

File tree

src/engine/renderer/glsl_source/forwardLighting_fp.glsl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -947,16 +947,15 @@ void main()
947947
vec3 L = normalize(u_LightOrigin - var_Position);
948948
#endif
949949

950-
vec2 texDiffuse = var_TexDiffuse.st;
950+
// compute view direction in world space
951+
vec3 viewDir = normalize(u_ViewOrigin - var_Position.xyz);
951952

952953
mat3 tangentToWorldMatrix = mat3(var_Tangent.xyz, var_Binormal.xyz, var_Normal.xyz);
953954

955+
vec2 texDiffuse = var_TexDiffuse.st;
954956
vec2 texNormal = var_TexNormal.st;
955957
vec2 texSpecular = var_TexSpecular.st;
956958

957-
// compute view direction in world space
958-
vec3 viewDir = normalize(u_ViewOrigin - var_Position.xyz);
959-
960959
#if defined(USE_PARALLAX_MAPPING)
961960
// compute texcoords offset from heightmap
962961
vec2 texOffset = ParallaxTexOffset(u_NormalMap, texNormal, u_DepthScale, u_OffsetBias, viewDir, tangentToWorldMatrix);

src/engine/renderer/glsl_source/lightMapping_fp.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ void main()
5050
// compute view direction in world space
5151
vec3 viewDir = normalize(u_ViewOrigin - var_Position);
5252

53+
mat3 tangentToWorldMatrix = mat3(var_Tangent.xyz, var_Binormal.xyz, var_Normal.xyz);
54+
5355
vec2 texDiffuse = var_TexDiffuseGlow.st;
5456
vec2 texGlow = var_TexDiffuseGlow.pq;
5557
vec2 texNormal = var_TexNormalSpecular.st;
5658
vec2 texSpecular = var_TexNormalSpecular.pq;
5759

58-
mat3 tangentToWorldMatrix = mat3(var_Tangent.xyz, var_Binormal.xyz, var_Normal.xyz);
59-
6060
#if defined(USE_PARALLAX_MAPPING)
6161
// compute texcoords offset from heightmap
6262
vec2 texOffset = ParallaxTexOffset(u_NormalMap, texNormal, u_DepthScale, u_OffsetBias, viewDir, tangentToWorldMatrix);

src/engine/renderer/glsl_source/liquid_fp.glsl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void ReadLightGrid(in vec3 pos, out vec3 lgtDir,
8282

8383
void main()
8484
{
85-
// compute incident ray
85+
// compute view direction in world space
8686
vec3 viewDir = normalize(u_ViewOrigin - var_Position);
8787

8888
mat3 tangentToWorldMatrix = mat3(var_Tangent.xyz, var_Binormal.xyz, var_Normal.xyz);
@@ -96,17 +96,14 @@ void main()
9696
vec2 texNormal = var_TexNormal.st;
9797

9898
#if defined(USE_PARALLAX_MAPPING)
99-
// ray intersect in view direction
100-
10199
// compute texcoords offset from heightmap
102100
vec2 texOffset = ParallaxTexOffset(u_NormalMap, texNormal, u_DepthScale, u_OffsetBias, viewDir, tangentToWorldMatrix);
103101

104102
texScreen += texOffset;
105103
texNormal += texOffset;
106-
#endif
104+
#endif // USE_PARALLAX_MAPPING
107105

108106
// compute normals
109-
110107
vec3 N = normalize(var_Normal);
111108

112109
// compute normal in world space from normalmap

src/engine/renderer/glsl_source/reliefMapping_fp.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,4 @@ vec2 ParallaxTexOffset(sampler2D normalMap, vec2 texCoords, float depthScale, fl
284284

285285
return bestDepth * ds;
286286
}
287-
#endif
287+
#endif // USE_PARALLAX_MAPPING

src/engine/renderer/glsl_source/vertexLighting_DBS_entity_fp.glsl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,10 @@ void main()
8585
// compute view direction in world space
8686
vec3 viewDir = normalize(u_ViewOrigin - var_Position);
8787

88-
vec2 texDiffuse = var_TexDiffuse.st;
89-
vec2 texGlow = var_TexGlow;
90-
9188
mat3 tangentToWorldMatrix = mat3(var_Tangent.xyz, var_Binormal.xyz, var_Normal.xyz);
9289

90+
vec2 texDiffuse = var_TexDiffuse.st;
91+
vec2 texGlow = var_TexGlow;
9392
vec2 texNormal = var_TexNormalSpecular.xy;
9493
vec2 texSpecular = var_TexNormalSpecular.zw;
9594

@@ -108,18 +107,15 @@ void main()
108107

109108
// compute the specular term
110109
#if defined(USE_REFLECTIVE_SPECULAR)
111-
112110
vec4 specBase = texture2D(u_SpecularMap, texSpecular).rgba;
113111

114112
vec4 envColor0 = textureCube(u_EnvironmentMap0, reflect(-viewDir, N)).rgba;
115113
vec4 envColor1 = textureCube(u_EnvironmentMap1, reflect(-viewDir, N)).rgba;
116114

117115
specBase.rgb *= mix(envColor0, envColor1, u_EnvironmentInterpolation).rgb;
118-
119116
#else
120117
// simple Blinn-Phong
121118
vec4 specBase = texture2D(u_SpecularMap, texSpecular).rgba;
122-
123119
#endif // USE_REFLECTIVE_SPECULAR
124120

125121
// compute the diffuse term

src/engine/renderer/glsl_source/vertexLighting_DBS_world_fp.glsl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,17 @@ void ReadLightGrid(in vec3 pos, out vec3 lgtDir,
7373

7474
void main()
7575
{
76-
vec2 texDiffuse = var_TexDiffuseGlow.st;
77-
vec2 texGlow = var_TexDiffuseGlow.pq;
78-
7976
// compute view direction in world space
8077
vec3 viewDir = normalize(u_ViewOrigin - var_Position);
8178

82-
mat3 tangentToWorldMatrix = mat3(var_Tangent.xyz, var_Binormal.xyz, var_Normal.xyx);
83-
8479
vec3 L, ambCol, dirCol;
8580
ReadLightGrid( (var_Position - u_LightGridOrigin) * u_LightGridScale,
8681
L, ambCol, dirCol);
8782

83+
mat3 tangentToWorldMatrix = mat3(var_Tangent.xyz, var_Binormal.xyz, var_Normal.xyx);
84+
85+
vec2 texDiffuse = var_TexDiffuseGlow.st;
86+
vec2 texGlow = var_TexDiffuseGlow.pq;
8887
vec2 texNormal = var_TexNormalSpecular.st;
8988
vec2 texSpecular = var_TexNormalSpecular.pq;
9089

0 commit comments

Comments
 (0)