medfall

A super great game engine
Log | Files | Refs

commit 8aa4d7eedda52cb594c0530b8a4a6f7e6b6bbbb8
parent 30449bd44266d91e55eea9c8ca539e348cd2535c
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue,  8 Jan 2019 19:32:01 +0200

BSP render test

Diffstat:
bsp.cc | 3++-
bsp_renderer.cc | 21++++++++++++++++++---
shaders.cc | 1+
shaders/gbuffer.glsl | 4+++-
4 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/bsp.cc b/bsp.cc @@ -353,7 +353,7 @@ static v2 screen_pos( const m4 & P, const m4 & V, v3 camera_pos, v3 target, v2 c } GAME_INIT( game_init ) { - bsp_init( &game->bsp, "assets/wbomb6.bsp" ); + bsp_init( &game->bsp, "assets/cocaine_b2.bsp" ); game->pos = v3( 0, -100, 450 ); game->pitch = 0; @@ -527,6 +527,7 @@ GAME_FRAME( game_frame ) { render_state.textures[ 0 ] = world_depth_and_normals.textures[ OUTPUT_NORMAL ]; render_state.textures[ 1 ] = world_depth_and_normals.textures[ OUTPUT_DEPTH ]; render_state.textures[ 2 ] = model_depth_outline.textures[ OUTPUT_DEPTH ]; + render_state.textures[ 3 ] = renderer_blue_noise(); bspr_render( &game->bspr, render_state ); diff --git a/bsp_renderer.cc b/bsp_renderer.cc @@ -9,9 +9,24 @@ #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.3, 0.3, 0.3 ); - return v3( 0.5, 0.5, 0.5 ); + if(strcmp(bsp->textures[face.texture].name, "textures/cocaine/s_lazery_blue") == 0) + return v3( 0.02, 0.7, 0.65 ); + if(strcmp(bsp->textures[face.texture].name, "textures/cocaine/s_lazery_green") == 0) + return v3( 0.25, 0.7, 0.02 ); + if(strcmp(bsp->textures[face.texture].name, "textures/cocaine/s_lazery_kush") == 0) + return v3( 0.6, 0.02, 0.7 ); + if(strcmp(bsp->textures[face.texture].name, "textures/cocaine/s_lazery_orange") == 0) + return v3( 0.7, 0.4, 0.02 ); + if(strcmp(bsp->textures[face.texture].name, "textures/cocaine/s_lazery_red") == 0) + return v3( 0.7, 0.02, 0.2 ); + if(strcmp(bsp->textures[face.texture].name, "textures/cocaine/s_lazery_white") == 0) + return v3( 0.85, 0.85, 0.85 ); + if(strcmp(bsp->textures[face.texture].name, "textures/world/lava") == 0) + return v3( 1.0, 0.19, 0.02 ); + if(strcmp(bsp->textures[face.texture].name, "textures/blx/new_sky") == 0) + return v3( 1, 1, 1 ); + + return v3( 0.03, 0.03, 0.03 ); 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) { diff --git a/shaders.cc b/shaders.cc @@ -78,6 +78,7 @@ void shaders_init() { shaders[ SHADER_GBUFFER ].texture_uniform_names[ 0 ] = "world_normal"; shaders[ SHADER_GBUFFER ].texture_uniform_names[ 1 ] = "world_depth"; shaders[ SHADER_GBUFFER ].texture_uniform_names[ 2 ] = "outline_depth"; + shaders[ SHADER_GBUFFER ].texture_uniform_names[ 3 ] = "blue_noise"; shaders[ SHADER_DEPTH_EDGE ].path = "shaders/depth_edge.glsl"; shaders[ SHADER_DEPTH_EDGE ].texture_uniform_names[ 0 ] = "model_depth"; diff --git a/shaders/gbuffer.glsl b/shaders/gbuffer.glsl @@ -10,6 +10,7 @@ layout( std140 ) uniform model { uniform sampler2D world_normal; uniform sampler2D world_depth; uniform sampler2D outline_depth; +uniform sampler2D blue_noise; struct VSOut { vec3 colour; @@ -81,9 +82,10 @@ void main() { vec3 edgeness = vec3( max( edgeness_depth, edgeness_normal ) ); - vec3 colour = texture( outline_depth, uv ).r > d4 ? vec3( 1.0, 0.0, 0.0 ) : v2f.colour - edgeness; + vec3 colour = texture( outline_depth, uv ).r > d4 ? vec3( 1.0, 0.0, 0.0 ) : v2f.colour; screen_colour = vec4( colour, 1.0 ); + screen_colour += vec4( vec3( d4 / 10.0 ) + get_dither_noise( blue_noise ) + edgeness * vec3( 0.1 ), 1.0 ); } #endif