kikonen / learnopengl

https://learnopengl.com
1 stars 0 forks source link

decal: Support clipping decals into parent mesh #83

Open kikonen opened 2 months ago

kikonen commented 2 months ago

Decals are attached to parent, but they are not clipped to parent boundaries.

This can work reasonably with small decals wree non-clipping is not very visible. But with bigger decals it can be noticeable.

Perhaps there could be some stencil mask bit used to mark elements with decals, and restrict decals based into that. However, this won't work well, if there is multiple different kinds of decals or if nodes with decals overlap are next to each other. In that case decals would leak from node to another.

Stencil mask in decals might also partially fix issues with decals being attached into phy geom boundaries, thus not strictly projected into actual mesh. For this case, calculating actual hit position in mesh might be also possible (requires triangle ray intersection test for whole mesh)