Author Topic: Height Based Texture Blending  (Read 29242 times)

2016-04-25, 20:30:46

JJG

  • Active Users
  • **
  • Posts: 20
    • View Profile
Hey,
I was wondering if it is possible to blend multiple materials together inside of 3ds Max using Vertex Color and something similar to THIS?

I have to admit I haven't checked indepth yet if something like this is possible using corona. But maybe someone here has already tried or done this before?

2016-04-25, 20:52:15
Reply #1

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8872
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Nothing you couldn't do with composite map, IMHO.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2016-04-25, 20:55:59
Reply #2

JJG

  • Active Users
  • **
  • Posts: 20
    • View Profile
Well, I couldn't really find anything about this online. And granted I haven't tried for very long yet but I couldn't make something that comes even close to the blending there.
Because all I am doing is changing the Vertex Color which is as far as I know just the texture coordinates for the blending ( I have no idea if I have this right ) instead of changing the way the material blend node actually blends.

2016-04-25, 22:32:58
Reply #3

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8872
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Well, if you have two textures with carefully prepared height maps, then it shouldn't be hard to blend those textures and use height maps as masks for conditional blending. Why you should need vertex colours for that, i don't know. But maybe i didn't understand that article fully - didn't read it carefully.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2016-04-26, 01:03:47
Reply #4

Juraj

  • Active Users
  • **
  • Posts: 4765
    • View Profile
    • studio website
Each of you got part of it correctly :- )

There are two blendings happening here:

1) Vertex color mask (easy to paint and use in real-time) to paint areas where blending between two materials happen, and where not (only base material shows).
2) Height-map mask to blend between two materials. You need at least one height map (the one with more depth ideally of course) for that. The better this heigh-map is, the more convincing is the result, so it's either sculpt based or scan-based. Alternatively, you can derive one from diffuse texture using Quixel NDO/Bitmat2Material/Skald/etc... but if won't be as convincing because it's only guessing the depth.

This is done using standard 3dsMax nodes as Romullus said.

With that said, this technique makes most sense in real-time, because the surface will be rendered only using parallax techniques. In Corona, you can just use displacement of two different surfaces and the effect will happen naturally (instead of vertex painting you can z-height paint directly using polygon brush).
« Last Edit: 2016-04-26, 01:07:10 by Juraj_Talcik »
Please follow my new Instagram for latest projects, tips&tricks, short video tutorials and free models
Behance  Probably best updated portfolio of my work
lysfaere.com Please check the new stuff!

2016-04-26, 09:51:10
Reply #5

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8872
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Vertex colours are good when you have relatively dense mesh to paint on or when there's a need to have maximum interactive feedback. In other cases i would stick with texmaps.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2016-04-26, 12:25:09
Reply #6

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12783
  • Marcin
    • View Profile
Answer: yes, it is possible with Corona. :)
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2016-04-26, 23:03:21
Reply #7

JJG

  • Active Users
  • **
  • Posts: 20
    • View Profile
I should have cleared up why I am asking and what I am trying to achieve in the first place.

I am using World Machine to create large scale terrains.
Now with a little bit of setting up, World Machine can provide masks that are then planar mapped onto the terrain mesh that define where a material is supposed to be displayed.
Simplest example would be a slope mask that defines where the cliff material is supposed to go and where grass is supposed to go.
Usually I would end up with around 5 of those masks for 5 different materials.

Up unto this point the whole thing is procedural and works A+ for backrounds especially.
But often times I would like to have a bit more fine control for areas closer to the camera on where the different materials go, so I would use Vertex Paint for that.

I haven't actually checked how to do this inside of 3ds max natively yet. Not sure if you can drag and drop a bitmap into a vertex paint slot to use as a base to later paint over manually.
( Usually I am using game engines like UE4 for this kinda stuff )

And in the end I would like to blend all those materials together using the height based blending approach.
The textures are Photoscanned textures provided by a guy named Christoph Schindelar. And the heightmaps are pretty much top of the line.
I'm real sorry that I haven't provided any actual examples yet ( I kinda don't have too much time lately ) but I will try to post an actual example tomorrow perhabs.

2016-04-26, 23:14:33
Reply #8

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8872
  • Let's move this topic, shall we?
    • View Profile
    • My Models
As for texture to vertex colours, you can bake that info with vertexpaint modifier. You just have to use scanline renderer for that.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2016-04-26, 23:23:26
Reply #9

JJG

  • Active Users
  • **
  • Posts: 20
    • View Profile
As for texture to vertex colours, you can bake that info with vertexpaint modifier. You just have to use scanline renderer for that.
Sounds good to me, I will give all of that a try tomorrow when I am come home from work, and post the results here.

2016-04-27, 12:12:34
Reply #10

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12783
  • Marcin
    • View Profile
I think for what you have described vertex paint modifier + vertex color map will be the base. Then you can experiment with setting different map channels for the vertex paint, baking (as Romullus suggested), mixing vertex map with procedurals to create masks, etc...
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2016-04-27, 19:33:49
Reply #11

JJG

  • Active Users
  • **
  • Posts: 20
    • View Profile
Just started looking at it again. And right off the bat I think something seems "fucky".


Sand Material


Forest Ground Material


Both of them blended together using "Corona Layer Mtl" and a "Vertex Color" node set to map channel 0, as the mask.
Only the albedo seems to be blended. The height and normal seem to only come from the "Forest Ground Material" though.

So, am I doing something wrong right from the start?
« Last Edit: 2016-04-27, 19:38:39 by JJG »

2016-04-27, 21:00:59
Reply #12

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8872
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Displacement is taken from base material only. That's current limitation of layered material unfortunatelly. Bump map should be picked correctly AFAIK. Try to mix displacement at map level instead of material level. Alternatively you can blend everything in single material.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2016-04-27, 21:15:27
Reply #13

Juraj

  • Active Users
  • **
  • Posts: 4765
    • View Profile
    • studio website
Displacement is taken from base material only. That's current limitation of layered material unfortunatelly. Bump map should be picked correctly AFAIK. Try to mix displacement at map level instead of material level. Alternatively you can blend everything in single material.

You could alternatively just decouple displacement to map level (as you suggest), but place it using Disp modifier onto geometry object.

This would retain benefits of layered material (separate maps, easier tweakable).

But by any of the above solutions, you loose the option to easily adjust height of each displacement separately no ? So it's not such an ultimate solution to current problem.
Please follow my new Instagram for latest projects, tips&tricks, short video tutorials and free models
Behance  Probably best updated portfolio of my work
lysfaere.com Please check the new stuff!

2016-04-27, 21:21:34
Reply #14

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8872
  • Let's move this topic, shall we?
    • View Profile
    • My Models
But by any of the above solutions, you loose the option to easily adjust height of each displacement separately no ? So it's not such an ultimate solution to current problem.

Well, you can use that same vertex colours map as mask for displacement mix. That should work.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2016-04-27, 21:35:19
Reply #15

JJG

  • Active Users
  • **
  • Posts: 20
    • View Profile
But by any of the above solutions, you loose the option to easily adjust height of each displacement separately no ? So it's not such an ultimate solution to current problem.

Well, you can use that same vertex colours map as mask for displacement mix. That should work.
This should easily be possible.
But my head is already starting to spin imagining the node network for a whole bunch of materials blended this way.
I also tried a bunch of different composite maps for all the different materials and I haven't gotten any closer to achieving a similar result to the article I posted at the start of the topic. :|

2016-04-27, 22:12:55
Reply #16

Juraj

  • Active Users
  • **
  • Posts: 4765
    • View Profile
    • studio website
But by any of the above solutions, you loose the option to easily adjust height of each displacement separately no ? So it's not such an ultimate solution to current problem.

Well, you can use that same vertex colours map as mask for displacement mix. That should work.

Well, I know. That's the only way it would work :- ).

But the modifier has only single "height" option (I don't mean relative height of texture map, I mean the physical units inside the modifier, ie. 2 cm). You will have to use this for the material with bigger depth, and adjust the other heightmap.

While keeping displacement map in two different materials, you can keep your texture heightmaps unmodified and adjust each height respectively.
Please follow my new Instagram for latest projects, tips&tricks, short video tutorials and free models
Behance  Probably best updated portfolio of my work
lysfaere.com Please check the new stuff!

2016-04-27, 22:43:49
Reply #17

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8872
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Sorry, i didn't read your post carefully enough for the first time. Yes, you're right, this method isn't flexible enough. Oh well, we have what we have for now. Let's hope layered material will be revisited someday :]

Anyway, recorded short video for OP. Just a proof of concept, nothing more:

I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2016-04-27, 22:57:40
Reply #18

Juraj

  • Active Users
  • **
  • Posts: 4765
    • View Profile
    • studio website
Quote
Let's hope layered material will be revisited someday :]

It could be bit more robust. Game engines now offer blend nodes that don't just lerp between two materials, but can 'stack' them (I think this is what the legacy Autodesk composite material was supposed to do ? But does anyone ever used it).
You could then lerp their diffuse/specular properties, but overlay normals.

This can be easily done through nodal network of course, but the charm of more advanced blend node, is that you can keep untouched presets, and mix them into final materials with very artistic, real-world resembling approach. A "dampness" layer, mixed with paving, would overlay normals, and multiply diffuse properties, lerping specularity, without any nodal network at all. Even a 5year old child could then easily create complex blended materials.

One can hope. Or not, when something like "check-box" caused hysteric reactions.
Please follow my new Instagram for latest projects, tips&tricks, short video tutorials and free models
Behance  Probably best updated portfolio of my work
lysfaere.com Please check the new stuff!

2016-04-27, 23:45:27
Reply #19

JJG

  • Active Users
  • **
  • Posts: 20
    • View Profile
Thanks the video is really nice especially for other people who want to do something similar in the future.

Now we have solved the issue of blending the dislplacements correctly and using Vertex Painting to mask the materials.
I am still not any closer to actually blending the materials properly based on height. Doing it in a DirectX material wouldn't be too hard but I am not sure how that would even work with Corona.
And in all honesty. The offline render displacements look so good that anything gained by heightmap based blending would almost be marginal.

On a different note, concering Juraj_Talcik's post.
The material system inside of 3ds Max is kinda meh in all honesty.
I don't mean Corona or Vray, just in general the native 3ds Max slate editor.
Comparing it to something like the UE4 material editor which is essentially just HLSL code presented as template nodes, 3ds Max's material editor is just meh.
Maybe it's my lack of experience working indepth with the 3ds Max material system but to me it feels simply too obscure to make more difficult things with.

2016-04-28, 00:18:10
Reply #20

JJG

  • Active Users
  • **
  • Posts: 20
    • View Profile
Alright, here are the blended materials.
Unfourtanetly I just realized that the normals are not blended either so I will have to do that tomorrow since it also just uses the Base Materials normal.


2016-04-28, 00:50:36
Reply #21

Juraj

  • Active Users
  • **
  • Posts: 4765
    • View Profile
    • studio website
Quote
I am still not any closer to actually blending the materials properly based on height.

Because you are currently not blending with heightmap as mask, but with vertex map. The vertex map, should be used to 'drive' the heightmap used as mask. You started with the latter, from opposite direction than you should have :- ).

Quote
....just in general the native 3ds Max slate editor.
Comparing it to something like the UE4 material editor....

We know : /


BTW, fantastic tutorial where I saw this method first is by Aaron Kaminer. It's...unsurprisingly UE4 tutorial that goes a little bit deeper but it's cheap and great. The macros should be (albeit awkardly) replicable in 3dsMax, you just won't create final master shader :- )

https://gumroad.com/aaronkaminer

« Last Edit: 2016-04-28, 00:54:11 by Juraj_Talcik »
Please follow my new Instagram for latest projects, tips&tricks, short video tutorials and free models
Behance  Probably best updated portfolio of my work
lysfaere.com Please check the new stuff!

2016-04-28, 09:07:17
Reply #22

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8872
  • Let's move this topic, shall we?
    • View Profile
    • My Models
I really need to try UE4 someday, to see if grass is really THAT greener on the other side :]
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2016-04-28, 11:50:15
Reply #23

Juraj

  • Active Users
  • **
  • Posts: 4765
    • View Profile
    • studio website
I really need to try UE4 someday, to see if grass is really THAT greener on the other side :]

Some day, in 5 years, where GPUs will be all powerful, real-time antialiasing and GI on same level as offline raytracing, it will be game over :- ) But not yet.

But the material system is really well thought out and nice, with hundreds of nodes for anything. And you can use a thousand of them if you want, it will use more drawcalls, but nothing hindering. Unlike archaic 3dsMax, where bunch of composite and color corrections maps together already start taxing the rendering time. Like...huh ?
Please follow my new Instagram for latest projects, tips&tricks, short video tutorials and free models
Behance  Probably best updated portfolio of my work
lysfaere.com Please check the new stuff!

2016-04-28, 17:38:05
Reply #24

JJG

  • Active Users
  • **
  • Posts: 20
    • View Profile
Alright I followed the tutorial that Juraj posted. One question though, is there someway to "Divide" two maps in 3ds Max? Composite map doesnt have that blend option and I don't see any other way of doing that.

2016-04-28, 17:58:58
Reply #25

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8872
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Try CoronaMix, it has divide blend mode.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2016-04-28, 18:03:15
Reply #26

JJG

  • Active Users
  • **
  • Posts: 20
    • View Profile
Try CoronaMix, it has divide blend mode.
Corona to the rescue :D
« Last Edit: 2016-04-28, 18:06:53 by JJG »

2016-04-28, 18:24:47
Reply #27

mferster

  • Active Users
  • **
  • Posts: 523
    • View Profile
Here is an alternative for elevation based blending that gives you a ton of control in changing the blends, and allows any number of layers.

Use the gradient ramp map!  What many people dont know is that if you right click on the colour flags and select properties, you can actually replace the colours with any kind of map.

Here are the steps I made in my example

1. mapped my elevation with planar mapping in one channel,
2. flip the uvw so it's oriented from top to bottom
3. add in your different colour flags in your gradient ramp map to determine your different levels.
4. add in your textures to each flag on a separate mapping channel, add in additional uvw mapping for said map channel
5. move the flags on the fly to make adjustments!

edit: and if you only want hard line transitions just change the interpolation to solid. <!-- you can change the blend curve here too -->

Obviously the downside is that it can be quite cumbersome once you add in additional gradients ramps for other map channels such as bumps, and reflections. but if you work on it incrementally I think it's manageable
« Last Edit: 2016-04-28, 20:11:27 by mferster »

2016-04-28, 19:51:46
Reply #28

JJG

  • Active Users
  • **
  • Posts: 20
    • View Profile
Thanks mferster I will try that at some point aswell.

Here is what I have gotten so far.
I am following the guide Juraj posted by the letter, I wouldn't know where I deviate from him.
The result looks different from the normal linear blending for sure, I am just not sure if it really is correct.






And last but not least an image of my node graph.


I really dont think I am doing this correctly. The water puddle especially just looks a bit wonky to me.

2016-12-13, 20:08:32
Reply #29

Deckel

  • Users
  • *
  • Posts: 1
    • View Profile
Hello there.
I am actually not a Corona or Max user but i think i find a way for this in Maya and vRay.
It schould be possible to do that in other render engines or software pakages where you can render vertex color information.
I also searched for a way for that and the only topic in the whole internet seems to be this topic.
Really strange by the way because this is an really awesome technique.
I made a short video tutorial for that:

t=1s

2019-11-18, 13:48:03
Reply #30

melviso

  • Active Users
  • **
  • Posts: 398
    • View Profile
    • Portfoilo
Is this now possible with Corona? It would also be cool if decals can be projected on meshes as well. This is very easy in ue4. There are a lot of things ue4 does efficiently that would save time, need for huge texture sizes and render time overall.

2019-11-19, 11:55:38
Reply #31

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12783
  • Marcin
    • View Profile
Anything (almost!) you can think of is possible with Corona and Max.

Example:

Video:

Scene:
Max 2020 - https://www.dropbox.com/s/srls5b5e779fvqf/vertex-blend.max?dl=1
Max 2017 - https://www.dropbox.com/s/srls5b5e779fvqf/vertex-blend.max?dl=1

Notes:
This is just a quick suggested workflow. I am sure there are better/easier/faster ways to do it.
You can blend between the materials and displacements separately.
You can show some of the mud in brick gaps.
You can show some of the bricks in the muddy areas.
You will have to use your own diffuse and displacement textures (and possibly other maps) because the ones I used cannot be shared.
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2019-11-19, 16:25:33
Reply #32

melviso

  • Active Users
  • **
  • Posts: 398
    • View Profile
    • Portfoilo
Thanks a lot Maru. I will try this out. If I do find other ways I will post back here :- )

2019-11-19, 23:37:37
Reply #33

melviso

  • Active Users
  • **
  • Posts: 398
    • View Profile
    • Portfoilo
Here is another method using 3dsmax osl shaders:
feature=youtu.be

Thanks to Mads Drøschler :- )

2021-08-28, 08:33:58
Reply #34

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
Chiming in to ask if there has been any significant development on this front?

I don't think it can be reasonably asserted (at this point) that the available solutions for height blending in 3ds Max / Corona Renderer are contemporary with respect to other render engines.

Looking over the provided examples, the solutions that exist for procedural height blending in 3ds Max / Corona Renderer are very complicated, cumbersome, and really echo a much older framework for shading / rendering, but it seems like the major obstacle is actually the implementation of displacement blending across materials in a layered material.

Is there some plugin or set of tools that operate within 3ds Max / Corona Renderer to facilitate layered material blending with displacement? To be sure, vertex paint is not a procedural solution and would not be appropriate for texturing multi-layered materials across a large surface.



P.S. the original post is from 2016!
Some day, in 5 years, where GPUs will be all powerful, real-time antialiasing and GI on same level as offline raytracing, it will be game over :- )
« Last Edit: 2021-08-28, 08:39:49 by cjwidd »

2021-08-29, 07:38:24
Reply #35

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
I have rudimentary version of height-blending working, but adjustment, error-checking, etc. is pretty cumbersome.