Texture adjustment at runtime for thermal image

Hi,

I’m working on the thermal vision using Post Process Material and I wanted to somehow simulate dynamic adjustment of gradient when different min/max temperatures are present.

As it is typical I use Custom Stencil, but I don’t think getting list of every recently rendered object, accesing their custom value (like int temperature) and then changing custom stencil would be efficient.

Other way I thought about was adjusting the gradient curve dynamicly, having precalculated nodes and simply adjust the nodes position to get the needed thermal look at specific moment, but I can’t force color curve to work…

Any ideas how to do this?
I don’t want to simply create bunch of different gradient textures as I want smooth transitions.

This sounds like a job for the inverse lerp.

You specify two values (ie the min and max temperature value) and the input image (your full spectrum heat-map). It will map those values into a 0-1 range which you can map to your gradient texture. To change the gradient’s focus you shift the A and B of your inverse lerp up and down. You’ll probably want to saturate the inverse lerp output as it does not clamp to the 0-1 range. This will cause everything outside of the range to clamp to 0-1 and everything within the specified temperature range to fall proportionately along the gradient UV.