You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +00:00
Add model_normal_matrix for fragment shader
This commit is contained in:
@@ -1030,6 +1030,13 @@ void fragment_shader(in SceneData scene_data) {
|
||||
vec3 light_vertex = vertex;
|
||||
#endif //LIGHT_VERTEX_USED
|
||||
|
||||
mat3 model_normal_matrix;
|
||||
if (bool(instances.data[instance_index].flags & INSTANCE_FLAGS_NON_UNIFORM_SCALE)) {
|
||||
model_normal_matrix = transpose(inverse(mat3(read_model_matrix)));
|
||||
} else {
|
||||
model_normal_matrix = mat3(read_model_matrix);
|
||||
}
|
||||
|
||||
mat4 read_view_matrix = scene_data.view_matrix;
|
||||
vec2 read_viewport_size = scene_data.viewport_size;
|
||||
{
|
||||
|
||||
@@ -839,6 +839,13 @@ void main() {
|
||||
vec3 light_vertex = vertex;
|
||||
#endif //LIGHT_VERTEX_USED
|
||||
|
||||
mat3 model_normal_matrix;
|
||||
if (bool(instances.data[draw_call.instance_index].flags & INSTANCE_FLAGS_NON_UNIFORM_SCALE)) {
|
||||
model_normal_matrix = transpose(inverse(mat3(read_model_matrix)));
|
||||
} else {
|
||||
model_normal_matrix = mat3(read_model_matrix);
|
||||
}
|
||||
|
||||
mat4 read_view_matrix = scene_data.view_matrix;
|
||||
vec2 read_viewport_size = scene_data.viewport_size;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user