summaryrefslogtreecommitdiffstats
path: root/drivers/gles3/shaders
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-08-20 10:01:36 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-08-20 10:01:36 +0200
commit333f0f910f164851218c5ece26d4c4b4931d4a30 (patch)
treef8452d97bd2792d6a692b5228e8424314b22baf4 /drivers/gles3/shaders
parent554dc002b505e7c5c2306a58008ec9a31bf2d2e7 (diff)
parente698351db24df691dc5ea88a6b011c24dad77ebd (diff)
downloadredot-engine-333f0f910f164851218c5ece26d4c4b4931d4a30.tar.gz
Merge pull request #86000 from jsjtxietian/add-missing-model_normal_matrix
Add `model_normal_matrix` for fragment shader
Diffstat (limited to 'drivers/gles3/shaders')
-rw-r--r--drivers/gles3/shaders/scene.glsl10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 04ba98a420..305a4f1010 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -583,6 +583,8 @@ void main() {
#define SHADER_IS_SRGB true
+#define FLAGS_NON_UNIFORM_SCALE (1 << 4)
+
/* Varyings */
#if defined(COLOR_USED)
@@ -955,6 +957,7 @@ ivec2 multiview_uv(ivec2 uv) {
uniform highp mat4 world_transform;
uniform mediump float opaque_prepass_threshold;
+uniform highp uint model_flags;
#if defined(RENDER_MATERIAL)
layout(location = 0) out vec4 albedo_output_buffer;
@@ -1521,6 +1524,13 @@ void main() {
vec3 light_vertex = vertex;
#endif //LIGHT_VERTEX_USED
+ highp mat3 model_normal_matrix;
+ if (bool(model_flags & uint(FLAGS_NON_UNIFORM_SCALE))) {
+ model_normal_matrix = transpose(inverse(mat3(model_matrix)));
+ } else {
+ model_normal_matrix = mat3(model_matrix);
+ }
+
{
#CODE : FRAGMENT
}