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[i] ) ); 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[i]) { V( g_Effect->SetTexture( g_Effect->GetParameterByName(NULL, "g_txScene") , g_Bar.BaseModel.m_pTextures[i] ) ); } 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
1 reply to this topic
Sponsor:
#2 Members - Reputation: 1133
Posted 14 September 2012 - 08:58 AM
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!
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!






