Hey everyone,
For one of our school’s game teams I am working on a rain system that can be used by the team through a custom UI widget in the editor. I wanted to have an option to mask areas on the different meshes so that only parts of the mesh that are exposed to this rain are masked. Which I then in turn can use to let only these segments react with animated maps/ different roughness values.
My idea was to use some form of light baking to do this masking but my main question with this is:
Is it possible to store this light data separated from the existing lightmaps to use it in the material?
The reason for wanting to use lightmaps is that they are relatively light and it creates separate baking data for modular assets used in the scene.
I know storing and saving lightmaps is possible in Unity and I read that this is a bit trickier in Unreal. Does someone have experience with storing lightmap data into materials in Unreal? If so please let me know!
All the help is really appreciated!
Hello RemcovdVen,
I have a hard time to understand why it should be necessary to create and grab another set of lightmap bake especially I do not understand how it should help with masking. To access the lightmaps, you have to change the source and then again, they are encoded differently than other textures. And I wouldn’t claim, that lightmaps are light, as they still have a memory cost, that can get out of hand.
If I understand your intend correctly, you want to enable the Level Artists in your Team to easily place rain and adjust the object surfaces to reflect that they are wet, right?
For the rain part you could create a particle tool, that reads from a heightmap that you captured. Like in the first part of this talk by Simon Trümpler: https://www.youtube.com/watch?v=aYZEmaQUrAo
For masking the wetness, on each object. I recommend using VertexColor in the material to lerp between the “wet and dry” settings. Painting vertex colors is quite easy in Unreal Engine. But be aware that this can result in more batching, as the static meshes then hold unique information on them.
I hope this helps
Hey raytheonly,
Thanks for the response! The reason for wanting to use a lightmap is that I think that this would be less performance heavy compared to baking it for each separate object and because the team is using a lot of modular assets the lightmap will create this light data for each separate mesh. It is a real challenge to find a solution that aligns with the team request and the possibilities and performance constraints in engine. The video gives another interesting approach, thanks for sharing
The reason I didn’t use vertex colors is because I feel that they are too inaccurate over flat meshes (like modular walls or floor assets) and that would make the wet/dry areas bigger or smaller than they should be.
Thanks for the message I’ll update the thread if I found a solution to the current issue.
Unless you need this to be a super shallow angle or something like that, I’d recommend using a Runtime Virtual Texture heightmap for your testing instead of a whole set of lightmap UVs (in Unreal at least, I’m not well-versed in the available systems in Unity).
Basically, all your materials (or some set of blocking objects) are set to draw their AbosluteWorldPosition.Z value into the Runtime Virtual Texture Output node. Then, in the material function for your rain you’d test the height of the current pixel against the height sampled from the RVT. You can select a lower mip value on the RVT to get a blurrier transition, too!
Hey ozzmeister00,
Thanks for the response/suggestion! I’ll try to look some more into finding a solution using the runtime virtual textures like you’re recommending. I’ll give an update here if I’m able to solve it.