I’m trying to recreate a thermal vision effect like the one in this video:
Some key components/limitations of the effect:
Rendered as an overlay with the actual image behind it (whether that be the default defuse color, or a separate night-vision effect - I’m only trying to achieve the thermal overlay here).
Only certain objects give off a heat signature.
Ability to have the effect confined to a portion of the screen.
Slight positional lag with quick movements.
Hopefully done in a way that doesn’t require the use of camera layers.
I’ll be the first to admit that I’m no expert when it comes to shader programming, but here’s my first (failed) approach:
Modified the standard shader to add an “EmissionType” tag and an emission texture for defining thermal signatures for objects.
Set up a 2nd camera that uses a replacement shader with the tag “EmissionType”=“Thermal” that writes the thermal intensity from the emission texture to the color buffer as black and white. (Currently only using the red value of the texture for thermal).
Run an image effect that maps the 0-1 thermal intensity to some color gradient.
Then the plan was to maybe apply some noise to that final image effect and lag it somehow, but using an image effect like this will be applied to the entire screen, and not just the heat overlay as I had hoped.
How can I render an overlay that has effects applied to it without affecting the standard image behind it?
I’d love to hear any feedback or alternate approaches :).
I have a thermal vision effect (2 different effects infact) in this pack, which doesnt do what you exactly want. However, when you buy the package you will be entitled to get one customization for your needs and i shall do that.
This guy makes really good videos about everything shader related (and he doesn’t try to sell you something ;))
Best part of it: he releases the source code of the shaders he re-create free of charge.
Maybe you can wack something up to achieve the effect showed in your video?
Unfortunately I cannot see the video but I would say your first (failed case is on the right track)
You should have your second camera render to a new render target.
Then you can use this render target as a texture in the main pass. Your second camera can be cloned from your main camera and rendered right before your main camera with a script on the main camera. I forget onerender or prerender. Check the monobehavior docs.
You can also control the resolution of this texture to give you some noise / less detail. Not to mention faster rendering for your extra pass.
Depending on your platform and exact requirements you could also look at multi target output or writing to alpha possibly to encode your heat signature in a single pass.
For the blur you will need an extra buffer you can use as a delay buffer. Which can just be a lerp between current frame and the other buffer basically for simple lag. You may need two actually to ping pong between as you accumulate the images.
For a night vision effect I did a long time ago I also had gain and bias plus bloom. The gain and bias was auto controlled and had a fixed rate. So if all of a sudden it got really bright everything would be white for a while until the sensor could adjust. Plus some random noise coming from a noise texture to simulate some of the sensors properties.
Oh a possible fake thermal might be able to just use the luminosity of the color data to simulate the temperature range. But having thermal texture would be better. A black car hood might still be hot.
@Mauri , Thanks for linking this video! Definitely helps a lot with my exploration. His videos are super helpful and more people need to know about them :).
@daxiongmao , awesome advice. I just started rendering to render textures and manipulating them, so your feedback makes me feel like I’m definitely heading in the right direction. Also love the ideas for adding noise and blurring. Thanks for all of your help!