Sign in to follow this  

Problems with nomalize in pixelshader

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this