Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 08 Apr 2011
Offline Last Active Today, 03:18 AM

Posts I've Made

In Topic: Simulating the sun

15 July 2015 - 02:46 AM

Here's what I've tried right now:

void Sun::Update()
	if (!mIsMoving)

	const auto now = Clock::now();
	const auto timeDiff = now - mTimeStart;
	const float count = std::chrono::duration_cast<Intervall>(timeDiff).count();

	assert(mNightDayRatio <= 1.0f);
	if (count >= 0.5f + 0.5f * mNightDayRatio)
		mTimeStart = now;

	const float angle = count * glm::two_pi<float>() - glm::pi<float>();

	mDirLight.mLightDirection = Vec3(glm::cos(angle), glm::sin(angle), glm::sin(angle));

The issue is that at low or high angles the shadows gets elongated/really long. Is there an easy remedy for this? I want to keep it simple it dosn't have to be realistic, only believable.

In Topic: Simulating the sun

08 July 2015 - 09:14 AM

Which part are you having trouble with? The initial angle, the movement over time, or both?


The angle is just a matter of picking an angle. If you want something specific, there's information online for calculating the exact angle the sun will be at for various times and places.


How do you move objects in your game now? The sun light is really just another thing in the game, so updating its rotation like you'd update another rotating object should work. (You could optimize it and only check in on it at long intervals if it's moving very slowly, but sounds like you just want to get it to work to start off with.)


This is a very basic setup, and there are a ton of other things you can do for the lighting in your game.



As for the initial angle, I found this for example while browsing (location: egypt):


On the 21st March/21st September, the sun will rise 91° east of due south and set 91° west of due south.


Which I suppose would be the initial/end direction. But how would I derive a XYZ directions from this? "East of due south"?


And for the rotation I suppose its simply transforming the current sun direction with a rotation matrix build using some angle along some axis. But what are those?

In Topic: GenerateMipmaps and staging textures

27 June 2015 - 01:58 PM

Do you really need your texture data to be in a staging texture? Why not just create a texture with D3D11_USAGE_DEFAULT with mip 0 filled in, and then generate the mips on the GPU?


That's what I do currently. But I figure since the textures are static wouldn't it be better for performance if I could create them as D3D11_USAGE_IMMUTABLE? But the issue is I need all mip-levels when creating them, hence the need for an intermediate texture. And I can't use "CopyResource" since the data has to be provided when creating the texture.

In Topic: GenerateMipmaps and staging textures

26 June 2015 - 01:25 PM

I'm stuck with these textures in a non-dds texture format. Is there no way to generate mipmaps with directx 11 and then read them back to the CPU?

In Topic: HLSL questions

15 June 2015 - 08:33 AM

Are you really sure you want to waste time for optimizing vertex shader code that only run for three vertices per fullscreen pass.


No, but I'm interested in the details nonetheless smile.png