Browse Source

more lighting

fix/style
Martin Dørum 3 years ago
parent
commit
d3ca166d2f

+ 1
- 1
core.mod/src/entities/PlayerEntity.h View File

@@ -24,7 +24,7 @@ private:
static constexpr float JUMP_VEL = 11;
static constexpr float DOWN_FORCE = 20 * MASS;
static constexpr Swan::Vec2 SIZE = Swan::Vec2(0.6, 1.9);
static constexpr float LIGHT_LEVEL = 30/255.0;
static constexpr float LIGHT_LEVEL = 0.2;

enum class State {
IDLE,

+ 1
- 1
libswan/include/swan/LightServer.h View File

@@ -51,7 +51,7 @@ public:

private:
static constexpr int LIGHT_CUTOFF_DIST = 64;
static constexpr float LIGHT_CUTOFF = 0.25/255.0;
static constexpr float LIGHT_CUTOFF = 0.001;

struct Event {
enum class Tag {

+ 2
- 3
libswan/src/LightServer.cc View File

@@ -32,12 +32,11 @@ static uint8_t linToSRGB(float lin) {
s = 1.055 * std::pow(lin, 1/2.4) - 0.055;
}

return std::clamp((int)(s * 255), 0, 255);
return std::clamp((int)round(s * 255), 0, 255);
}

static float attenuate(float dist, float squareDist) {
float a = 1 / (1 + 1.0 * dist + 0.1 * squareDist);
return a > 1 ? 1 : a;
return 1 / (1 + 1 * dist + 0.02 * squareDist);
}

static float attenuate(float dist) {

Loading…
Cancel
Save