Skip to content

Commit

Permalink
attempt to fix nvidia compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
stohrendorf committed Jan 30, 2021
1 parent c617950 commit 22babb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions shaders/lighting.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ layout(location=10) uniform float u_lightAmbient;

#include "csm_interface.glsl"

layout(std430) struct Light {
layout(offset=0) vec3 position;
layout(offset=12) float brightness;
layout(offset=16) float fadeDistance;
struct Light {
vec3 position;
float brightness;
float fadeDistance;
float _pad[2];
};

readonly layout(std430, binding=3) buffer b_lights {
Expand Down
7 changes: 4 additions & 3 deletions src/engine/lighting.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ struct Lighting
{
struct Light
{
glm::vec3 position{std::numeric_limits<float>::quiet_NaN()};
glm::vec4 position{std::numeric_limits<float>::quiet_NaN()};
float brightness = 0;
float fadeDistance = 0;
float _pad[3];
float _pad[2];

bool operator==(const Light& rhs) const
{
Expand Down Expand Up @@ -80,7 +80,8 @@ struct Lighting
// fade_distance / ( fade_distance + d )
std::transform(
room->lights.begin(), room->lights.end(), std::back_inserter(lights), [](const loader::file::Light& light) {
return Light{light.position.toRenderSystem(), light.getBrightness(), light.fadeDistance.get<float>()};
return Light{
glm::vec4{light.position.toRenderSystem(), 0.0f}, light.getBrightness(), light.fadeDistance.get<float>()};
});
}

Expand Down

0 comments on commit 22babb0

Please sign in to comment.