diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2018-07-06 17:14:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-06 17:14:06 +0200 |
commit | e19388df97743939efd0cfda3dae6de2db393897 (patch) | |
tree | d8b83463681f13426487b040c24d770c2e5a86bc | |
parent | 9f82368d40f1948de708804645374ea02ca6e7db (diff) | |
parent | 4421a6661d3753ef461315789ccd6d390215d2d1 (diff) |
Merge pull request #19980 from JFonS/fix_light_vec_rotation
Move light 2D rotation to vertex shader
-rw-r--r-- | drivers/gles3/shaders/canvas.glsl | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl index 7aafd28c35..e7828d265c 100644 --- a/drivers/gles3/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -82,6 +82,7 @@ layout(std140) uniform LightData { //ubo:1 out vec4 light_uv_interp; +out vec2 transformed_light_uv; out vec4 local_rot; @@ -236,6 +237,13 @@ VERTEX_SHADER_CODE light_uv_interp.xy = (light_matrix * outvec).xy; light_uv_interp.zw =(light_local_matrix * outvec).xy; + + mat3 inverse_light_matrix = mat3(inverse(light_matrix)); + inverse_light_matrix[0] = normalize(inverse_light_matrix[0]); + inverse_light_matrix[1] = normalize(inverse_light_matrix[1]); + inverse_light_matrix[2] = normalize(inverse_light_matrix[2]); + transformed_light_uv = (inverse_light_matrix * vec3(light_uv_interp.zw,0.0)).xy; //for normal mapping + #ifdef USE_SHADOWS pos=outvec.xy; #endif @@ -304,6 +312,7 @@ layout(std140) uniform LightData { uniform lowp sampler2D light_texture; // texunit:-1 in vec4 light_uv_interp; +in vec2 transformed_light_uv; in vec4 local_rot; @@ -520,11 +529,7 @@ FRAGMENT_SHADER_CODE #ifdef USE_LIGHTING - mat3 inverse_light_matrix = mat3(inverse(light_matrix)); - inverse_light_matrix[0] = normalize(inverse_light_matrix[0]); - inverse_light_matrix[1] = normalize(inverse_light_matrix[1]); - inverse_light_matrix[2] = normalize(inverse_light_matrix[2]); - vec2 light_vec = (inverse_light_matrix * vec3(light_uv_interp.zw,0.0)).xy; //for normal mapping + vec2 light_vec = transformed_light_uv; if (normal_used) { normal.xy = mat2(local_rot.xy,local_rot.zw) * normal.xy; |