DXGL r303 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r302‎ | r303 | r304 >
Date:02:13, 13 January 2013
Author:admin
Status:new
Tags:
Comment:
Get vertex fog working.
Modified paths:
  • /ddraw/shadergen.cpp (modified) (history)

Diff [purge]

Index: ddraw/shadergen.cpp
@@ -274,7 +274,7 @@
275275 static const char var_fogfactorvertex[] = "varying float fogfactor;\n";
276276 static const char var_fogfactorpixel[] = "float fogfactor;\n";
277277 // Operations
278 -static const char op_transform[] = "xyzw = vec4(xyz,1);\n\
 278+static const char op_transform[] = "xyzw = vec4(xyz,1.0);\n\
279279 vec4 pos = gl_ModelViewProjectionMatrix*xyzw;\n\
280280 gl_Position = vec4(pos.x,-pos.y,pos.z,pos.w);\n";
281281 static const char op_normalize[] = "N = normalize(gl_NormalMatrix*nxyz);\n";
@@ -301,8 +301,8 @@
302302 static const char op_texpassthru2strq[] = "strqX;\n";
303303 static const char op_texpassthru2null[] = "vec4(0,0,0,1);\n";
304304 static const char op_fogcoordstandardpixel[] = "gl_FogFragCoord = gl_FragCoord.z;\n";
305 -static const char op_fogcoordstandard[] = "gl_FogFragCoord = (gl_ModelViewMatrix*gl_Vertex).z;\n";
306 -static const char op_fogcoordrange[] = "vec4 eyepos = gl_ModelViewMatrix*gl_Vertex;\n\
 305+static const char op_fogcoordstandard[] = "gl_FogFragCoord = abs(gl_ModelViewMatrix*xyzw).z;\n";
 306+static const char op_fogcoordrange[] = "vec4 eyepos = gl_ModelViewMatrix*xyzw;\n\
307307 vec3 eyepos3 = eyepos.xyz / eyepos.w;\n\
308308 gl_FragFogCoord = sqrt((eyepos3.x * eyepos3.x) + (eyepos3.y * eyepos3.y) + (eyepos3.z * eyepos3.z));\n";
309309 static const char op_foglinear[] = "fogfactor = (gl_Fog.end - gl_FogFragCoord) / (gl_Fog.end - gl_Fog.start);\n";
@@ -310,7 +310,7 @@
311311 static const char op_fogexp2[] = "fogfactor = 1.0 / exp(gl_FogFragCoord * gl_FogFragCoord *\n\
312312 gl_Fog.density * gl_Fog.density);\n";
313313 static const char op_fogclamp[] = "fogfactor = clamp(fogfactor,0.0,1.0);\n";
314 -static const char op_fogblend[] = "color = mix(color,gl_Fog.color,fogfactor);\n";
 314+static const char op_fogblend[] = "color = mix(gl_Fog.color,color,fogfactor);\n";
315315
316316 // Functions
317317 static const char func_dirlight[] = "void DirLight(in Light light)\n\