Sign in to follow this  
Cedric Perthuis

reflect HLSL function doesn't work in 3dsmax

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
circlesoft    1178
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

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