Cleanup: DRW: Remove ObjectInfos legacy GLSL macros
_No response_ Pull Request: https://projects.blender.org/blender/blender/pulls/135542
This commit is contained in:
committed by
Clément Foucault
parent
6fc06388d4
commit
bb2d123fbd
@@ -564,6 +564,7 @@ set(GLSL_SRC
|
||||
intern/shaders/draw_intersect_lib.glsl
|
||||
intern/shaders/draw_math_geom_lib.glsl
|
||||
intern/shaders/draw_model_lib.glsl
|
||||
intern/shaders/draw_object_infos_lib.glsl
|
||||
intern/shaders/draw_pointcloud_lib.glsl
|
||||
intern/shaders/draw_resource_finalize_comp.glsl
|
||||
intern/shaders/draw_view_clipping_lib.glsl
|
||||
|
||||
@@ -789,7 +789,7 @@ void ShaderModule::material_create_info_amend(GPUMaterial *gpumat, GPUCodegenOut
|
||||
frag_gen << "ob_scale.x = length(drw_modelmat()[0].xyz);\n";
|
||||
frag_gen << "ob_scale.y = length(drw_modelmat()[1].xyz);\n";
|
||||
frag_gen << "ob_scale.z = length(drw_modelmat()[2].xyz);\n";
|
||||
frag_gen << "vec3 ls_dimensions = safe_rcp(abs(OrcoTexCoFactors[1].xyz));\n";
|
||||
frag_gen << "vec3 ls_dimensions = safe_rcp(abs(drw_object_infos().orco_mul.xyz));\n";
|
||||
frag_gen << "vec3 ws_dimensions = ob_scale * ls_dimensions;\n";
|
||||
/* Choose the minimum axis so that cuboids are better represented. */
|
||||
frag_gen << "return reduce_min(ws_dimensions);\n";
|
||||
|
||||
@@ -16,6 +16,7 @@ SHADER_LIBRARY_CREATE_INFO(draw_hair)
|
||||
|
||||
#include "common_hair_lib.glsl" /* TODO rename to curve. */
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
#include "gpu_shader_math_matrix_lib.glsl"
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
@@ -34,7 +35,7 @@ vec3 attr_load_orco(vec4 orco)
|
||||
{
|
||||
vec3 P = hair_get_strand_pos();
|
||||
vec3 lP = transform_point(drw_modelinv(), P);
|
||||
return OrcoTexCoFactors[0].xyz + lP * OrcoTexCoFactors[1].xyz;
|
||||
return drw_object_orco(lP);
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ SHADER_LIBRARY_CREATE_INFO(draw_modelmat)
|
||||
#endif
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
#include "gpu_shader_math_matrix_lib.glsl"
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
@@ -29,7 +30,7 @@ packed_float4 g_color;
|
||||
vec3 attr_load_orco(vec4 orco)
|
||||
{
|
||||
vec3 lP = drw_point_world_to_object(interp.P);
|
||||
return OrcoTexCoFactors[0].xyz + lP * OrcoTexCoFactors[1].xyz;
|
||||
return drw_object_orco(lP);
|
||||
}
|
||||
#endif
|
||||
vec4 attr_load_tangent(vec4 tangent)
|
||||
|
||||
@@ -11,6 +11,7 @@ SHADER_LIBRARY_CREATE_INFO(draw_modelmat)
|
||||
#endif
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
#include "gpu_shader_math_matrix_lib.glsl"
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
@@ -30,7 +31,7 @@ vec3 attr_load_orco(vec4 orco)
|
||||
if (orco.w == 1.0) {
|
||||
/* If the object does not have any deformation, the orco layer calculation is done on the fly
|
||||
* using the orco_madd factors. */
|
||||
return OrcoTexCoFactors[0].xyz + pos * OrcoTexCoFactors[1].xyz;
|
||||
return drw_object_orco(pos);
|
||||
}
|
||||
# endif
|
||||
return orco.xyz * 0.5 + 0.5;
|
||||
|
||||
@@ -15,6 +15,7 @@ SHADER_LIBRARY_CREATE_INFO(draw_modelmat)
|
||||
SHADER_LIBRARY_CREATE_INFO(draw_pointcloud)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_pointcloud_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
#include "gpu_shader_math_matrix_lib.glsl"
|
||||
@@ -31,7 +32,7 @@ vec3 attr_load_orco(vec4 orco)
|
||||
{
|
||||
vec3 P = pointcloud_get_pos();
|
||||
vec3 lP = transform_point(drw_modelinv(), P);
|
||||
return OrcoTexCoFactors[0].xyz + lP * OrcoTexCoFactors[1].xyz;
|
||||
return drw_object_orco(lP);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ SHADER_LIBRARY_CREATE_INFO(draw_modelmat)
|
||||
#endif
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
#include "gpu_shader_math_matrix_lib.glsl"
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
@@ -58,7 +59,7 @@ vec3 attr_load_orco(sampler3D tex)
|
||||
{
|
||||
g_attr_id += 1;
|
||||
# ifdef GRID_ATTRIBUTES
|
||||
return OrcoTexCoFactors[0].xyz + g_lP * OrcoTexCoFactors[1].xyz;
|
||||
return drw_object_orco(g_lP);
|
||||
# else
|
||||
return g_wP;
|
||||
# endif
|
||||
|
||||
@@ -8,6 +8,7 @@ VERTEX_SHADER_CREATE_INFO(eevee_clip_plane)
|
||||
VERTEX_SHADER_CREATE_INFO(eevee_geom_volume)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "eevee_surf_lib.glsl"
|
||||
|
||||
void main()
|
||||
@@ -17,8 +18,9 @@ void main()
|
||||
init_interface();
|
||||
|
||||
/* TODO(fclem): Find a better way? This is reverting what draw_resource_finalize does. */
|
||||
vec3 size = safe_rcp(OrcoTexCoFactors[1].xyz * 2.0); /* Box half-extent. */
|
||||
vec3 loc = size + (OrcoTexCoFactors[0].xyz / -OrcoTexCoFactors[1].xyz); /* Box center. */
|
||||
ObjectInfos info = drw_object_infos();
|
||||
vec3 size = safe_rcp(info.orco_mul * 2.0); /* Box half-extent. */
|
||||
vec3 loc = size + (info.orco_add / -info.orco_mul); /* Box center. */
|
||||
|
||||
/* Use bounding box geometry for now. */
|
||||
vec3 lP = loc + pos * size;
|
||||
|
||||
@@ -10,6 +10,7 @@ SHADER_LIBRARY_CREATE_INFO(eevee_global_ubo)
|
||||
SHADER_LIBRARY_CREATE_INFO(eevee_utility_texture)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "eevee_renderpass_lib.glsl"
|
||||
#include "gpu_shader_codegen_lib.glsl"
|
||||
@@ -783,20 +784,7 @@ vec4 attr_load_color_post(vec4 attr)
|
||||
|
||||
vec4 attr_load_uniform(vec4 attr, const uint attr_hash)
|
||||
{
|
||||
#if defined(OBATTR_LIB)
|
||||
uint index = floatBitsToUint(ObjectAttributeStart);
|
||||
for (uint i = 0; i < floatBitsToUint(ObjectAttributeLen); i++, index++) {
|
||||
if (drw_attrs[index].hash_code == attr_hash) {
|
||||
return vec4(drw_attrs[index].data_x,
|
||||
drw_attrs[index].data_y,
|
||||
drw_attrs[index].data_z,
|
||||
drw_attrs[index].data_w);
|
||||
}
|
||||
}
|
||||
return vec4(0.0);
|
||||
#else
|
||||
return attr;
|
||||
#endif
|
||||
return drw_object_attribute(attr_hash);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -62,7 +62,7 @@ void main()
|
||||
float alpha_rcp = safe_rcp(alpha);
|
||||
|
||||
/* Object holdout. */
|
||||
eObjectInfoFlag ob_flag = eObjectInfoFlag(floatBitsToUint(drw_infos[drw_resource_id()].infos.w));
|
||||
eObjectInfoFlag ob_flag = drw_object_infos().flag;
|
||||
if (flag_test(ob_flag, OBJECT_HOLDOUT)) {
|
||||
/* alpha is set from rejected pixels / dithering. */
|
||||
g_holdout = 1.0;
|
||||
|
||||
@@ -54,7 +54,7 @@ void main()
|
||||
|
||||
nodetree_surface(closure_rand);
|
||||
|
||||
eObjectInfoFlag ob_flag = eObjectInfoFlag(floatBitsToUint(drw_infos[drw_resource_id()].infos.w));
|
||||
eObjectInfoFlag ob_flag = drw_object_infos().flag;
|
||||
if (flag_test(ob_flag, OBJECT_HOLDOUT)) {
|
||||
g_holdout = 1.0 - average(g_transmittance);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ void main()
|
||||
float alpha_rcp = safe_rcp(alpha);
|
||||
|
||||
/* Object holdout. */
|
||||
eObjectInfoFlag ob_flag = eObjectInfoFlag(floatBitsToUint(drw_infos[drw_resource_id()].infos.w));
|
||||
eObjectInfoFlag ob_flag = drw_object_infos().flag;
|
||||
if (flag_test(ob_flag, OBJECT_HOLDOUT)) {
|
||||
/* alpha is set from rejected pixels / dithering. */
|
||||
g_holdout = 1.0;
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
# include "gpu_index_load_info.hh"
|
||||
# include "gpu_shader_create_info.hh"
|
||||
|
||||
# define OBINFO_NEW
|
||||
|
||||
# define HAIR_SHADER
|
||||
# define DRW_HAIR_INFO
|
||||
|
||||
|
||||
@@ -44,12 +44,6 @@ void main()
|
||||
uint in_primitive_id = uint(gl_VertexID) / output_vertex_count_per_input_primitive;
|
||||
uint in_primitive_first_vertex = in_primitive_id * input_primitive_vertex_count;
|
||||
|
||||
uint out_vertex_id = uint(gl_VertexID) % ouput_primitive_vertex_count;
|
||||
uint out_primitive_id = (uint(gl_VertexID) / ouput_primitive_vertex_count) %
|
||||
ouput_primitive_count;
|
||||
uint out_invocation_id = (uint(gl_VertexID) / output_vertex_count_per_invocation) %
|
||||
ouput_invocation_count;
|
||||
|
||||
uint vert_i = gpu_index_load(in_primitive_first_vertex);
|
||||
|
||||
vec3 ls_pos = gpu_attr_load_float3(pos, gpu_attr_1, vert_i);
|
||||
|
||||
@@ -275,7 +275,6 @@ void main()
|
||||
}
|
||||
|
||||
vec2 line_start, line_end;
|
||||
vec2 line_ofs;
|
||||
bvec4 extra_edges, extra_edges2;
|
||||
/* TODO: simplify this branching hell. */
|
||||
switch (edge_case) {
|
||||
|
||||
@@ -8,19 +8,15 @@ VERTEX_SHADER_CREATE_INFO(overlay_outline_prepass_curves)
|
||||
|
||||
#include "common_hair_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_view_clipping_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
|
||||
uint outline_colorid_get()
|
||||
{
|
||||
#ifdef OBINFO_NEW
|
||||
eObjectInfoFlag ob_flag = eObjectInfoFlag(floatBitsToUint(drw_infos[drw_resource_id()].infos.w));
|
||||
eObjectInfoFlag ob_flag = drw_object_infos().flag;
|
||||
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
|
||||
#else
|
||||
int flag = int(abs(ObjectInfo.w));
|
||||
bool is_active = (flag & DRW_BASE_ACTIVE) != 0;
|
||||
#endif
|
||||
|
||||
if (isTransform) {
|
||||
return 0u; /* colorTransform */
|
||||
|
||||
@@ -8,18 +8,14 @@ VERTEX_SHADER_CREATE_INFO(overlay_outline_prepass_gpencil)
|
||||
|
||||
#include "draw_grease_pencil_lib.glsl"
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_view_clipping_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
uint outline_colorid_get()
|
||||
{
|
||||
#ifdef OBINFO_NEW
|
||||
eObjectInfoFlag ob_flag = eObjectInfoFlag(floatBitsToUint(drw_infos[drw_resource_id()].infos.w));
|
||||
eObjectInfoFlag ob_flag = drw_object_infos().flag;
|
||||
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
|
||||
#else
|
||||
int flag = int(abs(ObjectInfo.w));
|
||||
bool is_active = (flag & DRW_BASE_ACTIVE) != 0;
|
||||
#endif
|
||||
|
||||
if (isTransform) {
|
||||
return 0u; /* colorTransform */
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
VERTEX_SHADER_CREATE_INFO(overlay_outline_prepass_pointcloud)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_pointcloud_lib.glsl"
|
||||
#include "draw_view_clipping_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
@@ -14,13 +15,8 @@ VERTEX_SHADER_CREATE_INFO(overlay_outline_prepass_pointcloud)
|
||||
|
||||
uint outline_colorid_get()
|
||||
{
|
||||
#ifdef OBINFO_NEW
|
||||
eObjectInfoFlag ob_flag = eObjectInfoFlag(floatBitsToUint(drw_infos[drw_resource_id()].infos.w));
|
||||
eObjectInfoFlag ob_flag = drw_object_infos().flag;
|
||||
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
|
||||
#else
|
||||
int flag = int(abs(ObjectInfo.w));
|
||||
bool is_active = (flag & DRW_BASE_ACTIVE) != 0;
|
||||
#endif
|
||||
|
||||
if (isTransform) {
|
||||
return 0u; /* colorTransform */
|
||||
|
||||
@@ -7,19 +7,15 @@
|
||||
VERTEX_SHADER_CREATE_INFO(overlay_outline_prepass_mesh)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_view_clipping_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
|
||||
uint outline_colorid_get()
|
||||
{
|
||||
#ifdef OBINFO_NEW
|
||||
eObjectInfoFlag ob_flag = eObjectInfoFlag(floatBitsToUint(drw_infos[drw_resource_id()].infos.w));
|
||||
eObjectInfoFlag ob_flag = drw_object_infos().flag;
|
||||
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
|
||||
#else
|
||||
int flag = int(abs(ObjectInfo.w));
|
||||
bool is_active = (flag & DRW_BASE_ACTIVE) != 0;
|
||||
#endif
|
||||
|
||||
if (isTransform) {
|
||||
return 0u; /* colorTransform */
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
VERTEX_SHADER_CREATE_INFO(overlay_outline_prepass_wire)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_view_clipping_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_attribute_load_lib.glsl"
|
||||
@@ -15,7 +16,7 @@ VERTEX_SHADER_CREATE_INFO(overlay_outline_prepass_wire)
|
||||
|
||||
uint outline_colorid_get()
|
||||
{
|
||||
eObjectInfoFlag ob_flag = eObjectInfoFlag(floatBitsToUint(drw_infos[drw_resource_id()].infos.w));
|
||||
eObjectInfoFlag ob_flag = drw_object_infos().flag;
|
||||
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
|
||||
|
||||
if (isTransform) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
VERTEX_SHADER_CREATE_INFO(overlay_particle_hair)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_view_clipping_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_math_base_lib.glsl"
|
||||
@@ -22,7 +23,7 @@ VERTEX_SHADER_CREATE_INFO(overlay_particle_hair)
|
||||
|
||||
void wire_color_get(out vec3 rim_col, out vec3 wire_col)
|
||||
{
|
||||
eObjectInfoFlag ob_flag = eObjectInfoFlag(floatBitsToUint(drw_infos[drw_resource_id()].infos.w));
|
||||
eObjectInfoFlag ob_flag = drw_object_infos().flag;
|
||||
bool is_selected = flag_test(ob_flag, OBJECT_SELECTED);
|
||||
bool is_from_set = flag_test(ob_flag, OBJECT_FROM_SET);
|
||||
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
|
||||
@@ -58,14 +59,14 @@ vec3 hsv_to_rgb(vec3 hsv)
|
||||
|
||||
void wire_object_color_get(out vec3 rim_col, out vec3 wire_col)
|
||||
{
|
||||
int flag = int(abs(ObjectInfo.w));
|
||||
bool is_selected = (flag & DRW_BASE_SELECTED) != 0;
|
||||
ObjectInfos info = drw_object_infos();
|
||||
bool is_selected = flag_test(info.flag, OBJECT_SELECTED);
|
||||
|
||||
if (colorType == V3D_SHADING_OBJECT_COLOR) {
|
||||
rim_col = wire_col = ObjectColor.rgb * 0.5;
|
||||
rim_col = wire_col = drw_object_infos().ob_color.rgb * 0.5;
|
||||
}
|
||||
else {
|
||||
float hue = ObjectInfo.z;
|
||||
float hue = info.random;
|
||||
vec3 hsv = vec3(hue, 0.75, 0.8);
|
||||
rim_col = wire_col = hsv_to_rgb(hsv);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
VERTEX_SHADER_CREATE_INFO(overlay_wireframe)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_view_clipping_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
@@ -23,17 +24,10 @@ bool is_edge_sharpness_visible(float wire_data)
|
||||
|
||||
void wire_color_get(out vec3 rim_col, out vec3 wire_col)
|
||||
{
|
||||
#ifdef OBINFO_NEW
|
||||
eObjectInfoFlag ob_flag = eObjectInfoFlag(floatBitsToUint(drw_infos[drw_resource_id()].infos.w));
|
||||
eObjectInfoFlag ob_flag = drw_object_infos().flag;
|
||||
bool is_selected = flag_test(ob_flag, OBJECT_SELECTED);
|
||||
bool is_from_set = flag_test(ob_flag, OBJECT_FROM_SET);
|
||||
bool is_active = flag_test(ob_flag, OBJECT_ACTIVE);
|
||||
#else
|
||||
int flag = int(abs(ObjectInfo.w));
|
||||
bool is_selected = (flag & DRW_BASE_SELECTED) != 0;
|
||||
bool is_from_set = (flag & DRW_BASE_FROM_SET) != 0;
|
||||
bool is_active = (flag & DRW_BASE_ACTIVE) != 0;
|
||||
#endif
|
||||
|
||||
if (is_from_set) {
|
||||
rim_col = colorWire.rgb;
|
||||
@@ -66,19 +60,14 @@ vec3 hsv_to_rgb(vec3 hsv)
|
||||
|
||||
void wire_object_color_get(out vec3 rim_col, out vec3 wire_col)
|
||||
{
|
||||
#ifdef OBINFO_NEW
|
||||
eObjectInfoFlag ob_flag = eObjectInfoFlag(floatBitsToUint(drw_infos[drw_resource_id()].infos.w));
|
||||
bool is_selected = flag_test(ob_flag, OBJECT_SELECTED);
|
||||
#else
|
||||
int flag = int(abs(ObjectInfo.w));
|
||||
bool is_selected = (flag & DRW_BASE_SELECTED) != 0;
|
||||
#endif
|
||||
ObjectInfos info = drw_object_infos();
|
||||
bool is_selected = flag_test(info.flag, OBJECT_SELECTED);
|
||||
|
||||
if (colorType == V3D_SHADING_OBJECT_COLOR) {
|
||||
rim_col = wire_col = ObjectColor.rgb * 0.5;
|
||||
rim_col = wire_col = drw_object_infos().ob_color.rgb * 0.5;
|
||||
}
|
||||
else {
|
||||
float hue = ObjectInfo.z;
|
||||
float hue = info.random;
|
||||
vec3 hsv = vec3(hue, 0.75, 0.8);
|
||||
rim_col = wire_col = hsv_to_rgb(hsv);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ void select_id_set(uint id)
|
||||
|
||||
void select_id_output(uint id)
|
||||
{
|
||||
if (id == -1) {
|
||||
if (id == uint(-1)) {
|
||||
/* Invalid index */
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ FRAGMENT_SHADER_CREATE_INFO(workbench_volume_cubic)
|
||||
FRAGMENT_SHADER_CREATE_INFO(workbench_volume_smoke)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_math_vector_lib.glsl"
|
||||
#include "workbench_common_lib.glsl"
|
||||
@@ -281,9 +282,9 @@ void main()
|
||||
vec3 ls_ray_end = drw_point_view_to_object(vs_ray_end);
|
||||
|
||||
# ifdef VOLUME_SMOKE
|
||||
ls_ray_dir = (OrcoTexCoFactors[0].xyz + ls_ray_dir * OrcoTexCoFactors[1].xyz) * 2.0 - 1.0;
|
||||
ls_ray_ori = (OrcoTexCoFactors[0].xyz + ls_ray_ori * OrcoTexCoFactors[1].xyz) * 2.0 - 1.0;
|
||||
ls_ray_end = (OrcoTexCoFactors[0].xyz + ls_ray_end * OrcoTexCoFactors[1].xyz) * 2.0 - 1.0;
|
||||
ls_ray_dir = (drw_object_orco(ls_ray_dir)) * 2.0 - 1.0;
|
||||
ls_ray_ori = (drw_object_orco(ls_ray_ori)) * 2.0 - 1.0;
|
||||
ls_ray_end = (drw_object_orco(ls_ray_end)) * 2.0 - 1.0;
|
||||
# else
|
||||
ls_ray_dir = (volumeObjectToTexture * vec4(ls_ray_dir, 1.0)).xyz * 2.0f - 1.0;
|
||||
ls_ray_ori = (volumeObjectToTexture * vec4(ls_ray_ori, 1.0)).xyz * 2.0f - 1.0;
|
||||
|
||||
@@ -11,6 +11,7 @@ VERTEX_SHADER_CREATE_INFO(workbench_volume_cubic)
|
||||
VERTEX_SHADER_CREATE_INFO(workbench_volume_smoke)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
|
||||
void main()
|
||||
@@ -33,7 +34,8 @@ void main()
|
||||
#endif
|
||||
|
||||
#ifdef VOLUME_SMOKE
|
||||
final_pos = ((final_pos * 0.5 + 0.5) - OrcoTexCoFactors[0].xyz) / OrcoTexCoFactors[1].xyz;
|
||||
ObjectInfos info = drw_object_infos();
|
||||
final_pos = ((final_pos * 0.5 + 0.5) - info.orco_add) / info.orco_mul;
|
||||
#else
|
||||
final_pos = (volumeTextureToObject * vec4(final_pos * 0.5 + 0.5, 1.0)).xyz;
|
||||
#endif
|
||||
|
||||
@@ -150,12 +150,6 @@ enum eObjectInfoFlag : uint32_t {
|
||||
};
|
||||
|
||||
struct ObjectInfos {
|
||||
#if defined(GPU_SHADER) && !defined(DRAW_FINALIZE_SHADER)
|
||||
/* TODO Rename to struct member for GLSL too. */
|
||||
float4 orco_mul_bias[2];
|
||||
float4 ob_color;
|
||||
float4 infos;
|
||||
#else
|
||||
/** Uploaded as center + size. Converted to mul+bias to local coord. */
|
||||
packed_float3 orco_add;
|
||||
uint object_attrs_offset;
|
||||
@@ -168,7 +162,6 @@ struct ObjectInfos {
|
||||
uint light_and_shadow_set_membership;
|
||||
float random;
|
||||
eObjectInfoFlag flag;
|
||||
#endif
|
||||
|
||||
#if !defined(GPU_SHADER) && defined(__cplusplus)
|
||||
void sync();
|
||||
@@ -179,20 +172,12 @@ BLI_STATIC_ASSERT_ALIGN(ObjectInfos, 16)
|
||||
|
||||
inline uint receiver_light_set_get(ObjectInfos object_infos)
|
||||
{
|
||||
#if defined(GPU_SHADER) && !defined(DRAW_FINALIZE_SHADER)
|
||||
return floatBitsToUint(object_infos.infos.y) & 0xFFu;
|
||||
#else
|
||||
return object_infos.light_and_shadow_set_membership & 0xFFu;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline uint blocker_shadow_set_get(ObjectInfos object_infos)
|
||||
{
|
||||
#if defined(GPU_SHADER) && !defined(DRAW_FINALIZE_SHADER)
|
||||
return (floatBitsToUint(object_infos.infos.y) >> 8u) & 0xFFu;
|
||||
#else
|
||||
return (object_infos.light_and_shadow_set_membership >> 8u) & 0xFFu;
|
||||
#endif
|
||||
}
|
||||
|
||||
struct ObjectBounds {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
SHADER_LIBRARY_CREATE_INFO(draw_gpencil)
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
#include "draw_object_infos_lib.glsl"
|
||||
#include "draw_view_lib.glsl"
|
||||
#include "gpu_shader_math_matrix_lib.glsl"
|
||||
#include "gpu_shader_utildefines_lib.glsl"
|
||||
@@ -352,7 +353,7 @@ vec4 gpencil_vertex(vec4 viewport_size,
|
||||
/* Flat normal following camera and object bounds. */
|
||||
vec3 V = drw_world_incident_vector(drw_modelmat()[3].xyz);
|
||||
vec3 N = drw_normal_world_to_object(V);
|
||||
N *= OrcoTexCoFactors[1].xyz;
|
||||
N *= drw_object_infos().orco_mul;
|
||||
N = drw_normal_world_to_object(N);
|
||||
out_N = safe_normalize(N);
|
||||
|
||||
|
||||
@@ -13,13 +13,6 @@
|
||||
|
||||
# define HAIR_SHADER
|
||||
# define DRW_GPENCIL_INFO
|
||||
|
||||
# define OrcoTexCoFactors (drw_infos[drw_resource_id()].orco_mul_bias)
|
||||
# define ObjectInfo (drw_infos[drw_resource_id()].infos)
|
||||
# define ObjectColor (drw_infos[drw_resource_id()].ob_color)
|
||||
|
||||
# define ObjectAttributeStart (drw_infos[drw_resource_id()].orco_mul_bias[0].w)
|
||||
# define ObjectAttributeLen (drw_infos[drw_resource_id()].orco_mul_bias[1].w)
|
||||
#endif
|
||||
|
||||
#include "draw_defines.hh"
|
||||
@@ -48,18 +41,12 @@ GPU_SHADER_CREATE_END()
|
||||
GPU_SHADER_CREATE_INFO(draw_object_infos)
|
||||
TYPEDEF_SOURCE("draw_shader_shared.hh")
|
||||
DEFINE("OBINFO_LIB")
|
||||
DEFINE("OBINFO_NEW")
|
||||
DEFINE_VALUE("OrcoTexCoFactors", "(drw_infos[drw_resource_id()].orco_mul_bias)")
|
||||
DEFINE_VALUE("ObjectInfo", "(drw_infos[drw_resource_id()].infos)")
|
||||
DEFINE_VALUE("ObjectColor", "(drw_infos[drw_resource_id()].ob_color)")
|
||||
STORAGE_BUF(DRW_OBJ_INFOS_SLOT, READ, ObjectInfos, drw_infos[])
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
/** \note Requires draw_object_infos. */
|
||||
GPU_SHADER_CREATE_INFO(draw_object_attributes)
|
||||
DEFINE("OBATTR_LIB")
|
||||
DEFINE_VALUE("ObjectAttributeStart", "(drw_infos[drw_resource_id()].orco_mul_bias[0].w)")
|
||||
DEFINE_VALUE("ObjectAttributeLen", "(drw_infos[drw_resource_id()].orco_mul_bias[1].w)")
|
||||
STORAGE_BUF(DRW_OBJ_ATTR_SLOT, READ, ObjectAttribute, drw_attrs[])
|
||||
ADDITIONAL_INFO(draw_object_infos)
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/* SPDX-FileCopyrightText: 2018-2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "draw_object_infos_info.hh"
|
||||
|
||||
#include "draw_model_lib.glsl"
|
||||
|
||||
#if !defined(OBINFO_LIB) && !defined(GLSL_CPP_STUBS)
|
||||
# error Missing draw_object_infos additional create info on shader create info
|
||||
#endif
|
||||
|
||||
#if defined(GPU_VERTEX_SHADER)
|
||||
VERTEX_SHADER_CREATE_INFO(draw_object_infos)
|
||||
#elif defined(GPU_FRAGMENT_SHADER)
|
||||
FRAGMENT_SHADER_CREATE_INFO(draw_object_infos)
|
||||
#elif defined(GPU_LIBRARY_SHADER)
|
||||
SHADER_LIBRARY_CREATE_INFO(draw_object_infos)
|
||||
#endif
|
||||
|
||||
ObjectInfos drw_object_infos()
|
||||
{
|
||||
#ifdef OBINFO_LIB
|
||||
return drw_infos[drw_resource_id()];
|
||||
#else
|
||||
return ObjectInfos();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Convert local coordinates to "Original coordinates" for texture mapping.
|
||||
* This is supposed to only be used if there is no modifier that distort the object.
|
||||
* Otherwise, a geometry attribute should be used instead. */
|
||||
vec3 drw_object_orco(vec3 lP)
|
||||
{
|
||||
ObjectInfos info = drw_object_infos();
|
||||
return info.orco_add + lP * info.orco_mul;
|
||||
}
|
||||
|
||||
vec4 drw_object_attribute(const uint attr_hash)
|
||||
{
|
||||
#if defined(OBATTR_LIB)
|
||||
ObjectInfos infos = drw_object_infos();
|
||||
uint index = infos.object_attrs_offset;
|
||||
for (uint i = 0; i < infos.object_attrs_len; i++, index++) {
|
||||
ObjectAttribute attr = drw_attrs[index];
|
||||
if (attr.hash_code == attr_hash) {
|
||||
return vec4(attr.data_x, attr.data_y, attr.data_z, attr.data_w);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return vec4(0.0);
|
||||
}
|
||||
@@ -356,7 +356,6 @@ enum GPUUniformBuiltin {
|
||||
GPU_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */
|
||||
|
||||
GPU_UNIFORM_NORMAL, /* mat3 NormalMatrix */
|
||||
GPU_UNIFORM_ORCO, /* vec4 OrcoTexCoFactors[] */
|
||||
GPU_UNIFORM_CLIPPLANES, /* vec4 WorldClipPlanes[] */
|
||||
|
||||
GPU_UNIFORM_COLOR, /* vec4 color */
|
||||
|
||||
@@ -198,8 +198,6 @@ inline const char *ShaderInterface::builtin_uniform_name(GPUUniformBuiltin u)
|
||||
|
||||
case GPU_UNIFORM_NORMAL:
|
||||
return "NormalMatrix";
|
||||
case GPU_UNIFORM_ORCO:
|
||||
return "OrcoTexCoFactors";
|
||||
case GPU_UNIFORM_CLIPPLANES:
|
||||
return "WorldClipPlanes";
|
||||
|
||||
|
||||
@@ -11,11 +11,7 @@ void node_normal_map(vec4 tangent, float strength, vec3 texnormal, out vec3 outn
|
||||
}
|
||||
tangent *= (FrontFacing ? 1.0 : -1.0);
|
||||
vec3 B = tangent.w * cross(g_data.Ni, tangent.xyz);
|
||||
# ifdef OBINFO_NEW
|
||||
B *= (floatBitsToUint(ObjectInfo.w) & OBJECT_NEGATIVE_SCALE) != 0 ? -1.0 : 1.0;
|
||||
# else
|
||||
B *= sign(ObjectInfo.w);
|
||||
# endif
|
||||
B *= (drw_object_infos().flag & OBJECT_NEGATIVE_SCALE) != 0 ? -1.0 : 1.0;
|
||||
|
||||
/* Apply strength here instead of in node_normal_map_mix for tangent space. */
|
||||
texnormal.xy *= strength;
|
||||
|
||||
@@ -11,14 +11,11 @@ void node_object_info(float mat_index,
|
||||
out float random)
|
||||
{
|
||||
location = drw_modelmat()[3].xyz;
|
||||
color = ObjectColor;
|
||||
alpha = ObjectColor.a;
|
||||
#ifdef OBINFO_NEW
|
||||
object_index = floatBitsToUint(ObjectInfo.x);
|
||||
#else
|
||||
object_index = ObjectInfo.x;
|
||||
#endif
|
||||
ObjectInfos info = drw_object_infos();
|
||||
color = info.ob_color;
|
||||
alpha = info.ob_color.a;
|
||||
object_index = info.index;
|
||||
/* TODO(fclem): Put that inside the Material UBO. */
|
||||
material_index = mat_index;
|
||||
random = ObjectInfo.z;
|
||||
random = info.random;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user