I'm trying to draw a "targetting ring" on the ground below a "unit" in a hobby 3d game I'm working on. Basically I want to project a bright red patterned ring onto the ground terrain below the unit.
The only approach I can think of is this -
Draw the world once as normal
Draw the world a second time but in my vertex shader I have the world x,y,z coordinates of the vertex and I can pass in the coordinates of the highlighted unit - so I can calculate what the u,v coordinates in my project texture should be at that point in the world for that vertex.
I'd then use the pixel shader to pick pixels from the target ring texture and blend them into the previously drawn world.
I believe that should be easy, and should work but it involves me drawing the whole visible world twice as it's hard t开发者_如何转开发o determine exactly which polygons the targetting ring might fall onto. It seems a big overhead to draw the whole world twice, once for the normal lit textured ground, and then again just to draw the targetting ring.
Is there a better approach that I'm missing?
Projective Texture Mapping is your friend.
精彩评论