Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

hello_there

cg problem

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

T have this cg program and i can''t figure out way it doesn''t work i know it somthing to do with the last bit but i can''t figure out what can someone please help me. float3 expand(float3 v) { return (v-0.5)*2; } void C8E2f_bumpSurf(float2 normalMapTexCoord : TEXCOORD0, float3 lightDirection : TEXCOORD1, float3 halfAngle : TEXCOORD2, out float4 color : COLOR, uniform float ambient, uniform float4 LMd, // Light-material diffuse uniform float4 LMs, // Light-material specular uniform sampler2D normalMap, uniform sampler2D decal, uniform samplerCUBE normalizeCube, uniform samplerCUBE normalizeCube2) { // Fetch and expand range-compressed normal float3 normalTex = tex2D(normalMap, normalMapTexCoord).xyz; float3 normal = expand(normalTex); // Fetch and expand normalized light vector float3 normLightDirTex = texCUBE(normalizeCube, lightDirection).xyz; float3 normLightDir = expand(normLightDirTex); // Fetch and expand normalized half-angle vector float3 normHalfAngleTex = texCUBE(normalizeCube2, halfAngle).xyz; float3 normHalfAngle = expand(normHalfAngleTex); // Compute diffuse and specular lighting dot products float diffuse = saturate(dot(normal, normLightDir)); float specular = saturate(dot(normal, normHalfAngle)); // Successive multiplies to raise specular to 8th power float specular2 = specular*specular; float specular4 = specular2*specular2; float specular8 = specular4*specular4; float4 decalColour = tex2D(decal, normalMapTexCoord); color = decalColour*(ambient+diffuse) + LMs*specular8; } the decalColour works i tried it out by just puting that as the colour. it''s realy weird since it works if you replace decalColour with LMd.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
If you want to compile a program with the PS11 profile, you may only use one TextureCoordinate-Set per Texture LookUp (your using "normalMapTexCoord" twice).

Just pass this TexCoord twice from your VS to your PS as followed

...
float2 normalMapTexCoord : TEXCOORD0,
float2 decalMapTexCoord : TEXCOORD1,
float3 lightDirection : TEXCOORD2,
float3 halfAngle : TEXCOORD3,
...

where normalMapTexCoord and decalMapTexCoord actually contain the same values.

When you replace "decalColour" with "LMd" in your last line the compiler simply erases your
"float4 decalColour = tex2D(decal, normalMapTexCoord);". That''s because decalColour isn''t needed.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
... of course you have to change

"float4 decalColour = tex2D(decal, normalMapTexCoord);"

to

"float4 decalColour = tex2D(decal, decalMapTexCoord);"

Share this post


Link to post
Share on other sites
i''m using the fp20 profile and it works using the same texture coordinates. change the last bit to this works. I''l give what you said a try any way.

float4 decalColour = tex2D(decal, normalMapTexCoord);

color = decalColour;

Share this post


Link to post
Share on other sites
hmm thanks that worked i though you where only allowed to do 1 texture lookup per fragment program. i never though there was a limit on using texture coordinates.

Share this post


Link to post
Share on other sites

  • 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!