Sign in to follow this  

shader won't take my texture

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

Hi, first : i'm using DirectX 9.0c I'm using the ID3DXEffect to implement some shaders in HLSL. I thought it was working, but recently, I noticed that when I don't do the d3dDevice->SetTexutre(...), the shader can't use a texture, even if I do effect->SetTexture(texHandle, myTexture); It seems like the effect completely ignore the ID3DXEffect::SetTexture and can only use the texture that were set by IDirect3DDevice9::SetTexture I checked on the DirectX sample : basic HLSL But when I do a pd3dDevice->SetTexture(0, NULL); just before V( g_pMesh->DrawSubset(0) ); the mesh is all whites, even if there is a g_Effect->SetTexture(...); ... So my question is : what's the use of ID3DXEffect::SetTexture if we must do a IDirect3DDevice9::SetTexture ?? (without the ID3DXEffect::SetTexture, it works the same) .:: Paic Citron ::.

Share this post


Link to post
Share on other sites
It's not necessary to use IDirect3DDevice9::SetTexture when you're rendering using a HLSL shader. ID3DXEffect::SetTexture should work. Are you sure you've got the handle right? Have you tested the shader in EffectEdit or FX Composer to make sure it's correct?

-- JJ

Share this post


Link to post
Share on other sites
thx for the reply but I tested that on the basic HLSL sample !
I just added pd3dDevice->SetTexture(0, NULL); before the rendering of the mesh. It should still work since ID3DXEffect::SetTexture is done, but the mesh appears white.

I checked my handles, they are correct, my texture, it's correct ... and I have no idea my it works like that :(


.:: Paic Citron ::.

Share this post


Link to post
Share on other sites
Quote:
Original post by paic
thx for the reply but I tested that on the basic HLSL sample !
I just added pd3dDevice->SetTexture(0, NULL);


Do you mean you used the BasicHLSL sample with the .fx file competely unchanged?
I edited this sample to call pd3dDevice->SetTexture(0, NULL) immediatly before rendering the mesh and the texturing worked OK for me.

If you did change the .fx file do you also set the texture correcty in the sampler state.

i.e. in your code:

g_pEffect->SetTexture( "g_MyTexture", g_pMyTexture);



and in the .fx file:

texture g_MyTexture;

sampler MyTextureSampler =
sampler_state
{
Texture = <g_MyTexture>;
...
...
...
};



Cambo_frog

Share this post


Link to post
Share on other sites
hi,

this is what I did : first, I use BasicHLSL completely unchanged, everything works fine.

second, on line 501 (in OnRenderFrame()) I have the following :

V( g_pMesh->DrawSubset(0) );

I just add this line before (and I do NOTHING more than just adding this line) :

V( pd3dDevice->SetTexture(0, NULL) );

And then the mesh is rendered all white -___-


.:: Paic Citron ::.

Share this post


Link to post
Share on other sites
If I insert V( pd3dDevice->SetTexture(0, NULL) );
in the position you do (i.e. after g_pEffect->Begin and after g_pEffect->BeginPass) it does stop the texturing, although for me the mesh doesn't render all white, but with multiple colors (vertex colors?).
See the two partial screen shots I took at:
http://www.camnet.myby.co.uk/tinytest.htm
The top picture is the result with V( pd3dDevice->SetTexture(0, NULL) );
The bottom picture is the result without that line.

if I change the SetTexture call to:

V( pd3dDevice->SetTexture(0, g_pMeshTexture) );

the mesh textures correcty.

But anyway (back to the problem).
The mesh in the BasicHLSL sample does texture correcty without a pd3dDevice->SetTexture call and just the g_pEffect->SetTexture call.

The problem in your own prog was that your mesh would not render correcty using just a g_pEffect->SetTexture call (but it should if your code is correct.

We need to see the following code from your prog.

1. The code where you obtain the handle to the texture name from the effect.

2. The code where you call g_pEffect->SetTexture with that handle.

3. The whole of your .fx file.

4. The code in your OnFrameRender callback.

Cambo_frog

Share this post


Link to post
Share on other sites

This topic is 4866 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.

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