File: Remove-code-for-r_equalize_entities.patch

package info (click to toggle)
darkplaces 0~20180908~beta1-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 17,424 kB
  • sloc: ansic: 152,917; pascal: 393; makefile: 392; perl: 372; objc: 245; sh: 102
file content (204 lines) | stat: -rw-r--r-- 9,879 bytes parent folder | download | duplicates (2)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
From: divverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Mon, 4 Feb 2019 15:09:01 +0000
Subject: Remove code for r_equalize_entities*.

r_fullbright_directed and slapping EF_FULLBRIGHT on these entities works a lot
better. I believe other than Xonotic nobody uses this, and Xonotic used it only
to make some fullbright stuff prettier and that's been removed for a few months
now.

After this change, older Xonotic versions will complain about nonexisting flag
at startup, but I bet no player will even notice the difference - all it changes
is that EF_FULLBRIGHT entities will appear less directionally, and
r_fullbright_directed 1 will fix this in a better way (already set in current
Xonotic).

Origin: upstream, commit:4d192dbaa2ce64ddb0f1fd687c44e79ea152a6af
---
 cl_main.c   | 59 -----------------------------------------------------------
 clvm_cmds.c |  3 ---
 csprogs.c   |  3 ---
 gl_rmain.c  | 10 ----------
 protocol.h  |  1 -
 5 files changed, 76 deletions(-)

diff --git a/cl_main.c b/cl_main.c
index 4fad100..a15db14 100644
--- a/cl_main.c
+++ b/cl_main.c
@@ -93,8 +93,6 @@ cvar_t cl_deathnoviewmodel = {0, "cl_deathnoviewmodel", "1", "hides gun model wh
 cvar_t cl_locs_enable = {CVAR_SAVE, "locs_enable", "1", "enables replacement of certain % codes in chat messages: %l (location), %d (last death location), %h (health), %a (armor), %x (rockets), %c (cells), %r (rocket launcher status), %p (powerup status), %w (weapon status), %t (current time in level)"};
 cvar_t cl_locs_show = {0, "locs_show", "0", "shows defined locations for editing purposes"};
 
-extern cvar_t r_equalize_entities_fullbright;
-
 client_static_t	cls;
 client_state_t	cl;
 
@@ -1166,8 +1164,6 @@ static void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit, qboolean int
 	{
 		if (!(e->render.effects & EF_FULLBRIGHT))
 			e->render.flags |= RENDER_LIGHT;
-		else if(r_equalize_entities_fullbright.integer)
-			e->render.flags |= RENDER_LIGHT | RENDER_EQUALIZE;
 	}
 	// hide player shadow during intermission or nehahra movie
 	if (!(e->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST))
@@ -1607,8 +1603,6 @@ static void CL_RelinkStaticEntities(void)
 		{
 			if (!(e->render.effects & EF_FULLBRIGHT))
 				e->render.flags |= RENDER_LIGHT;
-			else if(r_equalize_entities_fullbright.integer)
-				e->render.flags |= RENDER_LIGHT | RENDER_EQUALIZE;
 		}
 		// hide player shadow during intermission or nehahra movie
 		if (!(e->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST)) && (e->render.alpha >= 1))
@@ -2469,9 +2463,6 @@ extern cvar_t r_fullbright_directed_pitch;
 extern cvar_t r_fullbright_directed_ambient;
 extern cvar_t r_fullbright_directed_diffuse;
 extern cvar_t r_fullbright_directed;
-extern cvar_t r_equalize_entities_minambient;
-extern cvar_t r_equalize_entities_to;
-extern cvar_t r_equalize_entities_by;
 extern cvar_t r_hdr_glowintensity;
 
 static void CL_UpdateEntityShading_GetDirectedFullbright(vec3_t ambient, vec3_t diffuse, vec3_t worldspacenormal)
@@ -2589,56 +2580,6 @@ static void CL_UpdateEntityShading_Entity(entity_render_t *ent)
 			CL_UpdateEntityShading_GetDirectedFullbright(a, c, dir);
 		else
 			R_CompleteLightPoint(a, c, dir, shadingorigin, LP_LIGHTMAP, r_refdef.scene.lightmapintensity, r_refdef.scene.ambientintensity);
-
-		if (ent->flags & RENDER_EQUALIZE)
-		{
-			// first fix up ambient lighting...
-			if (r_equalize_entities_minambient.value > 0)
-			{
-				fd = 0.299f * ent->render_modellight_diffuse[0] + 0.587f * ent->render_modellight_diffuse[1] + 0.114f * ent->render_modellight_diffuse[2];
-				if (fd > 0)
-				{
-					fa = (0.299f * ent->render_modellight_ambient[0] + 0.587f * ent->render_modellight_ambient[1] + 0.114f * ent->render_modellight_ambient[2]);
-					if (fa < r_equalize_entities_minambient.value * fd)
-					{
-						// solve:
-						//   fa'/fd' = minambient
-						//   fa'+0.25*fd' = fa+0.25*fd
-						//   ...
-						//   fa' = fd' * minambient
-						//   fd'*(0.25+minambient) = fa+0.25*fd
-						//   ...
-						//   fd' = (fa+0.25*fd) * 1 / (0.25+minambient)
-						//   fa' = (fa+0.25*fd) * minambient / (0.25+minambient)
-						//   ...
-						fdd = (fa + 0.25f * fd) / (0.25f + r_equalize_entities_minambient.value);
-						f = fdd / fd; // f>0 because all this is additive; f<1 because fdd<fd because this follows from fa < r_equalize_entities_minambient.value * fd
-						for (q = 0; q < 3; q++)
-						{
-							a[q] = (1 - f)*0.25f * c[q];
-							c[q] *= f;
-						}
-					}
-				}
-			}
-
-			if (r_equalize_entities_to.value > 0 && r_equalize_entities_by.value != 0)
-			{
-				fa = 0.299f * a[0] + 0.587f * a[1] + 0.114f * a[2];
-				fd = 0.299f * c[0] + 0.587f * c[1] + 0.114f * c[2];
-				f = fa + 0.25 * fd;
-				if (f > 0)
-				{
-					// adjust brightness and saturation to target
-					float l2 = r_equalize_entities_by.value, l1 = 1 - l2;
-					for (q = 0; q < 3; q++)
-					{
-						a[q] = l1 * a[q] + l2 * (fa / f);
-						c[q] = l1 * c[q] + l2 * (fd / f);
-					}
-				}
-			}
-		}
 	}
 
 	for (q = 0; q < 3; q++)
diff --git a/clvm_cmds.c b/clvm_cmds.c
index 51f64b5..e0ac5e7 100644
--- a/clvm_cmds.c
+++ b/clvm_cmds.c
@@ -21,7 +21,6 @@
 //4 feature darkplaces csqc: add builtins to clientside qc for gl calls
 
 extern cvar_t v_flipped;
-extern cvar_t r_equalize_entities_fullbright;
 
 r_refdef_view_t csqc_original_r_refdef_view;
 r_refdef_view_t csqc_main_r_refdef_view;
@@ -1811,8 +1810,6 @@ static void VM_CL_makestatic (prvm_prog_t *prog)
 		{
 			if (!(staticent->render.effects & EF_FULLBRIGHT))
 				staticent->render.flags |= RENDER_LIGHT;
-			else if(r_equalize_entities_fullbright.integer)
-				staticent->render.flags |= RENDER_LIGHT | RENDER_EQUALIZE;
 		}
 		// turn off shadows from transparent objects
 		if (!(staticent->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST)) && (staticent->render.alpha >= 1))
diff --git a/csprogs.c b/csprogs.c
index 68dbd83..88c1241 100644
--- a/csprogs.c
+++ b/csprogs.c
@@ -286,7 +286,6 @@ void CSQC_Think (prvm_edict_t *ed)
 }
 
 extern cvar_t cl_noplayershadow;
-extern cvar_t r_equalize_entities_fullbright;
 qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
 {
 	prvm_prog_t *prog = CLVM_prog;
@@ -396,8 +395,6 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
 	{
 		if (!(entrender->effects & EF_FULLBRIGHT) && !(renderflags & RF_FULLBRIGHT))
 			entrender->flags |= RENDER_LIGHT;
-		else if(r_equalize_entities_fullbright.integer)
-			entrender->flags |= RENDER_LIGHT | RENDER_EQUALIZE;
 	}
 	// hide player shadow during intermission or nehahra movie
 	if (!(entrender->effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST))
diff --git a/gl_rmain.c b/gl_rmain.c
index d6ea4ba..bb32320 100644
--- a/gl_rmain.c
+++ b/gl_rmain.c
@@ -69,12 +69,6 @@ cvar_t r_motionblur_mousefactor = {CVAR_SAVE, "r_motionblur_mousefactor", "2", "
 cvar_t r_motionblur_mousefactor_minspeed = {CVAR_SAVE, "r_motionblur_mousefactor_minspeed", "0", "lower value of mouse acceleration when it starts to factor into blur equation"};
 cvar_t r_motionblur_mousefactor_maxspeed = {CVAR_SAVE, "r_motionblur_mousefactor_maxspeed", "50", "upper value of mouse acceleration when it reaches the peak factor into blur equation"};
 
-// TODO do we want a r_equalize_entities cvar that works on all ents, or would that be a cheat?
-cvar_t r_equalize_entities_fullbright = {CVAR_SAVE, "r_equalize_entities_fullbright", "0", "render fullbright entities by equalizing their lightness, not by not rendering light (DEPRECATED)"};
-cvar_t r_equalize_entities_minambient = {CVAR_SAVE, "r_equalize_entities_minambient", "0.5", "light equalizing: ensure at least this ambient/diffuse ratio (DEPRECATED)"};
-cvar_t r_equalize_entities_by = {CVAR_SAVE, "r_equalize_entities_by", "0.7", "light equalizing: exponent of dynamics compression (0 = no compression, 1 = full compression) (DEPRECATED)"};
-cvar_t r_equalize_entities_to = {CVAR_SAVE, "r_equalize_entities_to", "0.8", "light equalizing: target light level (DEPRECATED)"};
-
 cvar_t r_depthfirst = {CVAR_SAVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"};
 cvar_t r_useinfinitefarclip = {CVAR_SAVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"};
 cvar_t r_farclip_base = {0, "r_farclip_base", "65536", "farclip (furthest visible distance) for rendering when r_useinfinitefarclip is 0"};
@@ -3202,10 +3196,6 @@ void GL_Main_Init(void)
 	Cvar_RegisterVariable(&r_motionblur_mousefactor);
 	Cvar_RegisterVariable(&r_motionblur_mousefactor_minspeed);
 	Cvar_RegisterVariable(&r_motionblur_mousefactor_maxspeed);
-	Cvar_RegisterVariable(&r_equalize_entities_fullbright);
-	Cvar_RegisterVariable(&r_equalize_entities_minambient);
-	Cvar_RegisterVariable(&r_equalize_entities_by);
-	Cvar_RegisterVariable(&r_equalize_entities_to);
 	Cvar_RegisterVariable(&r_depthfirst);
 	Cvar_RegisterVariable(&r_useinfinitefarclip);
 	Cvar_RegisterVariable(&r_farclip_base);
diff --git a/protocol.h b/protocol.h
index a3a2677..8a83cba 100644
--- a/protocol.h
+++ b/protocol.h
@@ -340,7 +340,6 @@ void Protocol_Names(char *buffer, size_t buffersize);
 #define RENDER_LIGHT 131072 // receive light
 #define RENDER_NOSELFSHADOW 262144 // render lighting on this entity before its own shadow is added to the scene
 // (note: all RENDER_NOSELFSHADOW entities are grouped together and rendered in a batch before their shadows are rendered, so they can not shadow eachother either)
-#define RENDER_EQUALIZE 524288 // (subflag of RENDER_LIGHT) equalize the light from the light grid hitting this ent (less invasive EF_FULLBRIGHT implementation)
 #define RENDER_NODEPTHTEST 1048576
 #define RENDER_ADDITIVE 2097152
 #define RENDER_DOUBLESIDED 4194304