Timeline for Trying to understand how to render a volumetric point light
Current License: CC BY-SA 4.0
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 15, 2021 at 21:46 | vote | accept | mbl | ||
| Oct 15, 2021 at 21:46 | comment | added | mbl | Finally it all comes together :) I definitely learned a lot from implementing this and I probably would have gave up without your help. Thank you!!! | |
| Oct 15, 2021 at 9:37 | comment | added | pmw1234 | Yes, this algorithm requires linear depths. | |
| Oct 15, 2021 at 8:36 | comment | added | mbl | Is it possible that I have to linearize my depth buffer? I am getting values for ‘t0’ that are too high and I am confident that all my inputs are correct. Really running out of ideas :(, but at least I understand the algorithm much better now | |
| Oct 14, 2021 at 22:37 | comment | added | mbl | Yea I spoke too soon there. The equation in the book clearly doesn't normalize vdir in order to get t0. If you normalize it the results are wrong, because a length of 1 is too short, and it scales down the depth value too much, which means the halo looks too opaque. But somehow I have to do that in order to see the halo from any distance in my app. Something must be wrong with my data but I can't tell what it might be. For some reason the camera has to be at a distance of about 1 for the halo to show up. | |
| Oct 14, 2021 at 20:59 | comment | added | pmw1234 | I couldn't find an issue in your code, but, the magnitude of vdir represents the view distance along the ray passing through the halo, by normalizing it that distance is being forced to a value of 1 which would work in some cases but not others. | |
| Oct 14, 2021 at 20:18 | comment | added | mbl | Turns out I'm pretty sure there's a bug in the book. If I normalize vdir at the line float t0 = 1.f + depth / dot(cam_view, vdir); it all works. | |
| Oct 14, 2021 at 12:30 | comment | added | pmw1234 | This is usually related to the geometry of the cube being obscured in some way. Halo's need depth testing disabled to render correctly. Another issue is related to the placement of the halo within the cube, be careful to make sure the cube is centered on the origin rather then being offset from it. Often a cube has only 1 corner touching the origin, this would cause the halo to appear and disappear because it ofset from the center of the cube. | |
| Oct 14, 2021 at 5:11 | comment | added | mbl | I used the pixel world position and it seems to (almost) work! I updated my post with the details. | |
| Oct 13, 2021 at 21:30 | comment | added | pmw1234 | pobject is the position values of the object which is the cube that is being rendered. So compute gl_Position using the mvp matrix and pass the the pobject values down to the fragment shader. | |
| Oct 13, 2021 at 20:52 | comment | added | mbl | Also I should mention, if I pass (0,0,0) to pobject, the result I get seem to be correct in the case where the camera is inside the radius R. If the camera steps outside of this radius, nothing is rendered. | |
| Oct 13, 2021 at 20:40 | comment | added | mbl | Now the last question I have is, what value am I supposed to pass to pobject? From the book explanation, it sounds like I need to pass the current pixel position of the pixel that the box shader is currently rendering. But reading the comment above the description of the function it says: "This shader renders a halo effect of radius R at the object-space position pobject." so it makes it sound like in my case, I should pass (0,0,0). I tried both and neither give the result of rendering the basic shape of the halo. | |
| Oct 13, 2021 at 20:40 | comment | added | mbl | Thank you so much for the explanation! After writing this post I did come to the conclusion that I was supposed to render a box "inside out" but the "inside out" part I wasn't sure what was meant, so your advice to flip the normals clarified that. I am also additively blending. Now at this point I have the box rendering at world position (0,0,0) with the normals flipped. I am using the camera view and position in world space for now just to be safe and since the box is at (0, 0, 0) I should be fine. (continued) | |
| Oct 13, 2021 at 13:32 | history | edited | pmw1234 | CC BY-SA 4.0 | Removed the bit about using origin as it might be confusing. |
| Oct 13, 2021 at 13:19 | history | answered | pmw1234 | CC BY-SA 4.0 |