mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 18:01:15 +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 "GeometryCache.h"
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QtCore/QThreadPool>
|
||||||
#include <QThreadPool>
|
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtNetwork/QNetworkReply>
|
||||||
|
|
||||||
#include <FSTReader.h>
|
#include <FSTReader.h>
|
||||||
#include <NumericalConstants.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 GS = gpu::Shader::createGeometry(std::string(glowLine_geom));
|
||||||
auto PS = gpu::Shader::createPixel(std::string(glowLine_frag));
|
auto PS = gpu::Shader::createPixel(std::string(glowLine_frag));
|
||||||
auto program = gpu::Shader::createProgram(VS, GS, PS);
|
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->setDepthTest(true, true, gpu::LESS_EQUAL);
|
||||||
state->setDepthBias(1.0f);
|
state->setBlendFunction(true,
|
||||||
state->setDepthBiasSlopeScale(1.0f);
|
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;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), render::ShapePipeline::Slot::MAP::NORMAL_FITTING));
|
slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), render::ShapePipeline::Slot::MAP::NORMAL_FITTING));
|
||||||
gpu::Shader::makeProgram(*program, slotBindings);
|
gpu::Shader::makeProgram(*program, slotBindings);
|
||||||
|
|
|
@ -24,9 +24,12 @@ void main(void) {
|
||||||
d.x = 0.0;
|
d.x = 0.0;
|
||||||
}
|
}
|
||||||
float alpha = 1.0 - length(d);
|
float alpha = 1.0 - length(d);
|
||||||
if (alpha < 0.01) {
|
if (alpha <= 0.0) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
alpha = pow(alpha, 10.0);
|
alpha = pow(alpha, 10.0);
|
||||||
|
if (alpha < 0.05) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
_fragColor = vec4(inColor.rgb, alpha);
|
_fragColor = vec4(inColor.rgb, alpha);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
//
|
//
|
||||||
#extension GL_EXT_geometry_shader4 : enable
|
#extension GL_EXT_geometry_shader4 : enable
|
||||||
|
|
||||||
|
<@include gpu/Transform.slh@>
|
||||||
|
<$declareStandardCameraTransform()$>
|
||||||
|
|
||||||
layout(location = 0) in vec4 inColor[];
|
layout(location = 0) in vec4 inColor[];
|
||||||
|
|
||||||
layout(location = 0) out vec4 outColor;
|
layout(location = 0) out vec4 outColor;
|
||||||
|
@ -18,30 +21,6 @@ layout(location = 1) out vec3 outLineDistance;
|
||||||
layout(lines) in;
|
layout(lines) in;
|
||||||
layout(triangle_strip, max_vertices = 24) out;
|
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) {
|
vec3 ndcToEyeSpace(in vec4 v) {
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
vec4 u = cam._projectionInverse * v;
|
vec4 u = cam._projectionInverse * v;
|
||||||
|
|
Loading…
Reference in a new issue