diff options
author | JFonS <joan.fonssanchez@gmail.com> | 2018-07-05 11:12:04 +0200 |
---|---|---|
committer | JFonS <joan.fonssanchez@gmail.com> | 2018-07-05 11:12:04 +0200 |
commit | 4421a6661d3753ef461315789ccd6d390215d2d1 (patch) | |
tree | 3d28d8b8623d1f90226028cdce5e1299215a7c5d | |
parent | ac18444c7e14e2d7f5bf347c7a600156d3af6ac7 (diff) |
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; |