Skip to content

Commit

Permalink
fix world space position of point light lens flares
Browse files Browse the repository at this point in the history
  • Loading branch information
fallahn committed Sep 2, 2024
1 parent 58f6ce6 commit 837f29b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crogine.sln
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ Global
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|Any CPU.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|ARM.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|ARM64.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.ActiveCfg = Release|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.Build.0 = Release|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.ActiveCfg = ReleaseGNS|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.Build.0 = ReleaseGNS|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x86.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x86.Build.0 = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release-asan|Any CPU.ActiveCfg = Release-asan|Win32
Expand Down
4 changes: 2 additions & 2 deletions samples/golf/buildnumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef BUILD_NUMBER_H_
#define BUILD_NUMBER_H_

#define BUILDNUMBER 7142
#define BUILDNUMBER_STR "7142"
#define BUILDNUMBER 7145
#define BUILDNUMBER_STR "7145"

#endif /* BUILD_NUMBER_H_ */
3 changes: 3 additions & 0 deletions samples/golf/src/golf/GolfState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3859,6 +3859,9 @@ void GolfState::spawnBall(const ActorInfo& info)
entity.getComponent<cro::LightVolume>().colour = miniBallColour.getVec4() / 2.f;
entity.getComponent<cro::Model>().setHidden(true);

//hack to stop the point light lens flares drawing on balls
entity.addComponent<LightAnimation>().pattern.clear();

ballEnt.getComponent<cro::Transform>().addChild(entity.getComponent<cro::Transform>());
}
}
Expand Down
4 changes: 2 additions & 2 deletions samples/golf/src/golf/GolfStateCameras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2115,7 +2115,7 @@ void GolfState::updatePointFlares(cro::Entity e, float)
static constexpr float MaxLightDist = 50.f;
static constexpr float MaxLightDistSqr = MaxLightDist * MaxLightDist;

const auto lightPos = light.getComponent<cro::Transform>().getPosition();
const auto lightPos = light.getComponent<cro::Transform>().getWorldPosition();
if (glm::length2(lightPos - camPosition) > MaxLightDistSqr)
{
//skip lights further than max dist
Expand All @@ -2142,7 +2142,7 @@ void GolfState::updatePointFlares(cro::Entity e, float)

cro::Colour c(depthUV.x, depthUV.y, ndc.z / ndc.w, Brightness);
const auto pos = (screenPos * OutputSize) + OutputSize;
const float Scale = 1.f - (glm::length(lightPos - camPosition) / MaxLightDist);
const float Scale = (1.f - (glm::length(lightPos - camPosition) / MaxLightDist)) * light.getComponent<cro::Transform>().getWorldScale().x;

addQuad(glm::vec2(Scale) * m_viewScale.x, pos, c);
}
Expand Down

0 comments on commit 837f29b

Please sign in to comment.