pioneerspacesim / pioneer

A game of lonely space adventure
https://pioneerspacesim.net
1.64k stars 379 forks source link

Unlit planets are too dark #1624

Open Luomu opened 12 years ago

Luomu commented 12 years ago

Can't see shit :)

There used to be some extra ambient lighting when close to planets. I think it was better for gameplay. We could also have some faint rim lighting but that's for future consideration.

robn commented 12 years ago

Is this broken, or did the ambient light get removed? But yeah, that's pretty terrible. This is one of those places where realism sucks - you need to be able to see what the you're doing!

Luomu commented 12 years ago

Ambient light is still there. There's been some atmospheric adjustments in the recent months so perhaps the ambient just needs tweaking.

Ae-2222 commented 12 years ago

This is one of those places where realism sucks - you need to be able to see what the you're doing!

In the future, as far as gameplay is concerned, we can go into IR (planets retain heat), have some super-sensitive mode where star light illumination is enough (or just say HDR adjusts to star light) - even with the naked eye the Milkyway is bright enough to cast a shadow under dark sky conditions when there is no light pollution. Not to mention ship lights which can migrate to terrain. No real realism concern since the issue deals with technology which can be anything.

Ambient light is still there.

Tomm's take on the geosphereterrain.frag shader at the moment just adds a contribution from the atmosphere colour which depends on the optical depth of atmosphere between the eye and the fragment being coloured. It shouldn't make it any darker.

The code is operational. Changing the 0.1 in camdist = 0.1/ (camdist*camdist); in Geosphere.cpp GeoSphere::Render will change the magnitude of the effect.

so perhaps the ambient just needs tweaking.

Unfortunately contrast on my current setup is always too high even with it turned down a lot (I often have to adjust brightness to see specific things in bug images and generally don't see the ambient effect at all), so it's tricky to adjust it and say if it's enough on a typical system. (Actually, since most people just run on initial settings or adjust for desktop/typical desktop applications, it might help to have some post processing that adjusts brightness/contrast, in the far future).

It should be kept in mind that this code doubles as something which avoids terrain looking like moonscapes at close ranges during daytime. Too high values when brightly lit will cause some rgb values to clipped resulting in a bleached effect. A way to deal specifically with ambience during daytime, while still allowing occluded bits to be reasonably darker and taking into account altitude/atmosphere density/multiple suns/sun-positions, is on the to-do list. It requires some thought as it has a large impact on what people see.

Is it possible that your monitor/video settings have changed? Is the ambient light working as 'normal' in much earlier alpha tags..

Edit: Checking Lave.. when turning the brightness up a lot on my system the dark side of lave becomes visible. It seems that Lave's dark colour might mean that lighting by a dim ambient light does not show up as easily as it might for, say, Earth's moon.

Brianetta commented 12 years ago

The atmosphere is what provides night-time lighting (in the absence of reflective satellites), by refracting it over the horizon. Airless worlds should have dark skies and darker nights.

Is there a case for a headlight on a ship?

Ae-2222 commented 12 years ago

Is there a case for a headlight on a ship?

It's been requested/discussed before, so there's probably an issue but can't find it in a quick search. Navigating closer to terrain, inside shadow volumes in space once shadows are implemented (especially if there's identification writing to be read on un-powered ships), inside crevices on planets, or inside stations which have no power due to damage or disuse, would be easier.

Brianetta commented 12 years ago

I've just been looking at this (in the game). Planet surfaces remain quite dark even with the local sun above the horizon.The sun has to be really quite high before the terrain is properly lit.

Ae-2222 commented 12 years ago

Planet surfaces remain quite dark even with the local sun above the horizon

It's lit like a moon-scape even on planets with atmospheres where the sky is normally responsible for a large ambient component.

Brianetta commented 12 years ago

If only it were. Alas, Earth's surface isn't quite as pale.

Ae-2222 commented 12 years ago

Earth's surface isn't quite as pale.

I meant that there's no ambient component (other than the small nearness based ambient component), everything depends entirely on the extent the surface is perpendicular to the light direction (how close to 'noon' it is) and surfaces facing away are practically unlit.

Brianetta commented 12 years ago

I'd go with "no ambient component." Even if there's one in the code, it's not enough to see by.

Perpendicularity shouldn't have as great en effect; the terminator on an airless world is sharp.

Ae-2222 commented 12 years ago

Perpendicularity shouldn't have as great en effect;

I think we are talking about different things. I was talking about the lighting equation which fully lights the surface only if it's perfectly perpendicular to light direction..the directly lit component. On Earth there's an ambiently lit component too due to the radiance of the skydome. Currently there's no ambient component so the light drops away sharply once the sun is not overhead, assuming it's a flat plane.

The ambient component in the code is a artificial thing just there to stop people crashing into things at night. It could be replaced with various options discussed above like starlight HDR, IR modes, or ship spotlights.

the terminator on an airless world is sharp.

Yep, relatively speaking..but as part of the surface faces away from the light it will dim. (Also since the surface is not perfectly flat there will be a statistical distribution of local surface bits around the global surface angle.This will cause surfaces to be lit up for a bit even if they are facing slightly away. The effect will reduce the angle gets large.)

Ae-2222 commented 12 years ago

the terminator on an airless world is sharp.

The other factor is that the eye can see across a huge dynamic range when areas are not too close together especially given the ability to dilate/contract pupils. If you are on the surface the light at 'noon' and the light at 'dusk' may be very different and you can see well in both situations...if you are viewing light and dark regions at the same time and on a small image with light and dark regions nearby, it's a different matter.

Brianetta commented 12 years ago

I think we are talking about different things. I was talking about the lighting equation which fully lights the surface only if it's perfectly perpendicular to light direction..the directly lit component.

That strikes me as the wrong equation. Planetary surfaces are diffuse reflectors, so will appear to be fully lit no matter from what angle the light is shining. Perhaps this is the problem. If sunlight falls on a surface, that surface should be fully lit.

Ae-2222 commented 12 years ago

To sum up some discussion in IRC:

johnbartholomew commented 12 years ago

That strikes me as the wrong equation. Planetary surfaces are diffuse reflectors, so will appear to be fully lit no matter from what angle the light is shining. Perhaps this is the problem. If sunlight falls on a surface, that surface should be fully lit.

That's not quite correct. An ideal diffuse surface reflects light equally in all directions -- that is, its brightness appears the same for any viewing angle. But that's not the same as brightness being independent of the direction of incident light. The brightness of the surface is dependent on the irradiance, which is proportional to the cosine of the angle from the normal of the surface to the direction of the light.

See Lambert's cosine law

Luomu commented 12 years ago

So, the final terrain color is:

gl_FragColor =
    gl_FrontMaterial.emission + //wtf is this doing here, btw
    fogFactor *
    ((scene.ambient * vertexColor) +
    (diff * vertexColor)) +
    (1.0-fogFactor)*(atmosDiffuse*atmosColor);

Presumably fogFactor is zero or close to zero so it eats away the ambient color.

I suppose this became worse after the thicker atmospheres patch or changes to the atmospheric rendering formula.

Luomu commented 12 years ago

To sum up some discussion in IRC:

Most of these have nothing to do with the issue! This is all about there not being enough ambient lighting on unlit surfaces. Light angle doesn't matter. Post-processing of background stars doesn't matter.

Ae-2222 commented 12 years ago

Presumably fogFactor is zero or close to zero so it eats away the ambient color.

The fogFactor would have to be negative to subtract from the luminance value of the colour:) (atmosDiffuse*atmosColor shouldn't be negative..it's possible to just remove the entire term and see if it makes a difference.)

Most of these have nothing to do with the issue

Discussion veered off course a bit, the posts should be moved to another thread titled "planet surfaces are too dark" or something.

Luomu commented 12 years ago

The fogFactor would have to be negative to subtract from the luminance value of the colour

Not quite what I mean. Concentrate on this bit.

fogFactor * ( (scene.ambient * vertexColor) )

atmosDiffuseatmosColor does not matter, because we are looking at an unlit side of a planet. diff \ vertexColor does not matter for the same reason.

Ae-2222 commented 12 years ago

fogFactor * ( (scene.ambient * vertexColor) )

Oh..The fogFactor decreases from 1 to 0 as the amount of atmosphere between the eye and the fragment increases.

The term seems to simulate the fraction of light reaching the eye as a result of lighting by the ambient..if the atmosphere is thick enough the vertex colour won't be visible - it will be scattered out away from the fragment-eye ray (out scattering) or be small compared to in scattered light.

On worlds with a thick atmosphere, fogFactor will be ~0..i.e. it will stop the ambient light from reaching the eye. This seems approximately correct. However since the ambient is only used as a proximity light source we can rewrite it ..I think increasing scene ambient in Geosphere::Render and making fogFactor_scene.ambient to be the less than or equal to the largest value possible now on an airless world might help (i.e. fogFactor_scene.ambient < 0.1).

The scene ambient in Geosphere::Render should be calibrated to a typical atmosphere (Earth?) on a common monitor/video card setup.

(min(0.1,fogFactor * scene.ambient) * vertexColor)

Luomu commented 12 years ago

Airless worlds use a shader variation without the atmosphere calculation, so this shouldn't be an issue there. Good time to do a sanity check: fly to an unlit side of the moon and check if it is sufficiently visible.

Ae-2222 commented 12 years ago

It looks 'normal', i.e. not visible at all until I adjust the brightness a huge amount (and make things too bright on my system). I have to adjust the brightness even further to get Lave to show up so there is a difference there.

Brianetta commented 12 years ago

@Luomu The Moon. It's even darker when the sun isn't up. Imgur