[qfusion-cvs-commits] SF.net SVN: l33t: [789] trunk/qfusion/source/ref_gl
Brought to you by:
digiman
|
From: qfusion s. c. <l33...@li...> - 2007-12-04 20:33:17
|
Revision: 789
http://l33t.svn.sourceforge.net/l33t/?rev=789&view=rev
Author: digiman
Date: 2007-12-04 12:33:04 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
Only lerp reflection and refraction of alphagen is not identity
Modified Paths:
--------------
trunk/qfusion/source/ref_gl/r_backend.c
trunk/qfusion/source/ref_gl/r_local.h
trunk/qfusion/source/ref_gl/r_program.c
trunk/qfusion/source/ref_gl/r_shader.c
Modified: trunk/qfusion/source/ref_gl/r_backend.c
===================================================================
--- trunk/qfusion/source/ref_gl/r_backend.c 2007-12-03 21:24:42 UTC (rev 788)
+++ trunk/qfusion/source/ref_gl/r_backend.c 2007-12-04 20:33:04 UTC (rev 789)
@@ -1880,16 +1880,14 @@
R_BindShaderpass( pass, pass->anim_frames[0], 0 ); // dudvmap
+ // calculate the fragment color
+ R_ModifyColor( pass );
+
if( frontPlane )
- { // calculate the fragment color
- R_ModifyColor( pass );
+ {
+ if( pass->alphagen.type != ALPHA_GEN_IDENTITY )
+ programFeatures |= PROGRAM_APPLY_DISTORTION_ALPHA;
}
- else
- { // set refractional part to 1 (1-alpha), reflection doesn't work on backplane
- numColors = 1;
- colorArray[0][0] = colorArray[0][1] = colorArray[0][2] = 255;
- colorArray[0][3] = 0;
- }
// set shaderpass state (blending, depthwrite, etc)
state = r_currentShaderState | (pass->flags & r_currentShaderPassMask) | GLSTATE_BLEND_MTEX;
Modified: trunk/qfusion/source/ref_gl/r_local.h
===================================================================
--- trunk/qfusion/source/ref_gl/r_local.h 2007-12-03 21:24:42 UTC (rev 788)
+++ trunk/qfusion/source/ref_gl/r_local.h 2007-12-04 20:33:04 UTC (rev 789)
@@ -545,13 +545,14 @@
PROGRAM_APPLY_RELIEFMAPPING = 1 << 8,
PROGRAM_APPLY_EYEDOT = 1 << 9,
+ PROGRAM_APPLY_DISTORTION_ALPHA = 1 << 10,
- PROGRAM_APPLY_PCF2x2 = 1 << 10,
- PROGRAM_APPLY_PCF3x3 = 1 << 11,
+ PROGRAM_APPLY_PCF2x2 = 1 << 11,
+ PROGRAM_APPLY_PCF3x3 = 1 << 12,
- PROGRAM_APPLY_BRANCHING = 1 << 12,
- PROGRAM_APPLY_CLIPPING = 1 << 13,
- PROGRAM_APPLY_AMBIENT_COMPENSATION = 1 << 14
+ PROGRAM_APPLY_BRANCHING = 1 << 13,
+ PROGRAM_APPLY_CLIPPING = 1 << 14,
+ PROGRAM_APPLY_AMBIENT_COMPENSATION = 1 << 15
};
void R_InitGLSLPrograms( void );
Modified: trunk/qfusion/source/ref_gl/r_program.c
===================================================================
--- trunk/qfusion/source/ref_gl/r_program.c 2007-12-03 21:24:42 UTC (rev 788)
+++ trunk/qfusion/source/ref_gl/r_program.c 2007-12-04 20:33:04 UTC (rev 789)
@@ -209,7 +209,9 @@
{ PROGRAM_APPLY_SPECULAR, "#define APPLY_SPECULAR\n", "_gloss" },
{ PROGRAM_APPLY_OFFSETMAPPING, "#define APPLY_OFFSETMAPPING\n", "_offmap" },
{ PROGRAM_APPLY_RELIEFMAPPING, "#define APPLY_RELIEFMAPPING\n", "_relmap" },
+
{ PROGRAM_APPLY_EYEDOT, "#define APPLY_EYEDOT\n", "_eyedot" },
+ { PROGRAM_APPLY_DISTORTION_ALPHA, "#define APPLY_DISTORTION_ALPHA\n", "_alpha" },
{ PROGRAM_APPLY_PCF2x2, "#define APPLY_PCF2x2\n", "_pcf2x2" },
{ PROGRAM_APPLY_PCF3x3, "#define APPLY_PCF3x3\n", "_pcf3x3" },
@@ -557,7 +559,7 @@
"\n"
"void main(void)\n"
"{\n"
-"vec4 color = vec4 (0.0);\n"
+"vec3 color = vec3 (0.0);\n"
"\n"
"vec3 displacement = vec3(texture2D(DuDvMapTexture, vec2(TexCoord.pq) * vec2(0.25)));\n"
"vec2 coord = vec2(TexCoord.st) + vec2(displacement) * vec2 (0.2);\n"
@@ -580,7 +582,7 @@
"vec3 eyeNormal = vec3(normalize(vec3(EyeVector)));\n"
"\n"
"float refrdot = float(dot(surfaceNormal, eyeNormal));\n"
-"refrdot = float (clamp (refrdot, 0.0, 1.0));\n"
+"//refrdot = float (clamp (refrdot, 0.0, 1.0));\n"
"float refldot = 1.0 - refrdot;\n"
"// get refraction and reflection\n"
"vec3 refr = (vec3(texture2D(RefractionTexture, vec2(projCoord.st)))) * refrdot;\n"
@@ -592,8 +594,13 @@
"\n"
"\n"
"// add reflection and refraction\n"
-"color.rgb = (refr.rgb + vec3 (1.0) - vec3 (gl_Color.rgb)) * (1.0 - float(gl_Color.a)) + refl.rgb * (float(gl_Color.a));\n"
-"gl_FragColor = color;\n"
+"#ifdef APPLY_DISTORTION_ALPHA\n"
+"color = vec3(gl_Color.rgb) + mix (refr, refl, float(gl_Color.a));\n"
+"#else\n"
+"color = vec3(gl_Color.rgb) + refr + refl;\n"
+"#endif\n"
+"\n"
+"gl_FragColor = vec4 (color, 1.0);\n"
"}\n"
"\n"
"#endif // FRAGMENT_SHADER\n"
Modified: trunk/qfusion/source/ref_gl/r_shader.c
===================================================================
--- trunk/qfusion/source/ref_gl/r_shader.c 2007-12-03 21:24:42 UTC (rev 788)
+++ trunk/qfusion/source/ref_gl/r_shader.c 2007-12-04 20:33:04 UTC (rev 789)
@@ -1055,6 +1055,11 @@
pass->program_type = PROGRAM_TYPE_DISTORTION;
pass->anim_frames[0] = R_FindImage( dudv, flags & ~IT_HEIGHTMAP, 0 );
pass->anim_frames[1] = NULL;
+ if( pass->rgbgen.type == RGB_GEN_UNKNOWN )
+ {
+ pass->rgbgen.type = RGB_GEN_CONST;
+ VectorClear( pass->rgbgen.args );
+ }
if( !pass->anim_frames[0] ) {
Com_DPrintf( S_COLOR_YELLOW "WARNING: missing dudvmap image %s in shader %s.\n", dudv, shader->name );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|