Skip to content

Commit

Permalink
Make the lobby scene dark and add a bit of colour (#1968)
Browse files Browse the repository at this point in the history
* improve appearance of the lobby scene

* more descriptive comments in lobby frag

* english (unamerican)
  • Loading branch information
barnabwhy authored Jan 30, 2024
1 parent 2ed6b51 commit 7940952
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions alvr/client_core/cpp/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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";

Expand Down

0 comments on commit 7940952

Please sign in to comment.