Posted 04 September 2012 - 05:06 AM
ok i research all links, but everybody has 200 line effect file(.fx) how can i understand that ? im trying basic light with fx file i did that for now;
effect file :
[source lang="cpp"]float4x4 matWorldViewProj; float4x4 matWorld; float4 vecLightDir;struct VS_OUTPUT{ float4 Pos : POSITION; float3 Light : TEXCOORD0; float3 Norm : TEXCOORD1;};VS_OUTPUT VS(float4 Pos : POSITION, float3 Normal : NORMAL){ VS_OUTPUT Out = (VS_OUTPUT)0; Out.Pos = mul(Pos, matWorldViewProj); // transform Position Out.Light = vecLightDir; // output light vector Out.Norm = normalize(mul(Normal, matWorld)); // transform Normal and normalize it return Out;}float4 PS(float3 Light: TEXCOORD0, float3 Norm : TEXCOORD1) : COLOR{ float4 diffuse = { 255.0f, 255.0f, 255.0f, 0.0f}; float4 ambient = {255.0f, 255.0f, 255.0f, 0.0f}; return ambient + diffuse * saturate(dot(Light, Norm));}technique myLight{ pass P0 { vertexShader = compile vs_2_0 VS(); pixelShader = compile ps_2_0 PS(); }} [/source]
here is code;
[source lang="cpp"] id3dxEffect->SetMatrix(id3dxEffect->GetParameterByName(NULL, "matWorldViewProj"), &matView ); id3dxEffect->SetMatrix(id3dxEffect->GetParameterByName(NULL, "matWorld"), &matWorld ); D3DXCOLOR color(1,1,1,1); id3dxEffect->SetValue(id3dxEffect->GetParameterByName(NULL, "vecLightDir"), &color, sizeof(color) ); id3dxEffect->SetTechnique(id3dxEffect->GetParameterByName(NULL, "myLight") ) ; UINT numPasses = 0; id3dxEffect->Begin( &numPasses, 0 ); for( int i = 0; i < numPasses; i++ ) { id3dxEffect->BeginPass( i ); //terrain.Render(pd3dDevice); id3dxEffect->EndPass(); } id3dxEffect->End(); id3dxEffect->Begin( &numPasses, 0 ) ; id3dxEffect->BeginPass(0); terrain.Render(pd3dDevice); id3dxEffect->EndPass(); id3dxEffect->End() ;[/source]
and terrain is gonna just black. im calling terrain.render wrong place ? Really i need to understand that but at internet all so complicated
sorry for my english.