Skip to content

Commit

Permalink
Reduce indentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
skullernet committed Oct 24, 2024
1 parent 700de33 commit 4b4bb94
Showing 1 changed file with 73 additions and 73 deletions.
146 changes: 73 additions & 73 deletions src/refresh/shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down Expand Up @@ -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");
}

Expand Down

0 comments on commit 4b4bb94

Please sign in to comment.