Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Building Billboard from Mesh - Projection Question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 PhillipHamlyn   Members   -  Reputation: 454

Like
0Likes
Like

Posted 21 December 2012 - 04:02 PM

Hi,

 

In trying to reduce poly could for trees and other horizontally symmetrical meshes I'm trying a technique where I calculate a billboard dynamically from the mesh, and fade between the billboard and the 3D mesh at a given distance.

 

This works OK for most objects and in most circumstances (typically where the object orientation is not imporant; rocks, trees etc) but I'm having trouble working out how to project the billboard image from the mesh. These might be obvious questions, but I'm really stuck visualising what I'm doing.

 

First question; when generating the Texture2D image for the billboard, and I do this simply by rendering the mesh onto a transparent Texture2D Render Target but what is the relationship between the camera and the mesh bounding box ? I want to fill the billboard sprite as much as possible so I would want the camera position to be in a location which would make the projected image fit the 256x256 Texture2D as completely as possible (to get as much detail in the sprite as possible) but since my object meshes are different real world sizes, no one camera location gives me what I want for all objects. My problem seems to be to eliminate the distance scaling but is there a common projection matrix for instance which would prevent scaling with distance, so all I'd need to worry about was providing a Scale transform, rather than the Translate transform of the camera ?

 

Second question; I will scale the billboard at runtime to coincide with the 3D object bounding box, so that the billboard looks a similar size to the mesh when I segway between the two - is this a common technique ? If so, do you prepare multiple billboards for a series of orientations for non-horizontally symmetric meshes (i.e. buildings, where they have a fixed and important game orientation, we want a billboard which is a reasonable approximation of the bulding facade when seen from a particular angle - not truly a billboard I guess but a similar technique) ?

 

Thanks

 

Phillip



Sponsor:

#2 Morphex   Members   -  Reputation: 298

Like
0Likes
Like

Posted 21 December 2012 - 05:29 PM

If I am not mistaken, the technique you are speaking is calling Impostors.

This Article has a great explanation on Impostors: Impostor

You may find it usefull.

Also : Check this one

Edited by Morphex, 21 December 2012 - 05:34 PM.

Check out my new blog: Morphexe 


#3 PhillipHamlyn   Members   -  Reputation: 454

Like
0Likes
Like

Posted 22 December 2012 - 03:43 AM

If I am not mistaken, the technique you are speaking is calling Impostors.

 

Following your links; yes, this seems to be identical to what I'm trying to achieve. However the links dont go into the precise details of rendering the Billboard, other than "use the same technique you use to render your 3D mesh", which is fine as far as it goes, but still doesn't tell me how far away the mesh should be from the camera in order to most efficiently use the render target (i.e. to fill it up).

 

Put it another way; I guess what I am after is an understanding of how the mesh shrinks with distance - I can back calculate from the bounding box to work out how far away my camera must be to generate the largest possible unclipped visual of the mesh, but I'm not at all hot on matrix maths so dont understand what part of the projection matrix gives me this information.



#4 PhillipHamlyn   Members   -  Reputation: 454

Like
0Likes
Like

Posted 22 December 2012 - 09:12 AM

Ok - I'd done all the hard bits but forgotten my basic Trig.

 

The "best" distance to set the Camera location to is (mesh height/2) / (tan(field of view/2)) assuming that your camera is in the centre of the mesh in the X + Y dimensions. This calc provides the Adjacent (Z dimension) value of the triangle where the mesh height is the Opposite and the Projection matrix FOV is the angle.

 

Phillip






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS