knightcrawler25 / GLSL-PathTracer

A toy physically based GPU path tracer (C++/OpenGL/GLSL)
MIT License
1.85k stars 175 forks source link

Light Questions #23

Closed markusmoenig closed 3 years ago

markusmoenig commented 3 years ago

Hi,

I am porting the renderer over to my GPL based SDF modeler / renderer.

I have some questions re data structures for the lights:

For radiusAreaType, x is the radius for sphere lights, z is a switch between sphere and quad lights and Y is the volume of the light source, right ?

Also what would be the best way to support directional (sun) light ? I guess just setting the lightDir variable directly to the direction without any falloff I guess ?

And thanks for the easy to understand source code.

knightcrawler25 commented 3 years ago

Hello,

radiusAreaType.x hold the radius of a sphere light radiusAreaType.y holds the surface area of a sphere or a rect light radiusAreaType.z holds the type of light (0->rect and 1->sphere)

These are calculated here: https://github.com/knightcrawler25/GLSL-PathTracer/blob/a831432ad95982d06e2fed9ac8456f85c29e20b4/src/loaders/Loader.cpp#L169

https://github.com/knightcrawler25/GLSL-PathTracer/blob/a831432ad95982d06e2fed9ac8456f85c29e20b4/src/loaders/Loader.cpp#L174

Admittedly, this could have been written in a better way and the area could have been calculated on the fly using either the radius of the sphere or the two vectors which define the quad.

For punctual light sources like directional lights, you could use lightDir as you mentioned but since this does not have an area, you would not have soft shadows and it might end up looking a bit strange. A sun sky model might be better fit and would provide more control.

markusmoenig commented 3 years ago

Thanks for the fast answer @knightcrawler25

For punctual light sources like directional lights, you could use lightDir as you mentioned but since this does not have an area, you would not have soft shadows and it might end up looking a bit strange. A sun sky model might be better fit and would provide more control.

Ok, thanks for the pointer. I have no experience with a sun / sky model, will try to find some references.