Luminance Analysis Questions.

Forums: Luminance Analysis Questions.
Generic forum to discuss Octane Render, post ideas and suggest improvements.
Forum rules
Please add your OS and Hardware Configuration in your signature, it makes it easier for us to help you analyze problems. Example: Win 7 64 | Geforce GTX680 | i7 3770 | 16GB

Luminance Analysis Questions.

Postby MB » Tue Sep 19, 2023 4:23 pm

MB Tue Sep 19, 2023 4:23 pm
I have been working on a Lua script to analyze Luminance values within rendered images directly inside of Octane.
It is fully functional now and I will share the script with the community after posting these questions. It would
be great to get feedback from others as to the validity of my approach. The mathematics is not particularly difficult,
but never-the-less needs to be correct id=f the script is to be of any use. It would be great if someone from Otoy who
understands the mathematics behind deriving the RGB values in a beauty pass to check the logic described below. I would
also be interested in connecting with someone else who does this sort of thing in their job and who could validate the
results against other products that offer this capability, for instance V-Ray and Revit.

Thanks.


**********************************************************************************************************
**** The Theory
**********************************************************************************************************
Assumptions.
A rendering application calculates the color and intensity of the light reflected by a surface to paint a pixel
in the plane of the view that the reflected light happens to pass through on the way to the observer's eye.
However, this calculation is not what is normally displayed to the observer. The calculated color and intensity
is a component of the information supplied to a monitor to tell it how to configure the pixel for the observer.
In order to better represent reality to a human observer, the color and intensity are mathematically manipulated
to align with characteristics of human visual perception, the monitor, and efficient storage of the data in a
process referred to as Tone Mapping. If we can access the color and intensity data prior to any mathematical
manipulation, we should be able to extract some information useful to the lighting designer's needs described above.


Methodology. (Or how do we do this utilizing the capabilities in Octane? Otoy, please critique this)
In Octane, the raw color and intensity data is only visible when tone mapping is removed, and other settings are correct.
To visualize this information, the response curve should be set to Linear/off, and the Gamma to 1. Other settings also
need to be neutralized. Exposure should be set to 1. White light spectrum should be set to D65. Kernal to path tracing.
(Others?)

The equation for calculating the amount of light reflected by a surface using its RGB channel information is
179 * (0.265*R + 0.670*G + 0.065*B) lm/w, where R,G & B are linear, linear meaning normalized (0-1), gamma free RGB values.

See this web page for additional information:
This is the luminance value of the original diffuse Map calculated per LBNL Radiance software.
https://discourse.radiance-online.org/t ... icacy/1400

If we make the diffuse image's RGB values linear, i.e. normalize the sRGB values beforehand, by dividing them all by their
possible maximum value of 255 and then converting them back to sRGB the equation produces a theoretical maximum of 45645 lm/w.

-- What is stored in the luminance image.
((0.265 * lR) + (0.670 * lG) + (0.065 * lB)) * 255
-- What is reported in measurements where lR,lG, lB are linear (normalized, gamma free RGB) color channel values.
179 * (0.265 * lR + 0.670 * lG + 0.065 * lB) * 255

(Again can someone please confirm this, I cannot find any mention of these inputs needing to be
linear when this equation is discussed, however there is plenty of discussion around similar equations used to
mathematically manipulate sRGB pixels and how they should be made linear beforehand, essentially manipulate in linear color space,
but display in sRGB color space).

Currently the script determines the Luminance using pixels resulting from a Render Target
setup as follows.

Kernal.Type = Path Tracing
Kernal.White light spectrum = D65
Imager.Exposure = 1
Imager.Vignetting = 0
Imager.White point = 1,1,1
Imager.Saturation = 1
Imager.Response curve = sRGB
Imager.Gamma = 1

It samples the pixels in the Beauty Pass to produce an effectively untonemapped greyscale image that it calculates
internally by removing the Gamma (an sRGB with a gamma of 1 is equivalent to a linear/off image with a gamma of 2.2,
by removing the Gamma we have internally the same thing as Octane's linear/off version of the beauty pass that we
can then use to calculate the Luminance of each pixel).


Step 1, Normalize and Remove the Gamma.

For each pixel get the 3 channel values (sR,sG,sB) from the Beauty Pass and feed them to the following function.
The resulting gamma free normalized color component (nC) in the range of 0-1, equals the result of this function
applied to the sRGB input component (sC) in the range 0-255.
nC = ((sC/255) <= 0.04045 and (sC/255)/12.92 or math.pow(((sC/255)+0.055)/1.055, 2.4))


Step 2, Display the 'Luminance' image.

For each normalized channel value above, include it in the following equation and multiply the result by 255 to
get it back to sRGB so it can be displayed in an Octane LDR_MONO, or an Octane LDR_RGBA image type.
greyLumens = (0.265*lR + 0.670*lG + 0.065*lB) * 255, where lR, lG, and lB are linear (normalized, gamma free RGB)
values.

This result can be used directly to set the pixel value in a greyscale/monochrome image type and displayed on
screen, or it can be converted to a 4 component vector for use with an sRGBA image of type Octane LDR_RGBA as
follows. clrLumens = {greyLumens ,greyLumens ,greyLumens ,255},(looks grey on screen but can have color themes applied).

This image is still Gamma free and should be visually equivalent to an Octane image with the response curve set to
Linear/off and Saturation set to 0. When you look at the image on the Luminance Image Tab in the application,
each pixel represents this number.


Step 3, Report the Luminance values to the user.

Sample the pixels in the Luminance image, if it is a greyscale image, multiply the sample value by 179 to get
the value in lux. If it is a color image, multiply any one of the channel values in the sample by 179 to get
the value in lux, thus any measurements reported by the application are the result of this equation
179 * (0.265 * lR + 0.670 * lG + 0.065 * lB) * 255, where lR,lG, and lB are linear (normalized, gamma free RGB)
values.

Alternatively, sample the pixels in a beauty pass and feed it through the whole process as follows
local Lux = 179 * (0.265*inv_Gamm(sR) + 0.670*inv_Gamma(sG) + 0.065*inv_Gamma(sB)) * 255, where sR, sG, and sB
are the diffuse image sRGB channel values in the range 0-255.

**********************************************************************************************************
**** Could someone please verify that my logic above is correct, or otherwise critique it.
**********************************************************************************************************
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Re: Luminance Analysis Questions.

Postby MB » Tue Sep 19, 2023 9:00 pm

MB Tue Sep 19, 2023 9:00 pm
For a quick summary of what this script does, here is a video explaining the V-Ray equivalent implemented as a 3d max plugin, fortunately it's a little less complicated in Octane.

https://docs.chaos.com/display/CWVRAYMA ... g+Analysis


Below are some previous discussions on the forum around this topic. It is clear there are people in our community who know what they are talking about, and I hope they can weigh in. I am concerned about the method I described for setting up Octane emitters. Karl and Bepeg4d from the Octane Render team seem particularly knowledgeable on this topic.

Separately there is the issue of deriving the luminance value from an sRGB value, particularly the mathematical equation/equations to apply to the sRGB pixels in a rendering. Since I don't know or understand what went into calculating these in the first place, I can't be sure of what in essence is an attempt to reverse part of it. It would be great if someone from Otoy could comment and set me in the right direction if need be.

Finally, there is setting up the scene so that the above process is actually applied to output from Octanes rendering process that is correctly configured. Thoughts on whether or not I have described this both correctly and completely would be welcome.

Thanks for your help.

Mark

viewtopic.php?f=9&t=65521&p=415477&hilit=luminance#p415477

viewtopic.php?f=24&t=80315&p=415232&hilit=luminance#p415232

viewtopic.php?f=30&t=76543&p=394066&hilit=luminance#p394066

viewtopic.php?f=9&t=61714&p=315710#p315710
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Return to General Discussion


Who is online

Users browsing this forum: No registered users and 8 guests

Wed May 22, 2024 10:49 am [ UTC ]