Page MenuHome

Support for UVs generated for Curves, Surfaces and Texts
ClosedPublic

Authored by Germano Cavalcante (mano-wii) on Jan 2 2018, 7:42 PM.

Details

Summary

This patch creates a new type of batch if the Use UV for mapping option in the Object Data tab of Curves, Surfaces and Texts is enabled.

The downside is that to create a vbo with uvs, the current batch with index buffers is not applicable.

Therefore it was necessary to create a batch with a vertex buffer with the coordinates of all the looptris, along with the normal and the uvs of each vertex.

So more memory in the vram has to be used for Displists with UV :\

I do not know if there is a better solution, so here the patch for review.

Diff Detail

Repository
rB Blender

Event Timeline

  • Always add and calculate the UV attribute on format;
  • alloc vbo_len_capacity in the function stack;

Generally it would be good if we could add UV's as additional buffers on-top of existing buffers.
Apart from the extra memory use it ends up adding code duplication to have a copy of conversion functions just to support an extra data layer.

However it seems you've already looked into this?
if it's unavoidable then this patch seems OK.

source/blender/draw/intern/draw_cache_impl_displist.c
206

This function name should probably reference uv & normals in it's name.

213–226

While this is OK, GWN_vertbuf_raw_step gives faster direct access and avoids calculating offsets every time.

Think it's worth using in situations like this.

  • renamed displist_vertbuf_tri_add to displist_vertbuf_attr_set_tri_pos_normals_and_uv;
  • replaced unsigned int *vbo_len_used by Gwn_VertBufRaw *pos_step, *nor_step, *uv_step;

(...)
Apart from the extra memory use it ends up adding code duplication to have a copy of conversion functions just to support an extra data layer.
However it seems you've already looked into this?
(...)

Actually the new DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material function has lines very similar to the displist_indexbufbuilder_set function :\
But I don't know how to avoid this duplication because the vertexes of the DL_SURF displists are added in a very different order than the one made with indexbuffer.

Germano Cavalcante (mano-wii) marked 2 inline comments as done.Jan 9 2018, 5:43 PM
  • remove redundant flag test;
source/blender/draw/intern/draw_cache_impl_displist.c
297

Should be int, corrected in final commit.

This revision is now accepted and ready to land.Jan 10 2018, 12:05 AM