ezquake-source icon indicating copy to clipboard operation
ezquake-source copied to clipboard

The latest works of the Master

Open tcsabina opened this issue 2 years ago • 6 comments

tcsabina avatar Oct 05 '22 22:10 tcsabina

r_fx_fog throws glsl compilation errors and drops my framerate quite a bit

VertexShader.Compile(aliasmodel[0]) failed Shader->Compile(8B31) failed -- Version: 4.6 (Compatibility Profile) Mesa 22.2.0 -- GLSL: 4.60 0:201(20): error: illegal use of reserved word `input' 0:201(20): error: syntax error, unexpected ERROR_TOK, expecting ')'

VertexShader.Compile(aliasmodel[0]) failed

ciscon avatar Oct 06 '22 14:10 ciscon

This correctly prevents client exiting due to:

Error: GL_Upload8: image too big (dirt_grey01: 1024x1024)

As for fog, I'm not seeing those errors with NVIDIA 3080 at least, just says shader compilation successful. Still confused about colors. qss vs fte/ezq does fog colors differently from world spawn attribute. Not sure if one format is legacy and other is not.

dsvensson avatar Oct 06 '22 15:10 dsvensson

this fixes it fyi:

diff --git a/gl_program.c b/gl_program.c
index e45f3f20..686df86d 100644
--- a/gl_program.c
+++ b/gl_program.c
@@ -1276,10 +1276,10 @@ static void GL_BuildCoreDefinitions(void)
                                "uniform float fogDensity;\n"
                                "uniform vec3 fogColor;\n"
                        "#endif\n"
-                               "vec4 applyFog(vec4 input, float z) {\n"
+                               "vec4 applyFog(vec4 vecinput, float z) {\n"
                                "       float fogmix = exp(-fogDensity * z);\n"
                                "       fogmix = clamp(fogmix, 0.0, 1.0); \n"
-                               "       return vec4(mix(fogColor, input.rgb, fogmix), 1) * input.a; \n"
+                               "       return vec4(mix(fogColor, vecinput.rgb, fogmix), 1) * vecinput.a; \n"
                                "}\n"
                        "#elif defined(FOG_EXP2)\n"
                                "const float LOG2 = 1.442695;\n"
@@ -1288,10 +1288,10 @@ static void GL_BuildCoreDefinitions(void)
                                "uniform vec3 fogColor;\n"
                        "#endif"
                                "\n"
-                               "vec4 applyFog(vec4 input, float z) {\n"
+                               "vec4 applyFog(vec4 vecinput, float z) {\n"
                                "       float fogmix = exp2(-fogDensity * z * z * LOG2);\n"
                                "       fogmix = clamp(fogmix, 0.0, 1.0);\n"
-                               "       return vec4(mix(fogColor, input.rgb, fogmix), 1) * input.a;\n"
+                               "       return vec4(mix(fogColor, vecinput.rgb, fogmix), 1) * vecinput.a;\n"
                                "}\n"
                        "#elif defined(FOG_LINEAR)\n"
                        "#ifdef EZ_LEGACY_GL\n"
@@ -1300,14 +1300,14 @@ static void GL_BuildCoreDefinitions(void)
                                "uniform vec3 fogColor; \n"
                        "#endif"
                                "\n"
-                               "vec4 applyFog(vec4 input, float z) {\n"
+                               "vec4 applyFog(vec4 vecinput, float z) {\n"
                                        "float fogmix = (fogMaxZ - z) / (fogMaxZ - fogMinZ); \n"
                                        "fogmix = clamp(fogmix, 0.0, 1.0); \n"
-                                       "return vec4(mix(fogColor, input.rgb / input.a, fogmix), 1) * input.a; \n"
+                                       "return vec4(mix(fogColor, vecinput.rgb / vecinput.a, fogmix), 1) * vecinput.a; \n"
                                "}\n"
                        "#else\n"
-                               "vec4 applyFog(vec4 input, float z) {\n"
-                               "       return input; \n"
+                               "vec4 applyFog(vec4 vecinput, float z) {\n"
+                               "       return vecinput; \n"
                                "}\n"
                        "#endif\n"
                "#endif // DRAW_FOG\n", sizeof(core_definitions)

ciscon avatar Oct 06 '22 16:10 ciscon

...and this fixes loading fog color from maps

diff --git a/r_rmisc.c b/r_rmisc.c
index 04dbf54b..05682bcd 100644
--- a/r_rmisc.c
+++ b/r_rmisc.c
@@ -192,9 +192,9 @@ static qbool R_ParseWorldspawn(const char* entstring, worldspawn_info_t* worldsp
 			Cmd_TokenizeStringEx(&fog, temp);
 			if (Cmd_ArgcEx(&fog) == 4) {
 				worldspawn->fog_density = atof(Cmd_ArgvEx(&fog, 0));
-				worldspawn->fog_color[0] = atof(Cmd_ArgvEx(&fog, 0));
-				worldspawn->fog_color[1] = atof(Cmd_ArgvEx(&fog, 1));
-				worldspawn->fog_color[2] = atof(Cmd_ArgvEx(&fog, 2));
+				worldspawn->fog_color[0] = atof(Cmd_ArgvEx(&fog, 1));
+				worldspawn->fog_color[1] = atof(Cmd_ArgvEx(&fog, 2));
+				worldspawn->fog_color[2] = atof(Cmd_ArgvEx(&fog, 3));
 
 				worldspawn->fog_density = bound(0, worldspawn->fog_density, 1);
 				worldspawn->fog_color[0] = bound(0, worldspawn->fog_color[0], 1);

dsvensson avatar Oct 06 '22 18:10 dsvensson

All rockettrails except blood (4, 5) are not drawn if fog is enabled, haven't checked other particle effects.

dsvensson avatar Oct 06 '22 22:10 dsvensson

@ciscon @dsvensson, your patches are part of #692, as I was not able to update this PR.

tcsabina avatar Oct 08 '22 18:10 tcsabina

This PR is closed, as the follow-up (#692) will be merged. That one contains some patches on top of this.

tcsabina avatar Oct 17 '22 21:10 tcsabina