GarageGames / Torque3D Public
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New terrain texture blending #712
base: development
Are you sure you want to change the base?
New terrain texture blending #712
Conversation
|
WOOOO this look amazing Great work, We are very lucky to have you here :) |
|
Thanks @LuisAntonRebollo ! :) |
|
Awesome stuff Lukas ;-) |
28ac021
to
efaf311
Compare
|
Now updated to use the latest fix for the blending, and tweaked the blending algorithm a little. Should be good to go now. |
|
Does this replace #710? I get a merge conflict when merging this after that. |
|
Hmm.. Sounds odd, seems like the commits has recieved new hashes for some reason.. I did a couple of resets, try re-merging the 3 textures blending fix. |
|
Right, rebasing will tend to screw things up a bit. I'll give it another go today. Any chance you could provide us with the texture/normal map you're using? The normal maps have to have depth in the alpha channel, right? |
|
@eightyeight unfortunately no, I got the textures from Andrew Mac for testing, and I can't really share them or use them outside of testing. I'll see if I can create some other textures for testing. |
|
@eightyeight you can use this zip file (Windows only) to generate some simply parallax maps. You can use the "parallaxMask.bat" file to merge an existing heightmap with the parallax map or you can use "genParallaxMask.bat" to generate a parallax mask from a normal and a diffuse texture. |
efaf311
to
6bd501d
Compare
|
Updated with fix for the bug described in #710 . |
Now terrain basetexture is properly cleared and never transparent.
6bd501d
to
ad1ada7
Compare
Added an implementation of the terrain blending described in this article: http://www.gamasutra.com/blogs/AndreyMishkinis/20130716/196339/Advanced_Terrain_Texture_Splatting.php by Andrew Mishkinis. Textures without a heightmap will blend linearly.
ad1ada7
to
ce33589
Compare
|
This has a small issue with currentAlpha and blendTotal essentially being the same thing, but only blendTotal is being outputtted while not being calculated properly when not lerpBlending. Which I'll fix soon™ |
|
Define good? ;P I'm happy to push this back to 3.7. |
|
Pushed back due to time constraints. |
|
@eightyeight #710 isn't affected by the issues I found here in the last minute, it's just the new blending that is affected by it :) |
|
I meant this comment as a catch-all for the terrain blending issues - it was #710 that I was having problems with, and as it's prerequisite to these ones they've all had to be moved back a bit. I take it you fixed the 3-way blending issues I was having with the PR for basetex formats? In any case, rest assured that these changes will be some of the first merged in in 3.7 :). |
|
Yup the blending issues should be fixed with that PR. |
normals with alpha and material definitions
|
Oh :(. The results you had before were achieved with a more limited terrain situation? Also, to be honest, I don't think those lower images look all that bad. |
|
The results I had before were just a coincidence more or less. Somehow I managed to only blend the 3 textures together that were in the same pass, in bigger tests it would fail. I fear that the approximated solution might have some cases that it doesn't handle properly.. Dunno man, unless someone have a bright idea I might call this dead :( |
|
Is this something that might become possible with the deferred shading branch, for example? Or would it take rewriting all the terrain shaders/shadergen? |
|
10-1 having the capacity to write to a secondary render target during terrain layer accumulation would solve the problem. As would creating a one-off namedrendertarget similar to how the glowbuffer works. The latter line was explored though, and @lukaspj found the performance hit unacceptable. Call it something to perhaps revisit once that is a stock feature if continued interest in that project is maintained. |
|
Makes sense. @lukaspj I'll leave it in your hands if you want to close this PR and associated other ones. Would be a shame, but if we can't swing it then we can stop worrying about it and maybe revisit it later :). |
|
Hmm I'm currently thinking about trying to add a A8 texture, with the screen resolution, and make the pixelshader write and read that texture to preserve the Alpha and see the impact it has. |
|
That A8 texture method may very well work. You can also tinker with the maximum number of combined materials. Currently it is hard coded at 3 (obviously each material has multiple textures). Modern GPU can handle a far higher number of samplers than when that code was written ;-) |
|
@rextimmy unfortunately dx9 has a hardcoded limit of 16, so thats as how as we can go anyways. |
|
Oh yes your right, i'm stuck in OpenGL land where you will get double that :) Let's say we have 3 passes. Pass one you write alpha to the new A8 texture, how are you going to sample and write to that texture in the second pass? |
|
Well that was one of my issues, I wasn't sure whether that was possible or if I'd have to have two A8 textures and flip-flop between them. |
|
Yeah you can't read and write to that texture at the same time :(. Give it a go with the two textures but it honestly sounds expensive :/ I think what i am going to do in DM to solve this is remove the macro texture (we don't use it) and increase that hard coded limit of 3 and get it as close to the maximum of 16. If it breaks the limit than spit out a warning and tell Nils to go easy and stop using so many textures in the one area lol |


New terrain texture blending! As described here.
There is this thing called "blendDepth" that allows you to tweak how sharp the blending it is, to show you the effect of tweaking this depth I created the following album:
http://imgur.com/a/oae0O
First image is stock T3D blending, from there it is new blending with blendDepth 0.1,0.2 etc up to 0.9. Last image is blendDepth 0.99
You can set the "blendDepth" on the terrain material like this:
You enable the new blending method by setting
$terrain::lerpBlend = false;(defaults to true). This PR does not contain any UI changes so the new features have to be activated through script. (UI might come in a later PR!)Note for the new blending to work properly, the textures HAVE to have a normal map with a heightmap in the alpha channel. If you don't use normal maps, then this texture blending method is not for you.