diff options
Diffstat (limited to 'client/src/shaders/fragment_pbr.wgsl')
-rw-r--r-- | client/src/shaders/fragment_pbr.wgsl | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/client/src/shaders/fragment_pbr.wgsl b/client/src/shaders/fragment_pbr.wgsl index f3ed37e..f3387a1 100644 --- a/client/src/shaders/fragment_pbr.wgsl +++ b/client/src/shaders/fragment_pbr.wgsl @@ -17,7 +17,8 @@ struct VertexOut { @builtin(position) clip: vec4<f32>, @location(0) normal: vec3<f32>, @location(1) tangent: vec3<f32>, - @location(2) texcoord: vec2<f32>, + @location(2) view: vec3<f32>, + @location(3) texcoord: vec2<f32>, } struct Material { @@ -44,9 +45,15 @@ fn main(vo: VertexOut) -> @location(0) vec4<f32> { let normal = tangent_basis * (t_normal.rgb * 2. - 1.); let alpha = t_albedo.a; - let lighting = mix(1., saturate(dot(LIGHT, normal)), 0.9); + + let ambient = 0.1; + let diffuse = saturate(dot(LIGHT, normal)); + let specular = pow(dot(reflect(-LIGHT, normal), vo.view), material.roughness); + + let lighting = ambient + diffuse; // + specular; let color = t_albedo.rgb * lighting; + // let color = vec3(dot(normalize(vo.normal), normalize(vo.view)) * 0.5 + 0.5) ; // TODO better (and faster?) randomness for alpha dither if fract(dot(sin(vo.clip * 123.) * 1213., vec4(3., 2., 1., 4.))) > alpha { |