Archived

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

RipTorn

Cg 1.2 and D3D9 Expanded mode... oddness

Recommended Posts

I thought I''d put up my experience with nvidias recently released Cg 1.2 and DX 9... As a warning... I use Cg for GL as well btw (same shaders, same code, etc) Basically, everything was breaking in weird ways. it was mostly to do with pixel shader code... eg, the following would work find for both GL and D3D
float4 normal = tex2D(texture,texCoord) * 2 -1;
return dot(normal, lightDir);
 
or simply:
return lightColour;
 
but, if you changed to:
float4 normal = tex2D(texture,texCoord) * 2 -1;
return dot(normal, lightDir) * lightColour;
 
you would get a completely different result.. massivly overcontrasted, and frankly looked aweful. even weirder things occured when doing other stuff, I was using a second texture to add a cheap ''detail bump map'' something like:
float4 normal = tex2D(texture,texCoord) * 2 -1;
float4 detail = tex2D(texture2,texCoord2) -0.5;

return dot(normal + detail, lightDir);
 
that worked fine (just like GL) but if it was changed to this:
float4 normal = tex2D(texture,texCoord) * 2 -1;
float4 detail = tex2D(texture2,texCoord2) -0.5;

return dot(normal + detail * 2, lightDir);
 
(the only change is the *2, then the entire landscape became solid white, while in GL it simply became more bumpy... So. yeah. I don''t know if anyone else has had problems like this, but in the mean time I''d recommend if you are using Cg for D3D, to keep clear of 1.2, and stick with 1.1. | - My project website - | - email me - |

Share this post


Link to post
Share on other sites