diff options
author | jsjtxietian <jsjtxietian@outlook.com> | 2023-12-10 21:32:36 +0800 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-16 17:09:36 +0200 |
commit | 139f5ee15e3802e6416977e1b5880837a5d57d11 (patch) | |
tree | f27935cede1f389a0719085372d025eef9692f62 /drivers/gles3 | |
parent | bd552ff60930bcc9c7d64ee76ed1c916efa07397 (diff) | |
download | redot-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.glsl | 10 |
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 } |