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


All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: current best method of material blending?
PostPosted: Sat Jan 07, 2017 11:49 pm 

Joined: Wed Nov 23, 2016 3:46 pm
Posts: 4
hi again, happy new year for everyone, and im sorry if it is asked already but couldnt find it.

I have some questions not directly related to polyvox, and some somewhat related to Cubiquity, and some technical, but i pack them together here.

0.Im using polyvox with unreal latest version and decided this over Cubiquity because it is not supported in current versions of unreal and i seen poly more customisable, correct me if im wrong in this matter.

1.question I generate a mesh with marching cubes and I want to use many materials on it so i need blending, so there is the approach in gems, to make a black duplicate blended parts, then duplicate again num of meeting materials times and additively shade others on it with alpha, my first question is is this the best method still, or u advise to use other?

2. so with the gems algorythm I need to duplicate some vertices, by doing so i have to index them because they will reocurr at least 1 more time, and im doing it in post processing the data isnt that a huge overhead? also im lazy and haven't made a vertex factory yet so im using texture uvs as material and alpha on verts :)

3. any good way to calculate proper tangent vectors, because of no texture coords to calc from?

4. i downloaded the Cubiquity for unreal and i know it doesn't work for new versions, do you know about anyone who tryed to make it working, or how hard it would be to make it work with newer ones?

5. does Cubiquity use polyvox? I downloaded it form github, but it does not contain generating algs as i seen or mby havent looked at it well enough.

6. what blending method cub uses? as i seen u mentioned it uses something different in some post while i was searching the forums.

thanks in advance


Top
Offline Profile  
Reply with quote  
 Post subject: Re: current best method of material blending?
PostPosted: Tue Jan 10, 2017 11:19 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
fanari wrote:
0.Im using polyvox with unreal latest version and decided this over Cubiquity because it is not supported in current versions of unreal and i seen poly more customisable, correct me if im wrong in this matter.


That's fine, the current version of Cubiquity is indeed not under further development but work has been started on Cubiquity 2. When this is working I think the Unreal integration will come back (though probably in a somewhat different form). PolyVox is a sensible choice for now (though be aware that development has also stopped).

fanari wrote:
1.question I generate a mesh with marching cubes and I want to use many materials on it so i need blending, so there is the approach in gems, to make a black duplicate blended parts, then duplicate again num of meeting materials times and additively shade others on it with alpha, my first question is is this the best method still, or u advise to use other?


It's certainly a viable approach, though I don't know if it is still (or even was) the best. It's just what I came up with, but eight years ago I had less experience with 3D graphics so don't be afraid to try and improve it. It's a reasonable starting point anyway. It's also largely independent of PolyVox, as it is done a a post-processing step.

fanari wrote:
2. so with the gems algorythm I need to duplicate some vertices, by doing so i have to index them because they will reocurr at least 1 more time, and im doing it in post processing the data isnt that a huge overhead? also im lazy and haven't made a vertex factory yet so im using texture uvs as material and alpha on verts :)?


I'm afraid I don't have a clear idea of the memory/performance overhead. Most voxels won't need blending though.

fanari wrote:
3. any good way to calculate proper tangent vectors, because of no texture coords to calc from?


By 'proper' approach I assume you mean not just triplanar texturing? I've always been interested in Morten Mikkelsen's work (https://mmikkelsen3d.blogspot.co.uk/) such as this paper, though I've never looked into it properly

fanari wrote:
4. i downloaded the Cubiquity for unreal and i know it doesn't work for new versions, do you know about anyone who tryed to make it working, or how hard it would be to make it work with newer ones?


I didn't develop the Unreal bindings myself (my brother Matt did) so I don't have much insight here. I think he is not working further on the binding because I am not working further on Cubiquity. That may change with Cubiquity 2, but it's still in early development.

fanari wrote:
5. does Cubiquity use polyvox? I downloaded it form github, but it does not contain generating algs as i seen or mby havent looked at it well enough.


Cubiquity does, but Cubiquity 2 will not. For Cubiquity it is included as a dependency: https://bitbucket.org/volumesoffun/cubi ... ?at=master

fanari wrote:
6. what blending method cub uses? as i seen u mentioned it uses something different in some post while i was searching the forums.


You can start by reading about it here: http://www.cubiquity.net/cubiquity-for- ... l_set.html

It's pretty powerful and allows arbitrary blending (see this video), but is also too complicated to use. I even get confused myself when trying to generate terrains. Still, it's good to consider some different options.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: current best method of material blending?
PostPosted: Tue Jan 17, 2017 8:08 pm 

Joined: Wed Nov 23, 2016 3:46 pm
Posts: 4
thanks.

I chose the method whats in the gpu gems and,I made an attempt for rendering it in unreal, there is a shadow problem with the blending translucently shaded parts it trying to solve it it seems there is no built in solution for that and i think it will be quite hard, btw the post processing is not too bad on performance. here are the results :
Image
Image

i dont really get how you blend with cub from the page u linked :D


Top
Offline Profile  
Reply with quote  
 Post subject: Re: current best method of material blending?
PostPosted: Sat Jan 21, 2017 9:30 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I'm glad you got it working, though I can't really help with your shadow problem. Probably you get better answers for that on the Unreal forum.

fanari wrote:
i dont really get how you blend with cub from the page u linked :D


Indeed, it's complicated. Instead of each voxel having a single material value I instead store multiple materials per voxel, so that a voxel can be e.g. 75% material 1 and 25% material 2. Then in the shader I sample a lot (all?) of textures and blend them together.

It was complicated to implement, used more memory, and was difficult to understand which is why I don't really recommend it, but it did give some nice results.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: current best method of material blending?
PostPosted: Tue May 30, 2017 1:28 pm 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
This IS probably my most copy-pasted answer around the entire forum but there is what I'm doing in Crafterria, and TileVox:

PASTE:

You probably know that usually you can mix up to 4 materials per vertex in single pass.
Most old school terrain shaders then support 4 materials per pass with RGBA maps.

What if we can, however, have different set of materials per triangle?
This is what I am doing in my projects. 4 Materials per triangle.

Each triangle need to have its own ID. The ID must be same for all vertices by the triangle.
This ID is used to lookup actual Material Indices from a lookup texture that is using integer format, OR from vertex attributes (e.g. one UV channel with Material IDs, same for the triangle, and one with their splat percentage). I'm diong this in Unity by using Vertex Texture Fetch with vertex attributes in the texture to overcome Unity's limitations, but the example below will explain it with vertex attributes.

Triangle 1:
v1: pos, normal, tangent, color(blend factors RGBA), whatnot, uv2(1,2,5,6)
v2: pos, normal, tangent, color(blend factors RGBA), whatnot, uv2(1,2,5,6)
v3: pos, normal, tangent, color(blend factors RGBA), whatnot, uv2(1,2,5,6)

In this example, uv2 contains the material IDs to use for this single triangle.

Then, in the pixel shader, I'm doing the usual texture splatting and triplanar texturing,
just be sure the IDs are NOT interpolated.

the drawback is, that you must generate true, deoptimized triangle list, because a vertex in triangle 1 CAN and will most likely DO have different IDs that Triangle 2.

For best looking results like these in the Showcase/Crafterria thread, you should use Texture Array (sometimes they call them Array Samplers) - You load all your texture into a texture array with mipmaps, an you are ready to go - use Material IDs directly as Array Sample indices.
Just don't mistake a Texture Array with 3D Texture - with Texture Arrays you get correct mipmaps, they are basically wad of images but with third dimension to access the specific image, and they used to e not that popular at the time I manually had to issue a feature request to get them supported in Unity.

Of course such algorithm requires some preparations, and you will need to calculate your splatting ids on the CPU. And in case more than 5 materials want to contribute to single vertex.... Ignore the least contributor completely and use just the top 4 ranked contributing materials. Trilinear interpolation code is needed for this.

This algorithm also supports multiple material weights per voxel, e.g. you can have semi-grass-semi-dirt voxel, amd if you imlement Heightmap based blending, this will indeed look very, very cool.

This screenshot shows the idea. Notice that most of triangles have contributions set to (1,0,0,0) and only the Red channel contribution is used, however, the per-triangle-id table points to different texture id, the Red Channel texture is different.

In places where blending is needed, Red, Green and even Blue and Alpha channels are used to implement the splatting as and if needed.

This way you get the whole thing rendered in single pass, but it is quite expensive.

Image


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

All times are UTC


Who is online

Users browsing this forum: No registered users 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