Skip to main content
gamedev.net
🔒 Locked

Cg Compiler Error :-[

Started by silvermace 1 reply 700+ views
Original Post
silvermace
silvermace
Hi, im trying to compile a Fragment_program Cg shader, but the compiler keeps spitting this out at me. the wierd thing is i compile a Vertex program fine in the lines of code above where the cgCreateFromFile.. for the FP is callled. any help or pointers would GREATLY be appreciated! Thanks. (ignore the first line as its from my engines log files)
 SHADER ERROR: [CG ERROR : The compile returned an error.]
  "../data/shaders/fp.cg(19) : error C5041: cannot locate suitable resource to bind parameter "COL"
../data/shaders/fp.cg(19) : error C5041: cannot locate suitable resource to bind parameter "DEPR"
43 lines, 2 errors.
"
 
The Fragment Shader

// data interpolated from vertex program output

struct V2FI
{
    half4 HPosition    : POSITION;
    half3 TCoords0     : TEXCOORD0;
    half3 Normal       : TEXCOORD1;
    half3 ViewVector   : TEXCOORD2;
    half3 LightVector  : TEXCOORD3;
};

// fragment program output

struct PixelOut 
{
    half4 COL;
    half DEPR;
};

PixelOut main(V2FI IN, uniform sampler2D Texture : texunit0)
{
	// texture lookup

	half4 texcolor=h4tex2D(Texture,IN.TCoords0.xy);

	// normalize (interp. per-fragment => norm != 1.0)

	half3 n=normalize(IN.Normal.xyz);
	half3 v=normalize(IN.ViewVector.xyz);
	half3 l=normalize(IN.LightVector.xyz);

	// compute specular coeff

	half3 r=reflect(-v,n);
	half  spec=pow(clamp(dot(l,r),0.0,1.0),30.0);

	// compute diffuse coeff

	// -> clamp to keep an ambient illumination

	half diff=clamp(dot(n,l),0.3,1.0);

	// computes final color - uses alpha component for specular attenuation

	half4 color=texcolor*diff+(spec*texcolor.w);

	PixelOut OUT;
	OUT.COL = color;
	return OUT;
}
thanks!
vNistelrooy
vNistelrooy
You have to output color;



"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.