Merge pull request #19980 from JFonS/fix_light_vec_rotation

Move light 2D rotation to vertex shader
This commit is contained in:
Rémi Verschelde 2018-07-06 17:14:06 +02:00 committed by GitHub
commit e19388df97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 5 deletions

View File

@ -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;