Holy hell, yea with a height map it looks a ton better. Cheers.
And it allows for much more variations in the final look, then using a pure black and white mask.
I just to need to figure out how to get a normal map out of this so that the top textures get some normal info around the edges. If that's possible..
Cool stuff Shadows, this was exactly the kind of stuff I knew this type of thing would be good for
Here's a video of my .fx shader in action, I sorted out the vertexcolour trashing tonight, I still need to double-check my maths on the mask method because it's not quite what I think it should be.
Video shows initially starting off with black vertex colour, then painting white where I want the snow. I then change the "global falloff" value from 0.01 in steps up to 1.0 (the shader has a checkbox for using vertex alpha or not), and after that I change it to use the vertex alpha as the falloff (defaults to 1.0, very soft blend), and I paint it down to black in places for a really sharp blend.
Edit: OK, for people wanting to mess around with the shader, here's a beta version. I can't guarantee the maths for the blending is right, but it works visually for the most part.
Hell, I don't even think the maths for the lighting is correct. Try it on a sphere, it looks broken to me
Definitely not perfect yet, but fun to mess around with. I'd be very interested to see screenshots of what people try with it.
Disclaimer: .fx file only tested as a DirectX Shader on 3dsmax 2008, I have no idea about compatibility with other Max versions. I don't think it will run on other software. I take no responsibility for anything bad that should happen from using this shader (although I can't imagine what it could possibly do!).
Awesome mop, the shader seems to be looking fine for me in max.
The blending is a tiny bit different than the results I am getting inside UE with the same mesh, I think it;s handling the vertex color info differently. But really cool to see the results right away.
To get a normal map that will add an edge to the transition, you can do a few things. What i ended up doing was making a network that converts your mask texture into a normal map then blends the other normal maps on top of it. only issue with that is creating the map as a shader function, by offsetting each channel in a diff direction, can be sort of intensive if the source has a high res. But what also worked was after finalizing the mask, just creating a normal map from that using a filter, or CB or whatever, then mixing it the same way. Also forgot to mention using masks like this also works great when using multiple uv sets.
Yea I think offsetting each channel might be to expensive in the shader instructions. So probably going to use an extra texture map. Just wish epic could add support for bump maps instead. I could just use one of the channel from another texture instead and save a texture call. Unless it's already supported and I am just blind?! :S
shading is based on normals, old school "bumpmaps" were simply converted to normal maps, or used "directly" in "emboss bump mapping", which was a different type of shading hack (not suitable for a unified shading pipeline)
I just wanted to pop in here to say thanks to everyone for sharing all the great blending techniques I had been trying to figure out this same problem for some time now. It had never dawned on me to use a height map as part of the blend equation with vertex colors, pure genius thanks again.
shading is based on normals, old school "bumpmaps" were simply converted to normal maps, or used "directly" in "emboss bump mapping", which was a different type of shading hack (not suitable for a unified shading pipeline)
Indeed, although it seems not to be as responsive as doing it in max. But final touch ups, it's going to be great tool to have.
Hmm, I have not experienced any sluggishness with it. It's pretty cool though that you can now store unique vertex color for the same meshes. So using the same wall over and over w/ unique material blending via vertex color rocks!
Hmm, I have not experienced any sluggishness with it. It's pretty cool though that you can now store unique vertex color for the same meshes. So using the same wall over and over w/ unique material blending via vertex color rocks!
I just tried it again and it's working fine, not sure why because I used the default settings both times. Unless I clicked on something and did not notice it, so never mind on my previous comment.
first of this is not something new in uncharted 2 the first uncharted was already using these kind of shaders on .... well .... practically everything.
i was thrilled by it back than (still am) and tired to recreate that sort of shader in ut3 with little success i called up hourances to help me out with this task ( since he is my ue3 guru ^^ ) and he got a proof of concept implementation working and he described it in his tutorial after ward:
i intended to use that shader all over my diablo map but it never looked quit as good as it did in uncharted so i dropped it:
now uncharted 2 is out and OMFG does it look awesome so i said to myself this time ill do it for real and find out how they do it ... how foolish of me to think that i am the only person that noticed the pure awesomeness of this technique. and sure enough you guys already have it up and running but i think you guys are on the wrong path if you want to auto generate the snowy areas i am sure the guys at naughty dog are such control freaks that they hand color each vertex also i think they blend more than 2 textures i wouldn't be surprised if they had up to 5 materials in these shaders to blend between that way you could make really large batchable/drawcall-conservative objects. basically 1 base material and than use the R G B and A channel to push the opacity of another layer over it .
@ mop if this is an *.FX shader shouldnt it also work in maya ?
warby, not sure, i think the UI semantics are different. Feel free to give it a try though
And yeah, for the Uncharted 2 snow and ice, I totally agree, they're using way more than just this. Although I am fairly convinced that for the snow blending into the stone they only use 2 maps - a setup like I did here (stone as base, stone as heightmap with snow as upper texture) and just vertexcolour (of course by hand, not sure how else you'd do it!) for the large-scale blending.
Then maybe a different stone texture and mask image for the vertical walls.
And on top of that, modelled snow with a single snow texture tiling on it, and for the edges they've done ice and icicles hanging off things with a custom shader there too.
Yeah there are several ways this effect could be achieved in unreal. Either hand done or procedurally.
A few examples would be just with textures and masks and the lerp function or you can do a formula function that will actually detect where the snow should or should fall, or you could hand paint it with the vertex mesh paint tools mentioned earlier. Which uses lerp in the material set up anyways just stores it via vertex i believe. I haven't messed with that stuff yet.
wow this stuff is amazing! great RnD in here, i'm definitely going to try what Minotaru0 posted up though because thus far, that's looking pretty amazing! I need to mess with shaders more to get this kind of detail and unique-ness going.
This thread made me take a break from AC2, controller is on my lap.
But what I'd like to see is mop his node setup for shader FX, since we're learning this at school, and I think this technique is awesomeness, I'd like to take a look at it.
Awesome thread, I like your material mop, it looks like the "hardness" of the fade is a constant value, you could make one of the vertex colors be the hardness so that could be painted as well which would be really sick (If it's already like this I'm sorry!:) )
Yeah I put the "hardness" control (I call it the ramp or falloff) into the vertex alpha just because it's easier to paint in 3dsmax since per-channel painting seems a bit tricky. Or maybe I just don't know Max's vertex colour tools very well
I also have an "override" checkbox so you can use a constant if you can't be bothered setting up any vertex alpha for that control.
Rhinokey, we already did, but it requires megatexture
(my shader was basically an attempt to recreate in real-time, the method of blending that we used for the megatextures in ETQW, the only difference is mine is controlled with vertex colour instead of a very large image)
Also, to do good terrain, you really need to be blending at least 4+ different tiling textures in layers using this method, which is rapidly going to become prohibitively expensive for a single shader in this fashion.
Two textures blending together is nice for many uses (like plaster/brick on walls or snow/stones as demonstrated in Uncharted) and for smaller areas of terrain (eg. grass blending with cobblestones or something for an old street scene) but to do a full-on terrain with rock, stones, mud, grass, sand and whatever other material types you need on there, you're never going to get that out of one shader if you're using normals/spec/gloss/diffuse like this one does. Far too complex.
Plus you'd run out of vertex colour channels to blend with (4 if you're doing RGBA on one channel), you'd either have to allow more VCol channels (which I dunno if many engines support) or start using large unique greyscale images as masks.
But isn't that what Unreal's standard terrain material system does? I always understood it just sort of stacked together every material you use on the terrain, into one big-ass material. Hence why the terrain goes super-funky colors if you use too many different materials.
And my two-way blend material came out at 60 instructions, I guess making it 4 way would end up somewhere around 100-120, which is still semi acceptable? Not sure how that compares to the Unreal terrain material, since you never get to see the instruction count.
I have been working on vertex blending for a while now, and this thread has helped me alot.
I have taken the techniques discussed and added a bit more functionality to the shader that MoP was working on. I was thinking to myself, why not use the other 3 channels of the vertex color constant as inputs for other functionality for the shader? I got the idea after reading that MoP was using another channel to control the falloff of the vertex blend transition mask.
So here's what i did.
First i subtracted the red channel of the vertex color node by the height map, then divided it by the alpha channel of the vertex color node. Then i clamped that input to a value between .01 and 1. That's it. That little set of instructions is all you'll need for your linear interpretation. That little bit of math came from MoP. So credit goes there
After that i used the blue channel of the vertex color and multiplied it by 10 on the Blue channela constant 3 vector, Then i plugged that node into the World Position Offset input at the bottom of the material's master node
Good idea with the WorldpositionOffset, too bad its only a "visual" offset and the collision of the mesh does not actually change, afaik.
But that should work fine with small offsets for things like snow or sand where the player can supposedly "sink in" a little anyway.
since you can do like virtuo, whats the advantage in terrain over this? since terrain seems to be limited to materials and things you can do with them? i guess in super huge areas this may take a lot of time to paint up. but other than that, what technical advantage?
Not sure who you mean with "since you can do like virtuo", but the advantage of terrain in the case of painting height-offsets inside the editor is that it offsets the actual geometry used for collision and rendering, while the WorldPosition magick offsets only what's being rendered.
The downside of terrain is that so far nobody seems to have found a way to make this improved blending algo work with it's Material-Layers.
It's not a real issue if you model out the large forms in a 3D Package of course, and use WorldPositionOffset for smaller adjustments.
Yeah but making your terrain model in an external package isn't really efficient. You'll have to go back and forth for every tweak, there's no dynamic tesselation and culling, and worst of all: there are no split lightmaps...
I'd say that the best application for this would be on pretty flat floors that you just want to muck up with some variation. Something like a road or what i showed in the video. Using this method for a full out terrain setup would obviously be a disaster, unless you modeled it in a 3rd party application. but like xoliul said, it's not the fastest way to do things.
I wouldn't use the phrase "It isn't really efficient". If you mean it's not "TIME efficient" i'd accept that. But in terms of being memory efficient, it's leagues cheaper to use that method then a terrain actor.
I remember reading somewhere that Unreal's terrain has a more efficient/friendly collision method applied to it compared to what you would need to use for a gigantic static mesh collision. Here's where I read it, and here. So using this material technique for a gigantic static mesh terrain in a actual playable level might not be such a good idea.
Thought this post from Behrooz Roozbeh from Naughty Dog would help shed some light on this...it's pretty much what everyone has said up to this point about vertex blending. This comes from the Unhcarted 2 Art Thread on Zbrush Central, check it out here
There is a game shader technique called vertex blending that does wonders for tile-able textures..
The blend Shader uses two sets of textures plus an additional blend map to reveal another set of textures
Lets say top texture set is the undamaged version(diffuse, normal, specular,...etc maps)
and second set is the destroyed version of the tezture set, so using a blend map and painting the vertex (assume red channel of vertex is used for the blending) then depending on vertex value of red channel will reveal the second set of textures.
Replies
Ill test it with a heightmap instead and see how that looks like.
And it allows for much more variations in the final look, then using a pure black and white mask.
I just to need to figure out how to get a normal map out of this so that the top textures get some normal info around the edges. If that's possible..
Here's a video of my .fx shader in action, I sorted out the vertexcolour trashing tonight, I still need to double-check my maths on the mask method because it's not quite what I think it should be.
http://www.greveson.co.uk/dump/blend_mask_2.avi (1.6mb, XVid codec)
Video shows initially starting off with black vertex colour, then painting white where I want the snow. I then change the "global falloff" value from 0.01 in steps up to 1.0 (the shader has a checkbox for using vertex alpha or not), and after that I change it to use the vertex alpha as the falloff (defaults to 1.0, very soft blend), and I paint it down to black in places for a really sharp blend.
Edit: OK, for people wanting to mess around with the shader, here's a beta version. I can't guarantee the maths for the blending is right, but it works visually for the most part.
Hell, I don't even think the maths for the lighting is correct. Try it on a sphere, it looks broken to me
Definitely not perfect yet, but fun to mess around with. I'd be very interested to see screenshots of what people try with it.
Max 2008 .fx shader BETA download:
http://www.greveson.co.uk/shaders/MoP_TextureBlender.fx
Disclaimer: .fx file only tested as a DirectX Shader on 3dsmax 2008, I have no idea about compatibility with other Max versions. I don't think it will run on other software. I take no responsibility for anything bad that should happen from using this shader (although I can't imagine what it could possibly do!).
The blending is a tiny bit different than the results I am getting inside UE with the same mesh, I think it;s handling the vertex color info differently. But really cool to see the results right away.
Using this + this blend shader = awesomeness!
Ok thank you for the clarification.
Indeed, although it seems not to be as responsive as doing it in max. But final touch ups, it's going to be great tool to have.
I just tried it again and it's working fine, not sure why because I used the default settings both times. Unless I clicked on something and did not notice it, so never mind on my previous comment.
first of this is not something new in uncharted 2 the first uncharted was already using these kind of shaders on .... well .... practically everything.
i was thrilled by it back than (still am) and tired to recreate that sort of shader in ut3 with little success i called up hourances to help me out with this task ( since he is my ue3 guru ^^ ) and he got a proof of concept implementation working and he described it in his tutorial after ward:
http://www.hourences.com/book/tutorialsue3mated3.htm
i intended to use that shader all over my diablo map but it never looked quit as good as it did in uncharted so i dropped it:
now uncharted 2 is out and OMFG does it look awesome so i said to myself this time ill do it for real and find out how they do it ... how foolish of me to think that i am the only person that noticed the pure awesomeness of this technique. and sure enough you guys already have it up and running but i think you guys are on the wrong path if you want to auto generate the snowy areas i am sure the guys at naughty dog are such control freaks that they hand color each vertex also i think they blend more than 2 textures i wouldn't be surprised if they had up to 5 materials in these shaders to blend between that way you could make really large batchable/drawcall-conservative objects. basically 1 base material and than use the R G B and A channel to push the opacity of another layer over it .
@ mop if this is an *.FX shader shouldnt it also work in maya ?
And yeah, for the Uncharted 2 snow and ice, I totally agree, they're using way more than just this. Although I am fairly convinced that for the snow blending into the stone they only use 2 maps - a setup like I did here (stone as base, stone as heightmap with snow as upper texture) and just vertexcolour (of course by hand, not sure how else you'd do it!) for the large-scale blending.
Then maybe a different stone texture and mask image for the vertical walls.
And on top of that, modelled snow with a single snow texture tiling on it, and for the edges they've done ice and icicles hanging off things with a custom shader there too.
Yeah there are several ways this effect could be achieved in unreal. Either hand done or procedurally.
A few examples would be just with textures and masks and the lerp function or you can do a formula function that will actually detect where the snow should or should fall, or you could hand paint it with the vertex mesh paint tools mentioned earlier. Which uses lerp in the material set up anyways just stores it via vertex i believe. I haven't messed with that stuff yet.
Found another tackle on this subject. Looks pretty awesome and simple to do:
http://www.chrisalbeluhn.com/UDK_Advanced_Vertex_Painting.html
I didn't achieve to do that in Unreal but now it seems it'll be easy to do with this tutorial
But what I'd like to see is mop his node setup for shader FX, since we're learning this at school, and I think this technique is awesomeness, I'd like to take a look at it.
The blending isn't perfect yet, but it meets all technical requirements.
I also have an "override" checkbox so you can use a constant if you can't be bothered setting up any vertex alpha for that control.
(my shader was basically an attempt to recreate in real-time, the method of blending that we used for the megatextures in ETQW, the only difference is mine is controlled with vertex colour instead of a very large image)
Two textures blending together is nice for many uses (like plaster/brick on walls or snow/stones as demonstrated in Uncharted) and for smaller areas of terrain (eg. grass blending with cobblestones or something for an old street scene) but to do a full-on terrain with rock, stones, mud, grass, sand and whatever other material types you need on there, you're never going to get that out of one shader if you're using normals/spec/gloss/diffuse like this one does. Far too complex.
Plus you'd run out of vertex colour channels to blend with (4 if you're doing RGBA on one channel), you'd either have to allow more VCol channels (which I dunno if many engines support) or start using large unique greyscale images as masks.
And my two-way blend material came out at 60 instructions, I guess making it 4 way would end up somewhere around 100-120, which is still semi acceptable? Not sure how that compares to the Unreal terrain material, since you never get to see the instruction count.
Edit; my node setup, posted for Snipergen, sharing it for anyone:
http://www.laurenscorijn.com/vertex-blending-snow.html
You guys simply rock... so talented.
I have taken the techniques discussed and added a bit more functionality to the shader that MoP was working on. I was thinking to myself, why not use the other 3 channels of the vertex color constant as inputs for other functionality for the shader? I got the idea after reading that MoP was using another channel to control the falloff of the vertex blend transition mask.
So here's what i did.
First i subtracted the red channel of the vertex color node by the height map, then divided it by the alpha channel of the vertex color node. Then i clamped that input to a value between .01 and 1. That's it. That little set of instructions is all you'll need for your linear interpretation. That little bit of math came from MoP. So credit goes there
After that i used the blue channel of the vertex color and multiplied it by 10 on the Blue channela constant 3 vector, Then i plugged that node into the World Position Offset input at the bottom of the material's master node
here's a demo
[ame]http://www.youtube.com/watch?v=0V6bit8PrZo[/ame]
But that should work fine with small offsets for things like snow or sand where the player can supposedly "sink in" a little anyway.
The downside of terrain is that so far nobody seems to have found a way to make this improved blending algo work with it's Material-Layers.
It's not a real issue if you model out the large forms in a 3D Package of course, and use WorldPositionOffset for smaller adjustments.
I wouldn't use the phrase "It isn't really efficient". If you mean it's not "TIME efficient" i'd accept that. But in terms of being memory efficient, it's leagues cheaper to use that method then a terrain actor.
cant wait for the upk ! ))))))
Would be fantastic.
*stares at the page and hits F5*
http://www.zbrushcentral.com/showthread.php?t=79141&page=7&pp=15
There is a game shader technique called vertex blending that does wonders for tile-able textures..
The blend Shader uses two sets of textures plus an additional blend map to reveal another set of textures
Lets say top texture set is the undamaged version(diffuse, normal, specular,...etc maps)
and second set is the destroyed version of the tezture set, so using a blend map and painting the vertex (assume red channel of vertex is used for the blending) then depending on vertex value of red channel will reveal the second set of textures.