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/gpu/GPU_material.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/gpu/GPU_material.h')
-rw-r--r-- | source/blender/gpu/GPU_material.h | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index f38b9681ad7..55fbe3f981f 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -109,10 +109,10 @@ typedef enum eGPUMaterialStatus { GPU_MAT_SUCCESS, } eGPUMaterialStatus; -typedef enum eGPUVolumeDefaultValue { - GPU_VOLUME_DEFAULT_0, - GPU_VOLUME_DEFAULT_1, -} eGPUVolumeDefaultValue; +typedef enum eGPUDefaultValue { + GPU_DEFAULT_0 = 0, + GPU_DEFAULT_1, +} eGPUDefaultValue; typedef struct GPUCodegenOutput { char *attr_load; @@ -131,6 +131,10 @@ typedef void (*GPUCodegenCallbackFn)(void *thunk, GPUMaterial *mat, GPUCodegenOu GPUNodeLink *GPU_constant(const float *num); GPUNodeLink *GPU_uniform(const float *num); GPUNodeLink *GPU_attribute(GPUMaterial *mat, CustomDataType type, const char *name); +GPUNodeLink *GPU_attribute_with_default(GPUMaterial *mat, + CustomDataType type, + const char *name, + eGPUDefaultValue default_value); GPUNodeLink *GPU_uniform_attribute(GPUMaterial *mat, const char *name, bool use_dupli); GPUNodeLink *GPU_image(GPUMaterial *mat, struct Image *ima, @@ -142,9 +146,7 @@ GPUNodeLink *GPU_image_tiled(GPUMaterial *mat, eGPUSamplerState sampler_state); GPUNodeLink *GPU_image_tiled_mapping(GPUMaterial *mat, struct Image *ima, struct ImageUser *iuser); GPUNodeLink *GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *row); -GPUNodeLink *GPU_volume_grid(GPUMaterial *mat, - const char *name, - eGPUVolumeDefaultValue default_value); + /** * Create an implementation defined differential calculation of a float function. * The given function should return a float. @@ -255,9 +257,11 @@ void GPU_pass_cache_free(void); typedef struct GPUMaterialAttribute { struct GPUMaterialAttribute *next, *prev; - int type; /* CustomDataType */ - char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ + int type; /* CustomDataType */ + char name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ + char input_name[12 + 1]; /* GPU_MAX_SAFE_ATTR_NAME + 1 */ eGPUType gputype; + eGPUDefaultValue default_value; /* Only for volumes attributes. */ int id; int users; } GPUMaterialAttribute; @@ -274,18 +278,8 @@ typedef struct GPUMaterialTexture { int sampler_state; /* eGPUSamplerState */ } GPUMaterialTexture; -typedef struct GPUMaterialVolumeGrid { - struct GPUMaterialVolumeGrid *next, *prev; - char *name; - eGPUVolumeDefaultValue default_value; - char sampler_name[32]; /* Name of sampler in GLSL. */ - char transform_name[32]; /* Name of 4x4 matrix in GLSL. */ - int users; -} GPUMaterialVolumeGrid; - ListBase GPU_material_attributes(GPUMaterial *material); ListBase GPU_material_textures(GPUMaterial *material); -ListBase GPU_material_volume_grids(GPUMaterial *material); typedef struct GPUUniformAttr { struct GPUUniformAttr *next, *prev; |