mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 03:53:52 +02:00
Fix glow line vanishing, improve transparency interaction
This commit is contained in:
parent
8ca3630cfa
commit
c644c87e69
3 changed files with 14 additions and 31 deletions
|
@ -11,11 +11,12 @@
|
|||
|
||||
#include "GeometryCache.h"
|
||||
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QThreadPool>
|
||||
#include <QtCore/QThreadPool>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
#include <FSTReader.h>
|
||||
#include <NumericalConstants.h>
|
||||
|
@ -1462,11 +1463,11 @@ void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const
|
|||
auto GS = gpu::Shader::createGeometry(std::string(glowLine_geom));
|
||||
auto PS = gpu::Shader::createPixel(std::string(glowLine_frag));
|
||||
auto program = gpu::Shader::createProgram(VS, GS, PS);
|
||||
state->setCullMode(gpu::State::CULL_BACK);
|
||||
state->setCullMode(gpu::State::CULL_NONE);
|
||||
state->setDepthTest(true, true, gpu::LESS_EQUAL);
|
||||
state->setDepthBias(1.0f);
|
||||
state->setDepthBiasSlopeScale(1.0f);
|
||||
state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);
|
||||
state->setBlendFunction(true,
|
||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), render::ShapePipeline::Slot::MAP::NORMAL_FITTING));
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
|
|
@ -24,9 +24,12 @@ void main(void) {
|
|||
d.x = 0.0;
|
||||
}
|
||||
float alpha = 1.0 - length(d);
|
||||
if (alpha < 0.01) {
|
||||
if (alpha <= 0.0) {
|
||||
discard;
|
||||
}
|
||||
alpha = pow(alpha, 10.0);
|
||||
if (alpha < 0.05) {
|
||||
discard;
|
||||
}
|
||||
_fragColor = vec4(inColor.rgb, alpha);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
//
|
||||
#extension GL_EXT_geometry_shader4 : enable
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardCameraTransform()$>
|
||||
|
||||
layout(location = 0) in vec4 inColor[];
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
@ -18,30 +21,6 @@ layout(location = 1) out vec3 outLineDistance;
|
|||
layout(lines) in;
|
||||
layout(triangle_strip, max_vertices = 24) out;
|
||||
|
||||
struct TransformCamera {
|
||||
mat4 _view;
|
||||
mat4 _viewInverse;
|
||||
mat4 _projectionViewUntranslated;
|
||||
mat4 _projection;
|
||||
mat4 _projectionInverse;
|
||||
vec4 _viewport;
|
||||
};
|
||||
|
||||
layout(std140) uniform transformCameraBuffer {
|
||||
TransformCamera _camera;
|
||||
};
|
||||
|
||||
TransformCamera getTransformCamera() {
|
||||
return _camera;
|
||||
}
|
||||
|
||||
vec3 getEyeWorldPos() {
|
||||
return _camera._viewInverse[3].xyz;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
vec3 ndcToEyeSpace(in vec4 v) {
|
||||
TransformCamera cam = getTransformCamera();
|
||||
vec4 u = cam._projectionInverse * v;
|
||||
|
|
Loading…
Reference in a new issue