It is currently Sat Aug 22, 2020 3:37 am


All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: [0.2.1/0.3.1] MarchingCubes + NO vertex marging
PostPosted: Wed Mar 09, 2016 5:11 pm 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
Hi, David & All,

Unity 4.6 is coming with Texture Arrays support which exactly means that I am one more step closer to proper multi-texture terrain rendering in single pass.

However, in order to support undefined number of splatting textures, I need to overuse one single fact: A Triengle have 3 vertices. Single triangle needs only 3 textures to blend together.

This means that 0.3.1's getVertices/getIndices cannot suffice any longer. The only way to render it now is a triangle list. I need to generate VBO with Triangle-list semantics. For each triangle in this list, for each vertex I must set the proper texture IDs in order to do a Array texture lookup using them and blend them, for each triangle.

Is this possible? Or it already works like this? :D
I am using unpatched PolyVox 0.3.1 now
[the only patched thing is the MeshDecimator in order Bullet to be not a overhead on the server anymore]


Top
Offline Profile  
Reply with quote  
 Post subject: Re: [0.2.1/0.3.1] MarchingCubes + NO vertex marging
PostPosted: Thu Mar 10, 2016 11:18 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I'm slightly hazy on the terminology, but I believe PolyVox generates an indexed triangle list. That is, each triangle is defined by three indices, but another triangle may reuse some of these indices if the two triangles share some vertices. In general, no assumptions are made about the connectivity between the triangles (it is not a triangle strip).

The vertex list may have any length but the index list is always a multiple of three. Is this what you want anyway, or are you looking to get rid of indices completely?

At any rate, if you want a different format you will have to convert it. Getting rid of indices would not be difficult, but if you wanted something like a triangle strip then that would be more complicated.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: [0.2.1/0.3.1] MarchingCubes + NO vertex marging
PostPosted: Fri Mar 11, 2016 11:30 am 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
If the index buffer is indeed a triangle-list, then I can iterate over all of these triangles and generate 1D int8 texture with Texture Array indexes, and a new Vertex Buffer with Triangle List semantics, deoptimized, however, this is post-processing step, which I want to avoid.

Probably, I should attempt to find how Marching Cubes Extractor generates a triangle and make this one intentionally generate non-optimized VBO.

Doing a VTF with optimized VBO, IBO and a VTF 1D Texture for my huge task is impossible, because: Quote: if you're referencing a vertex 10 times with an index buffer, the corresponding vertex shader is still only executed one time.

The splatting algorithm needs to do (three texture fetches * number of texture maps) per fragment. Their indexes will be injected to the fragment shader in single integer vec3 by the vertex shader. We will also have per-vertex alphas passed to the vertex shader, interpolated for each pixel:

vec3 splattingIds = {0,3,2} // Same for all vertixes in the triangle
vec3 splattingAlphas = {0,0.7,0.3} // Alphas - different for each vertex in the triangle.

Then, I sample the Array Texture three times - tex[splattingIds[0]], tex[splattingIds[1]], tex[splattingIds[2]]; I will also sample the other maps - normal, spec, height...

Then I calculate how to blend them based on the alphas and eventually, their heightmaps, so we can get heightmap-based blending, and output the pixel value.
https://www.garagegames.com/community/f ... ead/134634

Sharing this algo with you, because this topic of research is very long one and you know that I will play until I achieve it :) And, because this algorithm must use rav Triangle list, unoptimized VBO, each vertex processed must have per-triangle different data, so vertex position duplications are a must, and well... :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: [0.2.1/0.3.1] MarchingCubes + NO vertex marging
PostPosted: Sat Mar 12, 2016 8:48 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
petersvp wrote:
If the index buffer is indeed a triangle-list, then I can iterate over all of these triangles and generate 1D int8 texture with Texture Array indexes, and a new Vertex Buffer with Triangle List semantics, deoptimized, however, this is post-processing step, which I want to avoid.


So just to be clear, you want to get rid of the index list and simply have a a list of vertices where each group of three represent a triangle? It should indeed to quite easy to do this as a post-processing step, and I'd recommend you do this first to make sure the technique works for you.

petersvp wrote:
Probably, I should attempt to find how Marching Cubes Extractor generates a triangle and make this one intentionally generate non-optimized VBO.


My gut feeling is that this will be quite straight-forward and will also give shorter code, as quite some effort is put into spotting duplicate vertices to reuse them. But we'll look at that when you come to it.

petersvp wrote:
Then I calculate how to blend them based on the alphas and eventually, their heightmaps, so we can get heightmap-based blending, and output the pixel value.
https://www.garagegames.com/community/f ... ead/134634


Heightmap-based blending is cool - I always wanted to try implementing that :-)


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net