Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


lyzerk

Member Since 29 Aug 2012
Offline Last Active Sep 14 2012 02:50 PM

Topics I've Started

light doesn't work on model

14 September 2012 - 04:02 AM

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

d3dx9math problem, how can its possible ?

08 September 2012 - 03:22 PM

[source lang="cpp"] D3DXMATRIXA16 matWorld; D3DXMatrixTranslation( &matWorld, -89.0f, 0.0f, -132.0f );[/source]
Im calling that code with 2 project one result is : http://prntscr.com/f7nie
and another project result is : http://prntscr.com/f7nkt

how can its possible , first result wrong i think. anybody can explain it for me ?

-Thanks

Light position problem

05 September 2012 - 12:33 PM

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.

Terrain light problem

03 September 2012 - 01:58 AM

Hello,

I have problem with lights. I want to do dark atmospher with a dark light


my vertex is that;
[source lang="cpp"]struct VertexType{ float x,y,z; float Tu1, Tv1; float Tu2, Tv2; D3DVECTOR NORMAL;};[/source]
I dont know what i should do with NORMAL ? examples in lights they write it handle like -1,0,1 -1,1,0.


here my settings;

[source lang="cpp"] pd3dDevice->SetRenderState(D3DRS_LIGHTING, TRUE); pd3dDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(50, 50, 50));[/source]

how i should do it ? for dark light on terrain ?


-Thanks.

Strategy Camera

31 August 2012 - 03:08 AM

Hello, again me.

I'm trying to do strategy camera. here my codes;

terrain world view;
[source lang="cpp"] D3DXMATRIXA16 matWorld; D3DXMatrixTranslation( &matWorld, 0, 0, 0); g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );[/source]

and camera view;

[source lang="cpp"] D3DXVECTOR3 vEyePt( 0, 0, 100 ); D3DXVECTOR3 vLookatPt(0, 0 , 0); D3DXVECTOR3 vUpVec( 0, 1, 0); //up D3DXMATRIXA16 matView; D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec ); pd3dDevice->SetTransform( D3DTS_VIEW, &matView );[/source]

my problem is that i tried all parametres in evept, lookatpt (upVec is for angle i think.) and i cant found right vector.

how can i do right and up vector with mouse ? like any strategy game ?

Thanks.

edit:

i tried camera world view like that before

[source lang="cpp"] D3DXMATRIXA16 matWorld; D3DXMatrixTranslation( &matWorld, camera.camera.x, camera.camera.y, camera.camera.z); pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); D3DXVECTOR3 vEyePt( 0, 0, 100 ); D3DXVECTOR3 vLookatPt(0, 0 , 0); D3DXVECTOR3 vUpVec( 0, 1, 0); //up D3DXMATRIXA16 matView; D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec ); pd3dDevice->SetTransform( D3DTS_VIEW, &matView );[/source]

but its doing nothing D3DTS_VIEW just like position of view i can't move it :S anybody have idea ?

PARTNERS