EEVEE: Hair: Fix wrong color when using color attribute without actual data
This commit is contained in:
parent
72461c09b4
commit
27e0998a8a
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "GPU_batch.h"
|
||||
#include "GPU_shader.h"
|
||||
#include "GPU_vertex_buffer.h"
|
||||
|
||||
#include "draw_hair_private.h"
|
||||
|
||||
|
@ -62,6 +63,8 @@ static int g_tf_target_width;
|
|||
static int g_tf_target_height;
|
||||
#endif
|
||||
|
||||
static GPUVertBuf *g_dummy_vbo = NULL;
|
||||
static GPUTexture *g_dummy_texture = NULL;
|
||||
static GPUShader *g_refine_shaders[PART_REFINE_MAX_SHADER] = {NULL};
|
||||
static DRWPass *g_tf_pass; /* XXX can be a problem with multiple DRWManager in the future */
|
||||
|
||||
|
@ -102,6 +105,22 @@ void DRW_hair_init(void)
|
|||
#else
|
||||
g_tf_pass = DRW_pass_create("Update Hair Pass", DRW_STATE_WRITE_COLOR);
|
||||
#endif
|
||||
|
||||
if (g_dummy_vbo == NULL) {
|
||||
/* initialize vertex format */
|
||||
GPUVertFormat format = {0};
|
||||
uint dummy_id = GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
||||
|
||||
g_dummy_vbo = GPU_vertbuf_create_with_format(&format);
|
||||
|
||||
float vert[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
GPU_vertbuf_data_alloc(g_dummy_vbo, 1);
|
||||
GPU_vertbuf_attr_fill(g_dummy_vbo, dummy_id, vert);
|
||||
/* Create vbo immediately to bind to texture buffer. */
|
||||
GPU_vertbuf_use(g_dummy_vbo);
|
||||
|
||||
g_dummy_texture = GPU_texture_create_from_vertbuf(g_dummy_vbo);
|
||||
}
|
||||
}
|
||||
|
||||
static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(Object *object,
|
||||
|
@ -158,12 +177,12 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(Object *object,
|
|||
/* Fix issue with certain driver not drawing anything if there is no texture bound to
|
||||
* "ac", "au", "u" or "c". */
|
||||
if (hair_cache->num_uv_layers == 0) {
|
||||
DRW_shgroup_uniform_texture(shgrp, "u", hair_cache->final[subdiv].proc_tex);
|
||||
DRW_shgroup_uniform_texture(shgrp, "au", hair_cache->final[subdiv].proc_tex);
|
||||
DRW_shgroup_uniform_texture(shgrp, "u", g_dummy_texture);
|
||||
DRW_shgroup_uniform_texture(shgrp, "au", g_dummy_texture);
|
||||
}
|
||||
if (hair_cache->num_col_layers == 0) {
|
||||
DRW_shgroup_uniform_texture(shgrp, "c", hair_cache->final[subdiv].proc_tex);
|
||||
DRW_shgroup_uniform_texture(shgrp, "ac", hair_cache->final[subdiv].proc_tex);
|
||||
DRW_shgroup_uniform_texture(shgrp, "c", g_dummy_texture);
|
||||
DRW_shgroup_uniform_texture(shgrp, "ac", g_dummy_texture);
|
||||
}
|
||||
|
||||
if ((dupli_parent != NULL) && (dupli_object != NULL)) {
|
||||
|
@ -336,4 +355,7 @@ void DRW_hair_free(void)
|
|||
for (int i = 0; i < PART_REFINE_MAX_SHADER; i++) {
|
||||
DRW_SHADER_FREE_SAFE(g_refine_shaders[i]);
|
||||
}
|
||||
|
||||
GPU_VERTBUF_DISCARD_SAFE(g_dummy_vbo);
|
||||
DRW_TEXTURE_FREE_SAFE(g_dummy_texture);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue