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

Make tracers actually glow #962

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Sources/Client/Tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
#include "Tracer.h"
#include "Client.h"
#include "IRenderer.h"
#include <Core/Settings.h>
#include <Draw/SWRenderer.h>

DEFINE_SPADES_SETTING(cg_tracerLights, "1");

namespace spades {
namespace client {
Tracer::Tracer(Client &_client, Vector3 p1, Vector3 p2, float bulletVel)
Expand Down Expand Up @@ -82,6 +85,31 @@ namespace spades {
r.AddLongSprite(*image, pos1, pos2, .05f);
}
}

// Add subtle dynamic light
if (cg_tracerLights) {
float startDist = curDistance;
float endDist = curDistance + visibleLength;

startDist = std::max(startDist, 0.f);
endDist = std::min(endDist, length);
if (startDist >= endDist) {
return;
}

Vector3 pos1 = startPos + dir * startDist;
Vector3 pos2 = startPos + dir * endDist;

DynamicLightParam light;
light.origin = pos1;
light.point2 = pos2;
light.color =
MakeVector3(1.f, 0.5f, 0.2f) * 0.1f * ((endDist - startDist) / visibleLength);
light.radius = 10.f;
light.type = DynamicLightTypeLinear;
light.image = nullptr;
r.AddLight(light);
}
}

Tracer::~Tracer() {}
Expand Down