diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-08 23:08:20 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-08 23:08:20 +0300 |
commit | 733811330c9bb0df6b6101dc45b0b58be6febfb8 (patch) | |
tree | da7f437201cf278da59ee5f101b186f1a67f1fe9 | |
parent | a8a11d35372a90c2d26089db2a2c778d31502427 (diff) |
Workbench: Use common_view_lib and remove NormalMatrix usage
This is in order to lower the number of matrices to compute.
5 files changed, 9 insertions, 11 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl index 65196c1a836..a1f80440404 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl @@ -1,8 +1,5 @@ out vec4 fragColor; -uniform mat4 ProjectionMatrix; -uniform mat4 ViewMatrixInverse; - uniform usampler2D objectId; uniform sampler2D materialBuffer; uniform sampler2D normalBuffer; diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl index 5eff0b41e20..32243787401 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl @@ -4,8 +4,6 @@ uniform sampler2D image; uniform bool imageSrgb; uniform bool imageNearest; -uniform mat4 ProjectionMatrix; -uniform mat4 ViewMatrixInverse; uniform float alpha = 0.5; uniform vec2 invertedViewportSize; uniform vec4 viewvecs[3]; diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl index f2c684cdb6a..1de6121bb5c 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl @@ -1,10 +1,7 @@ -uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelMatrix; uniform mat4 ModelMatrixInverse; -uniform mat4 ProjectionMatrix; -uniform mat4 ViewProjectionMatrix; -uniform mat4 ViewMatrixInverse; -uniform mat3 NormalMatrix; + +uniform mat4 ModelViewProjectionMatrix; #ifndef HAIR_SHADER in vec3 pos; @@ -91,7 +88,7 @@ void main() #endif #ifdef NORMAL_VIEWPORT_PASS_ENABLED - normal_viewport = NormalMatrix * nor; + normal_viewport = transform_normal_object_to_view(nor); # ifndef HAIR_SHADER normal_viewport = normalize(normal_viewport); # endif diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 64b00a05681..e0bf8da438b 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -91,6 +91,7 @@ static struct { /* Shaders */ extern char datatoc_common_hair_lib_glsl[]; +extern char datatoc_common_view_lib_glsl[]; extern char datatoc_workbench_prepass_vert_glsl[]; extern char datatoc_workbench_prepass_frag_glsl[]; @@ -119,6 +120,7 @@ static char *workbench_build_composite_frag(WORKBENCH_PrivateData *wpd) { DynStr *ds = BLI_dynstr_new(); + BLI_dynstr_append(ds, datatoc_common_view_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_data_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_background_lib_glsl); @@ -159,6 +161,7 @@ static char *workbench_build_prepass_vert(bool is_hair) if (is_hair) { BLI_dynstr_append(ds, datatoc_common_hair_lib_glsl); } + BLI_dynstr_append(ds, datatoc_common_view_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_prepass_vert_glsl); char *str = BLI_dynstr_get_cstring(ds); BLI_dynstr_free(ds); diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index fe3e0579c8e..25f95f0d4bc 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -68,6 +68,7 @@ static struct { /* Shaders */ extern char datatoc_common_hair_lib_glsl[]; +extern char datatoc_common_view_lib_glsl[]; extern char datatoc_workbench_forward_composite_frag_glsl[]; extern char datatoc_workbench_forward_depth_frag_glsl[]; @@ -88,6 +89,7 @@ static char *workbench_build_forward_vert(bool is_hair) if (is_hair) { BLI_dynstr_append(ds, datatoc_common_hair_lib_glsl); } + BLI_dynstr_append(ds, datatoc_common_view_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_prepass_vert_glsl); char *str = BLI_dynstr_get_cstring(ds); @@ -99,6 +101,7 @@ static char *workbench_build_forward_transparent_accum_frag(void) { DynStr *ds = BLI_dynstr_new(); + BLI_dynstr_append(ds, datatoc_common_view_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_data_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_common_lib_glsl); BLI_dynstr_append(ds, datatoc_workbench_world_light_lib_glsl); |