DXGL r304 - Code Review

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

Diff [purge]

Index: ddraw/shadergen.cpp
@@ -300,7 +300,7 @@
301301 static const char op_texpassthru2str[] = "vec4(strX,1);\n";
302302 static const char op_texpassthru2strq[] = "strqX;\n";
303303 static const char op_texpassthru2null[] = "vec4(0,0,0,1);\n";
304 -static const char op_fogcoordstandardpixel[] = "gl_FogFragCoord = gl_FragCoord.z;\n";
 304+static const char op_fogcoordstandardpixel[] = "float fogcoord = gl_FragCoord.z / gl_FragCoord.w;\n";
305305 static const char op_fogcoordstandard[] = "gl_FogFragCoord = abs(gl_ModelViewMatrix*xyzw).z;\n";
306306 static const char op_fogcoordrange[] = "vec4 eyepos = gl_ModelViewMatrix*xyzw;\n\
307307 vec3 eyepos3 = eyepos.xyz / eyepos.w;\n\
@@ -309,6 +309,10 @@
310310 static const char op_fogexp[] = "fogfactor = 1.0 / exp(gl_FogFragCoord * gl_Fog.density);\n";
311311 static const char op_fogexp2[] = "fogfactor = 1.0 / exp(gl_FogFragCoord * gl_FogFragCoord *\n\
312312 gl_Fog.density * gl_Fog.density);\n";
 313+static const char op_foglinearpixel[] = "fogfactor = (gl_Fog.end - fogcoord) / (gl_Fog.end - gl_Fog.start);\n";
 314+static const char op_fogexppixel[] = "fogfactor = 1.0 / exp(fogcoord * gl_Fog.density);\n";
 315+static const char op_fogexp2pixel[] = "fogfactor = 1.0 / exp(fogcoord * fogcoord *\n\
 316+gl_Fog.density * gl_Fog.density);\n";
313317 static const char op_fogclamp[] = "fogfactor = clamp(fogfactor,0.0,1.0);\n";
314318 static const char op_fogblend[] = "color = mix(gl_Fog.color,color,fogfactor);\n";
315319
@@ -999,15 +1003,16 @@
10001004 switch(pixelfog)
10011005 {
10021006 case D3DFOG_LINEAR:
1003 - vsrc->append(op_foglinear);
 1007+ fsrc->append(op_foglinearpixel);
10041008 break;
10051009 case D3DFOG_EXP:
1006 - vsrc->append(op_fogexp);
 1010+ fsrc->append(op_fogexppixel);
10071011 break;
10081012 case D3DFOG_EXP2:
1009 - vsrc->append(op_fogexp2);
 1013+ fsrc->append(op_fogexp2pixel);
10101014 break;
10111015 }
 1016+ fsrc->append(op_fogclamp);
10121017 fsrc->append(op_fogblend);
10131018 }
10141019 fsrc->append(op_colorfragout);