From 79409529b0ffd08052470517f7c6752b201f6ffd Mon Sep 17 00:00:00 2001 From: Barnaby <22575741+barnabwhy@users.noreply.github.com> Date: Tue, 30 Jan 2024 03:17:35 +0000 Subject: [PATCH] Make the lobby scene dark and add a bit of colour (#1968) * improve appearance of the lobby scene * more descriptive comments in lobby frag * english (unamerican) --- alvr/client_core/cpp/graphics.cpp | 46 +++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/alvr/client_core/cpp/graphics.cpp b/alvr/client_core/cpp/graphics.cpp index 1699f867da..3cf794f911 100644 --- a/alvr/client_core/cpp/graphics.cpp +++ b/alvr/client_core/cpp/graphics.cpp @@ -252,29 +252,54 @@ uniform lowp int Mode; void main() { if(Mode == 0){ // ground - lowp vec3 groundCenter = vec3(1.0, 1.0, 1.0); - lowp vec3 groundHorizon = vec3(1.0, 1.0, 1.0); + lowp vec3 groundCenter = vec3(0.0, 0.0, 0.00); + lowp vec3 groundHorizon = vec3(0.00, 0.00, 0.015); + + lowp vec3 gridClose = vec3(0.114, 0.545, 0.804); + lowp vec3 gridFar = vec3(0.259, 0.863, 0.886); + + lowp float lineFadeStart = 10.0; + lowp float lineFadeEnd = 50.0; + lowp float lineFadeDist = lineFadeEnd - lineFadeStart; + + lowp float lineBloom = 10.0; lowp float distance = length(position.xz); + // Pick a coordinate to visualize in a grid lowp vec2 coord = position.xz / 2.0; + // Compute anti-aliased world-space grid lines lowp vec2 grid = abs(fract(coord - 0.5) - 0.5) / fwidth(coord); - lowp float line = min(grid.x, grid.y); - outColor.rgb = vec3(min(line, 1.0) * (1.0 - exp(-distance / 5.0 - 0.01) / 4.0)) * groundCenter; - if(distance > 3.0){ - lowp float coef = 1.0 - 3.0 / distance; + + // Create mask for grid lines and fade over distance + lowp float line = clamp(1.0 - min(grid.x, grid.y), 0.0, 1.0); + line *= clamp((lineFadeStart - distance) / lineFadeDist, 0.0, 1.0); + + // Fill in normal ground colour + outColor.rgb = groundCenter * (1.0 - line); + + // Add cheap and simple "bloom" to the grid lines + line *= 1.0 + lineBloom; + + // Fill in grid line colour + outColor.rgb += line * mix(gridFar, gridClose, clamp((lineFadeEnd - distance) / lineFadeEnd, 0.0, 1.0)); + + // Fade to the horizon colour over distance + if(distance > 10.0){ + lowp float coef = 1.0 - 10.0 / distance; outColor.rgb = (1.0 - coef) * outColor.rgb + coef * groundHorizon; } + outColor.a = 1.0; } else if(Mode == 1) { // text - lowp vec3 textColor = vec3(0.0, 0.0, 0.0); + lowp vec3 textColor = vec3(1.0, 1.0, 1.0); outColor.rgb = textColor; outColor.a = texture(sTexture, uv).a; } else { // sky - lowp vec3 skyCenter = vec3(0.95, 0.95, 0.95); - lowp vec3 skyHorizon = vec3(1.0, 1.0, 1.0); + lowp vec3 skyCenter = vec3(0.0, 0.0, 0.0); + lowp vec3 skyHorizon = vec3(0.0, 0.0, 0.02); lowp float coef = 1.0; if(position.y < 50.0){ @@ -287,9 +312,6 @@ void main() outColor.a = 1.0; outColor.rgb = skyCenter * coef + skyHorizon * (1.0 - coef); } - - // invert. looks good only for black and white - outColor.rgb = 1.0 - outColor.rgb; } )glsl";