In the spirit of the holidays I thought I'd give away a little shader I've been toying around with.
I decided to make a post processing shader based upon the settings of a camera (ISO sensitivity, Aperture, Frame Speed).
Luckily I came across someone who did the same, so I may have 'borrowed'
a lot some of his code, so the credit really mostly goes to Krzysztof Narkowicz.
https://placeholderart.wordpress.com/2014/12/15/implementing-a-physically-based-camera-automatic-exposure/
DOWNLOAD http://www.mediafire.com/file/f2ssjhktaoyotto/Camera_PostFX.zipDOWNLOAD
Here's the rundown of the variables and tweakable settings.
float BloomWeights[5] = {1, 1, 1, 1, 1};
This controls the weight of the different bloom layers.
The first is the tightest/sharpest and the last is the widest/blurriest.
These can go to any value and will be normalised (be averaged to 1)
float AvgWeights[9] = {1, 1, 1, 1, 1, 1, 1, 1, 1};
This controls the weight of the different metering zones for the exposure adaption.
1 is the centre
2-5 are the 4 cardinal directions (left, right, up and down)
6-9 are the diagonals (corners)
float exposure
This controls how boosted you want the brightness to be.
+1 makes it X2 as bright
-1 makes it /2 as bright
float2 aperture = {2.1,8.3};
float2 iso = {100, 100};
float2 shutterSpeed = {100, 100};
These all control the ranges of the exposure adaption.
The first value is the setting for when it is darkest. The second is for when it is brightest.
You may need to understand camera settings to work this well.
Aperture simulates the size of the hole for the light to reach the sensor.
ISO simulates how sensitive the sensor is to light. (A higher value causes static and noise)
Shutter Speed simulates how long light is received by the sensor before the next frame.
NOTE: I did not tie Aperture to DOF or Shutter Speed to Motion blur, like it would be in realilty.
float2 sensitivity = {1, 1};
This controls the rate of exposure adaption.
The first value controls how sensitive the adaption is.
The second value controls how quickly it adapts.
float2 BloomThreshold = {0, 1};
This controls the threshold for the bloom.
The first value controls the treshold by cutting off any values below that level.
The second value creates a curve, allowing for a more smooth transition.
float PostBloomBoost
this controls how much bloom is present.
float TonemapMode
This controls what tonemapping mode is used.
0 is no tonemapping (good for digital camera style)
1 is reinhard
2 is colour preserving reinhard
3 is colour preserving reinhard with a whitepoint
4 is Uncharted 2 filmic tonemapping
5 is Filmic tonemapping
6 is ACES tonemapping
float Whitepoint
This controls at what brightness the tonemapped image is clamped to 1
this does not apply to settings 0,1 and 2
float width
This controls the width of the blur applied to bloom
float gamma
This controls the gamma.
It should be set to 2.2 for gamma correctness
If something compiles on the first try. Something is terribly wrong.