XNA Game Development Forums
2012/05/18 06:59:08 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Model & Shader Problems  (Read 2065 times)
Themodem
Newbie
*
Offline Offline

Posts: 3


View Profile
« on: 2007/03/26 02:42:57 »

Hey all, ive got a few problems with rendering.

1. When i try and render my boat (fbx file) it seems to render everything from one point, not from where it should be rendered from.



2. The shader seems to work on the boat but not on the water which stays black. //Ive managed to fix this

Any ideas what's going on?

Thanks Lee
« Last Edit: 2007/03/26 03:33:22 by Themodem » Logged
Nercury
Newbie
*
Offline Offline

Posts: 8


View Profile
« Reply #1 on: 2007/03/26 07:35:27 »

Can we see your shader code? Smiley
Logged
Themodem
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #2 on: 2007/03/26 07:39:18 »

Certainly can, its the BasicShader

Code:
float4x4 World;
float4x4 View;
float4x4 Projection;
float3 EyePosition;

float4 AmbientLightColor;
float4 DiffuseColor;
float SpecularPower;

float3 LightPosition;
float4 LightDiffuseColor;
float4 LightSpecularColor;

struct VS_INPUT {
float4 Position : POSITION0;
float3 Normal : NORMAL0;
};

struct VS_OUTPUT {
float4 Position : POSITION0;
float3 Normal : TEXCOORD1;
float3 ViewDirection : TEXCOORD2;
float3 LightDirection : TEXCOORD3;
};

VS_OUTPUT Transform(VS_INPUT Input){
float4x4 WorldViewProjection = mul(mul(World, View), Projection);
float3 ObjectPosition = mul(Input.Position, World);

VS_OUTPUT Output;
Output.Position = mul(Input.Position, WorldViewProjection);
Output.Normal = mul(Input.Normal, World);
Output.ViewDirection = EyePosition - ObjectPosition;
Output.LightDirection = LightPosition - ObjectPosition;

return Output;
}

struct PS_INPUT {
float3 Normal : TEXCOORD1;
float3 ViewDirection : TEXCOORD2;
float3 LightDirection : TEXCOORD3;
};

float4 BasicShader(PS_INPUT Input) : COLOR0{
float3 Normal = normalize(Input.Normal);
float3 ViewDirection = normalize(Input.ViewDirection);
float3 LightDirection = normalize(Input.LightDirection);
   
float EdgeComponent = dot(Normal, ViewDirection);
float4 TotalAmbient = saturate(AmbientLightColor * EdgeComponent);

float NDotL = dot(Normal, LightDirection);
float4 DiffuseAverage = (DiffuseColor + LightDiffuseColor) * 0.5f;
float4 TotalDiffuse = saturate(DiffuseAverage * NDotL);

float3 Reflection = normalize(2.0f * NDotL * Normal - LightDirection);
float RDotV = max(0.0f, dot(Reflection, ViewDirection));
float4 TotalSpecular = saturate(LightSpecularColor * pow(RDotV, SpecularPower));

float4 FinalColor = saturate(TotalAmbient + TotalDiffuse + TotalSpecular);
return FinalColor;
}

technique BasicShader {
pass P0 {
VertexShader = compile vs_2_0 Transform();
PixelShader  = compile ps_2_0 BasicShader();
}
}

I have managed to get around it by combining the polygons in maya and exporting it as one model, but i would like to know why its doing that  Smiley
Logged
Themodem
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #3 on: 2007/03/26 08:09:39 »

Ive managed to find another problem,


This is what the scene looks like normally


This is what it looks like when i zoom out a bit and move the camera, the boat appears to sink underwater  Huh

Not sure what's going on?

Thanks Lee
Logged
minich21
Newbie
*
Offline Offline

Posts: 12


View Profile
« Reply #4 on: 2007/03/26 08:26:55 »

The farther you go out the more of the boat disappears?  if so your culling is taking it out, you'll have to increase the distance if you want to see all your object at farther distances!
Logged
Tiago
Newbie
*
Offline Offline

Posts: 42


View Profile
« Reply #5 on: 2007/03/26 11:12:53 »

i dont think thats the problem since the water and background are still there.

my gess is you are passing a wrong world matrix when rendering the boat, try comparing the matrices you pass on your boat and the ones you pass for water and mountains since they seem to be working fine
Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Shader compiler General Discussion endre 2 2367 Last post 2006/08/12 01:24:40
by Chr0n1x
Having problems with my project Hazy Mind XNA Engine Twanks 10 3678 Last post 2006/11/18 09:51:53
by mikeschuld
Tut 6: Model Class Hazy Mind XNA Engine MicahN 2 2258 Last post 2006/11/15 09:43:47
by MicahN
How To: Render a model with a texture?? Hazy Mind XNA Engine Quinn 6 2323 Last post 2007/01/07 00:33:58
by mikeschuld
Intel GMA900 gfx problems Hazy Mind XNA Engine h4rdc0m 11 3537 Last post 2007/06/20 22:01:41
by zachaller
Problems with dll attempting managed Hazy Mind 3D Engine pjank42 2 2895 Last post 2007/03/11 18:42:00
by mikeschuld
Bumpmap Shader General Discussion « 1 2 3 4 5 » Nemo Krad 70 21675 Last post 2007/09/06 13:15:22
by Nemo Krad
Textured Quad Problems? Hazy Mind 3D Engine Robin Sarac 3 2168 Last post 2007/03/12 22:01:54
by Robin Sarac
Point Light Shader General Discussion Nemo Krad 0 2034 Last post 2007/03/18 07:18:13
by Nemo Krad
Have some problems... General Discussion EclipsE 6 2431 Last post 2007/03/28 08:23:06
by muchrejoicing
Model exporters General Discussion EclipsE 13 3719 Last post 2007/04/26 12:25:03
by EclipsE
Problems with HMModel Hazy Mind XNA Engine Hastur 1 1468 Last post 2007/08/03 12:34:48
by mikeschuld
Tranforming a model's vertices Hazy Mind XNA Engine « 1 2 » DoomMarine 29 6876 Last post 2007/08/28 05:15:34
by DoomMarine
Skybox and Mesh problems Hazy Mind 3D Engine EddyLuten 0 1597 Last post 2007/08/03 12:48:35
by EddyLuten
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.909 seconds with 19 queries.