How to project a Shape to the terrain as Decal? like Crysis

zhucde

19-11-2008 09:01:45

see the image as follow (screenshot of Crysis)

in crysis, there is a road creater, use mouse to draw a road helper shape, the Decal (i guess it is decal) projected to the terrain in Real-time (similar as shadow),

it aslo can be assigned materials.

how to do?


billykater

19-11-2008 09:50:55

For the projecting part.
I am using an extra texture as overlay on my terrain.
The UV coordinates fed into the PSSplat2.cg shader are in range of [0,1] on the terrain so i use


float4 overlaycolor = tex2D(overlay,iTexCoord0);

//Tile splatting textures
iTexCoord0.x *= splatScaleX;
iTexCoord0.y *= splatScaleZ;


to project a texture onto the terrain.

To get the shape of the road
I would do an orthographic Render to Texture to create a texture from the geometry. If you change the material of the road helper shape this should get you the result in picture 2.

This may not be the best solution because you will be limited by the resolution of the overlay texture(s).
Additionally you would need an Render to Texture each frame if dynamic changes should be allowed.

Hope anything of that helps you.