• Advertisement
Sign in to follow this  

Shadows by vertex

This topic is 4372 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have an object composed by different meshes with different textures. I want to calculate the shadows and store the values in each vertex to generate the rendering in good quality. My question is, is there any way to calculate the values by code, and not with a 3d modeler? I know that to calculate the shadows I need to define lights. I've been looking for an algorithm that makes the calculation. I found some routines that I didn't test, but I think the routines dont calculate when there is an object in fron of another. Well, I tried to be clear with my explanation, but maybe I don't use the right words to define what I'm looking for because I'm new to 3d programming. If anybody can point me to the solution, I will appreciate. Thanks warpjavier

Share this post


Link to post
Share on other sites
Advertisement
Are you looking for something relatively simple, i.e per-vertex lighting calculations with occlusion for a mesh that will remain static? Or something more advanced, like for dynamic objects?

Share this post


Link to post
Share on other sites
Hi,
Thanks for you prompt reply.
Yes, I'm looking for something simple for static objects, to be more specific for a soccer stadium. Could have just one light representing the sun for the day time or more than one for the night time. I would like to see the shadows generated in the tribune by the roof.

Thanks

warpjavier

Share this post


Link to post
Share on other sites
Quote:
Original post by warpjavier
Hi,
Thanks for you prompt reply.
Yes, I'm looking for something simple for static objects, to be more specific for a soccer stadium. Could have just one light representing the sun for the day time or more than one for the night time. I would like to see the shadows generated in the tribune by the roof.
Ok. I'm not a graphics expert, but I can make a couple of suggestions. Both of the technologies I'll mention here (per-vertex lighting and lightmaps) are becoming a bit dated, but are still viable solutions, I think.

The thing you will need no matter what is a function to determine whether a line segment or ray intersects any surface in your model. This can be a big topic in itself, but I can provide more details on that if needed. The naive method would be to google for 'ray triangle intersection', find an implementation, and then apply this to every triangle in your model. This has two potential problems: robustness and performance. You can address the former through choice of raytracing algorithm, and the latter through a broad-phase step.

Once you have that, you can proceed with either per-vertex lighting or lightmap generation. The latter will be considerably more complicated, but in either case you'll be checking for every point (either every vertex, or every lightmap pixel) whether any lights are incident on it (this is where your raytracing function comes into play), and adding the contribution for that light.

The lighting model can be fairly simple (but must be view-independent, which means no specular component). A good reference on simple lighting calculations can be found here; there's also good coverage in the OpenGL Red Book.

In terms of your original question of how to calculate lighting via code, per-vertex with a simple lighting model is probably the simplest way to go, and even though it's not state-of-the-art, it will improve the quality of your rendering considerably compared to no lighting at all.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement