Cleanup: ImageEngine: Shader interface naming
Pull Request: https://projects.blender.org/blender/blender/pulls/131228
This commit is contained in:
@@ -30,18 +30,18 @@ void ScreenSpaceDrawingMode::add_shgroups() const
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
|
||||
DRWShadingGroup *shgrp = DRW_shgroup_create(shader, instance_.state.passes.image_pass);
|
||||
DRW_shgroup_uniform_vec2_copy(shgrp, "farNearDistances", sh_params.far_near);
|
||||
DRW_shgroup_uniform_vec2_copy(shgrp, "far_near_distances", sh_params.far_near);
|
||||
DRW_shgroup_uniform_vec4_copy(shgrp, "shuffle", sh_params.shuffle);
|
||||
DRW_shgroup_uniform_int_copy(shgrp, "drawFlags", static_cast<int32_t>(sh_params.flags));
|
||||
DRW_shgroup_uniform_bool_copy(shgrp, "imgPremultiplied", sh_params.use_premul_alpha);
|
||||
DRW_shgroup_uniform_texture(shgrp, "depth_texture", dtxl->depth);
|
||||
DRW_shgroup_uniform_int_copy(shgrp, "draw_flags", static_cast<int32_t>(sh_params.flags));
|
||||
DRW_shgroup_uniform_bool_copy(shgrp, "is_image_premultiplied", sh_params.use_premul_alpha);
|
||||
DRW_shgroup_uniform_texture(shgrp, "depth_tx", dtxl->depth);
|
||||
float image_mat[4][4];
|
||||
unit_m4(image_mat);
|
||||
for (const TextureInfo &info : instance_.state.texture_infos) {
|
||||
DRWShadingGroup *shgrp_sub = DRW_shgroup_create_sub(shgrp);
|
||||
DRW_shgroup_uniform_ivec2_copy(shgrp_sub, "offset", info.offset());
|
||||
DRW_shgroup_uniform_texture_ex(
|
||||
shgrp_sub, "imageTexture", info.texture, GPUSamplerState::default_sampler());
|
||||
shgrp_sub, "image_tx", info.texture, GPUSamplerState::default_sampler());
|
||||
DRW_shgroup_call_obmat(shgrp_sub, info.batch, image_mat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,34 +10,34 @@
|
||||
#define IMAGE_DRAW_FLAG_SHUFFLING (1 << 2)
|
||||
#define IMAGE_DRAW_FLAG_DEPTH (1 << 3)
|
||||
|
||||
#define FAR_DISTANCE farNearDistances.x
|
||||
#define NEAR_DISTANCE farNearDistances.y
|
||||
#define FAR_DISTANCE far_near_distances.x
|
||||
#define NEAR_DISTANCE far_near_distances.y
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 uvs_clamped = ivec2(uv_screen);
|
||||
float depth = texelFetch(depth_texture, uvs_clamped, 0).r;
|
||||
float depth = texelFetch(depth_tx, uvs_clamped, 0).r;
|
||||
if (depth == 1.0) {
|
||||
discard;
|
||||
return;
|
||||
}
|
||||
|
||||
vec4 tex_color = texelFetch(imageTexture, uvs_clamped - offset, 0);
|
||||
vec4 tex_color = texelFetch(image_tx, uvs_clamped - offset, 0);
|
||||
|
||||
if ((drawFlags & IMAGE_DRAW_FLAG_APPLY_ALPHA) != 0) {
|
||||
if (!imgPremultiplied) {
|
||||
if ((draw_flags & IMAGE_DRAW_FLAG_APPLY_ALPHA) != 0) {
|
||||
if (!is_image_premultiplied) {
|
||||
tex_color.rgb *= tex_color.a;
|
||||
}
|
||||
}
|
||||
if ((drawFlags & IMAGE_DRAW_FLAG_DEPTH) != 0) {
|
||||
if ((draw_flags & IMAGE_DRAW_FLAG_DEPTH) != 0) {
|
||||
tex_color = smoothstep(FAR_DISTANCE, NEAR_DISTANCE, tex_color);
|
||||
}
|
||||
|
||||
if ((drawFlags & IMAGE_DRAW_FLAG_SHUFFLING) != 0) {
|
||||
if ((draw_flags & IMAGE_DRAW_FLAG_SHUFFLING) != 0) {
|
||||
tex_color = vec4(dot(tex_color, shuffle));
|
||||
}
|
||||
if ((drawFlags & IMAGE_DRAW_FLAG_SHOW_ALPHA) == 0) {
|
||||
if ((draw_flags & IMAGE_DRAW_FLAG_SHOW_ALPHA) == 0) {
|
||||
tex_color.a = 1.0;
|
||||
}
|
||||
fragColor = tex_color;
|
||||
out_color = tex_color;
|
||||
}
|
||||
|
||||
@@ -11,14 +11,14 @@ GPU_SHADER_INTERFACE_END()
|
||||
GPU_SHADER_CREATE_INFO(image_engine_color_shader)
|
||||
VERTEX_IN(0, IVEC2, pos)
|
||||
VERTEX_OUT(image_engine_color_iface)
|
||||
FRAGMENT_OUT(0, VEC4, fragColor)
|
||||
FRAGMENT_OUT(0, VEC4, out_color)
|
||||
PUSH_CONSTANT(VEC4, shuffle)
|
||||
PUSH_CONSTANT(VEC2, farNearDistances)
|
||||
PUSH_CONSTANT(VEC2, far_near_distances)
|
||||
PUSH_CONSTANT(IVEC2, offset)
|
||||
PUSH_CONSTANT(INT, drawFlags)
|
||||
PUSH_CONSTANT(BOOL, imgPremultiplied)
|
||||
SAMPLER(0, FLOAT_2D, imageTexture)
|
||||
SAMPLER(1, DEPTH_2D, depth_texture)
|
||||
PUSH_CONSTANT(INT, draw_flags)
|
||||
PUSH_CONSTANT(BOOL, is_image_premultiplied)
|
||||
SAMPLER(0, FLOAT_2D, image_tx)
|
||||
SAMPLER(1, DEPTH_2D, depth_tx)
|
||||
VERTEX_SOURCE("image_engine_color_vert.glsl")
|
||||
FRAGMENT_SOURCE("image_engine_color_frag.glsl")
|
||||
ADDITIONAL_INFO(draw_modelmat)
|
||||
|
||||
Reference in New Issue
Block a user