In C++, how can I render city lights on the night side of the Earth with D3D9?

0

What I'm doing to render some beautiful city lights on the night side of the Earth is to render a second sphere mesh on top of the Earth mesh, then I set the city lights texture on it with 200% ambient light so they become very bright, and make the alpha channel of the dds texture file transparent so the Earth texture can be seen behind on the original Earth mesh.

The result is this pretty nice effect: http://s24.postimg.org/gpqg8a491/screenshot_2.png

This is the code for the mesh holding the lights texture:

        d3ddev->LightEnable(0, FALSE);
        d3ddev->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(200, 200, 200));
        d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
        d3ddev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
        d3ddev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_DESTALPHA);
        //d3ddev->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x0000008f);
        d3ddev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
        d3ddev->SetTexture(0, earth_lights); 

However the bad thing is that the lights also show in the day side, always, and that's pretty bad.

How can I achieve a similar result but with the lights not showing in the day side? Texture blending? Shaders?

c++
directx
textures
asked on Stack Overflow Jan 20, 2015 by Haalef

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0