Jump to content

  • Log In with Google      Sign In   
  • Create Account


Create a LightMap with raytracing


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
7 replies to this topic

#1 tpastor   Members   -  Reputation: 121

Like
0Likes
Like

Posted 13 November 2012 - 07:14 PM

hi,
I want to create a light map render using ray tracing for learning purpose.
I already builded the raytracer part, but i dont know how to generate the lightmap from that.
Today, i just throw the rays from my camera, calculate the intersection, shading, throw extra rays ....
But how do i use this to generate the lightmap ?
Do i need throw rays from each texel of my model's texture ? (how many rays should i throw ??!!) Is this the right way ?
And, to "throw rays from each texel of my model's texture", do i need to rasterize my triangles, get the generated position, them throw the rays ?

Thanks !!

Edited by tpastor, 13 November 2012 - 07:37 PM.


Sponsor:

#2 Vilem Otte   Crossbones+   -  Reputation: 1274

Like
0Likes
Like

Posted 13 November 2012 - 07:54 PM

First of all you *need* to create texture coordinates for your lightmap (unless you already have them). For more information on how to unwrap your environment to lightmap read for example here - http://www.blackpawn.com/texts/lightmaps/

Now for each pixel in the lightmap, there exists "microfacet" in your scene, and you compute light for that microfacet using your ray tracer.

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com


#3 tpastor   Members   -  Reputation: 121

Like
0Likes
Like

Posted 13 November 2012 - 08:04 PM

In resume:
i have model that already have UV mapping.
I need to read the texels of my "empty" lightmap, find the model position associate with it and then use the raytracing in this position.
Do this for all my texels and thats it ??!!

Thanks !

#4 MrOMGWTF   Members   -  Reputation: 433

Like
0Likes
Like

Posted 14 November 2012 - 12:44 AM

First of all you *need* to create texture coordinates for your lightmap (unless you already have them). For more information on how to unwrap your environment to lightmap read for example here - http://www.blackpawn...exts/lightmaps/

Now for each pixel in the lightmap, there exists "microfacet" in your scene, and you compute light for that microfacet using your ray tracer.


Assumming that your whole world is made out of quads...
Is there any method for packing triangle world in to lightmap? Maybe I should just find every 2 triangles that has similar normal, and then assume those two triangles are one quad?

#5 MJP   Moderators   -  Reputation: 8752

Like
2Likes
Like

Posted 14 November 2012 - 02:24 AM

I need to read the texels of my "empty" lightmap, find the model position associate with it and then use the raytracing in this position.
Do this for all my texels and thats it ??!!


You actually need the position and normal, since you need to trace rays through the hemisphere surrounding the normal to calculate the total irradiance incident on the texel. Also in practice you'll find that it's actually not so simple to determine the position and normal for any given texel. To do it you need to figure out which triangle that the texel is mapped to, figure out the barycentric coordinates of the texel relative to the triangle, and then use those barycentric coordinates to intepolate the position and normal from the vertices. To make things even more complicated you'll often have multiple triangles overlapping a single texel, which means you have to be able to either consistently choose which triangle to use or you have to blend between the results from both triangles. One common way to do this is to rasterize the geometry in UV space. This lets you perform the interpolation as a normal part of the rasterization process, and you can also use standard rasterization techniques to choose which triangle to use or to even analytically compute the triangle coverage. You can even rasterize on the GPU if you want, although you'll probably want to use more than one sample per pixel since GPU's don't use conservative rasterizers.

#6 MJP   Moderators   -  Reputation: 8752

Like
3Likes
Like

Posted 14 November 2012 - 02:25 AM


First of all you *need* to create texture coordinates for your lightmap (unless you already have them). For more information on how to unwrap your environment to lightmap read for example here - http://www.blackpawn...exts/lightmaps/

Now for each pixel in the lightmap, there exists "microfacet" in your scene, and you compute light for that microfacet using your ray tracer.


Assumming that your whole world is made out of quads...
Is there any method for packing triangle world in to lightmap? Maybe I should just find every 2 triangles that has similar normal, and then assume those two triangles are one quad?


It's a fairly complex topic. You can read through this to get an idea of the headaches involved, as well as possible solutions.

Edited by MJP, 18 November 2012 - 11:51 PM.


#7 tpastor   Members   -  Reputation: 121

Like
0Likes
Like

Posted 18 November 2012 - 06:53 PM

hi,
thanks for the answers (specially MJP), they helped me to make some real progress (i finally got something working !!!)
But now that i am implementing some stuffs ... some new doubts are raising... (iam too much "ad hoc", i want to know if what iam doing is the right way to do !)
Instead of making some more questions here, i would love if someone point me a good book or a project that does the simple thing i want to do (a light baker with raytracing -- not the illumination calculation part ...)

Thanks !

#8 MJP   Moderators   -  Reputation: 8752

Like
0Likes
Like

Posted 19 November 2012 - 12:16 AM

I don't know of any projects that you could download. You could definitely take a look through some of the material in Principles of Digital Image Synthesis, as there is definitely some relevant sections in there.




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