Discussion : forum
Would it be possible to create a terrain material that could mix 6 to 8 textures as does the terrainMateriel extension but currently with 3 textures. For example by adding in addition RGB colors, black, white, yellow, pink and cyan.
It could receive shadows, fog, and lights (like standardMateriel).
Usefulness of this material :
This would be a perfect material to create terrain that can accommodate many textures such as earth, cobblestone paths, sand, grass, rocks and snow on the mountain top. (6 textures being the minimum, with 8 we can create several kinds of paved path textures or several types of grass)
It could be named as : advancedTerrainMateriel()
It would work with a mixMap like this :
MixMap
As on this extension :
Extension terrainMaterial
Thank you very much, a lot
Really cool!
Do we need a new class « AdvancedTerrainMaterial » or just improve the current terrain material ?
I thought you might want to keep your terrainMateriel as it was designed. But yes it can just be improved the current one that you had done Julien.
I think @julien-moreau could update the TerrainMaterial to allow one mode with 3 textures (by default) and one mode with 6(with two mix maps then)
Why 2 mixMap? This could complicate things for users. For example I use a textureDynamic to create the mixMap, I do not know how I would paint on 2 textureDynamic.
6 textures would be easier to use with a single mixMap.
Do you think it's feasible?
I don't see how. Texture has 3 channels (max 4). So how could we map 6 textures on 4 channels?
I am really new to all this. I'm just wondering how I could paint on 2 textureDynamic for the 2 mixMap.
I guess it's because of the color mixing history of 4 channels (RGBA)
I hope I can find solutions later to paint on 2 dynamicTextures if it can only be done like this.
How do you specify the weight of each map on your current CustomMaterial?
just uniform on indexes for Nasimi's ShaderBuilder and the colors black, red, green, blue, yellow, cyan, pink and white
new BABYLONX.ShaderBuilder().Map({alpha: true, index: 'dyTexture', bias:0.}).Reference(1)
.Black(1, BABYLONX.Helper().Map({alpha: true, index: 'texture1', uv: 'vec2(vuv*'+String(data.uvScale._8)+'.)'}).Build(), {rangeStep: rangeSt, rangePower: rangePo})
.Red(1, BABYLONX.Helper().Map({alpha: true, index: 'texture2', uv:'vec2(vuv*'+String(data.uvScale._1)+'.)'}).Build(), {rangeStep: rangeSt, rangePower: rangePo})
.Green(1, BABYLONX.Helper().Map({alpha: true, index: 'texture3', uv: 'vec2(vuv*'+String(data.uvScale._2)+'.)'}).Build(), {rangeStep: rangeSt, rangePower: rangePo})
.Blue(1, BABYLONX.Helper().Map({alpha: true, index: 'texture4', uv: 'vec2(vuv*'+String(data.uvScale._3)+'.)'}).Build(), {rangeStep: rangeSt, rangePower: rangePo})
.Yellow(1, BABYLONX.Helper().Map({alpha: true, index: 'texture5', uv: 'vec2(vuv*'+String(data.uvScale._4)+'.)'}).Build(), {rangeStep: rangeSt, rangePower: rangePo})
.Cyan(1, BABYLONX.Helper().Map({alpha: true, index: 'texture6', uv: 'vec2(vuv*'+String(data.uvScale._5)+'.)'}).Build(), {rangeStep: rangeSt, rangePower: rangePo})
.Pink(1, BABYLONX.Helper().Map({alpha: true, index: 'texture7', uv: 'vec2(vuv*'+String(data.uvScale._6)+'.)'}).Build(), {rangeStep: rangeSt, rangePower: rangePo})
.White(1, BABYLONX.Helper().Map({alpha: true, index: 'texture8', uv: 'vec2(vuv*'+String(data.uvScale._7)+'.)'}).Build(), {rangeStep: rangeSt, rangePower: rangePo})
More detail on this PG :
http://www.babylonjs-playground.com/#ICIAGK%2324
However I confess that for the mixture of colors to have fades on the joins of textures it is not really top
So here is my proposal: two mix maps and 8 channels:
texture0 to R channel of mixmap 0
texture1 to G channel of mixmap 0
texture2 to B channel of mixmap 0
texture3 to A channel of mixmap 0
texture4 to R channel of mixmap 1
texture5 to G channel of mixmap 1
texture6 to B channel of mixmap 1
texture7 to A channel of mixmap 1
You can easily paint on each mip maps with dynamicTexture (literally 3 lines of code)
Perhaps we call it MixMaterial. Thoughts? @julien-moreau
Yes it seems good to me like that. (roughly according to the textures that I select (0 to 3 and 4 to 7) to paint I activate mixMap 1 or mixMap 2 is that it?
Correct
:+1:
Agree !! Beginning the material :)
Cool, Thanks Julien. I am sure you will do a great field material with great use.
I hope that the update of this material does not cause you too much problem Julien.
Absolutely not, just looking for a moment to focus on. That would appear tomorrow :)
Ok, where will it appear ? I can not wait to test. :)
An idea of when will the material be available? I did not see it appear as you said for the next day or I misunderstood.
Hey I just finished with up to 8 textures. My problem is regarding normal mapping. I have to perturb normals but I'm not sure the way I have to do that:
Any idea ? :)
@deltakosh to the rescue: lighting calculation is done according to the "normalW" vector. Do you have an idea ? Maybe the mix material should not compute normal mapping to the its first version
For me the normal mapping should remain unchanged. Only diffuse should come from the textures
Then the designer will create 8 diffuse textures and only one normal map which is a mix between the 8 textures ?
If yes, I need a designer for the demo of this material ^^
I get your point..Perhaps first release does not support bump :)
Because else it will require 16 textures channels :)
I did not think about the Bump textures. Personally, I never use them on a terrain. She adds indeed an extra luxury, but is not of great necessity I think.
In any case, thank you Julien for the news of this material.
Hey Julien, you said you finished the first version (without the bump) but I did not see it published. Have I missed his publication? Thank you
No no it hasn’t been published, I’m polishing the code. I’ll let you know once done
Ah, ok, do you have an approximate date of its release? I have many projects that I must review using this new material because CustomMateriel is extremely buggy and all my projects are broken for several months. Thank you Julien.
Just created the PR here: https://github.com/BabylonJS/Babylon.js/pull/4331
I'm about to polish some functions and add the doc
Would be cool if you can test it and give me feedbacks :)
No problem, I'll add this to my terrain editor and I'll tell you what he has on the forum.
Cool thanks! :)
I have a small question for the colors. There are 8 textures. 4 for each mixMap. So red, green and blue. but what about color 4? (I see transparent but it's not a color. - Gray or black?)
Thank you for the info and this material.
I would probably be testing tomorrow.
It's good, I look at the mixMap_2.png and I saw the color black which is the color 4.
I will do a complete test before you make a report with what works and if I encounter any problems tomorrow or as soon as it will be available .
@julien-moreau will just create a doc and we can close this issue :)
There is still some bugs on the material or options can be added before doing the doc I guess.
@dad72 can you let me know if everything is fine for you ? :)
It seems that everything goes well with the material. For the moment I do not encounter any problem anymore. Apart from serializing the terrain, but that's another question that does not depend on the material I think.
Thank you Julien
Most helpful comment
Agree !! Beginning the material :)