Jump to content
  • Advertisement
Sign in to follow this  
leet bix

Deffered Light - Directional

This topic is 3431 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to convert this into DirectX9 code (http://www.catalinzima.com/?page_id=49), my depth, ambient colour and depth all seem to be rendering fine Colour map: http://img34.imageshack.us/img34/6673/screenshot0q.png Normal map: http://img30.imageshack.us/img30/7526/screenshot1i.png 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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!