Skip to content

Commit

Permalink
- exposed ui for changing global directional light orientation, curre…
Browse files Browse the repository at this point in the history
…ntly not saved anywhere
  • Loading branch information
kaffeewolf committed Nov 23, 2024
1 parent d389a2f commit ca62d49
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion code/render/lighting/lightcontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ LightContext::GetPosition(const Graphics::GraphicsEntityId id)
case LightType::AreaLightType:
return areaLightAllocator.Get<AreaLight_Transform>(lid).getposition();
default:
return directionalLightAllocator.Get<DirectionalLight_Transform>(lid).position;
return directionalLightAllocator.Get<DirectionalLight_Direction>(lid).vec;
}
}

Expand Down
11 changes: 11 additions & 0 deletions toolkit/editor/editor/ui/windows/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ Environment::Run(SaveMode save)
//const Math::vec3& color, const float intensity, const Math::vec3& ambient, const Math::vec3& backlight, const float backlightFactor, const float zenith, const float azimuth, bool castShadows = false);
Math::vec3 color = LightContext::GetColor(globalLight);
float intensity = LightContext::GetIntensity(globalLight);
Math::point direction = LightContext::GetPosition(globalLight);
// mildly hacky
float zenithrad = Math::acos(direction.y);
float zenith = Math::rad2deg(zenithrad);
float azimuth = Math::nearequal(zenithrad, 0.0f, TINY) ? 0.0f : Math::rad2deg(Math::asin(direction.z / Math::sin(zenithrad)));
bool changed = ImGui::SliderFloat("Azimut", &azimuth, 0.0f, 360.0f);
changed |= ImGui::SliderFloat("Zenith", &zenith, 0.0f, 90.0f);
if (changed)
{
LightContext::SetTransform(globalLight, Math::deg2rad(azimuth ), Math::deg2rad(zenith));
}
if (ImGui::ColorEdit3("Global light Color", &color.x))
{
LightContext::SetColor(globalLight, color);
Expand Down

0 comments on commit ca62d49

Please sign in to comment.