-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Just wondering how you handled something #68
Comments
@Pjbomb2 About the crepuscular(ah, such a flowery scientific word) rays, I'm going to have to clarify with you a little further so I can exactly know what the problem is. To make sure I am understanding correctly, is the problem that you do not want objects behind the crepuscular rays(let's just call them 'light shafts' from here on, ha) getting brighter? If that is indeed what is happening, then there might be a small error in your shader code. If you look at my Volumetric Rendering Demo with the two spheres in a red and blue Cornell Box that is surrounded by blueish fog, the light shafts are actually not a physical entity. It's more about the shadows from objects blocking the light source that gives the pretty shafting effects. If you remove the light blockers (spheres in my case) from the scene altogether, your scene should have a slight light gray, or blue, or yellow (whichever mood you're trying to set) fog around the entirety of the scene. It's exactly like classic OpenGL fog: the closer you are to an object, the clearer (and possibly brighter from color saturation) the object will be. As you pull the camera backwards, the farther you get from the object, the more de-saturated and hazy (and possibly darker) the object will become. If you have this fog mechanic working, you are ready to add the shadow shafts (and resulting crepuscular ray effects). When you place the blocker near the light source, shafts of dark areas should appear underneath the blocking object. These shadow shafts will start small and tight, hugging the bottom of the blocking objects, and then will increase in their radius as your eye follows them down into the depths of the scene. It's a little bit of an optical illusion because normally when we see 'God' rays coming dramatically through openings in cloud cover, our eyes 'see' the light areas that are not shadowed, and our attention is drawn to those, and they become almost real objects themselves- but in reality they are just part of the whole scene background fog lighting, and actually it's the shadow shafts that make the seperate areas of light vs dark, so that the shaft effects are even visible. In other words, nothing should be getting unusually brighter or clearer, just because they happen to be in or behind a light shaft (which is not a real thing, remember). The only thing that should happen, is if they are directly in the shadowed volume (or dark shaft),, they will not be able to directly see the light source, and therefore will indeed appear darker than other objects that can see the light source directly. Let me know if this sums up the issue you're facing, or if not, please clarify further, possibly with a PRTSC screenshot from your computer, posted here in the comments. Additionally if you like, you can create a GitHub Gist and copy and paste your shader there with a public link so I can read through it. I will say that Volumetric Rendering was one of the most challenging topics for me personally, just to make everything work and look right, without any obvious artifacts. The Volumetric sampling function I use, I copy-pasted from a Shadertoy demo (ha), who's author copy-pasted it from a Solid Angle team (famous for their Arnold renderer) research paper (double ha). I don't fully understand how this Volumetric 'equiangular-light sampling' function does its magic, but it works like a charm and it's freely available, so I use it! 😉 Looking forward to discussing this issue with you further. 🙂 |
Oh! That's a cool use-case project you have there! Are you using the volumetric lighting inside some kind of engine, like Unity or Godot? Or is this captured from a browser with WebGL? I really like the scenery geometry and the light shafts are a perfect touch for this kind of environment. Reminds me of an id Software Quake-type game - good work so far! Thank you for posting the helpful video and screenshots. I can see better now the issue you are trying to solve. As I mentioned before, Volumetric Rendering is not my strongest area, but I might have some tips for you. The 1st screenshot with the tapering horizontal light shaft shows 2 issues:
Hopefully this makes sense, and maybe you could check over your shader's ray-bounces loop to see if all these elements are in place. Is there a way you could share the shader code with me on a GitHub Gist? I like Gist a lot for this kind of thing, and it's easy to create a Gist (+ icon in upper right corner) and then copy, paste , and get a shareable link that you can post here in the comments section. I think that would help a lot, to be able to see the bounces loop myself. Talk to you soon! |
This does make sense! thank you! and the scene in the screenshot I got from sketchup, you can find the exact link on my github, but its like 1ish million polys |
@Pjbomb2 What back-end engine (Three.js, Unity, custom?) and what back-end language are you using to render all this geometry? Does this run in the browser, or is it a native C++ app? |
One more note, if you are doing real-time rendering (like for a game), then you may want to consider some sort of simple de-noising. In all of my demos, I use a simple custom-made one that you can feel free to use/copy/learn from. It's located in the ScreenOutput_Fragment.glsl file, which is in my shaders folder. I do a simple box-blur filter for all diffuse surfaces, and then for specular surfaces like glass, metal, etc., keep those at sharp resolution (no filter applied). The tricky part is handling the boundaries between diffuse (blurring is desired) and specular (blurring is to be avoided). For this, an edge detector is required - which I also have in place. The edge detector is in the main() function at the very bottom of the PathTracingCommon.js file in my js folder. It takes some tweaking on a scene-by-scene basis, but it makes a huge difference, especially for real-time dynamic scenes. Speaking of the old Quake series again, my inspiration for this was NVIDIA's insane real-time Quake RTX demo a couple years ago. This real-time denoiser is much, much more sophisticated in that it re-uses diffuse pixel samples and re-projects them for the next frame when the camera moves. I believe Minecraft RTX also does something similar with its shaders. I'm not at that level of wizardry yet, so I just have my simple custom denoiser that makes a good impact, without a lot of extra algos and code. But someday, I would love to be able to do what they did with Quake RTX. That would look incredible with your scene! |
Ok so, sorry for delayed reply, got distracted, and this is using unity only for things like mesh and texture loading, everything else is custom and can be found on my github under the reposityory "[Compute-Shader-Unity-PathTracer", ive tried to make a pathtracer that performs well, is completely compute based(so no rtx hardware used, itll even run on integrated graphics(have tested this)), and is realtime. Currently my denoising options are atrous for static scenes, but that messes with color due to the multiply by albedo at the end of it, and SVGF for dynamic scenes(tho I either need to tune it heavily or find something else, as it takes 13ms at 1080p and is still very very noisy for scenes with lots of lights/fireflys, but when it works, god is it magical), currently best performing scene is intels new Sponza, around 5 million triangles with the curtains, running at a steady 40 fps at 1080p on my system(3080 mobile) |
Wow, that sounds great! Although just dabbling in it, I really like Unity's streamlined interface/editor. That's really cool that you are using the strengths of Unity for engine-related stuff, and then using real time path tracing shaders on top for realistic rendering. I wish I could help further, but as I mentioned I don't have very much experience with Unity, let alone their shader system. But feel free whenever to share a shader (even if it's not in GLSL, I can sort of make it out) if you want. I would love to incorporate the ASGVF you mentioned into my renderer, but before I could do any porting, I would have to understand how it works at a detailed level, in order to make a successful js/GLSL port. In any case, hopefully you can check out how I did my simple denoiser here. I literally started from 0. Like most things on this project, I feel a need to understand the algos/code before I drop stuff into the codebase. Since there were no tutorials on how to make GLSL denoisers, I rolled my own! Lol. Best of luck - please keep me informed if you find a solution to the volumetric lighting issue! -Erich |
Thank you so much! Ill try the aditional kernel, and for me ive never been able to go off papers, ive usually had to have code to look at to implement something, but ASVGF is truely quite magical |
That's looking better! I'm not sure what values are good general values for their (Solid Angle team's) equations. Your cool images have inspired me to try a little experiment - I will try setting up a very simple scene, but with lighting effects that resemble your first horizontal beam screenshot with small window opening on the right wall. I may just put 2 spheres on the ground at the back of a Cornell Box room, then place a small square opening on the right side of the box, and a strong light source just outside of the window. I'll place dusty fog around the scene and see if I can get the result to look how I imagine it would be. I'll also check that the beam in front of my room test scene does not overly wash out or artificially brighten the 2 sphere objects behind it. Will be back in a day or two with hopefully some results. In other words, I'm going to put the Solid Angle team's equations to the test! Ha! 😁 |
The results are promising in that they match what I was seeing in my mind's eye before I created the scene. The 1st image shows how the light beam needs to fan out like a flashlight or spotlight. The 2nd image shows 2 things: that the beam itself is an optical illusion - it is just part of the background fog and should match the background exactly. And since the camera is pulled back from the scene, you can see the white and yellow spheres have been increasingly obscured and desaturated with dust particles. The 3rd image shows that the beam does not alter the lighting or shadows for the scene objects behind the beam. This is physically correct behavior, as far as I can tell. All the beam should do to objects behind it is maybe tint them ever so slightly - in my scene's case, a hazy blueish color. But it's almost imperceptible. The last image shows the camera placed directly in the light beam's volume. Again, the background objects may get a slight blueish tint, but reflections, color, and shadows are all intact. BTW, the reason for the extra rectangle panel light over the spheres is to give them very visible contact shadows (and a reflection highlight in the yellow sphere). So in conclusion, I guess the team at Solid Angle (Arnold renderer) knew their stuff and therefore deserve whatever pay they're getting! LOL Here's a live link to try it out for yourself: And the main shader source code file is here Let me know if you have any questions about the shader. I really didn't alter it that much from my old demo (just took out volumetric caustics and replaced sphere lights with rectangle lights). -Erich |
OOO thank you! I think I mostly fixed the volumes, not sure on my end, but one thing is that th light source was technically infinitely far away, as its a directional light, so much more concentrated, bout to update my github again tho as im mostly happy with it |
Hey, so sorry for the issue, but I dont know how else to contact you. Ive been trying to roughly copy what you have with the volume rendering for rendering things like crepuscular rays, but ive been having a major issue that im out of ideas for of how to solve, so I figured I should ask you. My issue is that the crepuscular rays seem to brighten the objects behind them, but in a way that makes them more clear, as well as being closer to a light source makes the entire environment around me physically brighter. I was wondering if you ran into this kind of thing, and if so how you handled it? thank you! and sorry for the trouble, but this project is absolutely amazing!
The text was updated successfully, but these errors were encountered: