godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.1k stars 69 forks source link

Add IES light profile import for realistic light projectors #715

Open fire opened 4 years ago

fire commented 4 years ago

Describe the project you are working on: Not related to my project.

Describe the problem or limitation you are having in your project: Lights in Godot Engine are clunky and look the same.

There are existing IES profiles that give varied and exciting light types.

https://www.cgarena.com/freestuff/tutorials/max/ieslights/

Describe the feature / enhancement and how it helps to overcome the problem or limitation: It would make artwork and level design improved if IES light profiles can be imported directly.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

  1. Read IES profile
  2. Generate a format the light projector feature can use
  3. Import the format as a light projector

If this enhancement will not be used often, can it be worked around with a few lines of script?:

No, the convenience of dragging a profile to be a light projector is the feature.

Is there a reason why this should be core and not an add-on in the asset library?: In theory this can be a gdnative plugin, but ies profiles are an important visual tool in lighting a scene.

Other

I am not working on IES lights import, feel free to take on the task.

Calinou commented 4 years ago

Out of curiosity, are there freely-licensed IES profiles out there? Not just freely downloadable, but under a public domain-like license or a libre Creative Commons license. This would be useful for a demo project.

fire commented 4 years ago

https://renderman.pixar.com/ies-profiles I found this one.

fire commented 4 years ago

https://seblagarde.wordpress.com/tag/ies-specification/ Described how Frostbite implemented IES lights.

[Edited]

This is a copy of the IES parser code linked in that blog.

iesparserianashdown.zip

There is a broken link to the Frostbite paper https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf

clayjohn commented 4 years ago

Also Filament has a great explanation https://google.github.io/filament/Filament.md.html#lighting/directlighting/photometriclights

orbatos commented 4 years ago

At ies Library (https://ieslibrary.com), which started early this month, they currently have more than 100k IES files and tools to convert to LDT. They are also planning a Blender plugin to access the library, a type of utility that could be valuable for Godot as well.

MikeGO2611 commented 2 years ago

I find this very necessary. It would be a great leap forward in Godot rendering capabilities. IES lights are a important step for achieving realism, and would put Godot in the ArchViz scope.

fire commented 1 year ago

See also https://github.com/KhronosGroup/glTF/pull/2200

Calinou commented 1 year ago

Regarding the IES rendering itself, isn't a dedicated 1D Attenuation Texture property needed for accurate rendering?

Light projector textures for both OmniLight3D and SpotLight are applied in 2D space, but it doesn't apply to the light's attenuation (when light goes further away from the origin). Projectors also require shadows to be enabled, which can be too demanding for some game use cases (but I assume you always have shadows enabled for archviz and offline rendering in general).

fire commented 8 months ago

Open the ies light and assign as a panorama.

Nikoraito commented 8 months ago

I would REALLY love to see this

Calinou commented 8 months ago

@Nikoraito Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.

fire commented 7 months ago

4.5 Photometric Lights Summary

Photometric lights utilize a photometric profile to describe their intensity distribution, which is stored in a photometric file. There are two common formats: IES (.ies) and EULUMDAT (.ldt).

  • IES: Created by the Illuminating Engineering Society for electronic transfer of photometric data over the web. It's widely used in North America and Europe.
  • EULUMDAT: The European standard and industry standard photometric data file in Europe.

Many lighting manufacturers provide these files freely on their websites. Both formats store luminous intensity for various angles, measured using light sensors spread spherically around a light source.

The spherical coordinate system used to describe light distribution is referred to as "the photometric web". There are three types of photometric webs:

  1. Type A: For automotive headlamp and signal lights
  2. Type B: For adjustable outdoor area and sports lighting luminaires
  3. Type C: For architectural and road lights (most commonly used in computer graphics)

The IES format stores luminous intensity values in candela, while the EULUMDAT format stores luminous intensity values in candela per total kilo-lumens emitted by the light.

In Frostbite, only the IES format is supported due to its widespread use in computer graphics. A photometric profile, created from IES files, can be directly applied on a point or a spot light. The IES profile can be used for describing the light intensity and can be adjusted with a multiplier.

When creating a new light profile, the spherical photometric function is reconstructed and sampled to fill a 2D texture with a spherical parametrization. In shaders, the 2D texture is evaluated and applied as an attenuation.

IES profiles are more useful for architectural design than in games. However, they can be used for simulating complex shadows, similar to cookie textures but with a different parametrization.

https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf

I am encountering linkrot here is the relevant text.

float getIESProfileAttenuation(float3 L, ShadowLightInfo light)
{
    // Sample direction into light space
    float3 iesSampleDirection = mul(light.worldToLight, -L);

    // Cartesian to spherical
    // Texture encoded with cos(phi), scale from -1 ->1 to 0 ->1
    float phiCoord = (iesSampleDirection.z * 0.5f) + 0.5f;
    float theta = atan2(iesSampleDirection.y, iesSampleDirection.x);
    float thetaCoord = theta * FB_INV_TWO_PI;
    float3 texCoord = float3(thetaCoord, phiCoord, light.lightIndex);
    float iesProfileScale = iesTexture.SampleLevel(sampler, texCoord, 0).r;

    return iesProfileScale;
}

// ...

att *= getAngleAtt(L, lightForward, lightAngleScale, lightAngleOffset);
att *= getIESProfileAttenuation(L, light);

// lightColor depends on option.
// Non masked: lightColor = color * MaxCandelas
// Masked (for point light with luminous power): lightColor = color * phi / (4 * PI)
float3 luminance = BSDF(...) * saturate(dot(N, L)) * lightColor * att;

// And lastly if you are generating a photometric web from the data for ray tracing or radiosity, you should interpolate the horizontal angles using a cubic spline curve (open or closed depending on whether the full 360 range of horizontal angles is specified).
Mohammad9760 commented 1 month ago

any news on this? is anyone working to implement this feature? if yes please share the progress.

Calinou commented 1 month ago

any news on this? is anyone working to implement this feature? if yes please share the progress.

To my knowledge, nobody is currently working on implementing this feature.

fire commented 1 month ago

My last work was here https://github.com/V-Sekai/godot/tree/salvage/ies-lights but I am not working on it currently.