Planar mapping and normals

Started by
21 comments, last by jpventoso 15 years, 11 months ago
Quote:Original post by JakeM
Quote:
This makes me unable to interpolate the vertex normals, as the projection on the plane for the lightmap may vary depending on the position values for each vertex.


How do you plan to use this interpolated normal? Are you trying to project it to 2D? If so, why?


He wants to know how bright a particular spot should be, using a particular lighting technique, and you need to know what the normal for that particular spot is. The more the normal points towards the light source, the brighter it should be. Even though the mesh isn't smooth, this method can give the illusion of smoothness.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Advertisement
Quote:Original post by erissian
He wants to know how bright a particular spot should be, using a particular lighting technique, and you need to know what the normal for that particular spot is. The more the normal points towards the light source, the brighter it should be. Even though the mesh isn't smooth, this method can give the illusion of smoothness.


I know, you can do all of that without projecting the plane to 2D. I still don't see the problem he's talking about.

Quote:Original post by JakeM
Quote:Original post by erissian
He wants to know how bright a particular spot should be, using a particular lighting technique, and you need to know what the normal for that particular spot is. The more the normal points towards the light source, the brighter it should be. Even though the mesh isn't smooth, this method can give the illusion of smoothness.


I know, you can do all of that without projecting the plane to 2D. I still don't see the problem he's talking about.


He's doing this, ultimately, for a light map, so he needs to be able to take this information and use it in texture-space.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Your algorithm greatly improved things (I'm now a step closer to a real phong lighting :) ), but as it can be noticed in this capture, a lighting difference between each triangle still remains:



I think this is due to the location of each triangle within the Lightmap (cases of the diagrams on my previous post), and I couldn't find a solution to this problem yet...

Erissian, do you use planar mapping to generate your Lightmaps (if you're using any)?

Thanks again!
Quote:Original post by jpventoso
Your algorithm greatly improved things (I'm now a step closer to a real phong lighting :) ), but as it can be noticed in this capture, a lighting difference between each triangle still remains:

I think this is due to the location of each triangle within the Lightmap (cases of the diagrams on my previous post), and I couldn't find a solution to this problem yet...


This last bit is now a problem with the interpolation. The triangles appear discretely because they are still treated as a plane defined by the vertexes, although the light is generated smoothly across that plane. For the final step, it will be a little harder because you now have to interpolate not across the shape of the model, but across the shape that the model represents. This will require spherical linear interpolation (slerp) between the three vertexes.

Quote:
Erissian, do you use planar mapping to generate your Lightmaps (if you're using any)?

Thanks again!


Sometimes, yes. It depends on the project. For instance, if I were rendering planets I would use two lightmaps that represent the planet's surface and the light from the star(s), the latter of which rotates with time, and multiply their values. Shadows from most objects are a non-issue, and until you are very close to the surface, lighting just isn't that dynamic.

Also, building interiors with fixed lighting. There's no sense in calculating the lighting in a scene every time you render several dozen static objects.

Also, no problem!
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Quote:Original post by erissian
This last bit is now a problem with the interpolation. The triangles appear discretely because they are still treated as a plane defined by the vertexes, although the light is generated smoothly across that plane. For the final step, it will be a little harder because you now have to interpolate not across the shape of the model, but across the shape that the model represents. This will require spherical linear interpolation (slerp) between the three vertexes.


OK, but, when I use per pixel lighting with shaders, I thought that I was only doing a linear interpolation. I'm asking this because, when I use shaders, this problem does not occur.

Or perhaps it is happening due to the fact that lightmaps are calculated at a lower resolution and thus loses definition on the edges?

Quote:Original post by erissian
Also, building interiors with fixed lighting. There's no sense in calculating the lighting in a scene every time you render several dozen static objects.


I wanted to implement lightmaps for the same reason, to increase performance by reducing the lighting calculations when the environment is static, and also to generate soft shadows (I'm having problems with this last item but that will be a new topic :) ).

Thanks again for your help!
Quote:Original post by erissian
This will require spherical linear interpolation (slerp) between the three vertexes.


What's the equation for slerping 3 vertex normals?

Quote:Original post by JakeM
What's the equation for slerping 3 vertex normals?


I'm interested in that as well...
The trick isn't slerping between three points (you slerp between two and then slerp between that answer and the third point), it's doing it so that the points are evenly distributed. This is how you iteratively slerp through a triangle using two coordinates:

Let's call our verts A,B and C. We'll use two coordinates, t and u. n will determine the number of individual points you want to sample, per ½(n-2)(n-1)

//pseudocode, returns Rn = some integerf = 1/nfor t=0:n  if t==0    R = A  P = slerp(A,B,t*f)  Q = slerp(A,C,t*f)  g = 1/t  for u=0:t    R = slerp(P,Q,u*g)


It may help to look at a ternary plot to get an idea of how it walks through the triangle. Also, it would be foolish to implement this literally - you can optimize it quite a bit by working through the math and reducing.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Quote:Original post by erissian
Let's call our verts A,B and C.


Are ABC vertex normals or quaternions? If they're quats, how did they get from vector to quat?

This topic is closed to new replies.

Advertisement