Jump to content
  • Advertisement
Sign in to follow this  
lipsryme

How to make a Sun (physical)

This topic is 3026 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

Hi, right now I'm doing an outside scene with daytime change but I've got a problem with the sun. Well of course the Sun would be the directional lighting but I want to have a sun on the horizon that I can translate according to the daytime. I've been trying to figure out a way to do that but I can't think of anything that'll work. Does any here have an idea how I can do that ? It doesn't have to be the best looking way.

Share this post


Link to post
Share on other sites
Advertisement
What's wrong with a white sphere? Or am i missing the point?

Share this post


Link to post
Share on other sites
Umm.....white sphere ?
I just want to know how to make a sun on the horizon (skydome) that I can move according to the current daytime.

Share this post


Link to post
Share on other sites
Well the sky dome i just a hemisphere that moves with the camera, draw a sphere just inside it that also moves with the camera.

Share this post


Link to post
Share on other sites
Quote:
Original post by lipsryme
so just a sphere ?
I'd have to deactivate depth as I did with the skydome then, right ?

Disable writes, but enable tests. Quick rule of thumb for this-- if you want it to be *hidden by* things, such as terrain, enable testing. If you want it to *hide* things, then enable writes.

Share this post


Link to post
Share on other sites
or you could compute the sun in the pixel shader for example like this


float3 norm = normalize(input.vertex);
float3 Sun = normalize(SunPos);
float SunDot = dot(Sun, norm);

vector sun = 0.5f * pow( max(0, SunDot), 300.0f );



code in action:

Share this post


Link to post
Share on other sites
Could you explain the last two lines?

Also what's with the normal calculation?
Do I draw a single vertex with Pos, Color and Normal ?
And where would the normal of that vertex point to ?

[Edited by - lipsryme on May 1, 2010 2:33:38 PM]

Share this post


Link to post
Share on other sites
well i'm not the best at explaining these thing but i'll give it a try:



You have a normal from the current pixel and one for the sun position. the smaller the angle between those, the bigger the dot product. the pow() is used to control the attenution.

Quote:

Also what's with the normal calculation?
Do I draw a single vertex with Pos, Color and Normal ?
[


No, you just have to pass the untransformed vertex position to the pixel shader to compute the normal because it is assumed that all faces of the skydome point to the center of the skydome.

vertex shader:


output.Vertex = input.Position;
output.Position = mul(float4(input.Position.xyz , 1.0f) , MatWVP);


Share this post


Link to post
Share on other sites
Hmm I don't quite get it.

So...the input.vertex is the untransformed Vertex Position of the Skydome ?

And the variable "norm" would then be the position vector of the Skydome pixel we are looking at ?

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!