How to make a Sun (physical)
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.
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.
I just want to know how to make a sun on the horizon (skydome) that I can move according to the current daytime.
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.
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.
or you could compute the sun in the pixel shader for example like this
code in action:
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:
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]
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]
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.
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:
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);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement