Fix rendering material when UV2 is compressed

This commit is contained in:
BlueCube3310 2025-02-06 20:17:49 +01:00
parent f0f5319b0b
commit 8714b36171
3 changed files with 24 additions and 3 deletions

View File

@ -713,7 +713,14 @@ void main() {
#endif
#ifdef RENDER_MATERIAL
gl_Position.xy = (uv2_attrib.xy + uv_offset) * 2.0 - 1.0;
vec2 uv_dest_attrib;
if (uv_scale != vec4(0.0)) {
uv_dest_attrib = (uv2_attrib.xy - 0.5) * uv_scale.zw;
} else {
uv_dest_attrib = uv2_attrib.xy;
}
gl_Position.xy = (uv_dest_attrib + uv_offset) * 2.0 - 1.0;
gl_Position.z = 0.00001;
gl_Position.w = 1.0;
#endif

View File

@ -652,8 +652,15 @@ void vertex_shader(vec3 vertex_input,
#endif
#ifdef MODE_RENDER_MATERIAL
if (scene_data.material_uv2_mode) {
vec2 uv_dest_attrib;
if (uv_scale != vec4(0.0)) {
uv_dest_attrib = (uv2_attrib.xy - 0.5) * uv_scale.zw;
} else {
uv_dest_attrib = uv2_attrib.xy;
}
vec2 uv_offset = unpackHalf2x16(draw_call.uv_offset);
gl_Position.xy = (uv2_attrib.xy + uv_offset) * 2.0 - 1.0;
gl_Position.xy = (uv_dest_attrib + uv_offset) * 2.0 - 1.0;
gl_Position.z = 0.00001;
gl_Position.w = 1.0;
}

View File

@ -557,7 +557,14 @@ void main() {
#endif // MODE_RENDER_DEPTH
#ifdef MODE_RENDER_MATERIAL
if (scene_data.material_uv2_mode) {
gl_Position.xy = (uv2_attrib.xy + draw_call.uv_offset) * 2.0 - 1.0;
vec2 uv_dest_attrib;
if (uv_scale != vec4(0.0)) {
uv_dest_attrib = (uv2_attrib.xy - 0.5) * uv_scale.zw;
} else {
uv_dest_attrib = uv2_attrib.xy;
}
gl_Position.xy = (uv_dest_attrib + draw_call.uv_offset) * 2.0 - 1.0;
gl_Position.z = 0.00001;
gl_Position.w = 1.0;
}