r/GraphicsProgramming • u/UsualSpace_ • 18m ago
Question Smoothly blending integer index based terrain material maps?
So imagine I am rendering terrain on an arbitrary chunk, that receives a height and normal map for said chunk. Now say I want to apply different materials to this chunk. Ideally I can store all of this info in one 4 channel texture. Height in r channel, 2 angles for the world space normal in the g and b channels, and then a spatial distribution of a 1D index dictating which materials exist where within the chunk. For example, if a region of the texture contains index 0, use dirt, if another region in the same texture contains index 1, use grass, and so on. I could have a ton of materials represented this way in just a single texture. The plan is that when I render the final terrain, the fragment shader will sample a texture array containing all the possible materials via the material index map stored in the terrain chunk texture.
The issue with this approach is that boundaries between materials will have hard edges. If I introduce a blending factor between edges, this could end up sampling material indices in between the 2 regions, which is not what we want to happen.
So my question is, is there a way to introduce smooth blending between these material indices, ideally restricted to a constant amount of extra memory if extra is necessary?
Alternatively, is there a better way to handle this?
•
u/AutoModerator 18m ago
Recently updated rules. Please check that your post is in compliance with Rules 1, 4, 5, and 6 on the sidebar. TL;DR:
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.