Download

Dynamically painting/masking materials

Hello Devs, I would really like your opinion and help.

I need to dynamically add layers of different materials on top of my terrains and meshes within defined polygonal areas.
Specifically I need to spawn circles of “cold area” (represented by condense, snow then ice) on random position of the map, then blend them together and change the layer to a colder one (from snow to ice, for example) where they overlap.
If 3 circles spawn near enough to overlap I need to break the circle form and create a polygon (the external perimeter) and another inner polygon (the overlapping area).
All this has not to be precise and geometric, the more natural it looks the better.

I can’t simply change the material of the terrain/meshes because only a part of it has to change.

Now, I can imagine these approaches:

  1. Spawn decals and make them blend together, when an overlap is detected spawn a different decal on top representing another layer.
  2. Keep a matrix containing the “levels of coldness” then translate it to the map (I don’t know how precisely)
  3. Draw circles onto an hidden image with alpha and use it as a mask to apply the materials (like sphere_mask function) if it’s possible.

Take this as an example (https://www.youtube.com/watch?v=btR8AU6fvKg), but if two “winter spheres” overlap a new material has to be placed there

Thank you a lot for yourhttps://www.youtube.com/watch?v=btR8AU6fvKg help and time!

  1. draw your shape mask into a render target
  2. sample this render target in your terrain and environmental materials, ensuring that it is mapped properly on terrain.
  3. Inside materials blend between normal and frozen textures based on that mask.

This method will have quite low resolution though. Depending on the game’s viewing perspective you might want to map the mask only around the player instead of whole terrain.

Sorry for late answer, I was really busy.

By low resolution you mean bad texture/material quality or bad edges and definition of the borders?
Should be the second imo, in this case is more of a desired effect.

Thank you for your help, I will try it really soon!