Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looking for recommendations to Create a physically accurate sun #674

Open
Drosaca opened this issue Oct 18, 2024 · 6 comments
Open

Looking for recommendations to Create a physically accurate sun #674

Drosaca opened this issue Oct 18, 2024 · 6 comments

Comments

@Drosaca
Copy link

Drosaca commented Oct 18, 2024

Hi, I' m trying to create the sun in space (as a light emitting object if it's feasible) with a light source as physically accurate as possible.

I was wondering if someone has any recommendations on which kind of light sources I shoud use (AreaLight or PhysicalSpotLight) and which values I should tweak to get the best result.

thanks,

@gkjohnson
Copy link
Owner

Your best bet for getting some kind of realistic sun and sky effect is probably to use an environment map for lighting.

@Drosaca
Copy link
Author

Drosaca commented Oct 22, 2024

My goal is to simulate sunlight hitting a distant object from various angles in space and render an image that closely resembles what a real camera would capture when pointing at the dark night sky.

Initially, I was considering creating the sun either as an object that emits light or as an invisible light source to simplify its positioning relative to the object . Do you think this path tracer can handle such a simulation?
Additionally, do you still believe that using a normal map would be the better approach here?
If this simulation doesn’t face any known limitations, I would greatly appreciate any suggestions on the types of objects or parameters that would help achieve the most realistic results.

@Drosaca
Copy link
Author

Drosaca commented Nov 15, 2024

I Tried with a physical spotlight and a sphere with emissivity set at 1 the spotlight is in the center of the sphere and all of this is positioned at 1 astronomical unit (in meters) with the real lumen value
which gives this
image
it's too bright even to see the colors
if I reduce the brigness by 10^4 it's better but not physically accurate
image

@gkjohnson
Copy link
Owner

Sorry for the delay in response - generally I would still recommend something like an environment map that has data encoded in a known unit for this use case. Punctual lights (like directional lights, spot lights, point lights) are difficult to model and not realistic representations of light sources, though at far ranges the sun is often modeled as a directional light.

Additionally, do you still believe that using a normal map would be the better approach here?

I don't think a normal map would help with lighting here. Do you mean an environment map?

render an image that closely resembles what a real camera would capture
...
all of this is positioned at 1 astronomical unit (in meters) with the real lumen value which gives this

There's a lot that's involved in modeling what a real camera would capture, I think, including lens distortion, etc, which isn't directly supported in the project. But I believe the primary piece that's missing here in terms of displayed light intensity would be tone mapping and color mapping - which will map the light intensities captured by the virtual (or real) sensor to a displayable color range.

You should be able to adjust both those fields on the WebGLRenderer (see the .colorMapping and .toneMapping settings).

@Drosaca
Copy link
Author

Drosaca commented Dec 8, 2024

Sorry for the delay in response - generally I would still recommend something like an environment map that has data encoded in a known unit for this use case

No worries thanks for your time :).

This solution will turn the positioning of the sun more difficult but it could work. As I'm looking for the sun in space It's quite difficult to find an image like that online, by any chance do you know how I could create that kind of environment map or know a good tutorial that could help ?

You should be able to adjust both those fields on the WebGLRenderer (see the .colorMapping and .toneMapping settings).

the .toneMappingExposure helped me to fix my luminosity and for the .toneMapping ACESFilmicToneMapping advestised as the best fit for camera was already set in my case. I didn't find the .colorMapping property in the docs the closest that i found is .outputColorSpace I will look further into these settings, though.

Punctual lights (like directional lights, spot lights, point lights) are difficult to model and not realistic representations of light sources

So the PhysicalSpotLight is not realistic ? Maybe this explains some unexpected results I got. Indeed I was wondering why when I rescaled my simulation by reducing distance between objects and turning them smaller, the objects became overexposed. This should not be the case since the unit for light power is expressed in lumen my objects being smaller shoud receive less light and thus keep the same luminosity or maybe i missed something?

I don't think a normal map would help with lighting here. Do you mean an environment map?

yes environment map sry

@gkjohnson
Copy link
Owner

gkjohnson commented Dec 15, 2024

As I'm looking for the sun in space It's quite difficult to find an image like that online, by any chance do you know how I could create that kind of environment map or know a good tutorial that could help ?

I don't have a good tutorial on hand but generally you can render a scene with a sun etc object in the right position and then use that cubemap as the environment map for lighting.

I didn't find the .colorMapping property in the docs the closest that i found is .outputColorSpace I will look further into these settings, though.

Sorry! Yes I meant colorSpace. The colorSpace properties need to be set correctly for each texture instance as well as on the WebGLRenderer.

So the PhysicalSpotLight is not realistic ? Maybe this explains some unexpected results I got. Indeed I was wondering why when I rescaled my simulation by reducing distance between objects and turning them smaller, the objects became overexposed. This should not be the case since the unit for light power is expressed in lumen my objects being smaller shoud receive less light and thus keep the same luminosity or maybe i missed something?

The fact that a spot light terminates at a single point makes it not very realistic. There are some properties to improve this (setting the radius) but it makes it behave a little more like an area light.

I want to be clear that this project isn't designed to be a rigorous lighting simulation tool for something like engineering use cases. The formulas used based on those commonly used in modern rendering as far as I understand but it hasn't be tested rigorously to ensure light preserving properties, correct light transfer, etc - in fact there are known issues. This is primarily a library for rendering things using path tracing to the end that they look physically plausible.

Regarding the scaling of objects changing the apparent exposure - I'd have to revisit some of the code in the project to remind myself of how some of these lights are behaving with scale but unfortunately I don't recall at the moment and don't have a ton of extra time at the moment to dig in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants