🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Terrain decals

Started by
2 comments, last by PLCrashy 2 years, 2 months ago

Hi,

I'm trying to find a way to render decals of any shape on my terrain.

I already have implemented a deferred decal system but it could only render simple stuff on “quads” ( very close to this https://mtnphil.wordpress.com/2014/05/24/decals-deferred-rendering/​ ), while I'd like to take any object and say “you will now be rendered on the terrain”

Basically something like Torque did on their road system but I don't know how they did it : http://docs.garagegames.com/torque-3d/official/content/documentation/World%20Editor/Editors/DecalRoadEditor.html.

So far I was thinking of rendering the objects flagged as “decals” from a top down ortho view to a texture, then apply it onto the terrain, but this would require multiple cascades to have high quality close to the main camera and also be able to render decals that are really far away.

Maybe an oblique unique frustum intersecting the main frustum would do the job but I'm not sure at all and this looks a bit hazardous, with the same issues we usually face when rendering shadow maps, ie pixel jittering when the camera moves.

Any hint or advice will be welcome,

Thanks.

Advertisement

Usually roads are defined by splines or some other parametric curve, along with a width. You can still do this with deferred decal projectors, you just need a different projection method. Instead of calculating the decal UV from a box shape, you would compute it by calculating projected distance from the spline.

Thanks for the answer.

I think I see what you are describing, but this would only work if the road mesh is already fitting the terrain, won't it ?

If I generate a road decal volume that is not glued to the terrain, this will introduce a strong parallax somehow.

See this quick drawing:

(green: the terrain, red: the road decal volume, blue: the main frustum, yellow: a sample dir, black cross: the expected sampled position, yellow cross: the true sampled position)

For simple quad decals we remove this parallax by converting back the pixel position in decal local space, but for splines this isn't possible afaik.

Of course if the road mesh is following the elevation as much as possible, the parallax will be greatly reduced.

This topic is closed to new replies.

Advertisement