Jump to content
  • Advertisement
Sign in to follow this  
FunkyMonkey

HLSL fill rates

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently developing a game for a student project and am attempting to use shaders for lighting. I've gotten them to work, only problem is my fill rate sucks and it's killing my FPS. Using hardware lights, I get over 200 FPS, switching to shaders drops it down to about 25 FPS...THAT SUCKS!!!!! Any suggestions on how to cut down on the fill rate? I'm already doing the obvious, backface culling, etc.

Share this post


Link to post
Share on other sites
Advertisement
Quote:

Using hardware lights, I get over 200 FPS, switching to shaders drops it down to about 25 FPS

Do you mean using the FFP? If you are using HLSL, they *are* hardware lights (unless you are using software vertex processing). Try posting the pertinent HLSL code - perhaps you are doing something inefficient.

Share this post


Link to post
Share on other sites
By FPS I mean frames per second and I'm not sure what you mean by FFP. Anyways, I'm trying to do headlights for a car. Here's what I'm doing...

VS_OUTPUT VS_SPOTLIGHT( float4 Pos : POSITION, float3 Normal : NORMAL, float2 Tex : TEXCOORD )
{
VS_OUTPUT Out = (VS_OUTPUT)0;

Out.Pos = mul( Pos, matWorldViewProj );

Out.Norm = normalize( mul( Normal, matrixWorld ));

Out.Tex = Tex.xy;

float4 PosWorld = mul( Pos, matrixWorld );

float3 fLight = vLightPos - PosWorld;

float3 temp = fLight * fLightRange;

Out.Light.xyz = fLight;

Out.Light.w = saturate( 1 - dot( temp, temp ));

return Out;
}

float4 PS_SPOTLIGHT( float3 Norm : TEXCOORD1, float4 Light : TEXCOORD2, float2 Tex : TEXCOORD0 ) : COLOR
{
float4 Color = tex2D( ColorMapSampler, Tex );

float4 TempColor = (float4)0;

float3 LightDir;
float fCosAngle, fSpotFactor, Diff;

LightDir = normalize( Light.xyz );

fCosAngle = dot( -vLightDirection, LightDir);

fSpotFactor = smoothstep( fCosOut, fCosIn, fCosAngle );

Diff = saturate( dot( Norm, LightDir ));

TempColor.xyz += 0.2f * Color + ( fSpotFactor * vLightColor * ( Color * Diff )) * Light.w;

TempColor.w = Color.w;

return TempColor;
}

Not sure if it makes any difference, but I'm using the .fx framework.

Share this post


Link to post
Share on other sites
Quote:
Original post by FunkyMonkey
By FPS I mean frames per second and I'm not sure what you mean by FFP

The FFP, or Fixed-Function-Pipeline, is the native DirectX renderer that is supported on all cards. If you use APIs like SetTexture(), SetLight(), and SetMaterial(), you are using the FFP. If you aren't using custom vertex and/or pixel shaders, you are using it.

What card do you have? That is a pretty complex and long pixel shader for some cards, including the low-numbered Nvidia FX 5000's.

Share this post


Link to post
Share on other sites
Ah, the FFP. I'm familiar with it, it just didn't click when I saw it earlier. I was under the impression that if you're using vertex and pixel shaders, you're skipping that particular part of the pipeline and taking things into your own hands. As far as my card is concerned, I have a radeon 9800 pro. If there are any sites or books that are good sources of info, I'd love to know about them.

Share this post


Link to post
Share on other sites
Quote:
Original post by FunkyMonkey
Ah, the FFP. I'm familiar with it, it just didn't click when I saw it earlier. I was under the impression that if you're using vertex and pixel shaders, you're skipping that particular part of the pipeline and taking things into your own hands.

Yea, you are exactly correct. Sorry, I didn't mean to confuse you.

Anyways, have you looked at the Nvidia SDK? It comes with *hundreds* of helpful effects, many of which pertain to lighting. A lot of different illumination models are included.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!