Skip to content

Sample shader and component for mesh decals aka floaters#1587

Merged
C-Core merged 8 commits into
devfrom
user/ck/mesh-decals
Jun 21, 2025
Merged

Sample shader and component for mesh decals aka floaters#1587
C-Core merged 8 commits into
devfrom
user/ck/mesh-decals

Conversation

@C-Core
Copy link
Copy Markdown
Member

@C-Core C-Core commented Jun 20, 2025

image

Mesh decals aka floaters or floating geometry is often used to add details to meshes without complicating the underlying geometry and uv mapping.
This PR adds a sample shader that uses a depth offset to ensure floaters are always rendered on top of the underlying geometry. The depth offset is in depth units so there won't be any z-fighting even when viewed from far away.
Furthermore the sample shader utilizes the runtime decal atlas to allow variation between mesh instances with increasing the number of draw calls. The shader works in tandem with the mesh decal component which allows the user to select arbitrary textures that will then be put into the runtime decal atlas. The component feeds the runtime decal indices as custom data per instance to the shader.
The shader uses the integer part of the UV coordinates to identify which decal slot should be used. There can be up to 8 slots per mesh:

image

The sample shader only supports base color from the runtime decal atlas and an additional alpha texture per material. The shader and also the component is meant as a starting point and can be customized to the individual needs of the user.

@C-Core C-Core merged commit a142319 into dev Jun 21, 2025
11 checks passed
@C-Core C-Core deleted the user/ck/mesh-decals branch June 21, 2025 20:33
@jankrassnigg jankrassnigg added this to the Next Release milestone Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants