medfall

A super great game engine
Log | Files | Refs

commit 4c8c849ad74a77037517b53a36ff926271106f27
parent 30c810ce445ddc5d0737475a3942d4c6b40b26cb
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat, 13 Oct 2018 23:25:27 +0900

BSP tweaks

Diffstat:
bsp_renderer.cc | 5++++-
shaders/gbuffer.glsl | 27++++++++++++---------------
2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/bsp_renderer.cc b/bsp_renderer.cc @@ -8,6 +8,9 @@ #include "renderer.h" v3 bspr_face_colour( const BSP * bsp, const BSP_Face & face ) { + if(strcmp(bsp->textures[face.texture].name, "textures/acidwdm2/sky_black") == 0) + return v3( 0.7, 0.7, 0.7 ); + return v3( 1, 1, 1 ); if(strcmp(bsp->textures[face.texture].name, "textures/acidwdm2/wall_olive033") == 0) { return v3(0, 0.33, 0); } else if(strcmp(bsp->textures[face.texture].name, "textures/acidwdm2/wall_olive066") == 0) { @@ -46,7 +49,7 @@ v3 bspr_face_colour( const BSP * bsp, const BSP_Face & face ) { } else if(strcmp(bsp->textures[face.texture].name, "textures/acidwdm2/struc_darkgrey") == 0) { return v3(0.5, 0.5, 0.5); } else if(strcmp(bsp->textures[face.texture].name, "textures/acidwdm2/sky_black") == 0) { - return v3(0, 0, 0); + return v3( 0.7, 0.7, 0.7 ); } else if(strcmp(bsp->textures[face.texture].name, "textures/acidwdm2/ink") == 0) { return v3( 0, 0, 0 ); } else { diff --git a/shaders/gbuffer.glsl b/shaders/gbuffer.glsl @@ -14,10 +14,8 @@ void main() { out vec4 screen_colour; -float LinearizeDepth(float depth) -{ - float z = depth * 2.0 - 1.0; // Back to NDC - return (2.0 * 0.1 * 10000.0) / (10000.0 + 0.1 - z * (10000.0 - 0.1)); +float linearize_depth( float depth ) { + return ( 2.0 + 0.1 ) / ( 10000.0 + 0.1 - depth * ( 10000.0 - 0.1 ) ); } void main() { @@ -26,15 +24,15 @@ void main() { vec2 uv = gl_FragCoord.xy / textureSize( albedo, 0 ); - float d0 = LinearizeDepth( texture( depth, uv + pixel.xy * pole.xx ).r ); // x1, y1 - float d1 = LinearizeDepth( texture( depth, uv + pixel.xy * pole.yx ).r ); // x2, y1 - float d2 = LinearizeDepth( texture( depth, uv + pixel.xy * pole.zx ).r ); // x3, y1 - float d3 = LinearizeDepth( texture( depth, uv + pixel.xy * pole.xy ).r ); // x1, y2 - // float d4 = LinearizeDepth( texture( depth, uv + pixel.xy * pole.yy ).r ); // x2, y2 - float d5 = LinearizeDepth( texture( depth, uv + pixel.xy * pole.zy ).r ); // x3, y2 - float d6 = LinearizeDepth( texture( depth, uv + pixel.xy * pole.xz ).r ); // x1, y3 - float d7 = LinearizeDepth( texture( depth, uv + pixel.xy * pole.yz ).r ); // x2, y3 - float d8 = LinearizeDepth( texture( depth, uv + pixel.xy * pole.zz ).r ); // x3, y3 + float d0 = linearize_depth( texture( depth, uv + pixel.xy * pole.xx ).r ); // x1, y1 + float d1 = linearize_depth( texture( depth, uv + pixel.xy * pole.yx ).r ); // x2, y1 + float d2 = linearize_depth( texture( depth, uv + pixel.xy * pole.zx ).r ); // x3, y1 + float d3 = linearize_depth( texture( depth, uv + pixel.xy * pole.xy ).r ); // x1, y2 + // float d4 = linearize_depth( texture( depth, uv + pixel.xy * pole.yy ).r ); // x2, y2 + float d5 = linearize_depth( texture( depth, uv + pixel.xy * pole.zy ).r ); // x3, y2 + float d6 = linearize_depth( texture( depth, uv + pixel.xy * pole.xz ).r ); // x1, y3 + float d7 = linearize_depth( texture( depth, uv + pixel.xy * pole.yz ).r ); // x2, y3 + float d8 = linearize_depth( texture( depth, uv + pixel.xy * pole.zz ).r ); // x3, y3 float edgeness_depth = ( abs( d1 - d7 ) + @@ -60,12 +58,11 @@ void main() { max( 0.0, 1.0 - dot( n2, n6 ) ) ) * 0.25; - edgeness_depth = max( edgeness_depth - 10.0, 0.0 ); edgeness_normal = max( edgeness_normal - 0.1, 0.0 ) / 0.9; vec4 edgeness = vec4( vec3( max( edgeness_depth, edgeness_normal ) ), 0.0 ); - screen_colour = texture( albedo, uv ) * 0.0001 + normal_to_01( texture( normal, uv ) ) - edgeness; + screen_colour = texture( albedo, uv ) - edgeness; } #endif