Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 13 Dec 2009
Offline Last Active Jun 22 2012 12:43 PM

#4830480 Best way to render Earth's day and night

Posted by SnailCoder on 02 July 2011 - 05:05 PM

Could you tell me what you're trying to achieve here? Do you just want Earth with some sort of atmospheric scattering? I'm working on a planet renderer and I can probably point you in the right direction based on what you want to do.

I try to do space-view to Earth for my game.
I want that looks like google earth.
Must be very fast and very easy - becouse will port to android and OpenGl ES

now i improve as ginkgo explained. will better:
Posted Image

and very easy shader for terminator and shadow
void main( void )
vec4 texel0, texel1, resultColor;
	float alpha		= clamp( 8.0 * max( 0.0, dot( light_dir,  normal ) ), 0.0, 1.0 );	
	texel0			= texture2D( sampler2d, myTexCoord );
	texel1			= texture2D( nightTexture, myTexCoord );
	resultColor		= mix( texel0, texel1,  alpha );
	gl_FragColor	= resultColor;

will to do glow around Earth looks like google earth.

Ah, ok, If you don't want anything fancy then I suggest taking a page from a guy that I will link below. If you want to keep it simple then this is probably the way to go, If you have any questions regarding his approach I'm sure he won't mind you asking him. I provided you with two links, depending on the complexity you want. If you want anything more realistic/appealling than that (taking into account that your atmosphere will most likely be very thin compared to his), then you will have to implement considerably harder code, with the added computation cost that comes with that. Hope that helped.


#4829339 DirectX11 - CopyResource (Basic)

Posted by SnailCoder on 29 June 2011 - 06:38 PM

When you map the staging texture to read back the data, you're not checking the pitch. When you specify the pitch while initializing a texture (the SysMemPitch member of the D3D11_SUBRESOURCE_DATA) , basically you're saying "here is some data, and here is the pitch of that data". It doesn't specify the pitch to be used of the actual texture resource memory, which will instead be based on hardware and driver requirements. So when you map that staging texture, you have to use the pitch specified by the RowPitch member of the D3D11_MAPPED_SUBRESOURCE you get back from ID3D11DeviceContext::Map.

It's times like this, that I love gamedev. Concise, non-condescending replies that genuinely help people. Thanks a bunch, enjoy your rep and I hope you will stick on gamedev for a long time to come. We need more people like you in this forum. Thanks!

float* pHeightmapData = (float*)HeightmapSubresource.pData;
float HeightValue = pHeightmapData[nCurrentVertex]

If I was to access the data like this, how would I incorporate the pitch?

I think I figured it out, for anyone wondering, I just did

UINT uPitch = HeightmapSubresource.RowPitch;
pHeightmapData[((uPitch/sizeof(float))*nHeightY) + nHeightX]