Hi.
I found a bottle neck or some thing.
When I scale the text coords say by 22.3 in the pixel shader(4) per channel(R, G, B, A). The frame per millisecond increases by 80 milliseconds.
the texture size's are 512x512.
this is from the pixel shader.
float3 c0 = gTex0.Sample(Tex0S, In.tiledTexC * gTexScaleRed).rgb;
Ah. good time to have a thought, Why not pass the 4 calculated text coord to the PS(input in add 4 more value. I'll try that now.
That got me 1 millisecond.
What other things could I do in here to improve performance.
.
PS_OUTPUT PS( PS_INPUT In) //: SV_Target
{
PS_OUTPUT pout;
//float4 diffuse = gBlendMap.Sample(BlendMapS, In.nonTiledTexC );
// Kill transparent pixels.
// clip(diffuse.a - 0.15f);
//float3 c0 = gTex0.Sample(Tex0S, In.tiledTexC * gTexScaleRed).rgb;
// float3 c1 = gTex1.Sample(Tex1S, In.tiledTexC * gTexScaleGreen).rgb;
//float3 c2 = gTex2.Sample(Tex2S, In.tiledTexC * gTexScaleBlue).rgb;
//float3 c3 = gTex3.Sample(Tex3S, In.tiledTexC * gTexScaleAlpha).rgb;
float3 c0 = gTex0.Sample(Tex0S, In.tiledTexC).rgb;
float3 c1 = gTex1.Sample(Tex1S, In.tiledTexCGreen).rgb;
float3 c2 = gTex2.Sample(Tex2S, In.tiledTexCBlue).rgb;
float3 c3 = gTex3.Sample(Tex3S, In.tiledTexCAlpha).rgb;
//shadow stuff
float shadowFactor = CalcShadowFactor( In.projTexC);
// Blendmap is not tiled.
float4 B = gBlendMap.Sample(BlendMapS,In.nonTiledTexC).rgba;//tex2D(BlendMapS, nonTiledTexC).rgb;
// Find the inverse of all the blend weights so that we can
// scale the total color to the range [0, 1].
float totalInverse = 1.0f / (B.r + B.g + B.b + B.a);
// Scale the colors by each layer by its corresponding weight
// stored in the blendmap.
c0 *= B.r * totalInverse;
c1 *= B.g * totalInverse;
c2 *= B.b * totalInverse;
c3 *= B.a * totalInverse;
// Sum the colors and modulate with the shade to brighten/darken.
float3 texColor = ((c0 + c1 + c2 + c3) * (In.shade * shadowFactor )) ;
/////////////////////////////////////////////////////////////////////
//projected text pos stuff
// Complete projection by doing division by w.
In.DecalprojTexC.xyz /= In.DecalprojTexC.w;
// Points outside the light volume are in shadow.
if( In.DecalprojTexC.x < -1.0f || In.DecalprojTexC.x > 1.0f ||
In.DecalprojTexC.y < -1.0f || In.DecalprojTexC.y > 1.0f )
{
//texColor *= 1.5f;
}
else
{
// Transform from NDC space to texture space.
In.DecalprojTexC.x = +0.5f*In.DecalprojTexC.x + 0.5f;
In.DecalprojTexC.y = -0.5f*In.DecalprojTexC.y + 0.5f;
float2 texelPos = In.DecalprojTexC.xy;//input.projTexC.xy;
// Sample projected tex map.
float4 s0 = gDecalProjectiveMap.Sample(gDecalProjectiveSam, texelPos);
//clip if black
if(s0.a > 0.15f)//
{
//blend the 2 images
//return lerp(float4(texColor, 0.5f), s0, 0.8f);//gDecalToDiffuseBlendAmt);
pout.RGBColor = lerp(float4(texColor, 0.5f), s0, 0.8f);
pout.RGBColor1 = float4(s0.rgb * 0.2,0.5);//pout.RGBColor;
return pout;
}
//else texColor *= 0.2f;
}//end in the projection
pout.RGBColor = (float4(texColor, 1.0f));
pout.RGBColor1 = float4(0,0,0,1);//pout.RGBColor;
return pout;
}