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 initial ies lights. #63835

Closed
wants to merge 4 commits into from
Closed

Add initial ies lights. #63835

wants to merge 4 commits into from

Conversation

fire
Copy link
Member

@fire fire commented Aug 2, 2022

Fixes: godotengine/godot-proposals#715

Status:

  • Copyright handling

Imports something into an image. Not sure how projectors work.

image

Part of the V-Sekai project. https://github.com/v-sekai

@fire fire force-pushed the ies-lights branch 3 times, most recently from 1414a5b to f4f9f98 Compare August 2, 2022 18:09
@Calinou Calinou added this to the 4.0 milestone Aug 2, 2022
@fire fire force-pushed the ies-lights branch 4 times, most recently from 036f62e to 74eed9e Compare August 2, 2022 18:27
@jcostello
Copy link
Contributor

How does it works?

@fire
Copy link
Member Author

fire commented Aug 2, 2022

I currently have generated a 521x1 strip.

My next task is to convert that to a cube map.

float interpolate2D(const IESFileInfo& info, float angleV, float angleH) const;

Assistance helpful.

@fire fire force-pushed the ies-lights branch 2 times, most recently from bc48fc7 to dd56013 Compare August 2, 2022 18:53
@fire
Copy link
Member Author

fire commented Aug 2, 2022

@clayjohn Said he'll describe how to integrate with the light projectors.

// From the original guide
// hlsl
float3 ComputeIESLightProfile1D(float3 L, float3 LightDirection)
{
    L = mul(L, (float3x3)matViewInverse);
    float angle = (1 - acos(dot(L, LightDirection)) / PI);
    return tex2Dlod(IESTextureSamp, float4(angle, 0, 0, 0)).rgb;
}

// add navigation debugmesh visual instances if debug is enabled
SceneTree *st = SceneTree::get_singleton();
if (st && st->is_debugging_navigation_hint()) {
if (!nm.navmesh_debug_instance.is_valid()) {
RID navmesh_debug_rid = navmesh->get_debug_mesh()->get_rid();
RID navmesh_debug_rid = navmesh->_get_debug_mesh()->get_rid();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems unrelated?

@reduz
Copy link
Member

reduz commented Aug 11, 2022

This looks good, why a draft?

#include "core/string/ustring.h"

#include "thirdparty/ies/ies_loader.h"
#include <ios>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What needs this? I only see std::string.

thirdparty/README.md Outdated Show resolved Hide resolved
thirdparty/README.md Outdated Show resolved Hide resolved
static void getInt(const std::string& data, std::string& next, std::int32_t& ret, bool stopOnWhiteSpace = true, bool stopOnComma = false);
};

#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline at EOF.

getLineContent(data, next, line, stopOnWhiteSpace, stopOnComma);
assert(!line.empty());
ret = std::atoi(line.c_str());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline.

Comment on lines 254 to 256
- License: MIT

See the standard from https://github.com/ray-cast/ies/blob/master/IES.pdf and from http://www.tc.faa.gov/its/worldpac/Standards/ansi/ansi-ies%20rp-1-04.pdf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- License: MIT
See the standard from https://github.com/ray-cast/ies/blob/master/IES.pdf and from http://www.tc.faa.gov/its/worldpac/Standards/ansi/ansi-ies%20rp-1-04.pdf
- License: MIT
Files extracted from upstream source:
- `ies_loader.{cpp,h}`
- `LICENSE.txt`
See the standard from https://github.com/ray-cast/ies/blob/master/IES.pdf and from http://www.tc.faa.gov/its/worldpac/Standards/ansi/ansi-ies%20rp-1-04.pdf

COPYRIGHT.txt Outdated Show resolved Hide resolved
@fire
Copy link
Member Author

fire commented Aug 11, 2022

@reduz I wasn't sure how to take the 1x512 px image and turn it into a projection that Godot can use for cookie lighting.

@Calinou
Copy link
Member

Calinou commented Aug 11, 2022

I wasn't sure how to take the 1x512 px image and turn it into a projection that Godot can use for cookie lighting.

OmniLights use a texture with spherical projection (like HDRI panoramas, but upside down). SpotLights use box texture projection in the direction the SpotLight is pointing towards.

You should be able to correct the OmniLight projector's perspective using a polar to cartesian (or cartesian to polar) function.

@jcostello
Copy link
Contributor

Please ensure that this feature works with static lights when baking lightmaps

@fire
Copy link
Member Author

fire commented Aug 11, 2022

@jcostello I do not know if projectors bake. The goal of this pr is to generate a image that can be loaded by the light cookie projector.

@jcostello
Copy link
Contributor

@fire projectors seems to not be working at the moment

#59488

// add navigation debugmesh visual instances if debug is enabled
SceneTree *st = SceneTree::get_singleton();
if (st && st->is_debugging_navigation_hint()) {
if (!nm.navmesh_debug_instance.is_valid()) {
RID navmesh_debug_rid = navmesh->get_debug_mesh()->get_rid();
RID navmesh_debug_rid = navmesh->_get_debug_mesh()->get_rid();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, should be removed (you can open an issue about what that bug is because it's weird you keep changing it - but I suspect you might be working off a slightly outdated master branch if this breaks).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens on all my rebases up to last night. I also have the same error on ming-llvm and osx's clang.

@akien-mga akien-mga removed this from the 4.0 milestone Sep 1, 2022
@akien-mga akien-mga added this to the 4.x milestone Sep 1, 2022
fire and others added 3 commits September 1, 2022 08:57
Co-authored-by: Rémi Verschelde <[email protected]>
Co-authored-by: Rémi Verschelde <[email protected]>
Co-authored-by: Rémi Verschelde <[email protected]>
@fire
Copy link
Member Author

fire commented Sep 7, 2022

This is salvageable. Will need to re-evaluate in 4.x

@fire fire closed this Sep 7, 2022
@aaronfranke aaronfranke removed this from the 4.x milestone Feb 1, 2023
@Nikoraito

This comment was marked as off-topic.

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

Successfully merging this pull request may close these issues.

Add IES light profile import for realistic light projectors
7 participants