diff options
| author | Dave Parks <davep@lindenlab.com> | 2024-06-11 13:27:54 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-11 13:27:54 -0500 | 
| commit | 429c92ad75fd3b3f7b9dfc52ed034b25004a3b9c (patch) | |
| tree | 2df4c730b78cdd1cd6bac4c119585f9ad44718d1 /indra/newview/app_settings/shaders/class1/gltf | |
| parent | 961b6b0c7e2499118c294810aeb9c5c0ac5df189 (diff) | |
#1687 Add support for KHR_texture_transform (#1717)
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/gltf')
| -rw-r--r-- | indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl | 3 | ||||
| -rw-r--r-- | indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl | 37 | 
2 files changed, 33 insertions, 7 deletions
| diff --git a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl index d71a3fad99..99bfcf70fa 100644 --- a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl +++ b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl @@ -61,6 +61,7 @@ in vec3 vary_tangent;  flat in float vary_sign;  in vec2 normal_texcoord;  in vec2 metallic_roughness_texcoord; +in vec2 occlusion_texcoord;  #endif  // ================================== @@ -199,7 +200,7 @@ void main()      //   roughness 0.0      //   metal     0.0      vec3 orm = texture(metallicRoughnessMap, metallic_roughness_texcoord.xy).rgb; -    orm.r = texture(occlusionMap, metallic_roughness_texcoord.xy).r; +    orm.r = texture(occlusionMap, occlusion_texcoord.xy).r;      orm.g *= roughnessFactor;      orm.b *= metallicFactor;  #endif diff --git a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl index f123c29101..bc9a47d41e 100644 --- a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl +++ b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl @@ -39,6 +39,7 @@ uniform vec4[2] texture_base_color_transform;  uniform vec4[2] texture_normal_transform;  uniform vec4[2] texture_metallic_roughness_transform;  uniform vec4[2] texture_emissive_transform; +uniform vec4[2] texture_occlusion_transform;  in vec3 position;  in vec4 diffuse_color; @@ -53,13 +54,37 @@ in vec3 normal;  in vec4 tangent;  out vec2 normal_texcoord;  out vec2 metallic_roughness_texcoord; +out vec2 occlusion_texcoord;  out vec3 vary_tangent;  flat out float vary_sign;  out vec3 vary_normal;  vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform);  #endif -vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); +vec2 gltf_texture_transform(vec2 texcoord, vec4[2] p) +{ +    texcoord.y = 1.0 - texcoord.y; + +    vec2 Scale = p[0].xy; +    float Rotation = -p[0].z; +    vec2 Offset = vec2(p[0].w, p[1].x); + +    mat3 translation = mat3(1,0,0, 0,1,0, Offset.x, Offset.y, 1); +    mat3 rotation = mat3( +        cos(Rotation), sin(Rotation), 0, +        -sin(Rotation), cos(Rotation), 0, +        0, 0, 1); + +    mat3 scale = mat3(Scale.x,0,0, 0,Scale.y,0, 0,0,1); + +    mat3 matrix = translation * rotation * scale; + +    vec2 uvTransformed = ( matrix * vec3(texcoord.xy, 1) ).xy; + +    uvTransformed.y = 1.0 - uvTransformed.y; + +    return uvTransformed; +}  #ifdef ALPHA_BLEND @@ -136,14 +161,14 @@ void main()      gl_Position = vert;  #endif -    base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); -    emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0); +    base_color_texcoord = gltf_texture_transform(texcoord0, texture_base_color_transform); +    emissive_texcoord = gltf_texture_transform(texcoord0, texture_emissive_transform);  #ifndef UNLIT -    normal_texcoord = texture_transform(texcoord0, texture_normal_transform, texture_matrix0); -    metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_transform, texture_matrix0); +    normal_texcoord = gltf_texture_transform(texcoord0, texture_normal_transform); +    metallic_roughness_texcoord = gltf_texture_transform(texcoord0, texture_metallic_roughness_transform); +    occlusion_texcoord = gltf_texture_transform(texcoord0, texture_occlusion_transform);  #endif -      #ifndef UNLIT  #ifdef HAS_SKIN | 
