Advertisement Jump to content
Sign in to follow this  

Problems with nomalize in pixelshader

This topic is 4884 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 all, I have a very strange and anoying error (At least I think it is) Ive just started to use vertex and pixel shaders, but I cant use the normalize function inside the pixelshader. This is how I do it. Gl.cpp
cgVertexProgram		=	cgCreateProgramFromFile(cgContext, CG_SOURCE, "./data/shaders/", cgVertexProfile, "main", NULL);

cgFragmentProgram	=	cgCreateProgramFromFile(cgContext, CG_SOURCE, "./data/shaders/", cgFragmentProfile, "main", NULL);
struct vertexin
	float4	Position 	: POSITION;
	float4	Normal	 	: NORMAL;
	float4	Color	 	: COLOR0;
	float3	Texture0 	: TEXCOORD0;

struct vertexout
	float4	Position 	: POSITION;
	float4 Color	: COLOR0;
	float2 Texture0 : TEXCOORD0;


vertexout main(vertexin IN, uniform float4x4 ModelViewProj, uniform float4x4 ModelView, uniform float4x4 ModelViewIT)
	vertexout OUT;

	OUT.Position = mul(ModelViewProj, IN.Position);
	OUT.Color = IN.Color;

	return OUT;
void main(float4 in_color: COLOR0, out float4 color : COLOR) {
	color = in_color;
	color.x = 0;		// Just to know that this program is actually running.

	float3 n;
	n.x = 2;
//	normalize(n); <- If I add this line I get a compiler error.


Now how can that be? And all I get using the cgGetErrorString(cgGetError()); is: CG ERROR : The compiler returned an error. Can you get some more detailed error messages somehow? Edit: One reason that I can think of is that I get the fp20 pofile which might not support the normalize function? Can that be the case? Edit again: That was the reason, my profile doesnt support normalize(), time to purchase a new gf [Edited by - Dies_Irae on September 7, 2005 11:10:30 AM]

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!