# Willywill

Member

22

264 Neutral

• Rank
Member

• Interests
Programming

## Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

1. ## Simple Solar Radiance Calculation

This helps immensely! Thanks a lot for the lengthy post, I'll start integrating it into my sky solution. I can't thank you enough, and I love all the work you do    I'm actually surprised that I understand it all. My current sky solution is based on the Preetham model and does not account for ground albedo, I'll see what I can do about integrating that as well. But again, everything you mentioned helps a lot!
2. ## Simple Solar Radiance Calculation

Hello everyone      I recently just made a sky and cloud shader, so I have a day night cycle being worked on, it is lacking something though.   I just read through The Order 1886 slides from Siggraph 2015 and they mention an accurate solution to calculating the sun color and intensity based on its location in the sky.   Slides here (slide 71): http://blog.selfshadow.com/publications/s2015-shading-course/rad/s2015_pbs_rad_slides.pdf   They used the solar radiance function mentioned in the Preetham sky model...   PDF here (starts at page 26):  http://www.cs.utah.edu/~shirley/papers/sunsky/sunsky.pdf   And it all sounds nice but looking at the math it becomes a little confusing.    I am assuming I need to make some assumptions for some of the variables to make it a little easier to code.   The color needs to be set as a Vector3 on the CPU side, and the intensity as a float or double. I am thinking this should be computed occasionally using a compute shader? I have a day night cycle where the sun is moving so I'll need these values every few frames.   But I don't see how to get these values from the function provided, or if that is even the correct function at all. Just hoping someone could point me in the right spot   Thanks for your time guys
3. ## Disk Area Light

Sorry for the double post,   I have this here but I'm still confused on how I can scale the distance to the radius of the disk Center = lightPos Projected point = P Disk radius = R float3 P = projectOntoPlane(); float3 closestPoint = distance(P, lightPos) < R ? P : (Scale distance to the radius); My assumption is, if we are looking for the distance to be less than the radius, the failure case is saying we are greater or equal to the radius, so we need to subtract it by the amount that we overshoot?   EDIT: I solved the problem! Thank you everyone for your help!     From left to right: Tube, Disk, Rectangle, Sphere   For a solution just see DICE's frosbite PBR slides, I took the approximation from there and combined it with the rectangular light code.
4. ## Disk Area Light

Not really, but it's the fastest approximation and nobody usually notices issues with it, anyway. It will look slightly wrong for surfaces near the light due to normals being shaded from just one direction, not the whole volume.   Ideally you'd want to sample the lighting from multiple (as many as possible) points in the light (or use more advanced equations to account for light direction "cone") to get accurate shading but I'm sure you can see why it's rarely practical.   P.S. For more accuracy, you might want to try raycasting the plane using the normal as ray direction.     Thanks for the heads up, that approach sounds similar to what I saw with what DICE was doing. I avoided it because I thought it was cost prohibitive and they showed lots of ugly overlapping in their screenshots from the different light sources. Is there anyway to get better blended results from that?   Their example using multiple sources:         Sorry for the misleading variables, If there are two thing I absolutely suck at, its matrices and converting math to code, I had just used some older code for the projection math. And surprisingly it worked just fine my first try. I removed the lightPos and it had no effect, I'm not sure why it was there in the first place.   Are there any tools graphics programmers use to help aid them with calculations such as these? I've seen someone mention MatLab but I have no idea how that works, and other visualizers.
5. ## Disk Area Light

Thank you for the very speedy reply is it really that simple? I guess I have a hard time following the terms and what exactly they mean. I have the rectangle closest point here based from the latest Frostbites PBR slides. I never went to school for graphics programming and I taught myself I'm assuming the projected a point onto a plane is the planeIntersect variable that I have there? As for the distance check that was clearly understood. Thanks again for your help! half3 dir = pos - lightPos; half3 planeIntersect = (pos - dot(dir, _LightNormal) * _LightNormal) - lightPos; half halfWidth = _LightWidth; halfWidth *= 0.5f; half halfHeight = _LightHeight; halfHeight *= 0.5f; half2 dist2D = half2( dot(dir, _LightRight), dot(dir, _LightUp) ); half2 rectHalf = half2(halfWidth, halfHeight); dist2D = clamp(dist2D, -rectHalf, rectHalf); half3 closestPoint = (lightPos + (_LightRight * dist2D.x + _LightUp * dist2D.y)) - pos;
6. ## Disk Area Light

Hello everyone,   I have just a quick question. I wanted to make sure I ask so I don't forget as it's on my to do list. I can't seem to find out how to get the closest point on a disk. I have tried to find papers that cover this topic but to no avail.   If someone could guide me in the right direction it would help a lot! I already have Sphere, Tube, and Rectangle area lights.    I have a great set of math skills but I don't know how to apply it in this scenario, or have any tools that can help me calculate the closest point.   Thank you for your time!
7. ## Procedural Cloud Rendering

Haha thanks guys,   After testing the waters I think I have come up with a few ideas. I really appreciate all of your input.   What I have decided to do after a couple of days of research is use 2D fractional browning motion noise. The clouds only really need to be 2D, and I really should have mentioned that in the OP.   As of now I have a 2D noise function that can generate x amounts of octaves on the GPU. With this information I need to project it in the sky in such a manner that it looks believable. My sky shader uses a bit of a hack to fake the earths curvature. I tried using the same method and got weird seems in the center of the sky and clouds would peel apart and come out from there. I can always just resort to a 2D plane of course.   One last thing I struggled to find is how to create realistic cirrus clouds. My end result I'm looking for maybe 2 layers of these clouds, some very high altitude clouds and lower altitude cumulus ones. I have yet to find sufficient enough research on cirrus clouds.   PS: Your video looks amazing Lightness, I actually have been following that software for quite some time!   Do you have any advice for the shading aspect of clouds? Also any tips for night time sky rendering? My sky lacks that as of now.

9. ## Screen Space Reflections... Again?

I have read your article and it was very useful, thank you very much!
10. ## Simple volumetric lighting

Hmmm, from going over these slides here, it appears you multiply by the visibility function, in your case the availability. It also shows you raymarch from light space. There are full slides linked below with notes.   I haven't actually got around to implementing it yet but this was on my to do list. I hope I helped somehow     http://bglatzel.movingblocks.net/wp-content/uploads/2014/05/Volumetric-Lighting-for-Many-Lights-in-Lords-of-the-Fallen-With-Notes.pdf
11. ## Ambient occlusion, have we been doing it al wrong?

Interesting, my noise approach is the one from Activisions new Call of Duty. They call it interleaved gradient noise. It's very easy to blur. But I'm going to attempt to skip the noise and see what my results are.
12. ## Ambient occlusion, have we been doing it al wrong?

Wow this is very interesting. I just recently implemented HBAO. I used 3x3 and I am curious as to why you receive such a huge benefit. What did your original method use in order to reduce banding?
13. ## Implementation of Analytical Lighting

http://en.wikipedia.org/wiki/Planck%27s_law   In short, Planck's law describes how much energy per wavelength in the visible spectrum (or outside it for that matter) is emitted by a black body (a nonreflective body in thermodynamic equilibrium with its surroundings, don't fret too much about that, it's a sufficient approximation of reality for computer graphics purposes) at a given temperature, you integrate that power spectrum via a wavelength to RGB (or XYZ) reference table to obtain the corresponding RGB (or XYZ) color, and the color can perhaps be precomputed for each temperature of interest. That spectral conversion part is what the article Spiro linked discusses, so I think the physical basis for the temperature curve was what you were missing.     Ok gotcha, thank you very much! I just need to figure out the spectral conversion part . I've read enough of Reinhard's references to know about CIE, XYZ to RGB conversion
14. ## Implementation of Analytical Lighting

Isn't there a much easier way, now that I think about it? How about a LUT that has that ramp, and I just sample the ramp based on temperature?   The issue is what function would I use in order to sample the color based on the temperture chosen?
15. ## x

#1: Learn Direct3D instead. #2: Never use OpenGL extensions. They are good in theory but just a headache in practice. Use core profiles. #3: Forego the fixed-function pipeline. Only use shaders. #4: Start simple with a clear and small goal in mind. Aim to make spinning blocks and a moving character before considering making that next big flop MMORGP. #5: Writing crappy code is only a problem for those who never scrap their code and start from scratch. You are going to have to throw away everything you have done at some point once it becomes to unmaintainable, so get used to the idea from the start. #6: Linear algebra isn’t actually necessary prerequisite knowledge as everyone claims. It is extremely useful, but you will learn it as you go anyway. #7: Graphics programming is hard.  It is the hardest form of any profession in the universe in any field ever in history and beyond.  Get used to being frustrated. #8: Learn to use graphics debugging tools such as RenderDoc or PerfHUD. #9: Learn to debug using colors as outputs from shaders.  Remember that negative values appear as black. #10: Learn how to ask questions.  This is likely the most important.  Explain what the problem is and what you have done to try to solve it.  Post relevant code only.  Post images when helpful.     L. Spiro      I agree with a lot of this but OpenGL isn't bad at all. Most likely Czar will end up learning them both like me, which is very useful when getting stuck, if something is in OpenGL I won't freeze up and get nausea from looking at the code, I can use that and translate it to Direct3D, HLSL, Cg etc.   I recommend what ever suits you best. On a superficial level, its so similar that it doesn't matter that much. My experience with OpenGL was pretty ok, although very fraustrating. I did begin with Direct3D and HLSL though because, well I bought into the fake DirectX hype going on at the time with Crysis 1