Jump to content

  • Log In with Google      Sign In   
  • Create Account


Sun light in space


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 MARS_999   Members   -  Reputation: 1239

Like
0Likes
Like

Posted 04 May 2012 - 11:15 PM

I am not sure what I should be using to do this, but I have a star in space, and want it to be the source of light for all the planets and such. Do I want to use a point light for this? Or is there some better way? I am guessing directional isn't what I want due to the star should emit in all directions...

Problem is I would also like the sides of the planets that aren't facing the sun to be somewhat light so the player can see them easier....

Any ideas on this?

Thanks!

Sponsor:

#2 Sandman   Moderators   -  Reputation: 2079

Like
0Likes
Like

Posted 05 May 2012 - 12:45 AM

It kind of depends on how you are representing your solar system.

If you are going for some kind of realistic sim approach, then due to the distances involved you're probably not going to want to draw all your planets in one 3d space anyway. You'd probably be better off rendering all but the very nearby objects to billboards with directional lighting and only updating them when the player/planet/sun angle changes by some amount (which will be fairly infrequent).

If your solar system is a bit more abstract, with shorter distances and larger planets so you can see more detail on screen at once, you would possibly be better off using the directional light.

For lighting the dark sides, tweak the ambient light values. Alternatively, look into some kind of rim lighting or atmosphere effect to give you a really dark 'dark side' but still making the outline visible.

#3 jfalstaff   Members   -  Reputation: 101

Like
0Likes
Like

Posted 05 May 2012 - 03:03 AM

I am not sure what I should be using to do this, but I have a star in space, and want it to be the source of light for all the planets and such. Do I want to use a point light for this? Or is there some better way? I am guessing directional isn't what I want due to the star should emit in all directions...


The distance between star and planets makes directional lighting realistic. A player would not, generally, travel enough distance to change the vector of light, unless they were traveling FTL.


Problem is I would also like the sides of the planets that aren't facing the sun to be somewhat light so the player can see them easier....


Ambient lighting.

#4 MARS_999   Members   -  Reputation: 1239

Like
0Likes
Like

Posted 05 May 2012 - 09:28 AM

ok, but what I am failing to understand is, with the sun at position(0,0,0) and say earth at 15,0,0 and it rotates around the sun the earth should be lit always when facing the sun, but with a directional light I don't see how this can be when I state a directional light of say 1,1,1 wouldn't I need a directional light of -1,-1,-1 also?

#5 Bacterius   Crossbones+   -  Reputation: 8178

Like
0Likes
Like

Posted 05 May 2012 - 08:44 PM

It should probably be modelled as a point light, emitting in all directions, you obtain the light direction by subtracting the world position of the pixel to light with the point light's position. Basically the light direction to a point P will be the vector going from the point light to P (normalized, if needed).

Directional light only makes sense if the light source is very, very far away and you cannot see any point with a significantly different directional vector to the light source. This works if you are an observer on the Earth, looking at the sun, as there is nothing to see "behind the sun", but it doesn't work if you are in space, as you will be able to see planets rotating around the Sun, which will break down the illusion.

But this is for a realistic simulation, you may be able to get away with directional lighting, it depends. But why would you want to? It's not like directional lighting is infinitely cheaper than other alternatives.Directional lighting is just an extreme case of a point light, in which the latter is located infinitely far away from the observer in the appropriate direction, which allows some simplifications.

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#6 kalle_h   Members   -  Reputation: 1277

Like
1Likes
Like

Posted 06 May 2012 - 04:29 AM

Calculate light direction per object basis and then use that as directional light.

#7 NickUdell   Members   -  Reputation: 288

Like
0Likes
Like

Posted 08 May 2012 - 09:16 AM

I would say it depends on the number of other light sources in the scene. If your sun is the only light source (or one of very few sources), then it's probably fine to use a point light, as it would be closest to simulating what you want. This way you can give more time to rendering a higher-resolution light map from that one point light, to compensate for the large distances / comparatively small items involved. If there are a lot of lights then a directional system is probably best, and simply update the light direction when your position moves sufficiently.

If you're also dealing with a lot of objects all around the star you could use the following in the vertex shader before your lighting stage:

const float3 sunPosition //sun position, I've used a constant here because I assume it doesn't move.
float3 position //untransformed position at that point

float3 lightDirection = normalize(position - sunPosition); //gets the direction the light will be travelling towards your object from the sun - push this to the pixel shader to get per-pixel light directions for each rendered pixel, then simply run the standard direction light code.

Even better: put the sun at the origin (0,0,0) and you don't have to do that initial calculation. simply normalize the position of the vertex in the world.

Edited by NickUdell, 08 May 2012 - 09:24 AM.

Sole Creator of Pigment - a procedural, block-base space trading sim.

PhD student working on medical imaging at the University of Southampton.

Enjoyer of games, films, books and cider.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS