pouët.net

Go to bottom

Texture sampling problem with cgD3D9

category: general [glöplog]
 
When using a Cg fragment shader it seems to sample the same texel for each pixel (0,0). The same shader works fine when using it in an OpenGL program.

Here's the Cg code (reduced to a bare minimum to exclude as many sources of error as possible):

Code: struct result { float4 color : COLOR; }; result FragmentTest(float2 texcoord : TEXCOORD0, uniform sampler2D mytexture) { result res; res.color = tex2D(mytexture, texcoord); return res; }


I'm doing cgD3D9SetTexture and cgD3D9BindProgram between BeginScene and DrawPrimitive. The vertex format I'm using is XYZ|TEX1. The texture I'm using was created with D3DXCreateTextureFromFile.

Is there something simple I've missed that you need to do when moving from OpenGL to D3D?
added on the 2008-03-21 19:16:25 by mic mic
Are you using a textured vertex format? Otherwise texcoord0 will be pretty much 0 all the time...
Quote:
Are you using a textured vertex format? Otherwise texcoord0 will be pretty much 0 all the time...

Quote:
The vertex format I'm using is XYZ|TEX1



Also, if I write the shader in shader assembly the sampling works. But in the Cg version it doesn't (at least not with D3D).
added on the 2008-03-22 17:55:07 by mic mic

login

Go to top