Skip to content

Commit

Permalink
volumetric: remove -1
Browse files Browse the repository at this point in the history
  • Loading branch information
vlj committed Jan 28, 2024
1 parent db57f4a commit e702003
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 2 additions & 4 deletions data/base/shaders/vk/pointlights.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ vec4 iterateOverAllPointLights(
int lightIndex = PointLightsIndex[entryInLightList / 4][entryInLightList % 4];
vec4 position = PointLightsPosition[lightIndex];
vec4 colorAndEnergy = PointLightsColorAndEnergy[lightIndex];
vec3 tmp = position.xyz * vec3(1., 1., -1.);
light += processPointLight(WorldFragPos, fragNormal, viewVector, material, tmp, colorAndEnergy.w, colorAndEnergy.xyz, normalWorldSpaceToLocalSpace);
light += processPointLight(WorldFragPos, fragNormal, viewVector, material, position.xyz, colorAndEnergy.w, colorAndEnergy.xyz, normalWorldSpaceToLocalSpace);
}
return light;
}
Expand Down Expand Up @@ -154,8 +153,7 @@ vec4 volumetricLights(
int lightIndex = PointLightsIndex[entryInLightList / 4][entryInLightList % 4];
vec4 position = PointLightsPosition[lightIndex];
vec4 colorAndEnergy = PointLightsColorAndEnergy[lightIndex];
vec3 tmp = position.xyz * vec3(1., 1., -1.);
scatteredLight += colorAndEnergy.xyz * pointLightEnergyAtPosition(posOnViewLine, tmp, colorAndEnergy.w) * od;
scatteredLight += colorAndEnergy.xyz * pointLightEnergyAtPosition(posOnViewLine, position.xyz, colorAndEnergy.w) * od;
}

result += scatteredLight * currentTransmittence;
Expand Down
3 changes: 2 additions & 1 deletion lib/ivis_opengl/pielighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ void renderingNew::LightingManager::ComputeFrameData(const LightingData& data, L
const auto& light = culledLights[lightIndex];
result.positions[lightIndex].x = light.position.x;
result.positions[lightIndex].y = light.position.y;
result.positions[lightIndex].z = light.position.z;
// z coordinate system require the -1 factor before entering shaders
result.positions[lightIndex].z = -light.position.z;
result.colorAndEnergy[lightIndex].x = light.colour.byte.r / 255.f;
result.colorAndEnergy[lightIndex].y = light.colour.byte.g / 255.f;
result.colorAndEnergy[lightIndex].z = light.colour.byte.b / 255.f;
Expand Down

0 comments on commit e702003

Please sign in to comment.