Sign in to follow this  

Can't seem to get 3DS Default.FX file working:(

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

Hello, I've been tring to get the default.fx file from 3DS Max working for a few days now, and am stuck, bigtime. I think I have everything set right, but the object with the .fx on it, just comes out white:( I'm not sure what I'm doing wrong, here is my draw code and int statements Effect effect2; effect2 = content.Load<Effect>("DEFAULT"); // Draw the model. foreach (ModelMesh mesh in tankModel.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.World = boneTransforms[mesh.ParentBone.Index]; effect.View = view; effect.Projection = projection; effect.EnableDefaultLighting(); // Effect 2 settings / Default.FX file from 3DS Max Design 2009 effect2.Parameters["World"].SetValue(boneTransforms[mesh.ParentBone.Index]); effect2.Parameters["View"].SetValue(view); effect2.Parameters["Projection"].SetValue(projection); Matrix WV = boneTransforms[mesh.ParentBone.Index] * view; effect2.Parameters["WorldView"].SetValue(WV); effect2.Parameters["WorldViewProj"].SetValue(WV * projection); //effect2.Parameters["WorldViewProj"].SetValue(world * view * projection); effect2.Begin(); effect2.End(); } mesh.Draw(); } } --------------------- and here is the .fx file defualt.fx from 3DS Max 2009 --------------------- // 3ds max effect file // Simple Lighting Model // This is used by 3dsmax to load the correct parser string ParamID = "0x0"; //DxMaterial specific // light direction (view space) float3 lightDir : Direction < string UIName = "Light Direction"; string Object = "TargetLight"; > = {-0.577, -0.577, 0.577}; // light intensity float4 I_a = { 0.1f, 0.1f, 0.1f, 1.0f }; // ambient float4 I_d = { 1.0f, 1.0f, 1.0f, 1.0f }; // diffuse float4 I_s = { 1.0f, 1.0f, 1.0f, 1.0f }; // specular // material reflectivity float4 k_a < string UIName = "Ambient"; > = float4( 0.47f, 0.47f, 0.47f, 1.0f ); // ambient float4 k_d < string UIName = "Diffuse"; > = float4( 0.47f, 0.47f, 0.47f, 1.0f ); // diffuse float4 k_s < string UIName = "Specular"; > = float4( 1.0f, 1.0f, 1.0f, 1.0f ); // diffuse // specular int n< string UIName = "Specular Power"; string UIType = "IntSpinner"; float UIMin = 0.0f; float UIMax = 50.0f; > = 15; // transformations float4x4 World : WORLD; float4x4 View : VIEW; float4x4 Projection : PROJECTION; float4x4 WorldViewProj : WORLDVIEWPROJ; float4x4 WorldView : WORLDVIEW; struct VS_OUTPUT { float4 Pos : POSITION; float4 col : COLOR0; }; VS_OUTPUT VS( float3 Pos : POSITION, float3 col : COLOR, float3 Norm : NORMAL, float2 Tex : TEXCOORD0) { VS_OUTPUT Out = (VS_OUTPUT)0; float3 L = lightDir; float3 P = mul(float4(Pos, 1),(float4x4)World); // position (view space) float3 N = normalize(mul(Norm,(float3x3)World)); // normal (view space) float3 R = normalize(2 * dot(N, L) * N - L); // reflection vector (view space) float3 V = normalize(P); // view direction (view space) Out.Pos = mul(float4(Pos,1),WorldViewProj); // position (projected) float4 Diff = I_a * k_a + I_d * k_d * max(0, dot(N, L)); // diffuse + ambient float4 Spec = I_s * k_s * pow(max(0, dot(R, V)), n/4); // specular Out.col = Diff + Spec; return Out; } float4 PS( float4 Diff : COLOR0, float4 Spec : COLOR1, float2 Tex : TEXCOORD0, float2 Tex1 : TEXCOORD1 ) : COLOR { float4 color = Diff + Spec; return color ; } technique DefaultTechnique { pass P0 { // shaders CullMode = None; ShadeMode = Gouraud; VertexShader = compile vs_2_0 VS(); PixelShader = compile ps_2_0 PS(); } } Sorry for the long post, I can't seem to find anything wrong with my code, so I figure I best let someone whos done this before take a look. Thanks, MajSlayer

Share this post


Link to post
Share on other sites

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