Omzy's Advanced Texture ShaderFor use with HeroEngineHello fellow Dev's!
We at
Odyssey of Ydris have been working hard creating our world these past few months, and in the process we have created a Texture Splatter shader for use with HeroEngine that revolutionizes the way texture layering is processed by the engine. This shader is merely a few lines of code injected into an existing .fx shader file within your repo.
You can read more about how to use custom shaders here:
http://hewiki.heroengine.com/wiki/Shaderhttp://hewiki.heroengine.com/wiki/Shader_panelI was working in our world when I became frustrated with the way opacity blending worked. There were textures that faded into nothingness, and unless you became extremely creative with alpha layers, you couldn't really create realistic layering effects with your terrain textures. I ran across this article (
http://www.gamasutra.com/blogs/AndreyMishkinis/20130716/196339/Advanced_Terrain_Texture_Splatting.php) which explains the math and the process for creating more realistic layering, and directed it to Omzy, our owner/programmer/developer. In response, he provided me with this shader, and we're sharing it with the community!
This custom shader replaces the normal opacity function on all layers except the bottom layer.
In order to create 'depth', you must use the alpha layer of the normal map (currently only for spec). To do this, create a heightmap/bump map of your texture and blend it with your spec map, so that the image has pronounced highs/lows. (you can modify/tweak this later using levels, brightness, and contrast controls). You must create a 'balance' between your spec and your heightmap so you don't completely sacrifice your spec.
I will be providing a more in-depth texture splatting tutorial using this shader at a later date. Until then, this video pretty much sums up how this functions:
https://www.youtube.com/watch?v=94B-5mWYTboAnd now for the shader!
Instructions:
Find this code in heightmappermutations.fx locade in your "Render/shaders200a/game" folder:
#if defined(DO_TEXTURE_ALPHA)
fadevalue *= diffuseTexColor.a;
(Insert the code below here) #endif
diffuseTexColor.rgb *= In.VertexColor;
//OMZY~
float4 normaltexture = tex2D(NormalSampler,In.TexCoord0.zw);
float heightval = normaltexture.w; //w is alpha, which contains spec = heightmap substitute
if (fadevalue > 0.2 && fadevalue < 0.6) { //transition width is 0.4
float fadenorm = (fadevalue - 0.2)/ 0.4;
float edgenorm = (fadevalue - 0.2)/ 0.0625; //edge blend value
if (fadenorm < (1-heightval)) {
if ( fadenorm > (1-heightval)*0.55) { //blend a few adjacent pixels
if ( fadevalue < 0.3) { //blend the edge down
fadevalue = (fadenorm - (1-heightval)*0.55) / ((1-heightval)*0.45) * edgenorm;
} else {
fadevalue = (fadenorm - (1-heightval)*0.55) / ((1-heightval)*0.45);
}
} else {
fadevalue = 0.0;
}
} else {
if ( fadevalue < 0.3) { //blend the edge down
fadevalue = edgenorm;
} else {
fadevalue = 1.0;
}
}
} else {
if (fadevalue < 0.2) {
fadevalue = 0.0;
} else {
fadevalue = 1.0;
}
}
//~OMZY
Screenshots of how it's used in our game:




And a video flyby of our world in progress:
https://www.youtube.com/watch?v=y4SFkDWdGe0Enjoy!
MCINDUS and Omzy
============
Odyssey of Ydris