[Bf-blender-cvs] [a1b71fe54cc] greasepencil-refactor: GPencil: Remove Lights VFX
Antonio Vazquez
noreply at git.blender.org
Mon Jan 6 20:23:47 CET 2020
Commit: a1b71fe54cc6b8f97aad87a8fd5a6a7a1ba4eda1
Author: Antonio Vazquez
Date: Mon Jan 6 20:23:20 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBa1b71fe54cc6b8f97aad87a8fd5a6a7a1ba4eda1
GPencil: Remove Lights VFX
This has been replaced with real scene lights
===================================================================
M release/scripts/startup/bl_ui/properties_data_shaderfx.py
M source/blender/draw/CMakeLists.txt
M source/blender/draw/engines/gpencil/gpencil_engine.h
M source/blender/draw/engines/gpencil/gpencil_shader_fx.c
D source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_light_frag.glsl
M source/blender/makesdna/DNA_shader_fx_types.h
M source/blender/makesrna/intern/rna_shader_fx.c
M source/blender/shader_fx/CMakeLists.txt
M source/blender/shader_fx/FX_shader_types.h
M source/blender/shader_fx/intern/FX_shader_util.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_shaderfx.py b/release/scripts/startup/bl_ui/properties_data_shaderfx.py
index a7791fa93f4..8a803bf2c55 100644
--- a/release/scripts/startup/bl_ui/properties_data_shaderfx.py
+++ b/release/scripts/startup/bl_ui/properties_data_shaderfx.py
@@ -147,12 +147,6 @@ class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
layout.prop(fx, "flip_horizontal")
layout.prop(fx, "flip_vertical")
- def FX_LIGHT(self, layout, fx):
- layout.prop(fx, "object", text="Object")
-
- layout.prop(fx, "energy")
- layout.prop(fx, "ambient")
-
classes = (
DATA_PT_shader_fx,
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 2a86aa48647..3434456c685 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -310,7 +310,6 @@ data_to_c_simple(engines/gpencil/shaders/fx/gpencil_fx_colorize_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/fx/gpencil_fx_flip_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/fx/gpencil_fx_glow_prepare_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/fx/gpencil_fx_glow_resolve_frag.glsl SRC)
-data_to_c_simple(engines/gpencil/shaders/fx/gpencil_fx_light_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/fx/gpencil_fx_pixel_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/fx/gpencil_fx_rim_prepare_frag.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/fx/gpencil_fx_rim_resolve_frag.glsl SRC)
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index d4f20f1a025..3057ccc05b1 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -587,7 +587,6 @@ typedef struct GPENCIL_e_data {
struct GPUShader *gpencil_fx_flip_sh;
struct GPUShader *gpencil_fx_glow_prepare_sh;
struct GPUShader *gpencil_fx_glow_resolve_sh;
- struct GPUShader *gpencil_fx_light_sh;
struct GPUShader *gpencil_fx_pixel_sh;
struct GPUShader *gpencil_fx_rim_prepare_sh;
struct GPUShader *gpencil_fx_rim_resolve_sh;
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index 45ac3085959..1e2b373dc01 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -38,7 +38,6 @@
extern char datatoc_gpencil_fx_blur_frag_glsl[];
extern char datatoc_gpencil_fx_colorize_frag_glsl[];
extern char datatoc_gpencil_fx_flip_frag_glsl[];
-extern char datatoc_gpencil_fx_light_frag_glsl[];
extern char datatoc_gpencil_fx_pixel_frag_glsl[];
extern char datatoc_gpencil_fx_rim_prepare_frag_glsl[];
extern char datatoc_gpencil_fx_rim_resolve_frag_glsl[];
@@ -273,60 +272,6 @@ static void gpencil_fx_flip(ShaderFxData *fx, GPENCIL_e_data *e_data, GPENCIL_Da
fxd->runtime.fx_sh = fx_shgrp;
}
-/* Light FX */
-static void gpencil_fx_light(ShaderFxData *fx,
- GPENCIL_e_data *e_data,
- GPENCIL_Data *vedata,
- tGPencilObjectCache *cache)
-{
- if (fx == NULL) {
- return;
- }
- LightShaderFxData *fxd = (LightShaderFxData *)fx;
-
- if (fxd->object == NULL) {
- return;
- }
- GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
- GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
- DRWShadingGroup *fx_shgrp;
-
- GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
- fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_light_sh, psl->fx_shader_pass);
- DRW_shgroup_call(fx_shgrp, fxquad, NULL);
- DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
- DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
-
- DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
-
- /* location of the light using obj location as origin */
- copy_v3_v3(fxd->loc, fxd->object->obmat[3]);
-
- /* Calc distance to strokes plane
- * The w component of location is used to transfer the distance to drawing plane
- */
- float r_point[3], r_normal[3];
- float r_plane[4];
- bGPdata *gpd = cache->gpd;
- if (!get_normal_vector(gpd, r_point, r_normal)) {
- return;
- }
- mul_mat3_m4_v3(cache->obmat, r_normal); /* only rotation component */
- plane_from_point_normal_v3(r_plane, r_point, r_normal);
- float dt = dist_to_plane_v3(fxd->object->obmat[3], r_plane);
- fxd->loc[3] = dt; /* use last element to save it */
-
- DRW_shgroup_uniform_vec4(fx_shgrp, "loc", &fxd->loc[0], 1);
-
- DRW_shgroup_uniform_float(fx_shgrp, "energy", &fxd->energy, 1);
- DRW_shgroup_uniform_float(fx_shgrp, "ambient", &fxd->ambient, 1);
-
- DRW_shgroup_uniform_float(fx_shgrp, "pixsize", stl->storage->pixsize, 1);
- DRW_shgroup_uniform_float(fx_shgrp, "pixfactor", &gpd->pixfactor, 1);
-
- fxd->runtime.fx_sh = fx_shgrp;
-}
-
/* Pixelate FX */
static void gpencil_fx_pixel(ShaderFxData *fx,
GPENCIL_e_data *e_data,
@@ -650,10 +595,6 @@ void GPENCIL_create_fx_shaders(GPENCIL_e_data *e_data)
e_data->gpencil_fx_flip_sh = DRW_shader_create_fullscreen(datatoc_gpencil_fx_flip_frag_glsl,
NULL);
}
- if (!e_data->gpencil_fx_light_sh) {
- e_data->gpencil_fx_light_sh = DRW_shader_create_fullscreen(datatoc_gpencil_fx_light_frag_glsl,
- NULL);
- }
if (!e_data->gpencil_fx_pixel_sh) {
e_data->gpencil_fx_pixel_sh = DRW_shader_create_fullscreen(datatoc_gpencil_fx_pixel_frag_glsl,
NULL);
@@ -695,7 +636,6 @@ void GPENCIL_delete_fx_shaders(GPENCIL_e_data *e_data)
DRW_SHADER_FREE_SAFE(e_data->gpencil_fx_blur_sh);
DRW_SHADER_FREE_SAFE(e_data->gpencil_fx_colorize_sh);
DRW_SHADER_FREE_SAFE(e_data->gpencil_fx_flip_sh);
- DRW_SHADER_FREE_SAFE(e_data->gpencil_fx_light_sh);
DRW_SHADER_FREE_SAFE(e_data->gpencil_fx_pixel_sh);
DRW_SHADER_FREE_SAFE(e_data->gpencil_fx_rim_prepare_sh);
DRW_SHADER_FREE_SAFE(e_data->gpencil_fx_rim_resolve_sh);
@@ -744,9 +684,6 @@ void gpencil_fx_prepare(GPENCIL_e_data *e_data,
case eShaderFxType_Flip:
gpencil_fx_flip(fx, e_data, vedata);
break;
- case eShaderFxType_Light:
- gpencil_fx_light(fx, e_data, vedata, cache_ob);
- break;
case eShaderFxType_Pixel:
gpencil_fx_pixel(fx, e_data, vedata, cache_ob);
break;
@@ -1024,11 +961,6 @@ void gpencil_fx_draw(GPENCIL_e_data *UNUSED(e_data),
gpencil_draw_fx_pass(vedata, fxd->runtime.fx_sh, false);
break;
}
- case eShaderFxType_Light: {
- LightShaderFxData *fxd = (LightShaderFxData *)fx;
- gpencil_draw_fx_pass(vedata, fxd->runtime.fx_sh, false);
- break;
- }
case eShaderFxType_Pixel: {
PixelShaderFxData *fxd = (PixelShaderFxData *)fx;
gpencil_draw_fx_pass(vedata, fxd->runtime.fx_sh, false);
@@ -1582,8 +1514,6 @@ void gpencil_vfx_cache_populate(GPENCIL_Data *vedata, Object *ob, GPENCIL_tObjec
case eShaderFxType_Flip:
gpencil_vfx_flip((FlipShaderFxData *)fx, ob, &iter);
break;
- case eShaderFxType_Light:
- break;
case eShaderFxType_Pixel:
gpencil_vfx_pixelize((PixelShaderFxData *)fx, ob, &iter);
break;
diff --git a/source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_light_frag.glsl b/source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_light_frag.glsl
deleted file mode 100644
index a5c321c20c1..00000000000
--- a/source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_light_frag.glsl
+++ /dev/null
@@ -1,70 +0,0 @@
-uniform mat4 ProjectionMatrix;
-uniform mat4 ViewMatrix;
-
-uniform sampler2D strokeColor;
-uniform sampler2D strokeDepth;
-uniform vec2 Viewport;
-uniform vec4 loc;
-uniform float energy;
-uniform float ambient;
-
-uniform float pixsize; /* rv3d->pixsize */
-uniform float pixfactor;
-
-out vec4 FragColor;
-
-float defaultpixsize = pixsize * (1000.0 / pixfactor);
-
-#define height loc.w
-
-/* project 3d point to 2d on screen space */
-vec2 toScreenSpace(vec4 vertex)
-{
- /* need to calculate ndc because this is not done by vertex shader */
- vec3 ndc = vec3(vertex).xyz / vertex.w;
-
- vec2 sc;
- sc.x = ((ndc.x + 1.0) / 2.0) * Viewport.x;
- sc.y = ((ndc.y + 1.0) / 2.0) * Viewport.y;
-
- return sc;
-}
-
-void main()
-{
- float stroke_depth;
- vec4 objcolor;
-
- vec4 light_loc = ProjectionMatrix * ViewMatrix * vec4(loc.xyz, 1.0);
- vec2 light2d = toScreenSpace(light_loc);
-
- /* calc pixel scale */
- float pxscale = (ProjectionMatrix[3][3] == 0.0) ? (10.0 / (light_loc.z * defaultpixsize)) :
- (10.0 / defaultpixsize);
- pxscale = max(pxscale, 0.000001);
-
- /* the height over plane is received in the w component of the loc
- * and needs a factor to adapt to pixels
- */
- float peak = height * 10.0 * pxscale;
- vec3 light3d = vec3(light2d.x, light2d.y, peak);
-
- vec2 uv = vec2(gl_FragCoord.xy);
- vec3 frag_loc = vec3(uv.x, uv.y, 0);
- vec3 norm = vec3(0, 0, 1.0); /* always z-up */
-
- ivec2 iuv = ivec2(uv.x, uv.y);
- stroke_depth = texelFetch(strokeDepth, iuv, 0).r;
- objcolor = texelFetch(strokeColor, iuv, 0);
-
- /* diffuse light */
- vec3 lightdir = normalize(light3d - frag_loc);
- float diff = max(dot(norm, lightdir), 0.0);
- float dist = length(light3d - frag_loc) / pxscale;
- float factor = diff * ((energy * 100.0) / (dist * dist));
-
- vec3 result = factor * max(ambient, 0.1) * vec3(objcolor);
-
- gl_FragDepth = stroke_depth;
- FragColor = vec4(result.r, result.g, result.b, objcolor.a);
-}
diff --git a/source/blender/makesdna/DNA_shader_fx_types.h b/source/blender/makesdna/DNA_shader_fx_types.h
index 6cda58a3279..b6a82854f83 100644
--- a/source/blender/makesdna/DNA_shader_fx_types.h
+++ b/source/blender/makesdna/DNA_shader_fx_types.h
@@ -34,7 +34,7 @@ typedef enum ShaderFxType {
eShaderFx
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list