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

Add IES light profile import for realistic light projectors #715

Open
fire opened this issue Apr 15, 2020 · 26 comments
Open

Add IES light profile import for realistic light projectors #715

fire opened this issue Apr 15, 2020 · 26 comments

Comments

@fire
Copy link
Member

fire commented Apr 15, 2020

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.

@fire fire changed the title IES Lights using the light projector system IES lights import Apr 15, 2020
@Calinou
Copy link
Member

Calinou commented Apr 16, 2020

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
Copy link
Member Author

fire commented Apr 16, 2020

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

@Calinou Calinou changed the title IES lights import Add IES light profile import for realistic light projectors Apr 16, 2020
@fire
Copy link
Member Author

fire commented Apr 17, 2020

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
Copy link
Member

@orbatos
Copy link

orbatos commented Jun 29, 2020

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
Copy link

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
Copy link
Member Author

fire commented Sep 14, 2022

See also KhronosGroup/glTF#2200

@Calinou
Copy link
Member

Calinou commented Oct 23, 2022

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
Copy link
Member Author

fire commented Dec 4, 2023

Open the ies light and assign as a panorama.

@Nikoraito

This comment was marked as off-topic.

@Calinou
Copy link
Member

Calinou commented Dec 16, 2023

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

@fire
Copy link
Member Author

fire commented Jan 24, 2024

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
Copy link

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

@Calinou
Copy link
Member

Calinou commented Jul 5, 2024

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
Copy link
Member Author

fire commented Jul 5, 2024

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

@unfa
Copy link

unfa commented Aug 26, 2024

I wonder - in the absence of such a feature, could a Gradient 1D texture be used with a Light shader to at least approximate this effect without using texture proiection (which needs shadows, which is costly)?

@atirut-w
Copy link

That solution could definitely work with some modifications to GradientTexture2D to create projection textures for spotlights. Doesn't directly solve this proposal, though.

@Calinou
Copy link
Member

Calinou commented Aug 31, 2024

I wonder - in the absence of such a feature, could a Gradient 1D texture be used with a Light shader to at least approximate this effect without using texture proiection (which needs shadows, which is costly)?

Yes, a custom light() function in a spatial shader should be able to achieve this. However, the shader needs to be assigned to each material that might touch the light with the IES profile at any point during gameplay. This can be tedious to do without shader templates.

@MikeGO2611
Copy link

MikeGO2611 commented Aug 31, 2024

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.

So, how things have changed, I've learn basic stuff about graphic pipeline and shaders, and as the one that commented this quote I have to correct myself. I no longer find this very necessary, in fact if implemented following the Godot philosophy it should be done in a plugin and not in the main engine.

Solutions provided here about using a GradientTexture2D or GradientTexture1D in the projection of a light are more optimal, the only "issue" is that there is no option to radially project the Gradient1D (only through a GradientTexture2D).

@MikeGO2611
Copy link

Using a Spotlight3D, a projector of a GradientTexture2D set to radial, and a GradientTexture1D, I'm able to simulate IES Profiles but with complete artistic control.

You can check the results atacched:

GradientLight
GradientLightSettings

@FlooferLand
Copy link

FlooferLand commented Nov 13, 2024

I really like that workaround, I think there still should be an official implementation though.
Some people might want to use IES profiles of real lights, the 1D gradient editor is kinda clunky, and that makes very symmetrical looking IES profiles.

Just throwing my hat in if anyone more skilled is able to implement this, but since IES files are just raw text files full of numbers, it would be nice if this hypothetical IesTexture resource allowed us to create our own IES files within Godot. That would have the side-benefit of allowing people to visually edit existing IES files imported from websites as well as people downloading Godot to use it as a best-in-class IES editing tool :)

PS: You can save the resource from the workaround that was posted above as a tres file and the editor gives you pretty previews for it

@atirut-w
Copy link

Can't one just render an IES profile to a cubemap projector?

@the-simian
Copy link

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.

Late to answer, but CNDL An open source IES lighting creation tool, if that's useful here.

@unfa
Copy link

unfa commented Jan 6, 2025

Can't one just render an IES profile to a cubemap projector?

That'd be interesting.
Is it possible to project cubemaps with OmniLights?
Or reflection probes?

@atirut-w
Copy link

atirut-w commented Jan 6, 2025

Is it possible to project cubemaps with OmniLights?

The base Light3D class which OmniLight3D inherits have a property for projector textures, so in theory, it should work just fine. I've never tried it myself, though. If it works as I expected, one could write an IES importer that creates a texture.

@Calinou
Copy link
Member

Calinou commented Jan 6, 2025

Rendering the IES to a cubemap for OmniLight3D will run into the same issue as #715 (comment). It may not be a dealbreaker for some use cases, but it's worth thinking about.

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

Successfully merging a pull request may close this issue.