Jump to content
  • Advertisement
Sign in to follow this  
NouseHLSL

HLSL PS loop and indexing

This topic is 4440 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

Hi, I'm trying to make per-pixel lighting in HLSL with pixel shader 3.0, but my code refuse to compile. I use DirectX 9 (April 2006) and I have a Geforce 6800GT. Here is part of my pixel shader:
float4 kDLightDir[3] : register(c3);
float4 kDLightAmbient : register(c6);
float4 kDLightDiffuse[3] : register(c7);
float4 kDLightSpecular[3] : register(c10);

int4 kiNbDirLight : register(i0);

for ( int i = 0; i < kiNbDirLight.x; i++ )
{
	float LdotN = dot(kDLightDir, inNormal);
	Diffuse += saturate(kDLightDiffuse * LdotN);
}
It gives me this error: "error X4556: Error: invalid register 'i0' in register binding." If I remplace the 2 constants I'm indexing in the loop, kDLightDir and kDLightDiffuse, by kDLightDir[0], and kDLightDiffuse[0] It compiles alright. Is constant indexing supported in pixel shader 3.0? I checked on google and I saw it is. I'm clueless, can somebody helps me? Thank

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by NouseHLSL
Hi,

I'm trying to make per-pixel lighting in HLSL with pixel shader 3.0, but my code refuse to compile. I use DirectX 9 (April 2006) and I have a Geforce 6800GT.

Here is part of my pixel shader:


float4 kDLightDir[3] : register(c3);
float4 kDLightAmbient : register(c6);
float4 kDLightDiffuse[3] : register(c7);
float4 kDLightSpecular[3] : register(c10);

int4 kiNbDirLight : register(i0);

for ( int i = 0; i < kiNbDirLight.x; i++ )
{
float LdotN = dot(kDLightDir, inNormal);
Diffuse += saturate(kDLightDiffuse * LdotN);
}



It gives me this error:
"error X4556: Error: invalid register 'i0' in register binding."

If I remplace the 2 constants I'm indexing in the loop, kDLightDir and kDLightDiffuse, by kDLightDir[0], and kDLightDiffuse[0] It compiles alright.

Is constant indexing supported in pixel shader 3.0? I checked on google and I saw it is.

I'm clueless, can somebody helps me?
Thank


No, you can't index constants in ps_3_0. you can only index t registers, looping is basically useless in pixel shaders.

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!