[Glsl] Spherical Area Light For Ggx Specular

Started by
2 comments, last by Hodgman 7 years, 9 months ago

I have a GGX shader for specular highlights.

I have some point lights.

I already have attenuation calculation for spherical area lights.

I yet don't have area light calculation for specular. And I don't know how to calculate it correctly.

Would be nice to get some help! :)

Note. GGX specular is inside DisneyBRDF-like shader.

Advertisement

The easiest solution is the "representative direction" method, though it's not accurate when it comes to energy conservation (overall, it will be too bright, especially for large sphere), etc... but is still a good place to get started :)

* First calculate the reflection direction like you would for Phong specular (R = reflect(V,N)).

* Form a ray originating from the surface and traveling along this reflection direction.

* Find the closest point on the sphere to this ray (or: find closest point on the ray from the center of the sphere, then the closest point on the sphere to that first point).

*^ If the ray intersects the sphere, the answer is either of the intersection points between the ray and the sphere!

* Create a new "representative reflection direction", which is the direction from the surface to this point on the sphere.

* Run your specular code as usual (for a point light), but use this "representative reflection direction" as the lighting direction.

With a zero-sized sphere, the representative direction will always be equal to the original lighting direction, so you get the same results as a point light.

With larger spheres, the lighting direction gets shifted a little bit so that every surface is getting lit by a slightly different point light -- one that's placed somewhere on the surface of your sphere, to give the impression that there's actually a sphere-light in your scene :D

Uh... Not as easy as I thought. Appearantly the physics of a tire is a bit simplier topic:D

Well, what is the math for ray intersection test? I have never ever made raytracers or anything like that.

Well, what is the math for ray intersection test? I have never ever made raytracers or anything like that.

It's not that complex in this case.

Use this to compare the line (x1 = surface, x2 = surface + reflection) with the center of the sphere:

http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html

The resulting point will be inside the sphere in the case of an intersection.

e.g. bool is_inside = distance(sphere_center, closest_point_on_line) < radius

If that's true, use the reflection direction as the lighting direction.

Otherwise, find the closest point on the surface of the sphere to the above point:

http://math.stackexchange.com/questions/324268/how-do-i-find-the-nearest-point-on-a-sphere

This topic is closed to new replies.

Advertisement