From 4b4bb948efaac24ffb52b2f4679d4a3f9b74e2af Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Fri, 25 Oct 2024 02:07:18 +0300 Subject: [PATCH] Reduce indentation. --- src/refresh/shader.c | 146 +++++++++++++++++++++---------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/src/refresh/shader.c b/src/refresh/shader.c index b3ebe6a17..782a1101a 100644 --- a/src/refresh/shader.c +++ b/src/refresh/shader.c @@ -322,26 +322,26 @@ static void write_vertex_shader(sizebuf_t *buf, glStateBits_t bits) GLSL(out vec3 v_world_pos;) GLSF("void main() {\n"); - if (bits & GLS_CLASSIC_SKY) { - GLSL(v_dir = (m_sky[1] * a_pos).xyz;) - } else if (bits & GLS_DEFAULT_SKY) { - GLSL(v_dir = (m_sky[0] * a_pos).xyz;) - } else if (bits & GLS_SCROLL_ENABLE) { - GLSL(v_tc = a_tc + u_scroll;) - } else { - GLSL(v_tc = a_tc;) - } + if (bits & GLS_CLASSIC_SKY) { + GLSL(v_dir = (m_sky[1] * a_pos).xyz;) + } else if (bits & GLS_DEFAULT_SKY) { + GLSL(v_dir = (m_sky[0] * a_pos).xyz;) + } else if (bits & GLS_SCROLL_ENABLE) { + GLSL(v_tc = a_tc + u_scroll;) + } else { + GLSL(v_tc = a_tc;) + } - if (bits & GLS_LIGHTMAP_ENABLE) - GLSL(v_lmtc = a_lmtc;) + if (bits & GLS_LIGHTMAP_ENABLE) + GLSL(v_lmtc = a_lmtc;) - if (!(bits & GLS_TEXTURE_REPLACE)) - GLSL(v_color = a_color;) + if (!(bits & GLS_TEXTURE_REPLACE)) + GLSL(v_color = a_color;) - if (bits & GLS_FOG_HEIGHT) - GLSL(v_world_pos = (m_model * a_pos).xyz;) + if (bits & GLS_FOG_HEIGHT) + GLSL(v_world_pos = (m_model * a_pos).xyz;) - GLSL(gl_Position = m_vp * a_pos;) + GLSL(gl_Position = m_vp * a_pos;) GLSF("}\n"); } @@ -407,78 +407,78 @@ static void write_fragment_shader(sizebuf_t *buf, glStateBits_t bits) GLSL(in vec3 v_world_pos;) GLSF("void main() {\n"); - if (bits & GLS_CLASSIC_SKY) { - GLSL( - float len = length(v_dir); - vec2 dir = v_dir.xy * (3.0 / len); - vec2 tc1 = dir + vec2(u_time * 0.0625); - vec2 tc2 = dir + vec2(u_time * 0.1250); - vec4 solid = texture(u_texture1, tc1); - vec4 alpha = texture(u_texture2, tc2); - vec4 diffuse = vec4((solid.rgb - alpha.rgb * 0.25) * 0.65, 1.0); - ) - } else if (bits & GLS_DEFAULT_SKY) { - GLSL(vec4 diffuse = texture(u_texture, v_dir);) - } else { - GLSL(vec2 tc = v_tc;) + if (bits & GLS_CLASSIC_SKY) { + GLSL( + float len = length(v_dir); + vec2 dir = v_dir.xy * (3.0 / len); + vec2 tc1 = dir + vec2(u_time * 0.0625); + vec2 tc2 = dir + vec2(u_time * 0.1250); + vec4 solid = texture(u_texture1, tc1); + vec4 alpha = texture(u_texture2, tc2); + vec4 diffuse = vec4((solid.rgb - alpha.rgb * 0.25) * 0.65, 1.0); + ) + } else if (bits & GLS_DEFAULT_SKY) { + GLSL(vec4 diffuse = texture(u_texture, v_dir);) + } else { + GLSL(vec2 tc = v_tc;) - if (bits & GLS_WARP_ENABLE) - GLSL(tc += w_amp * sin(tc.ts * w_phase + u_time);) + if (bits & GLS_WARP_ENABLE) + GLSL(tc += w_amp * sin(tc.ts * w_phase + u_time);) - GLSL(vec4 diffuse = texture(u_texture, tc);) - } - - if (bits & GLS_ALPHATEST_ENABLE) - GLSL(if (diffuse.a <= 0.666) discard;) + GLSL(vec4 diffuse = texture(u_texture, tc);) + } - if (bits & GLS_LIGHTMAP_ENABLE) { - GLSL(vec4 lightmap = texture(u_lightmap, v_lmtc);) + if (bits & GLS_ALPHATEST_ENABLE) + GLSL(if (diffuse.a <= 0.666) discard;) - if (bits & GLS_GLOWMAP_ENABLE) { - GLSL(vec4 glowmap = texture(u_glowmap, tc);) - GLSL(lightmap.rgb = mix(lightmap.rgb, vec3(1.0), glowmap.a);) - } + if (bits & GLS_LIGHTMAP_ENABLE) { + GLSL(vec4 lightmap = texture(u_lightmap, v_lmtc);) - GLSL(diffuse.rgb *= (lightmap.rgb + u_add) * u_modulate;) + if (bits & GLS_GLOWMAP_ENABLE) { + GLSL(vec4 glowmap = texture(u_glowmap, tc);) + GLSL(lightmap.rgb = mix(lightmap.rgb, vec3(1.0), glowmap.a);) } - if (bits & GLS_INTENSITY_ENABLE) - GLSL(diffuse.rgb *= u_intensity;) + GLSL(diffuse.rgb *= (lightmap.rgb + u_add) * u_modulate;) + } - if (bits & GLS_DEFAULT_FLARE) - GLSL( - diffuse.rgb *= (diffuse.r + diffuse.g + diffuse.b) / 3.0; - diffuse.rgb *= v_color.a; - ) + if (bits & GLS_INTENSITY_ENABLE) + GLSL(diffuse.rgb *= u_intensity;) - if (!(bits & GLS_TEXTURE_REPLACE)) - GLSL(diffuse *= v_color;) + if (bits & GLS_DEFAULT_FLARE) + GLSL( + diffuse.rgb *= (diffuse.r + diffuse.g + diffuse.b) / 3.0; + diffuse.rgb *= v_color.a; + ) - if (!(bits & GLS_LIGHTMAP_ENABLE) && (bits & GLS_GLOWMAP_ENABLE)) { - GLSL(vec4 glowmap = texture(u_glowmap, tc);) - if (bits & GLS_INTENSITY_ENABLE) - GLSL(diffuse.rgb += glowmap.rgb * u_intensity2;) - else - GLSL(diffuse.rgb += glowmap.rgb;) - } + if (!(bits & GLS_TEXTURE_REPLACE)) + GLSL(diffuse *= v_color;) - if (bits & (GLS_FOG_GLOBAL | GLS_FOG_HEIGHT)) - GLSL(float frag_depth = gl_FragCoord.z / gl_FragCoord.w;) + if (!(bits & GLS_LIGHTMAP_ENABLE) && (bits & GLS_GLOWMAP_ENABLE)) { + GLSL(vec4 glowmap = texture(u_glowmap, tc);) + if (bits & GLS_INTENSITY_ENABLE) + GLSL(diffuse.rgb += glowmap.rgb * u_intensity2;) + else + GLSL(diffuse.rgb += glowmap.rgb;) + } - if (bits & GLS_FOG_GLOBAL) - GLSL({ - float d = u_fog_color.a * frag_depth; - float fog = 1.0f - exp(-(d * d)); - diffuse.rgb = mix(diffuse.rgb, u_fog_color.rgb, fog); - }) + if (bits & (GLS_FOG_GLOBAL | GLS_FOG_HEIGHT)) + GLSL(float frag_depth = gl_FragCoord.z / gl_FragCoord.w;) - if (bits & GLS_FOG_HEIGHT) - write_height_fog(buf); + if (bits & GLS_FOG_GLOBAL) + GLSL({ + float d = u_fog_color.a * frag_depth; + float fog = 1.0f - exp(-(d * d)); + diffuse.rgb = mix(diffuse.rgb, u_fog_color.rgb, fog); + }) + + if (bits & GLS_FOG_HEIGHT) + write_height_fog(buf); - if (bits & GLS_FOG_SKY) - GLSL(diffuse.rgb = mix(diffuse.rgb, u_fog_color.rgb, u_fog_sky_factor);) + if (bits & GLS_FOG_SKY) + GLSL(diffuse.rgb = mix(diffuse.rgb, u_fog_color.rgb, u_fog_sky_factor);) - GLSL(o_color = diffuse;) + GLSL(o_color = diffuse;) GLSF("}\n"); }