-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreflection.patch
109 lines (105 loc) · 3.3 KB
/
reflection.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Index: src/renderer/tr_local.h
===================================================================
--- src/renderer/tr_local.h (revision 1880)
+++ src/renderer/tr_local.h (working copy)
@@ -208,6 +208,7 @@
TCGEN_LIGHTMAP,
TCGEN_TEXTURE,
TCGEN_ENVIRONMENT_MAPPED,
+ TCGEN_REFLECTION_MAPPED,
TCGEN_FOG,
TCGEN_VECTOR // S and T from world coordinates
} texCoordGen_t;
@@ -1519,7 +1520,8 @@
void RB_DeformTessGeometry( void );
-void RB_CalcEnvironmentTexCoords( float *dstTexCoords );
+void RB_CalcEnvironmentTexCoords( void );
+void RB_CalcReflectionTexCoords( void );
void RB_CalcFogTexCoords( float *dstTexCoords );
void RB_CalcScrollTexCoords( const float scroll[2], float *dstTexCoords );
void RB_CalcRotateTexCoords( float rotSpeed, float *dstTexCoords );
Index: src/renderer/tr_shade_calc.c
===================================================================
--- src/renderer/tr_shade_calc.c (revision 1880)
+++ src/renderer/tr_shade_calc.c (working copy)
@@ -889,30 +889,25 @@
/*
** RB_CalcEnvironmentTexCoords
*/
-void RB_CalcEnvironmentTexCoords( float *st )
+void RB_CalcEnvironmentTexCoords()
{
- int i;
- float *v, *normal;
- vec3_t viewer, reflected;
- float d;
+ qglTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
+ qglTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
+ qglEnable(GL_TEXTURE_GEN_S);
+ qglEnable(GL_TEXTURE_GEN_T);
+}
- v = tess.xyz[0];
- normal = tess.normal[0];
-
- for (i = 0 ; i < tess.numVertexes ; i++, v += 4, normal += 4, st += 2 )
- {
- VectorSubtract (backEnd.or.viewOrigin, v, viewer);
- VectorNormalizeFast (viewer);
-
- d = DotProduct (normal, viewer);
-
- reflected[0] = normal[0]*2*d - viewer[0];
- reflected[1] = normal[1]*2*d - viewer[1];
- reflected[2] = normal[2]*2*d - viewer[2];
-
- st[0] = 0.5 + reflected[1] * 0.5;
- st[1] = 0.5 - reflected[2] * 0.5;
- }
+/*
+** RB_CalcReflectionTexCoords
+*/
+void RB_CalcReflectionTexCoords()
+{
+ qglTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
+ qglTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
+ qglTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
+ qglEnable(GL_TEXTURE_GEN_S);
+ qglEnable(GL_TEXTURE_GEN_T);
+ qglEnable(GL_TEXTURE_GEN_R);
}
/*
Index: src/renderer/tr_shade.c
===================================================================
--- src/renderer/tr_shade.c (revision 1880)
+++ src/renderer/tr_shade.c (working copy)
@@ -1016,8 +1016,11 @@
RB_CalcFogTexCoords( ( float * ) tess.svars.texcoords[b] );
break;
case TCGEN_ENVIRONMENT_MAPPED:
- RB_CalcEnvironmentTexCoords( ( float * ) tess.svars.texcoords[b] );
+ RB_CalcEnvironmentTexCoords();
break;
+ case TCGEN_REFLECTION_MAPPED:
+ RB_CalcReflectionTexCoords();
+ break;
case TCGEN_BAD:
return;
}
@@ -1131,6 +1134,17 @@
//
R_DrawElements( input->numIndexes, input->indexes );
}
+ if ( pStage->bundle[0].tcGen == TCGEN_ENVIRONMENT_MAPPED )
+ {
+ qglDisable(GL_TEXTURE_GEN_S);
+ qglDisable(GL_TEXTURE_GEN_T);
+ }
+ if ( pStage->bundle[0].tcGen == TCGEN_REFLECTION_MAPPED )
+ {
+ qglDisable(GL_TEXTURE_GEN_S);
+ qglDisable(GL_TEXTURE_GEN_T);
+ qglDisable(GL_TEXTURE_GEN_R);
+ }
// allow skipping out to show just lightmaps during development
if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap || pStage->bundle[0].vertexLightmap ) )
{