Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-05-08 21:13:24 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-05-08 21:13:32 +0300
commitf2f62b184c67f6b548da1cd9c022c9383e541bb0 (patch)
tree12896f71f49dda76cc6c430c2cdb5ae454d58762 /source/blender
parentbb41626ab3de31f670fcbe3365b61064e899c87f (diff)
DRW: Remove WorldNormalMatrix
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl8
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_vert.glsl8
-rw-r--r--source/blender/draw/intern/draw_manager.h5
-rw-r--r--source/blender/draw/intern/draw_manager_data.c4
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c13
-rw-r--r--source/blender/draw/modes/shaders/common_view_lib.glsl3
-rw-r--r--source/blender/gpu/GPU_shader_interface.h1
-rw-r--r--source/blender/gpu/intern/gpu_shader_interface.c1
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl1
9 files changed, 13 insertions, 31 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
index 40075ed64be..cddc8e87a1e 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
@@ -1,10 +1,8 @@
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelViewMatrix;
-uniform mat3 WorldNormalMatrix;
#ifndef USE_ATTR
uniform mat4 ModelMatrix;
-uniform mat3 NormalMatrix;
uniform mat4 ModelMatrixInverse;
#endif
@@ -67,8 +65,10 @@ void main()
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
viewPosition = (ModelViewMatrix * vec4(pos, 1.0)).xyz;
worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- worldNormal = normalize(WorldNormalMatrix * nor);
- viewNormal = normalize(NormalMatrix * nor);
+
+ worldNormal = normalize(transform_normal_object_to_world(nor));
+ /* No need to normalize since this is just a rotation. */
+ viewNormal = transform_normal_world_to_view(worldNormal);
#endif
/* Used for planar reflections */
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
index f9225cd100b..f8850300dc4 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
@@ -2,10 +2,8 @@
uniform mat4 ModelViewProjectionMatrix;
#ifdef MESH_SHADER
uniform mat4 ModelViewMatrix;
-uniform mat3 WorldNormalMatrix;
# ifndef USE_ATTR
uniform mat4 ModelMatrix;
-uniform mat3 NormalMatrix;
# endif
#endif
@@ -25,8 +23,10 @@ void main()
#ifdef MESH_SHADER
viewPosition = (ModelViewMatrix * vec4(pos, 1.0)).xyz;
worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- viewNormal = normalize(NormalMatrix * nor);
- worldNormal = normalize(WorldNormalMatrix * nor);
+
+ worldNormal = normalize(transform_normal_object_to_world(nor));
+ /* No need to normalize since this is just a rotation. */
+ viewNormal = transform_normal_world_to_view(worldNormal);
# ifdef USE_ATTR
pass_attr(pos);
# endif
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index 4d74a95bf20..496e5b785bf 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -104,7 +104,6 @@ enum {
DRW_CALL_MODELVIEWINVERSE = (1 << 2),
DRW_CALL_MODELVIEWPROJECTION = (1 << 3),
DRW_CALL_NORMALVIEW = (1 << 4),
- DRW_CALL_NORMALWORLD = (1 << 6),
DRW_CALL_ORCOTEXFAC = (1 << 7),
DRW_CALL_OBJECTINFO = (1 << 8),
};
@@ -126,8 +125,7 @@ typedef struct DRWCallState {
float modelviewinverse[4][4];
float modelviewprojection[4][4];
float normalview[3][3];
- float normalworld[3][3]; /* Not view dependent */
- float orcotexfac[2][3]; /* Not view dependent */
+ float orcotexfac[2][3]; /* Not view dependent */
float objectinfo[2];
} DRWCallState;
@@ -258,7 +256,6 @@ struct DRWShadingGroup {
int modelviewinverse;
int modelviewprojection;
int normalview;
- int normalworld;
int orcotexfac;
int callid;
int objectinfo;
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index b7225275d72..deabffdaa0d 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -838,7 +838,6 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
shgroup->modelviewinverse = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW_INV);
shgroup->modelviewprojection = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MVP);
shgroup->normalview = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_NORMAL);
- shgroup->normalworld = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_WORLDNORMAL);
shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_ORCO);
shgroup->objectinfo = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_OBJECT_INFO);
shgroup->callid = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_CALLID);
@@ -859,9 +858,6 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
if (shgroup->normalview > -1) {
shgroup->matflag |= DRW_CALL_NORMALVIEW;
}
- if (shgroup->normalworld > -1) {
- shgroup->matflag |= DRW_CALL_NORMALWORLD;
- }
if (shgroup->orcotexfac > -1) {
shgroup->matflag |= DRW_CALL_ORCOTEXFAC;
}
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index f98c2cb1025..51ec38088c3 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -806,13 +806,6 @@ static void draw_matrices_model_prepare(DRWCallState *st)
invert_m3(st->normalview);
transpose_m3(st->normalview);
}
- /* Non view dependent */
- if (st->matflag & DRW_CALL_NORMALWORLD) {
- copy_m3_m4(st->normalworld, st->model);
- invert_m3(st->normalworld);
- transpose_m3(st->normalworld);
- st->matflag &= ~DRW_CALL_NORMALWORLD;
- }
}
static void draw_geometry_prepare(DRWShadingGroup *shgroup, DRWCall *call)
@@ -847,10 +840,6 @@ static void draw_geometry_prepare(DRWShadingGroup *shgroup, DRWCall *call)
GPU_shader_uniform_vector(
shgroup->shader, shgroup->normalview, 9, 1, (float *)state->normalview);
}
- if (shgroup->normalworld != -1) {
- GPU_shader_uniform_vector(
- shgroup->shader, shgroup->normalworld, 9, 1, (float *)state->normalworld);
- }
if (shgroup->objectinfo != -1) {
float objectinfo[4];
objectinfo[0] = state->objectinfo[0];
@@ -865,7 +854,7 @@ static void draw_geometry_prepare(DRWShadingGroup *shgroup, DRWCall *call)
}
}
else {
- BLI_assert((shgroup->normalview == -1) && (shgroup->normalworld == -1));
+ BLI_assert((shgroup->normalview == -1));
/* For instancing and batching. */
float unitmat[4][4];
unit_m4(unitmat);
diff --git a/source/blender/draw/modes/shaders/common_view_lib.glsl b/source/blender/draw/modes/shaders/common_view_lib.glsl
index 25aa8e19474..50d6760cafa 100644
--- a/source/blender/draw/modes/shaders/common_view_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_view_lib.glsl
@@ -17,5 +17,8 @@ layout(std140) uniform viewBlock
/* Transform shortcuts. */
#define transform_normal_object_to_world(nor) (transpose(mat3(ModelMatrixInverse)) * nor)
#define transform_normal_world_to_object(nor) (transpose(mat3(ModelMatrix)) * nor)
+#define transform_normal_world_to_view(nor) (transpose(mat3(ViewMatrixInverse)) * nor)
+#define transform_normal_object_to_view(nor) \
+ (transpose(mat3(ViewMatrixInverse)) * (transpose(mat3(ModelMatrixInverse)) * nor))
#define transform_point_view_to_object(point) \
((ModelMatrixInverse * (ViewMatrixInverse * vec4(point, 1.0))).xyz)
diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h
index 1b10de45cee..fc7d9e22ea3 100644
--- a/source/blender/gpu/GPU_shader_interface.h
+++ b/source/blender/gpu/GPU_shader_interface.h
@@ -45,7 +45,6 @@ typedef enum {
GPU_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */
GPU_UNIFORM_NORMAL, /* mat3 NormalMatrix */
- GPU_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */
GPU_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */
GPU_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */
diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c
index 207a218b5d1..97dbb80d736 100644
--- a/source/blender/gpu/intern/gpu_shader_interface.c
+++ b/source/blender/gpu/intern/gpu_shader_interface.c
@@ -61,7 +61,6 @@ static const char *BuiltinUniform_name(GPUUniformBuiltin u)
[GPU_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse",
[GPU_UNIFORM_NORMAL] = "NormalMatrix",
- [GPU_UNIFORM_WORLDNORMAL] = "WorldNormalMatrix",
[GPU_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors",
[GPU_UNIFORM_ORCO] = "OrcoTexCoFactors",
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index ca05a9b6238..f03e30b55f7 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -1,7 +1,6 @@
uniform mat4 ModelViewMatrix;
uniform mat4 ModelViewMatrixInverse;
-uniform mat3 NormalMatrix;
#ifndef USE_ATTR
uniform mat4 ModelMatrix;