JackNJ

12-19-2007, 02:07 PM

Hello. I'm using the following fragment program:

uniform sampler2D top : TEXUNIT1;

uniform sampler2D mid : TEXUNIT2;

uniform sampler2D low : TEXUNIT3;

uniform float3 LightPos;

struct vertexOut {

float2 UV : TEXCOORD0;

float3 WorldPos : TEXCOORD1;

float3 normal : TEXCOORD2;

float3 TexW : TEXCOORD3;

};

float4 main(vertexOut In) : COLOR {

float3 normal = normalize(In.normal.xyz);

float3 l = normalize(LightPos-In.WorldPos);

float coff = max(dot(normal, l), 0.0);

float2 dx = ddx(In.UV);

float2 dy = ddy(In.UV);

float3 lowcol = f3tex2D(low, In.UV, dx, dy)*In.TexW.x;

float3 midcol = f3tex2D(mid, In.UV, dx, dy)*In.TexW.y;

float3 topcol = f3tex2D(top, In.UV, dx, dy)*In.TexW.z;

float3 col = (lowcol+midcol+topcol) * coff;

return float4(col, 1.0);

}

I have two problems:

1)

First of all, from what I can tell it's always using the same MipMap level: I have even tried tex2Dlod(low, float4(In.UV, 0, 8), same for mid/high, there was no difference. I'm building my textures using gluBuild2DMipmaps() and setting min. filter to Mipmap linear.

I'm guessing I missed something obvious, so any suggestions are very welcome!

2)

Using hardcoded colors for the low-,mid- and top-col yields a framerate at about 700FPS. Looking only lowcol up in texture decreases framerate by 50%.. which seems a lot to me (gets even worse when looking up mid- and topcol). All three textures are 512x512. Is it normal for texture lookups to be this expensive performance-wise?

Thanks!

uniform sampler2D top : TEXUNIT1;

uniform sampler2D mid : TEXUNIT2;

uniform sampler2D low : TEXUNIT3;

uniform float3 LightPos;

struct vertexOut {

float2 UV : TEXCOORD0;

float3 WorldPos : TEXCOORD1;

float3 normal : TEXCOORD2;

float3 TexW : TEXCOORD3;

};

float4 main(vertexOut In) : COLOR {

float3 normal = normalize(In.normal.xyz);

float3 l = normalize(LightPos-In.WorldPos);

float coff = max(dot(normal, l), 0.0);

float2 dx = ddx(In.UV);

float2 dy = ddy(In.UV);

float3 lowcol = f3tex2D(low, In.UV, dx, dy)*In.TexW.x;

float3 midcol = f3tex2D(mid, In.UV, dx, dy)*In.TexW.y;

float3 topcol = f3tex2D(top, In.UV, dx, dy)*In.TexW.z;

float3 col = (lowcol+midcol+topcol) * coff;

return float4(col, 1.0);

}

I have two problems:

1)

First of all, from what I can tell it's always using the same MipMap level: I have even tried tex2Dlod(low, float4(In.UV, 0, 8), same for mid/high, there was no difference. I'm building my textures using gluBuild2DMipmaps() and setting min. filter to Mipmap linear.

I'm guessing I missed something obvious, so any suggestions are very welcome!

2)

Using hardcoded colors for the low-,mid- and top-col yields a framerate at about 700FPS. Looking only lowcol up in texture decreases framerate by 50%.. which seems a lot to me (gets even worse when looking up mid- and topcol). All three textures are 512x512. Is it normal for texture lookups to be this expensive performance-wise?

Thanks!