diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-01-28 16:13:42 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-01-28 16:27:43 +0300 |
commit | 9bc43223c109c413601eded1309963f3f4ec2568 (patch) | |
tree | e43076e55a9a5e673c6830e447afdd47f32f5b8b /source/blender/draw/intern | |
parent | 20acf3ded27671c9f564cbfe00ad36a313a51f3e (diff) |
DRW: support clipping for object & lamp centers
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/draw_builtin_shader.c | 6 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_common.c | 27 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_common.h | 6 |
3 files changed, 26 insertions, 13 deletions
diff --git a/source/blender/draw/intern/draw_builtin_shader.c b/source/blender/draw/intern/draw_builtin_shader.c index 5606d31f73f..0b3fc45f5e7 100644 --- a/source/blender/draw/intern/draw_builtin_shader.c +++ b/source/blender/draw/intern/draw_builtin_shader.c @@ -46,7 +46,11 @@ extern char datatoc_common_world_clip_lib_glsl[]; GPU_SHADER_3D_DEPTH_ONLY, \ GPU_SHADER_CAMERA, \ GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, \ - GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE) + GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE, \ + GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA, \ + GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA, \ + GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR, \ + GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED) /* cache of built-in shaders (each is created on first use) */ static struct { diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 45cfca4e7d5..e54ad6cdffc 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -343,15 +343,18 @@ DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(DRWPass *pass, const floa return grp; } -DRWShadingGroup *shgroup_dynpoints_uniform_color(DRWPass *pass, const float color[4], const float *size) +DRWShadingGroup *shgroup_dynpoints_uniform_color( + DRWPass *pass, const float color[4], const float *size, eDRW_ShaderSlot shader_slot) { - GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); + GPUShader *sh = DRW_shader_get_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA, shader_slot); DRWShadingGroup *grp = DRW_shgroup_point_batch_create(sh, pass); DRW_shgroup_uniform_vec4(grp, "color", color, 1); DRW_shgroup_uniform_float(grp, "size", size, 1); DRW_shgroup_state_enable(grp, DRW_STATE_POINT); - + if (shader_slot == DRW_SHADER_SLOT_CLIPPED) { + DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d); + } return grp; } @@ -376,9 +379,10 @@ DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, const float c return grp; } -DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct GPUBatch *geom, const float *size) +DRWShadingGroup *shgroup_instance_screenspace( + DRWPass *pass, struct GPUBatch *geom, const float *size, eDRW_ShaderSlot shader_slot) { - GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR); + GPUShader *sh = DRW_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR, shader_slot); DRW_shgroup_instance_format(g_formats.instance_screenspace, { {"world_pos", DRW_ATTRIB_FLOAT, 3}, @@ -389,7 +393,9 @@ DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct GPUBatch *ge DRW_shgroup_uniform_float(grp, "size", size, 1); DRW_shgroup_uniform_float(grp, "pixel_size", DRW_viewport_pixelsize_get(), 1); DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2); - + if (shader_slot == DRW_SHADER_SLOT_CLIPPED) { + DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d); + } return grp; } @@ -423,9 +429,10 @@ DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct GPUBatch *geom) return grp; } -DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct GPUBatch *geom) +DRWShadingGroup *shgroup_instance_screen_aligned( + DRWPass *pass, struct GPUBatch *geom, eDRW_ShaderSlot shader_slot) { - GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED); + GPUShader *sh = DRW_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED, shader_slot); DRW_shgroup_instance_format(g_formats.instance_screen_aligned, { {"color", DRW_ATTRIB_FLOAT, 3}, @@ -435,7 +442,9 @@ DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct GPUBatch DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom, g_formats.instance_screen_aligned); DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2); - + if (shader_slot == DRW_SHADER_SLOT_CLIPPED) { + DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d); + } return grp; } diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index 644e81e2f13..39a895632bd 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -142,13 +142,13 @@ void DRW_shgroup_world_clip_planes_from_rv3d(struct DRWShadingGroup *shgrp, cons struct DRWShadingGroup *shgroup_dynlines_flat_color(struct DRWPass *pass); struct DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(struct DRWPass *pass, const float color[4]); -struct DRWShadingGroup *shgroup_dynpoints_uniform_color(struct DRWPass *pass, const float color[4], const float *size); +struct DRWShadingGroup *shgroup_dynpoints_uniform_color(struct DRWPass *pass, const float color[4], const float *size, eDRW_ShaderSlot shader_slot); struct DRWShadingGroup *shgroup_groundlines_uniform_color(struct DRWPass *pass, const float color[4]); struct DRWShadingGroup *shgroup_groundpoints_uniform_color(struct DRWPass *pass, const float color[4]); -struct DRWShadingGroup *shgroup_instance_screenspace(struct DRWPass *pass, struct GPUBatch *geom, const float *size); +struct DRWShadingGroup *shgroup_instance_screenspace(struct DRWPass *pass, struct GPUBatch *geom, const float *size, eDRW_ShaderSlot shader_slot); struct DRWShadingGroup *shgroup_instance_solid(struct DRWPass *pass, struct GPUBatch *geom); struct DRWShadingGroup *shgroup_instance_wire(struct DRWPass *pass, struct GPUBatch *geom); -struct DRWShadingGroup *shgroup_instance_screen_aligned(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_screen_aligned(struct DRWPass *pass, struct GPUBatch *geom, eDRW_ShaderSlot shader_slot); struct DRWShadingGroup *shgroup_instance_empty_axes(struct DRWPass *pass, struct GPUBatch *geom, eDRW_ShaderSlot shader_slot); struct DRWShadingGroup *shgroup_instance_scaled(struct DRWPass *pass, struct GPUBatch *geom, eDRW_ShaderSlot shader_slot); struct DRWShadingGroup *shgroup_instance(struct DRWPass *pass, struct GPUBatch *geom, eDRW_ShaderSlot shader_slot); |