Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualPhillipHamlyn

Posted 20 January 2013 - 11:57 AM

Hmm,

I followed my nose and have the following now; which works nicely enough.

if(textureWeights1.a > 0) textureColor += tex2Dgrad(TextureSamplerAtlas1,getAtlasTextureCoords(textureCoords, float2(0,0)), texDdx, texDdy) * textureWeights1.a;
if(textureWeights1.r > 0) textureColor += tex2Dgrad(TextureSamplerAtlas1,getAtlasTextureCoords(textureCoords, float2(1,0)), texDdx, texDdy) * textureWeights1.r;
if(textureWeights1.g > 0) textureColor += tex2Dgrad(TextureSamplerAtlas1,getAtlasTextureCoords(textureCoords, float2(0,1)), texDdx, texDdy) * textureWeights1.g;
if(textureWeights1.b > 0) textureColor += tex2Dgrad(TextureSamplerAtlas1,getAtlasTextureCoords(textureCoords, float2(1,1)), texDdx, texDdy) * textureWeights1.b;

if(textureWeights2.a > 0) textureColor += tex2Dgrad(TextureSamplerAtlas2,getAtlasTextureCoords(textureCoords, float2(0,0)), texDdx, texDdy) * textureWeights2.a;
if(textureWeights2.r > 0) textureColor += tex2Dgrad(TextureSamplerAtlas2,getAtlasTextureCoords(textureCoords, float2(1,0)), texDdx, texDdy) * textureWeights2.r;
if(textureWeights2.g > 0) textureColor += tex2Dgrad(TextureSamplerAtlas2,getAtlasTextureCoords(textureCoords, float2(0,1)), texDdx, texDdy) * textureWeights2.g;
if(textureWeights2.b > 0) textureColor += tex2Dgrad(TextureSamplerAtlas2,getAtlasTextureCoords(textureCoords, float2(1,1)), texDdx, texDdy) * textureWeights2.b;

 

Phillip


#1PhillipHamlyn

Posted 20 January 2013 - 09:37 AM

Hmm,

 

I followed my nose and have the following now; but my combined textureColor is always the total of all four samples, even where the textureWeights1 value for that channel is zero. Its almost like the shader is ignoring the control of flow AND the multiplication factor. I wonder whats going on here ?

 

float2 atlasCoordinates = getAtlasTextureCoords(textureCoords, float2(0,0));
if(textureWeights1.a > 0) textureColor += tex2Dgrad(TextureSamplerAtlas1, atlasCoordinates, texDdx, texDdy) * textureWeights1.a;
atlasCoordinates = getAtlasTextureCoords(textureCoords, float2(1,0));
if(textureWeights1.r > 0) textureColor += tex2Dgrad(TextureSamplerAtlas1,atlasCoordinates, texDdx, texDdy) * textureWeights1.r;
atlasCoordinates = getAtlasTextureCoords(textureCoords, float2(0,1));
if(textureWeights1.g > 0) textureColor += tex2Dgrad(TextureSamplerAtlas1,atlasCoordinates, texDdx, texDdy) * textureWeights1.g;
atlasCoordinates = getAtlasTextureCoords(textureCoords, float2(1,1));
if(textureWeights1.b > 0) textureColor += tex2Dgrad(TextureSamplerAtlas1,atlasCoordinates, texDdx, texDdy) * textureWeights1.b ;

PARTNERS