summaryrefslogtreecommitdiffstats
path: root/drivers/gles3
diff options
context:
space:
mode:
authorjsjtxietian <jsjtxietian@outlook.com>2023-12-10 21:32:36 +0800
committerRémi Verschelde <rverschelde@gmail.com>2024-09-16 17:09:36 +0200
commit139f5ee15e3802e6416977e1b5880837a5d57d11 (patch)
treef27935cede1f389a0719085372d025eef9692f62 /drivers/gles3
parentbd552ff60930bcc9c7d64ee76ed1c916efa07397 (diff)
downloadredot-engine-139f5ee15e3802e6416977e1b5880837a5d57d11.tar.gz
Add model_normal_matrix for fragment shader
(cherry picked from commit e698351db24df691dc5ea88a6b011c24dad77ebd)
Diffstat (limited to 'drivers/gles3')
-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 ba70de9e34..dde01a8428 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
}