Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualHodgman

Posted 24 October 2012 - 01:30 AM

+1 for sharing Posted Image

Getting rid of the if statements should speed it up.

^this, and using lerp is a lot faster than manually writing linear interpolation math. I'd also pack all the masks together to reduce the number of texture fetches:
e.g. http://pastebin.com/KfEw0sjW

#5Hodgman

Posted 24 October 2012 - 01:29 AM

+1 for sharing Posted Image

Getting rid of the if statements should speed it up.

^this, and using lerp is a lot faster than manually writing linear interpolation math. I'd also pack all the masks together to reduce the number of texture fetches:
float4 masks1234 = tex2D(texture00Sampler, input.uv1 * maskScale);
float3 masks567  = tex2D(texture01Sampler, input.uv1 * maskScale).rgb;
float4 final  = tex2D(texture02Sampler, input.uv1 * uvScale0);
float4 layer1 = tex2D(texture03Sampler, input.uv1 * uvScale1);
float4 layer2 = tex2D(texture04Sampler, input.uv1 * uvScale2);
float4 layer3 = tex2D(texture05Sampler, input.uv1 * uvScale3);
float4 layer4 = tex2D(texture06Sampler, input.uv1 * uvScale4);
float4 layer5 = tex2D(texture07Sampler, input.uv1 * uvScale5);
float4 layer6 = tex2D(texture08Sampler, input.uv1 * uvScale6);
float4 layer7 = tex2D(texture09Sampler, input.uv1 * uvScale7);
final = lerp( final, layer1, masks1234.r );
final = lerp( final, layer2, masks1234.g );
final = lerp( final, layer3, masks1234.b );
final = lerp( final, layer4, masks1234.a );
final = lerp( final, layer5, masks567.r );
final = lerp( final, layer6, masks567.g );
final = lerp( final, layer7, masks567.b );

#4Hodgman

Posted 24 October 2012 - 01:28 AM

+1 for sharing Posted Image

Getting rid of the if statements should speed it up.

^this, and using lerp is a lot faster than manually writing linear interpolation math. I'd also pack all the masks together to reduce the number of texture fetches:
float4 masks1234 = tex2D(texture00Sampler, input.uv1 * maskScale);
float3 masks567  = tex2D(texture01Sampler, input.uv1 * maskScale).rgb;
float4 final  = tex2D(texture02Sampler, input.uv1 * uvScale0);
float4 layer1 = tex2D(texture03Sampler, input.uv1 * uvScale1);
float4 layer2 = tex2D(texture04Sampler, input.uv1 * uvScale2);
float4 layer3 = tex2D(texture05Sampler, input.uv1 * uvScale3);
float4 layer4 = tex2D(texture06Sampler, input.uv1 * uvScale4);
float4 layer5 = tex2D(texture07Sampler, input.uv1 * uvScale5);
float4 layer6 = tex2D(texture08Sampler, input.uv1 * uvScale6);
float4 layer7 = tex2D(texture09Sampler, input.uv1 * uvScale7);
final = lerp( final, layer1, masks1234.r );
final = lerp( final, layer2, masks1234.g );
final = lerp( final, layer3, masks1234.b );
final = lerp( final, layer4, masks1234.a );
final = lerp( final, layer5, masks567.r );
final = lerp( final, layer6, masks567.g );
final = lerp( final, layer7, masks567.b );

#3Hodgman

Posted 24 October 2012 - 01:28 AM

+1 for sharing Posted Image

Getting rid of the if statements should speed it up.

^this, and using lerp is a lot faster than manually writing linear interpolation math. I'd also pack all the masks together to reduce the number of texture fetches:
float4 masks1234 = tex2D(texture00Sampler, input.uv1 * maskScale);
float3 masks567  = tex2D(texture01Sampler, input.uv1 * maskScale).rgb;
float4 final  = tex2D(texture02Sampler, input.uv1 * uvScale0);
float4 layer1 = tex2D(texture03Sampler, input.uv1 * uvScale1);
float4 layer2 = tex2D(texture04Sampler, input.uv1 * uvScale2);
float4 layer3 = tex2D(texture05Sampler, input.uv1 * uvScale3);
float4 layer4 = tex2D(texture06Sampler, input.uv1 * uvScale4);
float4 layer5 = tex2D(texture07Sampler, input.uv1 * uvScale5);
float4 layer6 = tex2D(texture08Sampler, input.uv1 * uvScale6);
float4 layer7 = tex2D(texture09Sampler, input.uv1 * uvScale7);
final = lerp( final, layer1, masks1234.r );
final = lerp( final, layer2, masks1234.g );
final = lerp( final, layer3, masks1234.b );
final = lerp( final, layer4, masks1234.a );
final = lerp( final, layer5, masks567.r );
final = lerp( final, layer6, masks567.g );
final = lerp( final, layer7, masks567.b );

#2Hodgman

Posted 24 October 2012 - 01:28 AM

+1 for sharing Posted Image

Getting rid of the if statements should speed it up.

^this, and using lerp is a lot faster than manually writing linear interpolation math. I'd also pack all the masks together to reduce the number of texture fetches:
float4 masks1234 = tex2D(texture00Sampler, input.uv1 * maskScale);
float3 masks567  = tex2D(texture01Sampler, input.uv1 * maskScale).rgb;
float4 final  = tex2D(texture02Sampler, input.uv1 * uvScale0);
float4 layer1 = tex2D(texture03Sampler, input.uv1 * uvScale1);
float4 layer2 = tex2D(texture04Sampler, input.uv1 * uvScale2);
float4 layer3 = tex2D(texture05Sampler, input.uv1 * uvScale3);
float4 layer4 = tex2D(texture06Sampler, input.uv1 * uvScale4);
float4 layer5 = tex2D(texture07Sampler, input.uv1 * uvScale5);
float4 layer6 = tex2D(texture08Sampler, input.uv1 * uvScale6);
float4 layer7 = tex2D(texture09Sampler, input.uv1 * uvScale7);
final = lerp( final, layer1, masks1234.r );
final = lerp( final, layer2, masks1234.g );
final = lerp( final, layer3, masks1234.b );
final = lerp( final, layer4, masks1234.a );
final = lerp( final, layer5, masks567.r );
final = lerp( final, layer6, masks567.g );
final = lerp( final, layer7, masks567.b );

#1Hodgman

Posted 23 October 2012 - 11:21 PM

+1 for sharing Posted Image

Getting rid of the if statements should speed it up.

^this, and using lerp is a lot faster than manually writing linear interpolation math. I'd also pack all the masks together to reduce the number of texture fetches:
float4 masks1234 = tex2D(texture00Sampler, input.uv1 * maskScale);
float3 masks567  = tex2D(texture01Sampler, input.uv1 * maskScale).rgb;
float4 final  = tex2D(texture02Sampler, input.uv1 * uvScale0);
float4 layer1 = tex2D(texture03Sampler, input.uv1 * uvScale1);
float4 layer2 = tex2D(texture04Sampler, input.uv1 * uvScale2);
float4 layer3 = tex2D(texture05Sampler, input.uv1 * uvScale3);
float4 layer4 = tex2D(texture06Sampler, input.uv1 * uvScale4);
float4 layer5 = tex2D(texture07Sampler, input.uv1 * uvScale5);
float4 layer6 = tex2D(texture08Sampler, input.uv1 * uvScale6);
float4 layer7 = tex2D(texture09Sampler, input.uv1 * uvScale7);
final = lerp( final, layer1, masks1234.r );
final = lerp( final, layer2, masks1234.g );
final = lerp( final, layer3, masks1234.b );
final = lerp( final, layer4, masks1234.a );
final = lerp( final, layer5, masks567.r );
final = lerp( final, layer6, masks567.g );
final = lerp( final, layer7, masks567.b );

PARTNERS