Monday, August 14, 2017

Dependent Texture Reads

Not dependent:
float3 nonDependentTextureRead = tex2D(_MainTexture, input.texcoord).xyz;

Dependent:
float3 DependentTextureRead = tex2D(_MainTexture, input.texcoord.zw).xyz;
float3 DependentTextureRead = tex2D(_MainTexture, input.texcoord.yx).xyz;
float3 DependentTextureRead = tex2D(_MainTexture, input.texcoord*2.0).xyz;

==========================

struct v2f{
 half2 uv : TEXCOORDn; //pass uvs direcly
 half4 packed2uvs : TEXCOORDn; //afraid of dependent texture read, avoid packing 2 uvs into 1 varying
 half4 packed4Scalars : TEXCOORDn; //for general purpose scalar packing
}

tex2D(_Texture,i.uv); //good, fastest
tex2D(_Texture,i.uv.xy); //afraid of dependent texture read, depends on driver?. avoid
tex2D(_Texture,i.uv.zw); //afraid of dependent texture read. avoid

No comments:

Post a Comment