This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/gpu/shaders/material/gpu_shader_material_attribute.glsl
Clément Foucault e48a6fcc63 DRW-Next: Add uniform attributes (object attributes) support
This replaces the direct shader uniform layout declaration by a linear
search through a global buffer.

Each instance has an attribute offset inside the global buffer and an
attribute count.

This removes any padding and tighly pack all uniform attributes inside
a single buffer.

This would also remove the limit of 8 attribute but it is kept because of
compatibility with the old system that is still used by the old draw
manager.
2022-09-02 19:37:15 +02:00

40 lines
972 B
GLSL

void node_attribute_color(vec4 attr, out vec4 out_attr)
{
out_attr = attr_load_color_post(attr);
}
void node_attribute_temperature(vec4 attr, out vec4 out_attr)
{
out_attr.x = attr_load_temperature_post(attr.x);
out_attr.y = 0.0;
out_attr.z = 0.0;
out_attr.w = 1.0;
}
void node_attribute_density(vec4 attr, out float out_attr)
{
out_attr = attr.x;
}
void node_attribute_flame(vec4 attr, out float out_attr)
{
out_attr = attr.x;
}
void node_attribute_uniform(vec4 attr, const float attr_hash, out vec4 out_attr)
{
/* Temporary solution to support both old UBO attribs and new SSBO loading.
* Old UBO load is already done through `attr` and will just be passed through. */
out_attr = attr_load_uniform(attr, floatBitsToUint(attr_hash));
}
void node_attribute(
vec4 attr, out vec4 outcol, out vec3 outvec, out float outf, out float outalpha)
{
outcol = vec4(attr.xyz, 1.0);
outvec = attr.xyz;
outf = avg(attr.xyz);
outalpha = attr.w;
}