Sign in to follow this  
leet bix

Deffered Light - Directional

Recommended Posts

I'm trying to convert this into DirectX9 code (, my depth, ambient colour and depth all seem to be rendering fine Colour map: Normal map: Although, when it comes around to rendering the directional light section, I get just the specular highlights (which are black for some odd reason), and it fades off, where the alpha on points when there is no specular highlight is 0. I use the hlsl from that as is except for the their method of directly mapping texels to pixels, I do that in my DrawFullScreenQuad function, I'm really stumpped, here's the directional light code:
void DefferedDirectionalLight()
	UINT uiPass, uiPassCount;

	g_pd3dDevice->SetRenderTarget(0, g_pSurfScene);

	D3DXVECTOR3 vColour = D3DXVECTOR3(1.0f, 1.0f, 1.0f);

	D3DXMATRIX mViewProj = D3DXMATRIX(g_Camera.GetViewMatrix() * g_Camera.GetProjectionMatrix());
	D3DXMATRIX mInverseViewProj;
	D3DXMatrixInverse(&mInverseViewProj, NULL, &mViewProj);

	g_pEffect->SetTexture("colorMap", g_pColourRT);
	g_pEffect->SetTexture("normalMap", g_pNormalRT);
	g_pEffect->SetTexture("depthMap", g_pDepthRT);
	g_pEffect->SetValue("lightDirection", g_Camera.GetEyeVector(), sizeof(g_Camera.GetEyeVector()));
	g_pEffect->SetValue("Color", vColour, sizeof(vColour));
	g_pEffect->SetValue("cameraPosition", g_Camera.GetEyeVector(), sizeof(g_Camera.GetEyeVector()));
	g_pEffect->SetValue("InvertViewProjection", mInverseViewProj, sizeof(mInverseViewProj));
	g_pEffect->Begin(&uiPassCount, 0);

	for(uiPass = 0; uiPass < uiPassCount; uiPass++)

		// Draw a fullscreen quad to sample the RT
        DrawFullScreenQuad(0.0f, 0.0f, 1.0f, 1.0f);


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this