# Rendering using Linearly Transformed Cosines

Is it possible to get Ray Traced Effects in Rasterized Framework or at the least minimal Ray Tracing

Code Link The fonts used in the images are from my favourite graphics card company Nvidia and the colors used in the renders reflect my predilection towards the other graphics competitors (green > blue > red.)

## Brief Into

Rasterization is widely used method for rendering geometries. To achieve photo-realistic effects it makes suitable approximations, takes scene awarness into account. Many works have tried incorporating the photo-realisim using required approximation namely Spherical Harmonics Lighting.

One of the complex scenario to reproduce in a rasterized setup is as follows:

Simple Path tracing can be used to get the above result using the equation provided below. I have used `Nvidia Optix 7+`

to achieve it.

As the light source present in the scene is an area light(scene is shown below). The work of `[Arvo 1995 Siggraph]`

provides a line-integral based approach for finding the contibution of the area-light in the setting of *direct lighting*.

## Stage 1: LTC’s(Linearly Transfomed Cosines)

Fairly recent, work `LTC [Heitz et al. 2016 Siggraph]`

has formualted a `BRDF`

fitting approch to obtain the *area* light contributions without the tracing rays at the run-time. The renders looks very similar to that of a ray-traced. Specifically in the regions of *highlights*.

#### Brief mathematical Explaination of how it is done?

`(Why not detailled? Just to spare the jargon!!!! Isn't that obvious)`

The approach of LTC(*Linearly Transformed Cosines*) relies on a transformation obtained from the fitting of Cosine samples to that of a GGX.(OK! How does that help?)

Well, once you have such fitting rather than shooting rays into scene and obtaining radiance values like we do in the case of Ray-tracing, we just keep a record of the light in the scene. Now, for every point to be rederered, we project the *area* lights on to the point’s hemisphere, apply a transformation using the matricies fitted using LTC. The transfromed matrix can be used in conjunction with the Linear Integral(Boundary Integral) to obtain light’s contribution effect.

## Stage 2: OK! How to address the lost Visibility?

Look at the picture below.

To obtain the contribution of shadows, the work of `Ratio Estimator[Heitz et al 2018]`

sparsely shoots rays and evaluates of the intergral `with and without`

taking Visiblity into account.

`What does that mean???`

The above equations says:
The first-term `unshadowed analytical evaluation using LTC`

is calcualted via LTCs using prior approch of `LTC [Heitz et al. 2016]`

the rest of terms are obtained via a performing sparse ray-traced estimate using `MIS(Multiple Importance Sampling)`

of *Light* and *BRDF-GGX(NDF)*. The second-term *numerator* is evaluated taking the *visibility* into account and the *denominator* does not take *visibility* into account. The calculation of both terms are using same set of sampled rays.

*BOTH NEEDS TO DENOISED INDIVIDUALLY AND DIVIDED!*

In order to obtain the results of direct illumination in the setting of LTC `Ratio Estimator`

suggests denoising of individual terms of `numerator`

and `denominator`

.
I have used `Optix 7.5`

*deep learning based* denoiser instead of Bilater filter.

We multiply *first term* with the *second term* and get the following result.

Visually we can notice a difference. It is a good approximation of ray-traced direct illumination.

## Stage 3: Is the problem solved??????

Not exactly! What about GI?

I built the `Stage 1`

and `Stage 2`

till now using `Optix 7.5`

and I am currently trying figure out ways to incorporate *GI - Global Illumination* in this setting.

References:

```
[Arvo 1995 Siggraph]: Applications of Irradiance Tensors to the Simulation of Non-Lambertian Phenomena.
[Heitz et al. 2016]: Real-Time Polygonal-Light Shading with Linearly Transformed Cosines
[Heitz et al. 2018 I3D]: Combining Analytic Direct Illumination and Stochastic Shadows
```