Jump to content
  • Advertisement
Sign in to follow this  
lyzerk

light doesn't work on model

This topic is 2228 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, im working on lights but i have problem with it.

http://prntscr.com/finfv

as you see terrain model has light but that house model never effect with that light, i didn't understand why im doing same process to house model.

here is my HLSL code :

[source lang="java"]float4 PixScene( float4 ViewPos : TEXCOORD0,
float3 ViewNormal : TEXCOORD1,
float2 Tex0 : TEXCOORD2,
float4 Diffuse : TEXCOORD3 ) : COLOR0
{
float3 L = g_vLightView - ViewPos;
float LenSq = dot( L, L );
L = normalize( L );

float4 I = saturate( dot( normalize( ViewNormal ), L ) ) * Diffuse *
(LIGHT_FALLOFF * LIGHT_FALLOFF) / LenSq;

return float4( tex2D( g_samScene, Tex0 ).xyz, 1.0f ) * I;
//return float4(1.0f,1.0f,1.0f,1.0f);
}[/source]

cpp
[source lang="cpp"] V ( g_Effect->Begin( &cPasses, 0 ) );

for( int p = 0; p < cPasses; p++)
{
V ( g_Effect->BeginPass ( p ) );

world = g_Map.GetWorldMatrix();
V( g_Effect->SetMatrix( g_Effect->GetParameterByName(NULL, "g_mWorldView"), &world ) );
V( g_Effect->CommitChanges() );
ID3DXMesh* mesh = g_Map.BaseModel.GetMesh();

for( UINT i = 0; i < g_Map.BaseModel.m_dwNumMaterials; ++i )
{
V( g_Effect->SetTexture( g_Effect->GetParameterByName(NULL, "g_txScene") , g_Map.BaseModel.m_pTextures ) );
V( g_Effect->CommitChanges() );

mesh->DrawSubset( i ) ;
}

V ( g_Effect->EndPass() );
}

g_Effect->End();

cPasses = 0;
V ( g_Effect->Begin( &cPasses, 0 ) );

for( int p = 0; p < cPasses; p++)
{
V ( g_Effect->BeginPass ( p ) );

world = g_Bar.GetWorldMatrix();
V( g_Effect->SetMatrix( g_Effect->GetParameterByName(NULL, "g_mWorldView"), &world ) );
V( g_Effect->CommitChanges() );
ID3DXMesh* mesh = g_Bar.BaseModel.GetMesh();

for( UINT i = 0; i < g_Bar.BaseModel.m_dwNumMaterials; ++i )
{
if(g_Bar.BaseModel.m_pTextures)
{
V( g_Effect->SetTexture( g_Effect->GetParameterByName(NULL, "g_txScene") , g_Bar.BaseModel.m_pTextures ) );
}
else
{
V( g_Effect->SetTexture( g_Effect->GetParameterByName(NULL, "g_txScene") , g_pDefaultTex ) );
}
V( g_Effect->CommitChanges() );
mesh->DrawSubset( i ) ;
}


V ( g_Effect->EndPass() );
}[/source]

-Thanks

Share this post


Link to post
Share on other sites
Advertisement
Well, in my last post I gave you already some hints how to solve this kind of situations:

simple things you may try are:

- make your pixel shader to output float4(ViewNormal,0.0f) to test the normals, the diffuse value (last time it was pretty black), output float4(L,0.0f) to test your camera to light vector etc.
- check that you really set all your lighting parameter values.

The formula works as I checked it last time. Your parameters just weren't correct.

Cheers!

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!