Overlay: Port volume shaders to use shaderCreateInfo
This should have no functional changes.
This commit is contained in:
@@ -1205,38 +1205,23 @@ struct GPUShader *OVERLAY_shader_volume_velocity(bool use_needle, bool use_mac)
|
||||
{
|
||||
OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
|
||||
if (use_needle && !sh_data->volume_velocity_needle_sh) {
|
||||
sh_data->volume_velocity_needle_sh = DRW_shader_create_with_lib(
|
||||
datatoc_volume_velocity_vert_glsl,
|
||||
NULL,
|
||||
datatoc_gpu_shader_flat_color_frag_glsl,
|
||||
datatoc_common_view_lib_glsl,
|
||||
"#define blender_srgb_to_framebuffer_space(a) a\n"
|
||||
"#define USE_NEEDLE\n");
|
||||
sh_data->volume_velocity_needle_sh = GPU_shader_create_from_info_name(
|
||||
"overlay_volume_velocity_needle");
|
||||
}
|
||||
else if (use_mac && !sh_data->volume_velocity_mac_sh) {
|
||||
sh_data->volume_velocity_mac_sh = DRW_shader_create_with_lib(
|
||||
datatoc_volume_velocity_vert_glsl,
|
||||
NULL,
|
||||
datatoc_gpu_shader_3D_smooth_color_frag_glsl,
|
||||
datatoc_common_view_lib_glsl,
|
||||
"#define blender_srgb_to_framebuffer_space(a) a\n"
|
||||
"#define USE_MAC\n");
|
||||
sh_data->volume_velocity_mac_sh = GPU_shader_create_from_info_name(
|
||||
"overlay_volume_velocity_mac");
|
||||
}
|
||||
else if (!sh_data->volume_velocity_sh) {
|
||||
sh_data->volume_velocity_sh = DRW_shader_create_with_lib(
|
||||
datatoc_volume_velocity_vert_glsl,
|
||||
NULL,
|
||||
datatoc_gpu_shader_flat_color_frag_glsl,
|
||||
datatoc_common_view_lib_glsl,
|
||||
"#define blender_srgb_to_framebuffer_space(a) a\n");
|
||||
sh_data->volume_velocity_sh = GPU_shader_create_from_info_name("overlay_volume_velocity");
|
||||
}
|
||||
|
||||
if (use_needle) {
|
||||
return sh_data->volume_velocity_needle_sh;
|
||||
}
|
||||
if (use_mac) {
|
||||
return sh_data->volume_velocity_mac_sh;
|
||||
}
|
||||
|
||||
return sh_data->volume_velocity_sh;
|
||||
}
|
||||
|
||||
@@ -1244,30 +1229,15 @@ struct GPUShader *OVERLAY_shader_volume_gridlines(bool color_with_flags, bool co
|
||||
{
|
||||
OVERLAY_Shaders *sh_data = &e_data.sh_data[0];
|
||||
if (!sh_data->volume_gridlines_flags_sh && color_with_flags) {
|
||||
sh_data->volume_gridlines_flags_sh = DRW_shader_create_with_lib(
|
||||
datatoc_volume_gridlines_vert_glsl,
|
||||
NULL,
|
||||
datatoc_gpu_shader_flat_color_frag_glsl,
|
||||
datatoc_common_view_lib_glsl,
|
||||
"#define blender_srgb_to_framebuffer_space(a) a\n"
|
||||
"#define SHOW_FLAGS\n");
|
||||
sh_data->volume_gridlines_flags_sh = GPU_shader_create_from_info_name(
|
||||
"overlay_volume_gridlines_flags");
|
||||
}
|
||||
else if (!sh_data->volume_gridlines_range_sh && color_range) {
|
||||
sh_data->volume_gridlines_range_sh = DRW_shader_create_with_lib(
|
||||
datatoc_volume_gridlines_vert_glsl,
|
||||
NULL,
|
||||
datatoc_gpu_shader_flat_color_frag_glsl,
|
||||
datatoc_common_view_lib_glsl,
|
||||
"#define blender_srgb_to_framebuffer_space(a) a\n"
|
||||
"#define SHOW_RANGE\n");
|
||||
sh_data->volume_gridlines_range_sh = GPU_shader_create_from_info_name(
|
||||
"overlay_volume_gridlines_range");
|
||||
}
|
||||
else if (!sh_data->volume_gridlines_sh) {
|
||||
sh_data->volume_gridlines_sh = DRW_shader_create_with_lib(
|
||||
datatoc_volume_gridlines_vert_glsl,
|
||||
NULL,
|
||||
datatoc_gpu_shader_flat_color_frag_glsl,
|
||||
datatoc_common_view_lib_glsl,
|
||||
"#define blender_srgb_to_framebuffer_space(a) a\n");
|
||||
sh_data->volume_gridlines_sh = GPU_shader_create_from_info_name("overlay_volume_gridlines");
|
||||
}
|
||||
|
||||
if (color_with_flags) {
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "gpu_shader_create_info.hh"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Volume Velocity
|
||||
* \{ */
|
||||
|
||||
GPU_SHADER_INTERFACE_INFO(overlay_volume_velocity_iface, "").smooth(Type::VEC4, "finalColor");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_velocity)
|
||||
.do_static_compilation(true)
|
||||
/* Colors are already in linear space. */
|
||||
.define("srgbTarget", "false")
|
||||
.sampler(0, ImageType::FLOAT_3D, "velocityX")
|
||||
.sampler(1, ImageType::FLOAT_3D, "velocityY")
|
||||
.sampler(2, ImageType::FLOAT_3D, "velocityZ")
|
||||
.push_constant(Type::FLOAT, "displaySize")
|
||||
.push_constant(Type::FLOAT, "slicePosition")
|
||||
.push_constant(Type::INT, "sliceAxis")
|
||||
.push_constant(Type::BOOL, "scaleWithMagnitude")
|
||||
.push_constant(Type::BOOL, "isCellCentered")
|
||||
/* FluidDomainSettings.cell_size */
|
||||
.push_constant(Type::VEC3, "cellSize")
|
||||
/* FluidDomainSettings.p0 */
|
||||
.push_constant(Type::VEC3, "domainOriginOffset")
|
||||
/* FluidDomainSettings.res_min */
|
||||
.push_constant(Type::IVEC3, "adaptiveCellOffset")
|
||||
.vertex_out(overlay_volume_velocity_iface)
|
||||
.fragment_out(0, Type::VEC4, "fragColor")
|
||||
.vertex_source("volume_velocity_vert.glsl")
|
||||
.fragment_source("gpu_shader_3D_smooth_color_frag.glsl")
|
||||
.additional_info("draw_volume");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_velocity_mac)
|
||||
.do_static_compilation(true)
|
||||
.define("USE_MAC")
|
||||
.push_constant(Type::BOOL, "drawMACX")
|
||||
.push_constant(Type::BOOL, "drawMACY")
|
||||
.push_constant(Type::BOOL, "drawMACZ")
|
||||
.additional_info("overlay_volume_velocity");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_velocity_needle)
|
||||
.do_static_compilation(true)
|
||||
.define("USE_NEEDLE")
|
||||
.additional_info("overlay_volume_velocity");
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Volume Gridlines
|
||||
* \{ */
|
||||
|
||||
GPU_SHADER_INTERFACE_INFO(overlay_volume_gridlines_iface, "").flat(Type::VEC4, "finalColor");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_gridlines)
|
||||
.do_static_compilation(true)
|
||||
/* Colors are already in linear space. */
|
||||
.define("srgbTarget", "false")
|
||||
.push_constant(Type::FLOAT, "slicePosition")
|
||||
.push_constant(Type::INT, "sliceAxis")
|
||||
/* FluidDomainSettings.res */
|
||||
.push_constant(Type::IVEC3, "volumeSize")
|
||||
/* FluidDomainSettings.cell_size */
|
||||
.push_constant(Type::VEC3, "cellSize")
|
||||
/* FluidDomainSettings.p0 */
|
||||
.push_constant(Type::VEC3, "domainOriginOffset")
|
||||
/* FluidDomainSettings.res_min */
|
||||
.push_constant(Type::IVEC3, "adaptiveCellOffset")
|
||||
.vertex_out(overlay_volume_gridlines_iface)
|
||||
.fragment_out(0, Type::VEC4, "fragColor")
|
||||
.vertex_source("volume_gridlines_vert.glsl")
|
||||
.fragment_source("gpu_shader_flat_color_frag.glsl")
|
||||
.additional_info("draw_volume");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_flags)
|
||||
.do_static_compilation(true)
|
||||
.define("SHOW_FLAGS")
|
||||
.sampler(0, ImageType::UINT_3D, "flagTexture")
|
||||
.additional_info("overlay_volume_gridlines");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(overlay_volume_gridlines_range)
|
||||
.do_static_compilation(true)
|
||||
.define("SHOW_RANGE")
|
||||
.push_constant(Type::FLOAT, "lowerBound")
|
||||
.push_constant(Type::FLOAT, "upperBound")
|
||||
.push_constant(Type::VEC4, "rangeColor")
|
||||
.push_constant(Type::INT, "cellFilter")
|
||||
.sampler(0, ImageType::UINT_3D, "flagTexture")
|
||||
.sampler(1, ImageType::FLOAT_3D, "fieldTexture")
|
||||
.additional_info("overlay_volume_gridlines");
|
||||
|
||||
/** \} */
|
||||
@@ -1,28 +1,5 @@
|
||||
uniform float slicePosition;
|
||||
uniform int sliceAxis; /* -1 is no slice, 0 is X, 1 is Y, 2 is Z. */
|
||||
|
||||
/* FluidDomainSettings.res */
|
||||
uniform ivec3 volumeSize;
|
||||
/* FluidDomainSettings.cell_size */
|
||||
uniform vec3 cellSize;
|
||||
/* FluidDomainSettings.p0 */
|
||||
uniform vec3 domainOriginOffset;
|
||||
/* FluidDomainSettings.res_min */
|
||||
uniform ivec3 adaptiveCellOffset;
|
||||
|
||||
#if defined(SHOW_FLAGS) || defined(SHOW_RANGE)
|
||||
uniform usampler3D flagTexture;
|
||||
#endif
|
||||
|
||||
#ifdef SHOW_RANGE
|
||||
uniform sampler3D fieldTexture;
|
||||
uniform float lowerBound = 0.0;
|
||||
uniform float upperBound = 0.0;
|
||||
uniform vec4 rangeColor;
|
||||
uniform int cellFilter;
|
||||
#endif
|
||||
|
||||
flat out vec4 finalColor;
|
||||
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
|
||||
|
||||
/* Corners for cell outlines. 0.45 is arbitrary. Any value below 0.5 can be used to avoid
|
||||
* overlapping of the outlines. */
|
||||
|
||||
@@ -1,29 +1,5 @@
|
||||
|
||||
uniform sampler3D velocityX;
|
||||
uniform sampler3D velocityY;
|
||||
uniform sampler3D velocityZ;
|
||||
uniform float displaySize = 1.0;
|
||||
uniform float slicePosition;
|
||||
uniform int sliceAxis; /* -1 is no slice, 0 is X, 1 is Y, 2 is Z. */
|
||||
uniform bool scaleWithMagnitude = false;
|
||||
uniform bool isCellCentered = false;
|
||||
|
||||
/* FluidDomainSettings.cell_size */
|
||||
uniform vec3 cellSize;
|
||||
/* FluidDomainSettings.p0 */
|
||||
uniform vec3 domainOriginOffset;
|
||||
/* FluidDomainSettings.res_min */
|
||||
uniform ivec3 adaptiveCellOffset;
|
||||
|
||||
#ifdef USE_MAC
|
||||
uniform bool drawMACX;
|
||||
uniform bool drawMACY;
|
||||
uniform bool drawMACZ;
|
||||
|
||||
out vec4 finalColor;
|
||||
#else
|
||||
flat out vec4 finalColor;
|
||||
#endif
|
||||
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
|
||||
|
||||
const vec3 corners[4] = vec3[4](vec3(0.0, 0.2, -0.5),
|
||||
vec3(-0.2 * 0.866, -0.2 * 0.5, -0.5),
|
||||
|
||||
@@ -447,6 +447,7 @@ set(SRC_SHADER_CREATE_INFOS
|
||||
../draw/engines/overlay/shaders/infos/extra_info.hh
|
||||
../draw/engines/overlay/shaders/infos/grid_info.hh
|
||||
../draw/engines/overlay/shaders/infos/edit_mode_info.hh
|
||||
../draw/engines/overlay/shaders/infos/volume_info.hh
|
||||
../draw/engines/select/shaders/infos/select_id_info.hh
|
||||
../draw/engines/workbench/shaders/infos/workbench_composite_info.hh
|
||||
../draw/engines/workbench/shaders/infos/workbench_effect_antialiasing_info.hh
|
||||
|
||||
Reference in New Issue
Block a user