- Home /
How to fill texture that would be avaliable to ither shaders?
How to create a simple pixel color shader that say takes a texture, applyes something like masking:
half4 color = tex2D(_Texture0, i.uv.xy);
if(distance(color, mask) > _CutOff)
{
return color;
}else{return static_color}
in and returns a texture that can be passed to next shader from c# code in a way like ` mats[1].SetTexture("_MainTex", mats[0].GetTexture("_OutputTex"));`? Example wanted.
Answer by Montraydavis · Oct 31, 2012 at 03:02 AM
You do know that you can access other components in your project. No need to really rely on passing a bunch of variables. That can get a bit confusing when you have thousands of lines of code. Instead, get a texture.
Textures myTex = Resources.Load("Materials/MyTexture", typeof(Texture)) as Textures;
And just make sure it's global ( variable 'Textures' ). . . . And accessing it from another script just requires a GetComponent() .
TexturesScript : Textures_Scripts = GetComponent ( Textures_Scripts ) ;
mats[1].SetTexture("_MainTex", mats[0].GetTexture(TexturesScript.myTex));
Please let me know if I misunderstood your question.
$$anonymous$$y point was to modify texture with one shader and p[ass result to another (modified) so to say create a chain