- Home /
How do you choose/set the texture used in shader properties?
Greetings! In short, I can't seem to find how shaders know automatically which texture to use for each texture declared in a shader's properties. For example, if you declare a diffuse (albedo) map, a normal map, etc. in the properties the shader will set these by default automatically. All objects in our game will contain both a diffuse map and a thermal map, and I am looking to create an effect that renders the thermal map instead of a diffuse/albedo map when I enable the effect.
For more detail, I'm trying to create an infrared post-processing effect, where, when enabled, all objects in the scene use a thermal texture instead of their diffuse texture. Disabling the post-processing effect, of course, will revert back to rendering normal diffuse colors. The most basic of post-processing shaders, if they don't do anything, will pass along the diffuse color in the fragment shader. How can I set up the image effects script for all objects in the scene to use a particular texture "type"? Thank you.
Example of the effect:
I think what you are looking for is replacement shaders http://docs.unity3d.com/$$anonymous$$anual/SL-ShaderReplacement.html
Answer by PAHeartBeat · Jul 28, 2015 at 11:13 AM
Hi
First-of all shader will not identifiy which texture is set or change it on some particular condition. we can assing two texture on shader via matiial with a flag based value and lerp to texutre on based on flag value.
Still you can change your shader texture via cs / js
script. Unity In-built shaders and most other third party shader has _MainTex
varialble for it's main texture. which you can change it via script as bellow maintain
public Texture2D ThermalTex;
renderer.material.SetTexture("_MainTex",ThermalTex);
You can also replace ment shaders or Image Effect shaders to make your scene view looks like thermal Map,
you also can use render texture with camera, and process render texture with Image effect like thermal map and then use it.
Your answer
Follow this Question
Related Questions
Clean up Material Properties 1 Answer
Finding a list of properties in Shaders 1 Answer
Multiple materials on same object 0 Answers