Original Post
Hello,
I have problem with light pos, I did one HLSL file here technique
[source lang="cpp"]technique RenderDarkAtmospher
{
pass P0
{
VertexShader = compile vs_2_0 VertSceneAmbient();
PixelShader = compile ps_2_0 PixSceneAmbient();
StencilEnable = false;
ZFunc = LessEqual;
}
pass P1
{
VertexShader = compile vs_2_0 VertScene();
PixelShader = compile ps_2_0 PixScene();
ZEnable = true;
ZFunc = LessEqual;
StencilEnable = true;
AlphaBlendEnable = true;
BlendOp = Add;
SrcBlend = One;
DestBlend = One;
StencilRef = 1;
StencilFunc = Greater;
StencilPass = Keep;
}
}[/source]
anyway my HLSL functions is correct, i copy it from working one project. pass p0 is working great all terrain going a black Atmospher, but i tryed a values for light pos but itsnt worked. I want camera with light.
PixScene :
[source lang="cpp"] float3 L = g_vLightView - ViewPos;
float LenSq = dot( L, L );
L = normalize( L );
// Compute lighting amount
float4 I = saturate( dot( normalize( ViewNormal ), L ) ) * Diffuse *
(LIGHT_FALLOFF * LIGHT_FALLOFF) / LenSq;
// Lookup mesh texture and modulate it with diffuse
return float4( tex2D( g_samScene, Tex0 ).xyz, 1.0f ) * I;[/source]
and my camera matrixes
[source lang="cpp"] D3DXMATRIXA16 matWorld;
D3DXMatrixTranslation( &matWorld, camera.camera.x, camera.camera.y, camera.camera.z);
D3DXVECTOR3 vEyePt( 0, 100, 0 );
D3DXVECTOR3 vLookatPt( 0 , 0, camera.vec );
D3DXVECTOR3 vUpVec( 0, 1, 1 ); //up
D3DXMATRIXA16 matView;
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
D3DXMATRIXA16 result = matWorld * matView;
pd3dDevice->SetTransform( D3DTS_VIEW, &result );
D3DXMATRIXA16 matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI / 4, 1.0f, 1.0f, 1000.0f );
pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );[/source]
[source lang="cpp"] D3DXVECTOR3 vLight( -100, -100, -100);
id3dxEffect->SetValue( id3dxEffect->GetParameterByName(NULL, "g_vLightView"), &vLight, sizeof(vLight) );[/source]
What i should do for light pos ? nothings apper
Thanks.
I have problem with light pos, I did one HLSL file here technique
[source lang="cpp"]technique RenderDarkAtmospher
{
pass P0
{
VertexShader = compile vs_2_0 VertSceneAmbient();
PixelShader = compile ps_2_0 PixSceneAmbient();
StencilEnable = false;
ZFunc = LessEqual;
}
pass P1
{
VertexShader = compile vs_2_0 VertScene();
PixelShader = compile ps_2_0 PixScene();
ZEnable = true;
ZFunc = LessEqual;
StencilEnable = true;
AlphaBlendEnable = true;
BlendOp = Add;
SrcBlend = One;
DestBlend = One;
StencilRef = 1;
StencilFunc = Greater;
StencilPass = Keep;
}
}[/source]
anyway my HLSL functions is correct, i copy it from working one project. pass p0 is working great all terrain going a black Atmospher, but i tryed a values for light pos but itsnt worked. I want camera with light.
PixScene :
[source lang="cpp"] float3 L = g_vLightView - ViewPos;
float LenSq = dot( L, L );
L = normalize( L );
// Compute lighting amount
float4 I = saturate( dot( normalize( ViewNormal ), L ) ) * Diffuse *
(LIGHT_FALLOFF * LIGHT_FALLOFF) / LenSq;
// Lookup mesh texture and modulate it with diffuse
return float4( tex2D( g_samScene, Tex0 ).xyz, 1.0f ) * I;[/source]
and my camera matrixes
[source lang="cpp"] D3DXMATRIXA16 matWorld;
D3DXMatrixTranslation( &matWorld, camera.camera.x, camera.camera.y, camera.camera.z);
D3DXVECTOR3 vEyePt( 0, 100, 0 );
D3DXVECTOR3 vLookatPt( 0 , 0, camera.vec );
D3DXVECTOR3 vUpVec( 0, 1, 1 ); //up
D3DXMATRIXA16 matView;
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
D3DXMATRIXA16 result = matWorld * matView;
pd3dDevice->SetTransform( D3DTS_VIEW, &result );
D3DXMATRIXA16 matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI / 4, 1.0f, 1.0f, 1000.0f );
pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );[/source]
[source lang="cpp"] D3DXVECTOR3 vLight( -100, -100, -100);
id3dxEffect->SetValue( id3dxEffect->GetParameterByName(NULL, "g_vLightView"), &vLight, sizeof(vLight) );[/source]
What i should do for light pos ? nothings apper
Thanks.