GPUShader: Port polyline shaders to use shaderCreateInfo
This should have no functional changes.
This commit is contained in:
parent
aa34706aac
commit
2a7a01b339
|
@ -497,6 +497,7 @@ set(SRC_SHADER_CREATE_INFOS
|
||||||
shaders/infos/gpu_shader_3D_flat_color_info.hh
|
shaders/infos/gpu_shader_3D_flat_color_info.hh
|
||||||
shaders/infos/gpu_shader_3D_image_modulate_alpha_info.hh
|
shaders/infos/gpu_shader_3D_image_modulate_alpha_info.hh
|
||||||
shaders/infos/gpu_shader_3D_point_info.hh
|
shaders/infos/gpu_shader_3D_point_info.hh
|
||||||
|
shaders/infos/gpu_shader_3D_polyline_info.hh
|
||||||
shaders/infos/gpu_shader_3D_smooth_color_info.hh
|
shaders/infos/gpu_shader_3D_smooth_color_info.hh
|
||||||
shaders/infos/gpu_shader_3D_uniform_color_info.hh
|
shaders/infos/gpu_shader_3D_uniform_color_info.hh
|
||||||
shaders/infos/gpu_shader_gpencil_stroke_info.hh
|
shaders/infos/gpu_shader_gpencil_stroke_info.hh
|
||||||
|
|
|
@ -227,39 +227,16 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = {
|
||||||
.frag = datatoc_gpu_shader_uniform_color_frag_glsl,
|
.frag = datatoc_gpu_shader_uniform_color_frag_glsl,
|
||||||
},
|
},
|
||||||
|
|
||||||
[GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR] =
|
[GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR] = {.name = "GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR",
|
||||||
{
|
.create_info =
|
||||||
.name = "GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR",
|
"gpu_shader_3D_polyline_uniform_color"},
|
||||||
.vert = datatoc_gpu_shader_3D_polyline_vert_glsl,
|
|
||||||
.geom = datatoc_gpu_shader_3D_polyline_geom_glsl,
|
|
||||||
.frag = datatoc_gpu_shader_3D_polyline_frag_glsl,
|
|
||||||
.defs = "#define UNIFORM\n",
|
|
||||||
},
|
|
||||||
[GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR] =
|
[GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR] =
|
||||||
{
|
{.name = "GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR",
|
||||||
.name = "GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR",
|
.create_info = "gpu_shader_3D_polyline_uniform_color_clipped"},
|
||||||
.vert = datatoc_gpu_shader_3D_polyline_vert_glsl,
|
[GPU_SHADER_3D_POLYLINE_FLAT_COLOR] = {.name = "GPU_SHADER_3D_POLYLINE_FLAT_COLOR",
|
||||||
.geom = datatoc_gpu_shader_3D_polyline_geom_glsl,
|
.create_info = "gpu_shader_3D_polyline_flat_color"},
|
||||||
.frag = datatoc_gpu_shader_3D_polyline_frag_glsl,
|
[GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR] = {.name = "GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR",
|
||||||
.defs = "#define UNIFORM\n"
|
.create_info = "gpu_shader_3D_polyline_smooth_color"},
|
||||||
"#define CLIP\n",
|
|
||||||
},
|
|
||||||
[GPU_SHADER_3D_POLYLINE_FLAT_COLOR] =
|
|
||||||
{
|
|
||||||
.name = "GPU_SHADER_3D_POLYLINE_FLAT_COLOR",
|
|
||||||
.vert = datatoc_gpu_shader_3D_polyline_vert_glsl,
|
|
||||||
.geom = datatoc_gpu_shader_3D_polyline_geom_glsl,
|
|
||||||
.frag = datatoc_gpu_shader_3D_polyline_frag_glsl,
|
|
||||||
.defs = "#define FLAT\n",
|
|
||||||
},
|
|
||||||
[GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR] =
|
|
||||||
{
|
|
||||||
.name = "GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR",
|
|
||||||
.vert = datatoc_gpu_shader_3D_polyline_vert_glsl,
|
|
||||||
.geom = datatoc_gpu_shader_3D_polyline_geom_glsl,
|
|
||||||
.frag = datatoc_gpu_shader_3D_polyline_frag_glsl,
|
|
||||||
.defs = "#define SMOOTH\n",
|
|
||||||
},
|
|
||||||
|
|
||||||
[GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR] =
|
[GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR] =
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,28 +1,15 @@
|
||||||
#ifndef USE_GPU_SHADER_CREATE_INFO
|
#pragma BLENDER_REQUIRE(gpu_shader_colorspace_lib.glsl)
|
||||||
uniform float lineWidth;
|
|
||||||
uniform bool lineSmooth = true;
|
|
||||||
|
|
||||||
in vec4 finalColor;
|
|
||||||
noperspective in float smoothline;
|
|
||||||
# ifdef CLIP
|
|
||||||
in float clip;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
out vec4 fragColor;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SMOOTH_WIDTH 1.0
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
#ifdef CLIP
|
#ifdef CLIP
|
||||||
if (clip < 0.0) {
|
if (interp.clip < 0.0) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fragColor = finalColor;
|
fragColor = interp.color;
|
||||||
if (lineSmooth) {
|
if (lineSmooth) {
|
||||||
fragColor.a *= clamp((lineWidth + SMOOTH_WIDTH) * 0.5 - abs(smoothline), 0.0, 1.0);
|
fragColor.a *= clamp((lineWidth + SMOOTH_WIDTH) * 0.5 - abs(interp.smoothline), 0.0, 1.0);
|
||||||
}
|
}
|
||||||
fragColor = blender_srgb_to_framebuffer_space(fragColor);
|
fragColor = blender_srgb_to_framebuffer_space(fragColor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,3 @@
|
||||||
#ifndef USE_GPU_SHADER_CREATE_INFO
|
|
||||||
layout(lines) in;
|
|
||||||
layout(triangle_strip, max_vertices = 4) out;
|
|
||||||
|
|
||||||
uniform vec4 color;
|
|
||||||
uniform vec2 viewportSize;
|
|
||||||
uniform float lineWidth;
|
|
||||||
uniform bool lineSmooth = true;
|
|
||||||
|
|
||||||
# if !defined(UNIFORM)
|
|
||||||
in vec4 finalColor_g[];
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef CLIP
|
|
||||||
in float clip_g[];
|
|
||||||
out float clip;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
out vec4 finalColor;
|
|
||||||
noperspective out float smoothline;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SMOOTH_WIDTH 1.0
|
|
||||||
|
|
||||||
/* Clips point to near clip plane before perspective divide. */
|
/* Clips point to near clip plane before perspective divide. */
|
||||||
vec4 clip_line_point_homogeneous_space(vec4 p, vec4 q)
|
vec4 clip_line_point_homogeneous_space(vec4 p, vec4 q)
|
||||||
|
@ -41,26 +18,26 @@ vec4 clip_line_point_homogeneous_space(vec4 p, vec4 q)
|
||||||
void do_vertex(const int i, vec4 pos, vec2 ofs)
|
void do_vertex(const int i, vec4 pos, vec2 ofs)
|
||||||
{
|
{
|
||||||
#if defined(UNIFORM)
|
#if defined(UNIFORM)
|
||||||
finalColor = color;
|
interp_out.color = color;
|
||||||
|
|
||||||
#elif defined(FLAT)
|
#elif defined(FLAT)
|
||||||
/* WATCH: Assuming last provoking vertex. */
|
/* WATCH: Assuming last provoking vertex. */
|
||||||
finalColor = finalColor_g[1];
|
interp_out.color = interp_in[1].color;
|
||||||
|
|
||||||
#elif defined(SMOOTH)
|
#elif defined(SMOOTH)
|
||||||
finalColor = finalColor_g[i];
|
interp_out.color = interp_in[i].color;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CLIP
|
#ifdef CLIP
|
||||||
clip = clip_g[i];
|
interp_out.clip = interp_in[i].clip;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
smoothline = (lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
interp_out.smoothline = (lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||||
gl_Position = pos;
|
gl_Position = pos;
|
||||||
gl_Position.xy += ofs * pos.w;
|
gl_Position.xy += ofs * pos.w;
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
||||||
smoothline = -(lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
interp_out.smoothline = -(lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||||
gl_Position = pos;
|
gl_Position = pos;
|
||||||
gl_Position.xy -= ofs * pos.w;
|
gl_Position.xy -= ofs * pos.w;
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
|
@ -1,29 +1,11 @@
|
||||||
#ifndef USE_GPU_SHADER_CREATE_INFO
|
|
||||||
uniform mat4 ModelViewProjectionMatrix;
|
|
||||||
uniform mat4 ModelMatrix;
|
|
||||||
uniform vec4 ClipPlane;
|
|
||||||
|
|
||||||
in vec3 pos;
|
|
||||||
|
|
||||||
# if !defined(UNIFORM)
|
|
||||||
in vec4 color;
|
|
||||||
|
|
||||||
out vec4 finalColor_g;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef CLIP
|
|
||||||
out float clip_g;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
|
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
|
||||||
#if !defined(UNIFORM)
|
#ifndef UNIFORM
|
||||||
finalColor_g = color;
|
interp.color = color;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CLIP
|
#ifdef CLIP
|
||||||
clip_g = dot(ModelMatrix * vec4(pos, 1.0), ClipPlane);
|
interp.clip = dot(ModelMatrix * vec4(pos, 1.0), ClipPlane);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,49 @@
|
||||||
#include "gpu_interface_info.hh"
|
#include "gpu_interface_info.hh"
|
||||||
#include "gpu_shader_create_info.hh"
|
#include "gpu_shader_create_info.hh"
|
||||||
|
|
||||||
/* TODO(jbakker): Skipped as it needs a uniform/storage buffer. */
|
GPU_SHADER_INTERFACE_INFO(gpu_shader_3D_polyline_iface, "interp")
|
||||||
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_uniform_color)
|
.smooth(Type::VEC4, "color")
|
||||||
|
.smooth(Type::FLOAT, "clip")
|
||||||
|
.no_perspective(Type::FLOAT, "smoothline");
|
||||||
|
|
||||||
|
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline)
|
||||||
|
.define("SMOOTH_WIDTH", "1.0")
|
||||||
|
.push_constant(Type::MAT4, "ModelViewProjectionMatrix")
|
||||||
|
.push_constant(Type::VEC2, "viewportSize")
|
||||||
|
.push_constant(Type::FLOAT, "lineWidth")
|
||||||
|
.push_constant(Type::BOOL, "lineSmooth")
|
||||||
|
.vertex_in(0, Type::VEC3, "pos")
|
||||||
|
.vertex_out(gpu_shader_3D_polyline_iface)
|
||||||
|
.geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4)
|
||||||
|
.geometry_out(gpu_shader_3D_polyline_iface)
|
||||||
|
.fragment_out(0, Type::VEC4, "fragColor")
|
||||||
.vertex_source("gpu_shader_3D_polyline_vert.glsl")
|
.vertex_source("gpu_shader_3D_polyline_vert.glsl")
|
||||||
.geometry_source("gpu_shader_3D_polyline_geom.glsl")
|
.geometry_source("gpu_shader_3D_polyline_geom.glsl")
|
||||||
.fragment_source("gpu_shader_3D_polyline_frag.glsl")
|
.fragment_source("gpu_shader_3D_polyline_frag.glsl")
|
||||||
.do_static_compilation(true);
|
.additional_info("gpu_srgb_to_framebuffer_space");
|
||||||
|
|
||||||
|
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_uniform_color)
|
||||||
|
.do_static_compilation(true)
|
||||||
|
.define("UNIFORM")
|
||||||
|
.push_constant(Type::VEC4, "color")
|
||||||
|
.additional_info("gpu_shader_3D_polyline");
|
||||||
|
|
||||||
|
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_uniform_color_clipped)
|
||||||
|
.do_static_compilation(true)
|
||||||
|
/* TODO(fclem): Put in an UBO to fit the 128byte requirement. */
|
||||||
|
.push_constant(Type::MAT4, "ModelMatrix")
|
||||||
|
.push_constant(Type::VEC4, "ClipPlane")
|
||||||
|
.define("CLIP")
|
||||||
|
.additional_info("gpu_shader_3D_polyline_uniform_color");
|
||||||
|
|
||||||
|
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_flat_color)
|
||||||
|
.do_static_compilation(true)
|
||||||
|
.define("FLAT")
|
||||||
|
.vertex_in(1, Type::VEC4, "color")
|
||||||
|
.additional_info("gpu_shader_3D_polyline");
|
||||||
|
|
||||||
|
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_smooth_color)
|
||||||
|
.do_static_compilation(true)
|
||||||
|
.define("SMOOTH")
|
||||||
|
.vertex_in(1, Type::VEC4, "color")
|
||||||
|
.additional_info("gpu_shader_3D_polyline");
|
||||||
|
|
Loading…
Reference in New Issue