Choosing Channel in the Inspector

Hi

I would like to be able to choose a channel of a Texture inside the inspector. What I’ve tried so far doesn’t work. Is this a limitation?

In Properties:

_FogDetailChannel ("Fog Detail Channel", Float) = 0     // it's not a float, but there doesn't seem to be in type

In the Shader:

uniform int			_FogDetailChannel;

....

                fixed3 tex = tex2D(_FogDetail, i.tex.xy * _FogDetail_ST.xy + _FogDetail_ST.zw).rgb;
               	fogDensity *= tex[_FogDetailChannel];

In Properties:

_FogDetailChannel ("Fog Detail Channel", Float) = 0     // it's not a float, but there doesn't seem to be in type

In the Shader:

uniform float _FogDetailChannel;

....

                fixed3 tex = tex2D(_FogDetail, i.tex.xy * _FogDetail_ST.xy + _FogDetail_ST.zw).rgb;
               	fogDensity *= _FogDetailChannel;

That should work better.

Thanks Duney for the fast response.

That’s not what I want though. :slight_smile:

I would like to set _FogDetailChannel in the inspector, either 0, 1 or 2.
if it’s 0 it takes the RED channel of the tex, if it’s 1 it takes the GREEN channel… and so forth.

Mhm… I just figured I could try to do it with a lerp. That might work (and even allow to blend).

Sorry was early morning and clearly didn’t read you question right in my head.
I guess lerp’ing might be your best bet, as throwing in branches of if statements in shaders isn’t too nice.