From f0c376a52a53db98bd8d8db3c79116f71001fb5c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 Sep 2020 15:26:52 +0200 Subject: 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. --- source/blender/gpu/intern/gpu_node_graph.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source/blender/gpu/intern') 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; -- cgit v1.2.3