mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Add render mode to ensure correct normals when using non-uniform scaling
This commit is contained in:
parent
0a1c1c660f
commit
c8cf71753c
5 changed files with 21 additions and 1 deletions
|
|
@ -322,7 +322,13 @@ void main() {
|
|||
#if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED)
|
||||
|
||||
vertex = world_matrix * vertex;
|
||||
|
||||
#if defined(ENSURE_CORRECT_NORMALS)
|
||||
mat3 normal_matrix = mat3(transpose(inverse(world_matrix)));
|
||||
normal = normal_matrix * normal;
|
||||
#else
|
||||
normal = normalize((world_matrix * vec4(normal,0.0)).xyz);
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY)
|
||||
|
||||
|
|
@ -394,7 +400,13 @@ VERTEX_SHADER_CODE
|
|||
#if !defined(SKIP_TRANSFORM_USED) && !defined(VERTEX_WORLD_COORDS_USED)
|
||||
|
||||
vertex = modelview * vertex;
|
||||
|
||||
#if defined(ENSURE_CORRECT_NORMALS)
|
||||
mat3 normal_matrix = mat3(transpose(inverse(modelview)));
|
||||
normal = normal_matrix * normal;
|
||||
#else
|
||||
normal = normalize((modelview * vec4(normal,0.0)).xyz);
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue