From 622e634e1cfd55dd875979a1f109a804d3dbe7ee Mon Sep 17 00:00:00 2001 From: quou Date: Thu, 9 Jan 2025 22:53:40 +1100 Subject: mipmap the environment probe --- intermediate/mip_spec.glsl | 44 ++++++++++++++++++++++++++++++++++++++++++++ intermediate/plastic.mat | 2 +- intermediate/surface.glsl | 4 ++-- 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 intermediate/mip_spec.glsl (limited to 'intermediate') diff --git a/intermediate/mip_spec.glsl b/intermediate/mip_spec.glsl new file mode 100644 index 0000000..bddcbb0 --- /dev/null +++ b/intermediate/mip_spec.glsl @@ -0,0 +1,44 @@ +#ifdef DESC +[program] +type: graphics +vertex: main +fragment: main + +[binding] +name: verts +rate: vertex +[attribute] +name: position +type: vec2 +[attribute] +name: uv +type: vec2 + +[interpolator] +name: uv +type: vec2 + +[texture] +name: src +stage: fragment +dimension: 2 + +[target] +name: colour +type: vec4 +#endif + +#ifdef VERTEX_SHADER +void main() { + interpolator.uv = uv; + gl_Position = vec4(position, 1.0, 1.0); +} +#endif + +#ifdef FRAGMENT_SHADER +void main() { + vec2 uv = interpolator.uv; + colour = texture(src, uv); +} +#endif + diff --git a/intermediate/plastic.mat b/intermediate/plastic.mat index 3d59385..bb52092 100644 --- a/intermediate/plastic.mat +++ b/intermediate/plastic.mat @@ -1,6 +1,6 @@ [params] metalness: 0.0 -roughness: 0.1 +roughness: 0.3 ao: 1.0 albedo: ff0000 diff --git a/intermediate/surface.glsl b/intermediate/surface.glsl index 8ec24f0..fab8694 100644 --- a/intermediate/surface.glsl +++ b/intermediate/surface.glsl @@ -165,8 +165,8 @@ void main() { float met = texture(metal, uv).r * material.metalness; vec3 ref = reflect(-view_dir, nrm); - vec3 spec_col = texture(env_cube, ref).rgb; - vec3 amb_col = texture(env_cube, nrm).rgb; + vec3 spec_col = texture(env_cube, ref, material.roughness * 8.0).rgb; + vec3 amb_col = textureLod(env_cube, nrm, 8.0).rgb; vec3 diffuse = diffuse_brdf(uv) * -- cgit v1.2.3-54-g00ecf