mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 11:39:49 -06:00
Fix issue with atmosphere rendering on top of spheres
This commit is contained in:
@@ -41,9 +41,9 @@
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr std::array<const char*, 5> UniformNames = {
|
||||
"opacity", "modelViewProjection", "modelViewRotation", "colorTexture",
|
||||
"mirrorTexture"
|
||||
constexpr std::array<const char*, 6> UniformNames = {
|
||||
"opacity", "modelViewProjection", "modelViewTransform", "modelViewRotation",
|
||||
"colorTexture", "mirrorTexture"
|
||||
};
|
||||
|
||||
enum class Orientation : int {
|
||||
@@ -275,6 +275,10 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) {
|
||||
glm::mat4(data.camera.combinedViewMatrix() * modelTransform);
|
||||
_shader->setUniform(_uniformCache.modelViewProjection, modelViewProjection);
|
||||
|
||||
const glm::dmat4 modelViewTransform =
|
||||
data.camera.combinedViewMatrix() * modelTransform;
|
||||
_shader->setUniform(_uniformCache.modelViewTransform, glm::mat4(modelViewTransform));
|
||||
|
||||
glm::mat3 modelViewRotation = glm::mat3(
|
||||
glm::dmat3(data.camera.viewRotationMatrix()) * modelRotation
|
||||
);
|
||||
@@ -342,7 +346,7 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) {
|
||||
}
|
||||
|
||||
_shader->setUniform(_uniformCache.opacity, adjustedOpacity);
|
||||
_shader->setUniform(_uniformCache._mirrorTexture, _mirrorTexture.value());
|
||||
_shader->setUniform(_uniformCache.mirrorTexture, _mirrorTexture.value());
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
|
||||
@@ -84,8 +84,8 @@ private:
|
||||
|
||||
std::unique_ptr<Sphere> _sphere;
|
||||
|
||||
UniformCache(opacity, modelViewProjection, modelViewRotation, colorTexture,
|
||||
_mirrorTexture) _uniformCache;
|
||||
UniformCache(opacity, modelViewProjection, modelViewTransform, modelViewRotation,
|
||||
colorTexture, mirrorTexture) _uniformCache;
|
||||
|
||||
bool _sphereIsDirty = false;
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
in vec4 vs_position;
|
||||
in vec2 vs_textureCoords;
|
||||
in vec3 vs_normal;
|
||||
in float vs_screenSpaceDepth;
|
||||
|
||||
uniform sampler2D colorTexture;
|
||||
uniform float opacity;
|
||||
@@ -43,7 +44,7 @@ Fragment getFragment() {
|
||||
|
||||
frag.color = texture(colorTexture, texCoord);
|
||||
frag.color.a *= opacity;
|
||||
frag.depth = vs_position.w;
|
||||
frag.depth = vs_screenSpaceDepth;
|
||||
|
||||
// G-Buffer
|
||||
frag.gPosition = vs_position;
|
||||
|
||||
@@ -30,8 +30,10 @@ layout(location = 1) in vec2 in_textureCoords;
|
||||
out vec2 vs_textureCoords;
|
||||
out vec4 vs_position;
|
||||
out vec3 vs_normal;
|
||||
out float vs_screenSpaceDepth;
|
||||
|
||||
uniform mat4 modelViewProjection;
|
||||
uniform mat4 modelViewTransform;
|
||||
uniform mat3 modelViewRotation;
|
||||
|
||||
|
||||
@@ -40,8 +42,10 @@ void main() {
|
||||
vs_textureCoords = in_textureCoords;
|
||||
|
||||
vec4 position = modelViewProjection * vec4(in_position.xyz, 1.0);
|
||||
vs_position = position;
|
||||
vs_position = modelViewTransform * vec4(in_position.xyz, 1.0);
|
||||
|
||||
// Set z to 0 to disable near/far-plane clipping
|
||||
gl_Position = vec4(position.xy, 0.0, position.w);
|
||||
|
||||
vs_screenSpaceDepth = position.w;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user