Nemo Krad

I have been playing with these shaders:

http://msdn.microsoft.com/library/default.asp url=/library/en-us/directx9_c/Goal_3___Environment_Mapping.asp

and I have got these shaders up and working in my engine, with the exception of 3 and 4, they light my model correctly, but they don't seem to be rendering the cube map I am giving them.

The shader manages the cubemap like this:

texture EnvironmentMap
<
string type = "CUBE";
string name = "lobbycube.dds";
>;


samplerCUBE EnvironmentSampler = sampler_state
{
Texture = (EnvironmentMap);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};

I load the cube map like this:

private TextureCube myCube;
myCube = myLoader.Load<TextureCube>("Content/Textures/SkyBox/RC/default_reflection");

This now loads fine. So I then pass the TextureCube param to the effect:

if (myEffect.Parameters["EnvironmentMap"] != null)
myEffect.Parameters["EnvironmentMap"].SetValue(myCube);

I have put a break on this and I know it is loading myCube into the paramter.

Unlike the other params I set this does not seem to be working, can anyone tell me where I am going wrong



Re: XNA Framework Trying to pass a cubemap.dds to a fx shader

Darkside

You could try, either removing the environment section and replacing it with a Texture parameter then passing the texture from the content manager to it (the same as your doing now)

Or set the texture file properties so the content mnager does not load it and pass the stringfilename for the .DDS file to the shader instead.

Not had chace to test these options, but give them a try!

Darkside






Re: XNA Framework Trying to pass a cubemap.dds to a fx shader

Nemo Krad

Darkside,

Thanks for taking the time to have a look and respond.

If I replace Environment with a texture parameter then I get a compile error as the lerp function needs it to be a float4.

If I don't load the parameter and hard code the texture location this does not work either, pluss this would be *** as I would want to change the environment of my reflected model as it moved from scene to scene.

Surly this should just work as the shader is part of a MSDN tutoral and I would have thought that the XNA development team would not leave out cube maps :) I just cant for the life of me see why it is not working...

If you have any other ideas I am all ears :)

Thanks in advance :)





Re: XNA Framework Trying to pass a cubemap.dds to a fx shader

Jon Watte

Does it work if you bind a 2D texture instead of the cube map (And declare/load it as 2D, of course)

Not that it would work the way you'd want it to, but it can help isolate whether it's the texture type, or something else.






Re: XNA Framework Trying to pass a cubemap.dds to a fx shader

Nemo Krad

It behaves the same if I use a Texture but comes up with a ContentLoadException saying that the file contains a TextureCube but trying to load a Texture2D if I try a Texture2D. Same sort of error with a Texture3D to :(

Any one got any ideas.... This is killing me... lol

 





Re: XNA Framework Trying to pass a cubemap.dds to a fx shader

Nemo Krad

bump ...



Re: XNA Framework Trying to pass a cubemap.dds to a fx shader

Nemo Krad

Yet another shameless bump...

Any suggestions would be appreciated; I really would love to get this working...





Re: XNA Framework Trying to pass a cubemap.dds to a fx shader

Leaf.

I knocked up a quick test using the solution for the Goal3 shader, the skull model and the lobbyCube texture. There were no differences in my code to the few snippets you have shown from your code - so my guess is that your problem is not in the bits of code that you have shown.

Here is the download link for the test project I created. There's nothing clever going on but it might help you.

Cheers,
Leaf.






Re: XNA Framework Trying to pass a cubemap.dds to a fx shader

Nemo Krad

No thats great.

At least I have a working example now and so I should be able to puzzle it out from here.

Thanks a lot :)