Jump to content
  • Advertisement
Sign in to follow this  
Cedric Perthuis

reflect HLSL function doesn't work in 3dsmax

This topic is 4479 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, my shader was behaving differently in FX composer and in 3dsmax8, and I isolated the problem on the line where I call the HLSL function "reflect". Here's the relevant parts of my shader and my workaround.
texture environmentMap : Environment
<
	string ResourceName = "default_reflection.dds";
	string ResourceType = "Cube";
	string UIName = "Environment Texture";
>;

samplerCUBE environmentSampler = sampler_state
{
	Texture = <environmentMap>;
	MIPFILTER = LINEAR;
    MINFILTER = LINEAR;
    MAGFILTER = LINEAR;
};

//float3 R = reflect(-eyeVector, IN.oNormal); //---> doesn't work
float3 R = -eyeVector - 2*dot(-eyeVector,IN.oNormal)*IN.oNormal;// ---> works fine
half4 reflColor = texCUBE(environmentSampler, R)*(half4)(float4(glossColor,1.0f))*0.8f;
return reflColor;
So I just replaced the reflect function by its formula and it works fine after that, I can see the reflection without any problem in 3dsmax in the DirectX 9 viewport. So it basically means that I need an extra shader for 3dsmax that the artists have to use rather than the real one which will be used in the game. So I would like to try to understand why the reflect function doesn't work in max. Is it a shader compiler issue ? Does someone knows if autodesk is using a different effect/shader compiler ? than the one from DirectX ? I figured out I would get a faster response here than on the autodesk support website :). thanks, Cedric

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Cedric Perthuis
Is it a shader compiler issue ? Does someone knows if autodesk is using a different effect/shader compiler ? than the one from DirectX ?

If I remember correctly, this is a coordinate system issue. I forget the exact differences, but the Max documentation on its coordinate system might point you in the right direction.

The final result is that you have to change the shader for use in 3ds Max, which is kinda opposite the whole point of the D3D9 Material in the first place. However, you can do it pretty easily by using #define's. Personally, I just give better support for the Standard material, as that is easier for both artists and coders to deal with.

Share this post


Link to post
Share on other sites
Sign in to follow this  

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