Tuesday, February 1, 2022

Direct Light 3: what goes in the direct light function?

Part 1 of 3

Part 2 of 3

 

 In the previous two posts I discussed why one might want direct lighting as a separate computation.  But what goes in that function?

If we are just sampling a single light, then we need to bite the bullet and do a Monte Carlo integration with actual probability density functions.  These functions can either be defined over the area of the light, or the angles the light is seen through.  You can dive into all of that later-- it looks intimidating but is mainly like learning anything new with bad terminology and symbols-- just eat the pain :)

But for now, we can do it the easiest way possible and "just take my word for it".  After you have implemented this once, the written descriptions will make more sense.

First, pick a random point uniformly on the surface of the light.  Chapter 16 of this book will show you how to do this for various shapes.

The magic integral you need to solve, often referred to as the "rendering equation" is this:


 The key formula you evaluate is in red.  Area is the total area of the light.  The "rho" is the BRDF and for a diffuse (matte) surface that is "rho = reflectance / pi".   So pick a random point y uniformly on the light, see if x can "see" y by tracing a "shadow" ray from x to y (or vice-versa).  That's it!  It will be noisy for spherical lights (half the time, y is on the back and so will be shadowed, and the cosb will vary a lot), but it will work well for polygonal lights.  Worry about that later-- just get it to work.

What about multiple lights.  Three choices:

  1. do one of these computations for each light and add them
  2. pick one of the N lights at random, do the computation for that one light, and multiply by N
  3. implement reservoir sampling like all the cool kids do (it is a new technique and works really well)

I endorse option 2 as your first step.  

 


10 comments:

Phil Dutré said...

For years I also discussed this in my graphics class, leading students to option 2. And then of course the question: "How would you assign probabilities to different light sources?"

Whatever answer the students give (equal probability, proportional to intensity, distance only, ...) it is always easy to give a counterexample where that doesn't work, because it is hard to set up probabilities for the entire scene at once. And no one ever thinks to insert the visibility term into the probability of picking the light source - so that was/is usually the first homework ;-)

Unknown said...

From the book, this is the code to sample sphere uniformly:

1 a = 1 - 2*u[0];
2 b = sqrt(1 - a*a);
3 phi = 2*M_PI*u[1];
4 x = R*b*cos(phi);
5 y = R*b*sin(phi);
6 z = R*a;

-u[0] and u[1] are the x and y components of the hit point I'm sending the ray from, right?

-And it was also specified that the z value of the sampled point ranges from -1 to 1, I just multiply that with the z value of the sphere light to make it right?

3D Revolution said...

Thanks for sharing such an Amazing post with us, For Professional 3D Townhouse Rendering services in Los Angeles, Visit 3D Revolution Rendering company.

thedraftingexperts said...

nice blog you are sharing very informatics blog i will recommended to all Architectural 3D rendering service provider in California,usa

Eme Academy said...

Really informative! I had no idea how important mentorship is when choosing Power BI training near me. Thanks for pointing that out—super useful.

power bi training near me

onlineAssignmenthelp said...

Coursework is stressful, yet do not have to do it alone. Using The Tutors Help, you are provided with professional advice, high-quality writing, and reassurance. We want to help you pass your studies without the pressure and doubt that normally come with assignments.
Let us take care of your coursework while you focus on learning. Chat with The Tutors Help today and get the best coursework writing service for students!
https://www.thetutorshelp.com/coursework-writing-service.php

Coursework Writing Service for Students

onlineAssignmenthelp said...

If you are searching "do my assignment for me cheap," your search is over. The Tutors Help is here to provide you with quality, cheap assignment help. Do not allow deadline stress and anxiety get the better of you. Let us take care of your assignments as you study and enjoy student life.
Chat with us today, and get expert help at prices you can afford to pay!

https://www.thetutorshelp.com/do-my-assignment.php
Do My Assignment for Me Cheap


Do One Thing said...

Get the best of spiritual peace and fearless style with Apna Showroom’s powerhouse combo. It brings together divine vibes with modern charm: Gangajal Kalash, Feng Shui tortoise, crystal energy, sacred Shaligram Shivling, and sassy fishnet stockings. Apna Showroom Women's net Fishnet Lingerie Stockings - Fishnet Stockings for women - (Black Free Size) Pack of 2
Apna Showroom Baby Boy's and Girl's Night Suit for 0-6 Months Combo Set Pair of 2 (4 Pieces) Newborn Baby Night Suits cotton with desent Look
Apna Showroom Women's Nylon Underskirt Pantyhose Stockings for women - (Black Free Size) Pack of 1
Novasox Ankle High Fishnet Mesh Women Socks, Women Fishnet Mesh Ankle Socks
Apna Showroom Men's and Women's Metal Hair Bands (Black) Combo set of 5
This 5-in-1 set suits the woman who meditates in the morning and commands attention by night. A unique fusion for home rituals or unforgettable gifts. It’s bold, it’s blessed, it’s beautifully you. Shop now and shine from soul to sole.

onlineAssignmenthelp said...

It is a wonderful experience to study in Belfast, but assignment work can prove to be very stressful. You don't have to do it all on your own. By availing The Tutors Help, you receive specialized guidance and high-quality help for all your scholastic needs.
We can relieve you of the pressure of studying. Chat with The Tutors Help today for the highest quality assignment assistance in Belfast and begin attaining those grades that you so rightly deserve!
https://uk.thetutorshelp.com/assignment-help-in-belfast
Assignment Help in Edinburgh

To Gear Business said...

Best interior and exterior industrial painting solutions surrey