diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-04-19 13:01:16 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-04-19 13:09:18 +0300 |
commit | fa3bd17ae87301ca198d16d2dc7d2432548f34f9 (patch) | |
tree | c08eb8740784799dd3bf9517f4eb4380bc4e6cab /source/blender/draw/intern/draw_shader_shared.h | |
parent | 1e3f4c70ab56578b8b0e0056870bd17cc118982a (diff) |
GPU: Replace `GPUMaterialVolumeGrid` by `GPUMaterialAttribute`
This is to make the codegen and shading nodes object type agnostic. This
is essential for flexibility of the engine to use the nodetree as it see
fits.
The essential volume attributes struct properties are moved to the
`GPUMaterialAttribute` which see its final input name set on creation.
The binding process is centralized into `draw_volume.cc` to avoid
duplicating the code between multiple engines. It mimics the hair attributes
process.
Volume object grid transforms and other per object uniforms are packed into
one UBO per object. The grid transform is now based on object which simplify
the matrix preparations.
This also gets rid of the double transforms and use object info orco factors
for volume objects.
Tagging @brecht because he did the initial implementation of Volume Grids.
Diffstat (limited to 'source/blender/draw/intern/draw_shader_shared.h')
-rw-r--r-- | source/blender/draw/intern/draw_shader_shared.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_shader_shared.h b/source/blender/draw/intern/draw_shader_shared.h index 58875c0496a..d2e51b67468 100644 --- a/source/blender/draw/intern/draw_shader_shared.h +++ b/source/blender/draw/intern/draw_shader_shared.h @@ -6,12 +6,16 @@ typedef struct ViewInfos ViewInfos; typedef struct ObjectMatrices ObjectMatrices; typedef struct ObjectInfos ObjectInfos; +typedef struct VolumeInfos VolumeInfos; #endif #define DRW_SHADER_SHARED_H #define DRW_RESOURCE_CHUNK_LEN 512 +/* Define the maximum number of grid we allow in a volume UBO. */ +#define DRW_GRID_PER_VOLUME_MAX 16 + struct ViewInfos { /* View matrices */ float4x4 persmat; @@ -63,6 +67,18 @@ struct ObjectInfos { }; BLI_STATIC_ASSERT_ALIGN(ViewInfos, 16) +struct VolumeInfos { + /* Object to grid-space. */ + float4x4 grids_xform[DRW_GRID_PER_VOLUME_MAX]; + /* NOTE: vec4 for alignement. Only float3 needed. */ + float4 color_mul; + float density_scale; + float temperature_mul; + float temperature_bias; + float _pad; +}; +BLI_STATIC_ASSERT_ALIGN(VolumeInfos, 16) + #define OrcoTexCoFactors (drw_infos[resource_id].drw_OrcoTexCoFactors) #define ObjectInfo (drw_infos[resource_id].drw_Infos) #define ObjectColor (drw_infos[resource_id].drw_ObjectColor) |