1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-13 13:31:48 +00:00

Use proper UV in cubemap downsampler raster

This removes bias in cubemap downsampling shader that resulted in the bottom of cubemaps being over represented
This commit is contained in:
clayjohn
2023-05-03 01:06:34 -07:00
parent 2a0aef5f09
commit fb77021559

View File

@@ -55,15 +55,14 @@ void main() {
// Converted from compute shader which uses absolute coordinates. // Converted from compute shader which uses absolute coordinates.
// Could possibly simplify this // Could possibly simplify this
float face_size = float(params.face_size); float face_size = float(params.face_size);
if (uv_interp.x < face_size && uv_interp.y < face_size) {
float inv_face_size = 1.0 / face_size; float inv_face_size = 1.0 / face_size;
vec2 id = floor(uv_interp);
float u0 = (uv_interp.x * 2.0 + 1.0 - 0.75) * inv_face_size - 1.0; float u1 = (id.x * 2.0 + 1.0 + 0.75) * inv_face_size - 1.0;
float u1 = (uv_interp.x * 2.0 + 1.0 + 0.75) * inv_face_size - 1.0; float u0 = (id.x * 2.0 + 1.0 - 0.75) * inv_face_size - 1.0;
float v0 = (uv_interp.y * 2.0 + 1.0 - 0.75) * -inv_face_size + 1.0; float v0 = (id.y * 2.0 + 1.0 - 0.75) * -inv_face_size + 1.0;
float v1 = (uv_interp.y * 2.0 + 1.0 + 0.75) * -inv_face_size + 1.0; float v1 = (id.y * 2.0 + 1.0 + 0.75) * -inv_face_size + 1.0;
float weights[4]; float weights[4];
weights[0] = calcWeight(u0, v0); weights[0] = calcWeight(u0, v0);
@@ -159,5 +158,4 @@ void main() {
break; break;
} }
frag_color = color; frag_color = color;
}
} }