Jump to content

Blending mode for terrain materials....


Mitovo

Recommended Posts

I'll note on the 'Textures always looked oversaturated to me" part: it could well be that the textures themselves have an element of being 'over done', as well. They're rather old textures at this point, and we use much different and more accurate color handling now. So that could easily be exacerbating any oddities with the terrain textures. I'll work with Lukas and get some new, properly modern terrain textures we can use to better assure testing and correctness, and replace the old ones.

Link to comment
Share on other sites

  • Replies 93
  • Created
  • Last Reply

Top Posters In This Topic

So, just to give the cliffs notes to the conversation today, we pow-wowed on a game plan for terrain to get a better idea of where it needs to be, and how to get it there.


The unanimous consensus was that the detail textures need to be a full color diffuse texture which looks as-the-image-intends up close, where the detail textures are utilized.


So from there, we worked out the following concept for how terrain rendering of materials could proceed:


BaseTexture: Basically what 'DiffuseTexture' does now, but trades the confusing nomenclature. This texture basically paints onto the terrain-wide diffuse texture map that acts as your long-distance detailing(how mountains look in the distance, yada yada)


Detail Diffuse Texture: Full color, up-close texture. Behaves similarly to the detail textures now, where they will blend in based on distance, but doesn't do the weird light/darkening gray image business. You pass in a full color texture and it'll render it as expected.


Detail Diffuse Texture, Alpha Channel: While most cases of the detail texture brightening/darkening are annoying because of how the math is kinda weird, being able to take contribution from the base texture's color to help create visual variation and cut back on repetition is still useful, so we had the idea that the alpha channel could basically act as a 'Blend Mask'. Would basically be a lerp of the blend values of your diffuse textures. At 0(black), it would use the color of the BaseTexture, at 0.5, it would be a 50/50 blend of color, and at 1 it would fully use the Detail Diffuse's color. This would allow you to, say, have a grass texture with flowers, where the grass can pick up some color variation from the BaseTexture, but the flowers would keep their detail-texture-based color and be unmodified. Would also have a override in the mat editor to just assign a flat constant to the channel for simplicity if no special blend masks are required.


Detail Normal Texture: Normal map texture. Natch


Detail Normal Texture, Alpha Channel: Your height information. This and the normal will get used in Lukas' much nicer blending logic as detailed in his blog thread, and also can be utilized in parallax mapping for added depth fidelity.


Detail Composite Texture: This is for the PBR side of things. It'll contain the roughness, AO and metalness info for the detail texture, so that it renders the same as any non-terrain materials.


I also figured that with this setup, it would be quite easy to have the frontend accept picking regular materials, to which we would-in the backend out of view- pull the appropriate textures and fill in the data(allowing a clean, uniform hook to secondary material information, like particle effects to deploy, footstep sounds, etc).

So the front end would see a uniform interface as an option for picking materials, but the backend keeps a separate, streamlined terrain material to keep things efficient and targeted. This has the bonus of letting us get the texture packing to get the draw calls down as long as physically possible(potentially in 1!).


So yeah, I think this is actually a pretty sweet setup, that keeps the positives of the current terrain system, while shifting to a more intuitive and standardized setup with the pros of other, modern terrain systems.


If you guys have any ideas of suggestions to build on this stuff, by all means, throw it in the hat so we can get everything dialed in, but I feel this is a really good starting point.


I'm also gunna put together several new, PBR-ready terrain materials a) for better testing and b) a better example than the poor, old textures we currently have. They've served us well, but they're oooooold at this point, and need some replacing.

Link to comment
Share on other sites

The base texture is supposed to give the detail texture the diffuse color, therefore the detail texture is supposed to be unsaturated, so the color adds up properly.

Having the detail texture full color diffuse will defeat the purpose of having other textures like base texture and macro texture blend into it.


How I make my textures is like the following: I make the base texture a blurred version of the detail texture, so you do not see the details in the distance, just the rough color with some variation, then the detail texture which is mostly removed of the main color, like if you have a grass texture I remove most or all of the green in the texture, so that the green from the base texture fills it up again with different variations depending on location and macro texture is mostly black and white which adds more variations. Later I often exchange the generated final base texture by hand to give each level individual colors, in that situation it is important to not have too much color in the detail textures, since they would not fit then.


If you make the detail texture a full color diffuse, it will probably never match the ground color, since the baste texture usually gives a slightly different color every meter ingame distance, but the full color detal texture will give you always the same.


Regarding the base texture it should be as big as your terrain like 1024x1024 terrain needs 1024x1024 base texture and it will vertex paint the terrain


So do not break a working well thought through system. I would consider Torques terrain system even better than other engines on mid ranges.

Link to comment
Share on other sites

The base texture is supposed to give the detail texture the diffuse color, therefore the detail texture is supposed to be unsaturated, so the color adds up properly.

Having the detail texture full color diffuse will defeat the purpose of having other textures like base texture and macro texture blend into it.


How I make my textures is like the following: I make the base texture a blurred version of the detail texture, so you do not see the details in the distance, just the rough color with some variation, then the detail texture which is mostly removed of the main color, like if you have a grass texture I remove most or all of the green in the texture, so that the green from the base texture fills it up again with different variations depending on location and macro texture is mostly black and white which adds more variations. Later I often exchange the generated final base texture by hand to give each level individual colors, in that situation it is important to not have too much color in the detail textures, since they would not fit then.


If you make the detail texture a full color diffuse, it will probably never match the ground color, since the baste texture usually gives a slightly different color every meter ingame distance, but the full color detal texture will give you always the same.


Regarding the base texture it should be as big as your terrain like 1024x1024 terrain needs 1024x1024 base texture and it will vertex paint the terrain


So do not break a working well thought through system. I would consider Torques terrain system even better than other engines on mid ranges.

 

I gotta say i agree with what duion says above. I think there is some confusion about the detail maps, currently in the T3D system these should be a grey scale image described exactly as duion said above, the detail maps job is to provide detail not color.


Just some references:


Unity: https://docs.unity3d.com/462/Documentation/Manual/HOWTO-UseDetailTexture.html

Cryengine 3: http://docs.cryengine.com/display/SDKDOC2/Painting+Terrain

Cryengine 5: http://docs.cryengine.com/display/SDKDOC2/Detail+Maps


With CryEngine 5, they have optimized this since CryEngine 3, the "diffuse" is still a single channel image.

Link to comment
Share on other sites


I gotta say i agree with what duion says above. I think there is some confusion about the detail maps, currently in the T3D system these should be a grey scale image described exactly as duion said above, the detail maps job is to provide detail not color.


Just some references:


Unity: https://docs.unity3d.com/462/Documentation/Manual/HOWTO-UseDetailTexture.html

Cryengine 3: http://docs.cryengine.com/display/SDKDOC2/Painting+Terrain

Cryengine 5: http://docs.cryengine.com/display/SDKDOC2/Detail+Maps


With CryEngine 5, they have optimized this since CryEngine 3, the "diffuse" is still a single channel image.

 

The issue with that, is that you might want micro-control over color on the terrain. E.g. for painting a flower on the grass, how would that work if the detail maps are just for gray-scale image-detail?

Link to comment
Share on other sites

I already explained how that works, I said I usually remove the main color out of the detail texture, so for example I have green grass with yellow flowers, so I remove the green out of the texture leaving me with a mostly grey grass texture but with yellow flowers, if you now blend those two, you get yellow flowers on green grass.

No idea if that is intended this way, but it works fine, you can also just party desaturate the detail texture so all colors will stay in, you just have to take greater care what the final result will look like, since they will add up and you cannot use too much color overall.

Link to comment
Share on other sites

While you are correct that you can do additional processing on the various textures in order to not make them conflict in use, that's a lot of unwanted extra overhead to the art pipeline where there probably shouldn't be. The idea is to make stuff faster and more efficient to use.


Another point of discussion that's come up is shifting over to Virtual Textures for the terrain. I'll do a bit more of a writeup on the details for that a bit later, and if we do it, it'd be after the more immediate blend fixes lukas is already working on(because it'd be a full rework, not just an update), but there are some definite pros and only a few cons to using VTs for terrain.

Link to comment
Share on other sites

@JeffR

Detail Normal Texture, Alpha Channel: Your height information.

Won't this create horrible artifacts if you can't use DDS DXT5_NM? Or huge file sizes? What else except DDS has an alpha channel? PNG has transparency but not actual alpha.



I like the idea of full colour diffuseDetailMap with alpha transparancy to control how much diffuseMap comes through.

Link to comment
Share on other sites

@JeffR

Detail Normal Texture, Alpha Channel: Your height information.

Won't this create horrible artifacts if you can't use DDS DXT5_NM? Or huge file sizes? What else except DDS has an alpha channel? PNG has transparency but not actual alpha.



I like the idea of full colour diffuseDetailMap with alpha transparancy to control how much diffuseMap comes through.

 

Couple points simply to clarify: Transparency is Alpha. And the only thing that uses _nm s are normal maps. (Dxt5 does store usable alpha info, though being a compressed format, can lead to artifacting, yes.)

Link to comment
Share on other sites

I personally don't think you should have to edit the images in photoshop in order to get good results, desaturating some parts and not others etc. Aside from the extra work and slower iteration when trying out different combinations of textures, it also involves a ton of guessing and experimentation.


Why can't we just say that if there's a detail texture, we use that colour and ignore the base altogether? Or mix the base in but never go higher than the sum of the both.

Link to comment
Share on other sites

I personally don't think you should have to edit the images in photoshop in order to get good results, desaturating some parts and not others etc. Aside from the extra work and slower iteration when trying out different combinations of textures, it also involves a ton of guessing and experimentation.


Why can't we just say that if there's a detail texture, we use that colour and ignore the base altogether? Or mix the base in but never go higher than the sum of the both.

 

I implemented the approach that Jeff suggested. It uses the detail texture color by default (still fading out to the base in distance), but you can choose to blend in the base by adding transparency to your detail texture, basically the more transparent it is, the more of the base color shines through. It uses a lerp between the two based on the alpha channel.


You can try it out for yourself here: https://1drv.ms/u/s!AtrTgygwv8wijutDYzqJ90UqSlqgEQ

There are a few bugs, lerpBlend isn't working and you have to re-generate the base texture (by painting a bit) to make the baseTexture work and it needs a normal map with an alpha-channel in order to blend, but it should give an idea of how it would be with this alternate way of blending.


Edit:

Oh, also the saturation, brightness and contrast are a bit off and way too bright. Press "ctrl+o" to fiddle with that.

Link to comment
Share on other sites

Come on, editing the textures to make them fit just takes a few steps, desaturate, or partly desaturate, move up the brightness until it is around 128 grey, done, then you can test in the engine and make eventual fixes to the texture itself.

The more options you give people inside the engine, the more complicated and overloaded it all gets and the lazier the people get and the worse art they will produce, if you do not understand how to do 1-2 operations in an image editing program, then you maybe should not do art at all.

Link to comment
Share on other sites

Come on, editing the textures to make them fit just takes a few steps, desaturate, or partly desaturate, move up the brightness until it is around 128 grey, done, then you can test in the engine and make eventual fixes to the texture itself.

The more options you give people inside the engine, the more complicated and overloaded it all gets and the lazier the people get and the worse art they will produce, if you do not understand how to do 1-2 operations in an image editing program, then you maybe should not do art at all.

 

Duion, you seem to argue that we shouldn't change it, because people should just learn how it works. However, if we're willing to change it, and if we believe it will be easier to use, then what are the arguments against changing it?

Is it actually better with gray-scale maps? We can still allow variety and letting the base-texture bleed through to avoid repetitiveness. In fact we would have fine-grained control over it through the alpha-channel. So what do we lose?


As I see it, the only major thing, would be losing backwards compatibility with existing textures.

Link to comment
Share on other sites

We could not even identify, if there is any issue, since the original poster could not describe his problem nor bring any evidence and now he seems to be gone anyway.

So what exactly do you want to change now? You need to know what to change in order to change something.


An option to reduce the base texture influence may be a usefull addon, but there are limitations for it, since it brings new problems, for example that the texture will look different in the distance compared to close up and that is already an issue by default, so adding more to it will make it probably worse, then you will need to find something to fix the newly created problem etc etc.

Other engines do it the same, as someone already posted proofs for that, so if not even the biggest engines know how to make it better, how are we supposed to know?

Link to comment
Share on other sites

Other engines do it the same, as someone already posted proofs for that, so if not even the biggest engines know how to make it better, how are we supposed to know?

 

By taking the idea, implementing it, and seeing if we like it better or not. If we don't we just go back to the prior method.

Link to comment
Share on other sites

Come on, editing the textures to make them fit just takes a few steps, desaturate, or partly desaturate, move up the brightness until it is around 128 grey, done, then you can test in the engine and make eventual fixes to the texture itself.

The more options you give people inside the engine, the more complicated and overloaded it all gets and the lazier the people get and the worse art they will produce, if you do not understand how to do 1-2 operations in an image editing program, then you maybe should not do art at all.

 

That's great if you know the engine inside out... but most people will just load in a terrain texture from an asset library or whatever and it will look rubbish, and then they think the engine is crappy. Plus, if we have a dozen or so different terrain textures to use/test, it is a pain to have to load up a photo editor and tweak every one... and by how much should we desaturate it to get it to look the same as it does in the editor? Then we want to edit the texture and add some flowers... we need to desaturate it all again to save it out. And say we only have the desaturated version that someone else has saved already - we need to edit it in the desaturated form and guess how its going to look when saturated. You need to be able to visualize all that in your head and can't accurately pick the shade you're going for.

The whole reason PBR workflow has got so popular these days is that you can be pretty sure what it looks like when you design it is how it will look in the engine. That's kinda ruined if you have to then guess at how much to desaturate your terrain textures by to get the look you're going for in the engine.


Personally I think if it can be done in the engine and make the workflow easier, why not? It will help people make better looking stuff out of the box. And when making a whole game with just 1 or 2 people every little productivity boost helps.

Link to comment
Share on other sites

You people always act like Torque does it all so different as in other engines, while the truth is, that Torque probably does it exactly like other engines as well.

Torque was modeled a lot after Cry Engine and you can assume that the terrain will work the same.

And if people cannot open images with an image editing editor and spend a few minutes to do some changes, then they are hopelessly lost and probably should not do art at all.

Improving tools when people do not even understand the basics will not help anything.


If you look up time budgets of even professional artists, making a simple texture can add up to several hours in time, depending on complexity, multiply this by an hourly rate of 20-50 dollar and you know the costs of production and you seriously want to argue that you cannot spend a few minutes to make (an already mostly done) texture right.

Link to comment
Share on other sites

You people always act like Torque does it all so different as in other engines, while the truth is, that Torque probably does it exactly like other engines as well.

Torque was modeled a lot after Cry Engine and you can assume that the terrain will work the same.

And if people cannot open images with an image editing editor and spend a few minutes to do some changes, then they are hopelessly lost and probably should not do art at all.

Improving tools when people do not even understand the basics will not help anything.


If you look up time budgets of even professional artists, making a simple texture can add up to several hours in time, depending on complexity, multiply this by an hourly rate of 20-50 dollar and you know the costs of production and you seriously want to argue that you cannot spend a few minutes to make (an already mostly done) texture right.

 

I think the general consensus, is that T3D does it pretty much like CryEngine, but another approach has been suggested in this thread, which might be more intuitive and some wants to investigate that road.


We shouldn't keep the tool as-is just because people coming to the engine just needs to "git-gud". That is the equivalent of answering bug-reports with "the code is right there, fix it!". I'm not an artist, I don't spend several hours on a single texture, I download one, throw it in the engine and hope it works out well. Many indie-developers are programmers, using programmer-art and that's alright.


If the suggested method is inferior to the existing method, then sure we shouldn't fix it. But if it can yield the same or better results, while being more intuitive, then why not use it? I'm not saying that's how it is, but let's discuss whether the suggested method is superior to the existing method, rather than whether people just need to learn it.

Link to comment
Share on other sites

@Azaezel

Just to try and iron out my confusion - Back to:

Detail Normal Texture, Alpha Channel: Your height information.

 

If it's the detailMap_nm, you'd still not be able to use DDS.dxt5_nm because that compression/format needs the alpha channel to reduce artifacts. (using standard DDS.dxt1/3/5 for normal mapping gives horrible artifacts so I either use dxt5_NM or a png).


PNG gets alpha from erasing/fading the image, but you can't fit a greyscale (heightMap) into it. Can you?


:?:

Link to comment
Share on other sites

PNG gets alpha from erasing/fading the image, but you can't fit a greyscale (heightMap) into it. Can you?

 

Sure can, to demonstrate using a pre-existing texture in-engine:


http://imgur.com/a/uM625


Reason the image wasn't displaying the rest in most viewers, applications, or editors in the second shot is purely down to highly agreed upon application interpretation. Nothing inherent in the actual file its-self is anything but raw data to be interpreted however we wish.

Link to comment
Share on other sites

@Azaezel

Just to try and iron out my confusion - Back to:

Detail Normal Texture, Alpha Channel: Your height information.

 

If it's the detailMap_nm, you'd still not be able to use DDS.dxt5_nm because that compression/format needs the alpha channel to reduce artifacts. (using standard DDS.dxt1/3/5 for normal mapping gives horrible artifacts so I either use dxt5_NM or a png).


PNG gets alpha from erasing/fading the image, but you can't fit a greyscale (heightMap) into it. Can you?


:?:

 

If you happen to use the latest development version, i finally added in proper support for BC5 aka 3Dc normal maps. Obviously that format is useless though if you need the alpha channel for something.

Link to comment
Share on other sites

Ended out getting a late start due to a back-log of errands I had to run, but I started on a breakdown/example post on what the general issue people are running into is, what Lukas's work is intended to improve on, and try and get everyone on the same page, since it seems like the wither-tos and whyfors are getting muddled in the discussion a little.


I'd done up some regular PBR materials out of Substance, as a representation of your average joe's creation or something you may get out of an art pack. From there, I'll do up the gray/highpass convert to make detail texture versions, and do a nice post that breaks everyone down to try and re-focus the discussion. So I'll try to have that posted here tomorrow.

Link to comment
Share on other sites

Alright, gunna try and go through this, and do it in 2 parts.


We'll start with the stock devhead.


So, as we've discussed, the correct way to currently texture terrains is to have a color diffuse texture which paints to the BaseTexture of the terrain, and supplies color to the detail texture, which normally a grayscale/highpass texture of the same diffuse for up-close detailings. Then obviously your normal, and optionally a macro detail texture for intermediate ranges. The macro texture is basically a longer-distance extension of the detail stuff, so I'll ignore it for now.


So, using the 5 textures I'd exported from Substance tools - acting as an artist using a normal workflow - we end out with the Albedo, Normal + Height and Composite(for PBR in the near future). You'd load the albedo into a image editing program and desaturate them and fidget with the levels until it's fairly neutral gray. Depending on the texture's complexity, this can actually be a fair time sink if you're not experienced, and getting the almost-passable results in my images took me about 15-20 minutes of fidgeting for the 5 materials. Pragmatically, that's quite a time cost for 'almost passable' and 'good' results will take longer still, especially when you figure you're very likely to have far more than 5 materials on your various terrains.


Anyways, if we paint them down, at a distance, they look like this. I blew up the preview window so we can better compare the image's actual colors to the in-render results:


Sand

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_01.png


Dirt

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_02.png


Grass

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_03.png


Forest Ground

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_04.png


And Rock

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_05.png


As we can see, the colors as supplied on the BaseTexture look pretty good and are accurate to the source textures as we'd expect.


Now, if we were to try and just use our albedo image for the detail as well - either out of naivety or because you want the full color of the textures up close so it looks like the source image, the results are far less pleasing:


Sand

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_01_color.png


Dirt

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_02_color.png


Grass

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_03_color.png


Forest Ground

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_04_color.png


Rock

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_05_color.png


As we can see, not only do we not get anywhere close to the preview window's example of what the albedo color looks like when up close, the colors are completely destroyed, the detail is lost, and it just looks BAD.


So, lets try and use our 'almost decent' detail textures a new person would likely put together


Sand

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_01_detail.png


Dirt

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_02_detail.png


Grass

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_03_detail.png


Forest Ground

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_04_detail.png


Rock

http://ghc-games.com/public/terrain_example/Terrain_Explain_Stock_05_detail.png


Sand and Dirt see a huge improvement. Their detail textures were easy to create because it was a simple desaturate. They don't have much contrast, so they look OK. The colors are washed out compared to the albedo though, and getting it completely dialed in to look the same as the source texture would be a time consuming process.


Grass and Forest Ground fared better than with the albedo color detail, but still don't look good. They have a far broader extreme in contrast, between the grass/dirt and dirt/wood chips for the respective textures. Completely crushing the contrast will likely lose out a lot of the detail(already the grass itself looks like stringy mush), and will definitely not look like the source texture color-wise.

Rock is in a kind of weird middle ground. It's got a bit too much contrast from the cracks, so we're dealing with some discoloration, but it's not HORRIBLE. Enough fussing to dial it in would produce an acceptable result.


So with the current intended method of grayscale/highpass textures, we can see that yes - you can definitely get good results, but it's already - even with minimal correctness - more labor intensive, and still doesn't just simply return back the stock texture colors if that was what you were going for when looking at textures up close.

The tradeoff, however, is that if you get those detail textures dialed in, the base texture color blending in creates a good detail of visual variation, and it helps mask patterns and keep things visually fresh, which is absolutely a bonus.


Part of the problem with details getting blown out in stock currently is that it's not just simply a color modifier, but is a somewhat odd multiplier situation, so darker grays in the grayscale will darken the final merged color of BaseTexture + detail, and brighter grays will brighten it. The range on that is innately half because it's split + or -, so you get some extreme darks and brights at the same time because it's kinda unintuitive like that as well. To avoid extreme contrasts like that with the detail, you need most all the detail texture to be as close to true neutral gray as possible, which restricts you a good bit.


If we were to stick on with the highpass detail approach, we'd want to help make the modifier behavior of the detail textures easier to understand and work with so it doesn't completely blow the detail out without even approaching the extremes of 0 or 1 brightness levels. Also some examples/guidelines for how to produce good grayscale detail textures to cut down on how much fussing is required to achieve good results in order to save time while still making everything look good.



Tomorrow, I'll use the same textures with lukas's build and see how the newer approach fares with trying to get the detail textures to display the true color of the source texture to test situations where that's what the artist wants to do.


If there's any bits that you guys feel need further clarifying so we can all be on the same page about this, lemme know.

Link to comment
Share on other sites

Just putting it out there, texture creation shouldn't be easy, this is a complicated process that requires skill and time. Just because one can slap in any ol' texture and make it look good shouldn't even factor into the equation imho. Personally i think the lukas method would be fantastic if the terrain was using virtual textures,that is a setup with pretty much unlimited layers.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...