diff options
author | Brecht Van Lommel <brecht@blender.org> | 2020-09-03 16:26:52 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-09-03 16:49:41 +0300 |
commit | f0c376a52a53db98bd8d8db3c79116f71001fb5c (patch) | |
tree | 6553e87a82f831c3e6f6bbdb527fda8337ab06ac /source/blender/gpu | |
parent | 96439de784801c7ed0072408a5238bb877af828e (diff) |
Fix T80332: principle volume shader not working for world in Eevee
The handling of missing volume grids for the principled volume shader was
incomplete, different inputs need different default values.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_material.h | 10 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_node_graph.c | 13 |
2 files changed, 18 insertions, 5 deletions
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index 680e717e615..12152a937d9 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -128,6 +128,11 @@ typedef enum eGPUMaterialStatus { GPU_MAT_SUCCESS, } eGPUMaterialStatus; +typedef enum eGPUVolumeDefaultValue { + GPU_VOLUME_DEFAULT_0, + GPU_VOLUME_DEFAULT_1, +} eGPUVolumeDefaultValue; + typedef void (*GPUMaterialEvalCallbackFn)(GPUMaterial *mat, int options, const char **vert_code, @@ -148,7 +153,9 @@ 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 *layer); -GPUNodeLink *GPU_volume_grid(GPUMaterial *mat, const char *name); +GPUNodeLink *GPU_volume_grid(GPUMaterial *mat, + const char *name, + eGPUVolumeDefaultValue default_value); GPUNodeLink *GPU_builtin(eGPUBuiltin builtin); bool GPU_link(GPUMaterial *mat, const char *name, ...); @@ -242,6 +249,7 @@ typedef struct 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; diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c index 1b8a5e20240..b48b1d53dee 100644 --- a/source/blender/gpu/intern/gpu_node_graph.c +++ b/source/blender/gpu/intern/gpu_node_graph.c @@ -333,13 +333,15 @@ static GPUMaterialTexture *gpu_node_graph_add_texture(GPUNodeGraph *graph, return tex; } -static GPUMaterialVolumeGrid *gpu_node_graph_add_volume_grid(GPUNodeGraph *graph, const char *name) +static GPUMaterialVolumeGrid *gpu_node_graph_add_volume_grid(GPUNodeGraph *graph, + const char *name, + eGPUVolumeDefaultValue default_value) { /* Find existing volume grid. */ int num_grids = 0; GPUMaterialVolumeGrid *grid = graph->volume_grids.first; for (; grid; grid = grid->next) { - if (STREQ(grid->name, name)) { + if (STREQ(grid->name, name) && grid->default_value == default_value) { break; } num_grids++; @@ -349,6 +351,7 @@ static GPUMaterialVolumeGrid *gpu_node_graph_add_volume_grid(GPUNodeGraph *graph if (grid == NULL) { grid = MEM_callocN(sizeof(*grid), __func__); grid->name = BLI_strdup(name); + grid->default_value = default_value; BLI_snprintf(grid->sampler_name, sizeof(grid->sampler_name), "vsamp%d", num_grids); BLI_snprintf(grid->transform_name, sizeof(grid->transform_name), "vtfm%d", num_grids); BLI_addtail(&graph->volume_grids, grid); @@ -442,14 +445,16 @@ GPUNodeLink *GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *ro return link; } -GPUNodeLink *GPU_volume_grid(GPUMaterial *mat, const char *name) +GPUNodeLink *GPU_volume_grid(GPUMaterial *mat, + const char *name, + eGPUVolumeDefaultValue default_value) { /* NOTE: this could be optimized by automatically merging duplicate * lookups of the same attribute. */ GPUNodeGraph *graph = gpu_material_node_graph(mat); GPUNodeLink *link = gpu_node_link_create(); link->link_type = GPU_NODE_LINK_VOLUME_GRID; - link->volume_grid = gpu_node_graph_add_volume_grid(graph, name); + link->volume_grid = gpu_node_graph_add_volume_grid(graph, name, default_value); GPUNodeLink *transform_link = gpu_node_link_create(); transform_link->link_type = GPU_NODE_LINK_VOLUME_GRID_TRANSFORM; |