Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-03-28 18:36:45 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-03-29 00:08:54 +0300
commitec0eeb918baca89dece33a6d95c7b8c913507a80 (patch)
treef961ea9baacf552d31c1c4bb56a26d22645b616e /source/blender/gpu
parent1ef59026e4a20919cd6822d0b789eed09f25e42b (diff)
DRW/Eevee: Add correct support for Orco
Until now, Orcos were computed by the gpu (GLSL) and were not taking into account the modifier stack (breaking orco for deformed mesh). Now Orco is now computed on CPU but only if a modifier stack is present. Tagging that an ORCO layer is present is done via a 4th component, which is a waste of memory/bandwidth. Best would be to do the same as auto attrib color space and save a bool uniform somewhere but for now it's too disruptive.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_batch.h2
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c8
2 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index 95eb59a57ae..3d013eb8af4 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -39,7 +39,7 @@ typedef enum {
GPU_BATCH_READY_TO_DRAW
} GPUBatchPhase;
-#define GPU_BATCH_VBO_MAX_LEN 3
+#define GPU_BATCH_VBO_MAX_LEN 4
#define GPU_BATCH_VAO_STATIC_LEN 3
#define GPU_BATCH_VAO_DYN_ALLOC_COUNT 16
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index cf770599fc7..b1d94d22f35 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -872,8 +872,9 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
/* XXX FIXME : see notes in mesh_render_data_create() */
/* NOTE : Replicate changes to mesh_render_data_create() in draw_cache_impl_mesh.c */
if (input->attr_type == CD_ORCO) {
- /* orco is computed from local positions, see below */
+ /* OPTI : orco is computed from local positions, but only if no modifier is present. */
BLI_dynstr_append(ds, "uniform vec3 OrcoTexCoFactors[2];\n");
+ BLI_dynstr_append(ds, "DEFINE_ATTR(vec4, orco);\n");
}
else if (input->attr_name[0] == '\0') {
BLI_dynstr_appendf(ds, "DEFINE_ATTR(%s, %s);\n", GPU_DATATYPE_STR[input->type], attr_prefix_get(input->attr_type));
@@ -976,6 +977,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
BLI_dynstr_appendf(
ds, "\tvar%d%s = OrcoTexCoFactors[0] + (ModelMatrixInverse * vec4(hair_get_strand_pos(), 1.0)).xyz * OrcoTexCoFactors[1];\n",
input->attr_id, use_geom ? "g" : "");
+ /* TODO: fix ORCO with modifiers. */
}
else {
BLI_dynstr_appendf(
@@ -1018,6 +1020,10 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
BLI_dynstr_appendf(
ds, "\tvar%d%s = OrcoTexCoFactors[0] + position * OrcoTexCoFactors[1];\n",
input->attr_id, use_geom ? "g" : "");
+ /* See mesh_create_loop_orco() for explanation. */
+ BLI_dynstr_appendf(
+ ds, "\tif (orco.w == 0.0) { var%d%s = orco.xyz * 0.5 + 0.5; }\n",
+ input->attr_id, use_geom ? "g" : "");
}
else if (input->attr_type == CD_MCOL) {
BLI_dynstr_appendf(