Clean up constants in shaders
This commit is contained in:
parent
09e0feb4ff
commit
8b99a617f4
3 changed files with 7 additions and 6 deletions
|
@ -1,10 +1,12 @@
|
|||
const PI = 3.14159;
|
||||
const INV_SQRT_2 = 0.70710678118654752440; // 1 / sqrt(2)
|
||||
const INV_SQRT_3 = 0.57735026918962576451; // 1 / sqrt(3)
|
||||
|
||||
// in every direction from 0,0
|
||||
// total = (2n + 1)^2
|
||||
const SHADOW_SAMPLES = 2;
|
||||
const INV_SHADOW_SAMPLES = 1.0 / 25.0;
|
||||
|
||||
const FOG_MAX_STEPS = 30;
|
||||
const FOG_STEP_SIZE = 5.0;
|
||||
const FOG_LIGHT_MAX_STEPS = 10;
|
||||
|
@ -13,3 +15,6 @@ const FOG_DENSITY = 2.0;
|
|||
const FOG_LIGHT_DENSITY = 3.0;
|
||||
const FOG_ALPHA = 1.0;
|
||||
const FOG_AMBIENT = 0.06;
|
||||
const FOG_DENSITY_COLOR = vec2<f32>(0.5, 0.1);
|
||||
|
||||
const PBR_AMBIENT = 0.02;
|
||||
|
|
|
@ -140,7 +140,7 @@ fn fs_main(vert: FogVertexOutput) -> @location(0) vec4<f32> {
|
|||
let fog_depth = march_result.y;
|
||||
let occlusion = march_result.z;
|
||||
|
||||
let base_color = vec3<f32>(mix(0.5, 0.1, fog_density));
|
||||
let base_color = vec3<f32>(mix(FOG_DENSITY_COLOR.x, FOG_DENSITY_COLOR.y, fog_density));
|
||||
let ambient_strength = FOG_AMBIENT;
|
||||
let ambient_color = base_color * ambient_strength;
|
||||
|
||||
|
|
|
@ -113,16 +113,12 @@ fn fs_main(vert: VertexOutput) -> @location(0) vec4<f32> {
|
|||
}
|
||||
|
||||
// ambient
|
||||
let ambient_strength = 0.02;
|
||||
let ambient_color = ambient_strength * albedo;
|
||||
let ambient_color = PBR_AMBIENT * albedo;
|
||||
|
||||
var result = ambient_color + total_radiance;
|
||||
|
||||
// tonemap
|
||||
result = result / (result + vec3(1.0));
|
||||
// gamma correction
|
||||
// TODO: seems to already be handled by wgpu?
|
||||
// result = pow(result, vec3(1.0/2.2));
|
||||
|
||||
return vec4<f32>(result, object_color.a);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue