mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
add width param to vertex shader
This commit is contained in:
parent
8c5f97f3d1
commit
1791ed01ca
7 changed files with 15 additions and 28 deletions
|
@ -14,6 +14,8 @@
|
|||
#include "avatar/AvatarManager.h"
|
||||
#include "RayPickScriptingInterface.h"
|
||||
|
||||
static const float DEFAULT_LASER_POINTER_SIZE = 0.02f;
|
||||
|
||||
LaserPointer::LaserPointer(const QVariant& rayProps, const RenderStateMap& renderStates, const DefaultRenderStateMap& defaultRenderStates,
|
||||
const bool faceAvatar, const bool centerEndY, const bool lockEnd, const bool distanceScaleEnd, const bool scaleWithAvatar, const bool enabled) :
|
||||
_renderingEnabled(enabled),
|
||||
|
@ -163,11 +165,10 @@ void LaserPointer::updateRenderState(const RenderState& renderState, const Inter
|
|||
pathProps.insert("end", end);
|
||||
pathProps.insert("visible", true);
|
||||
pathProps.insert("ignoreRayIntersection", renderState.doesPathIgnoreRays());
|
||||
if (_scaleWithAvatar) {
|
||||
auto glowScaleProp = qApp->getOverlays().getProperty(renderState.getPathID(), "glowScale").value;
|
||||
float glowScale = glowScaleProp.isValid() ? avatarScale * glowScaleProp.toFloat() : avatarScale;
|
||||
pathProps.insert("glowScale", glowScale);
|
||||
}
|
||||
|
||||
float glowWidth = _scaleWithAvatar ? DEFAULT_LASER_POINTER_SIZE * avatarScale : DEFAULT_LASER_POINTER_SIZE;
|
||||
pathProps.insert("glowWidth", glowWidth);
|
||||
|
||||
qApp->getOverlays().editOverlay(renderState.getPathID(), pathProps);
|
||||
}
|
||||
if (!renderState.getEndID().isNull()) {
|
||||
|
|
|
@ -35,7 +35,6 @@ Line3DOverlay::Line3DOverlay(const Line3DOverlay* line3DOverlay) :
|
|||
_endParentJointIndex = line3DOverlay->getEndJointIndex();
|
||||
_glow = line3DOverlay->getGlow();
|
||||
_glowWidth = line3DOverlay->getGlowWidth();
|
||||
_glowScale = line3DOverlay->getGlowScale();
|
||||
}
|
||||
|
||||
Line3DOverlay::~Line3DOverlay() {
|
||||
|
@ -146,7 +145,7 @@ void Line3DOverlay::render(RenderArgs* args) {
|
|||
geometryCache->renderDashedLine(*batch, start, end, colorv4, _geometryCacheID);
|
||||
} else {
|
||||
// renderGlowLine handles both glow = 0 and glow > 0 cases
|
||||
geometryCache->renderGlowLine(*batch, start, end, colorv4, _glow, _glowWidth, _glowScale, _geometryCacheID);
|
||||
geometryCache->renderGlowLine(*batch, start, end, colorv4, _glow, _glowWidth, _geometryCacheID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -244,13 +243,6 @@ void Line3DOverlay::setProperties(const QVariantMap& originalProperties) {
|
|||
if (glowWidth.isValid()) {
|
||||
setGlowWidth(glowWidth.toFloat());
|
||||
}
|
||||
|
||||
auto glowScale = properties["glowScale"];
|
||||
if (glowScale.isValid()) {
|
||||
float gscale = glowScale.toFloat();
|
||||
setGlowScale(gscale);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QVariant Line3DOverlay::getProperty(const QString& property) {
|
||||
|
|
|
@ -33,7 +33,6 @@ public:
|
|||
glm::vec3 getEnd() const;
|
||||
const float& getGlow() const { return _glow; }
|
||||
const float& getGlowWidth() const { return _glowWidth; }
|
||||
const float& getGlowScale() const { return _glowScale; }
|
||||
|
||||
// setters
|
||||
void setStart(const glm::vec3& start);
|
||||
|
@ -44,7 +43,6 @@ public:
|
|||
|
||||
void setGlow(const float& glow) { _glow = glow; }
|
||||
void setGlowWidth(const float& glowWidth) { _glowWidth = glowWidth; }
|
||||
void setGlowScale(const float& glowScale) { _glowScale = glowScale; }
|
||||
|
||||
void setProperties(const QVariantMap& properties) override;
|
||||
QVariant getProperty(const QString& property) override;
|
||||
|
@ -74,7 +72,6 @@ private:
|
|||
|
||||
float _glow { 0.0 };
|
||||
float _glowWidth { 0.0 };
|
||||
float _glowScale { 1.0 };
|
||||
int _geometryCacheID;
|
||||
};
|
||||
|
||||
|
|
|
@ -1868,7 +1868,7 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm
|
|||
|
||||
|
||||
void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color, float glowIntensity, float glowWidth, float glowScale, int id) {
|
||||
const glm::vec4& color, float glowIntensity, float glowWidth, int id) {
|
||||
|
||||
// Disable glow lines on OSX
|
||||
#ifndef Q_OS_WIN
|
||||
|
@ -1931,10 +1931,10 @@ void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const
|
|||
vec4 p1;
|
||||
vec4 p2;
|
||||
vec4 color;
|
||||
float scale;
|
||||
float width;
|
||||
};
|
||||
|
||||
LineData lineData { vec4(p1, 1.0f), vec4(p2, 1.0f), color, glowScale };
|
||||
LineData lineData { vec4(p1, 1.0f), vec4(p2, 1.0f), color, glowWidth };
|
||||
details.uniformBuffer->resize(sizeof(LineData));
|
||||
details.uniformBuffer->setSubData(0, lineData);
|
||||
}
|
||||
|
|
|
@ -314,10 +314,10 @@ public:
|
|||
const glm::vec4& color1, const glm::vec4& color2, int id);
|
||||
|
||||
void renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||
const glm::vec4& color, float glowIntensity, float glowWidth, float glowScale, int id);
|
||||
const glm::vec4& color, float glowIntensity, float glowWidth, int id);
|
||||
|
||||
void renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2, const glm::vec4& color, int id)
|
||||
{ renderGlowLine(batch, p1, p2, color, 1.0f, 0.05f, 1.0f, id); }
|
||||
{ renderGlowLine(batch, p1, p2, color, 1.0f, 0.05f, id); }
|
||||
|
||||
void renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id)
|
||||
{ renderDashedLine(batch, start, end, color, 0.05f, 0.025f, id); }
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
//
|
||||
|
||||
in vec4 _color;
|
||||
in float _scale;
|
||||
|
||||
in float distanceFromCenter;
|
||||
out vec4 _fragColor;
|
||||
|
@ -22,7 +21,7 @@ void main(void) {
|
|||
float alpha = 1.0 - abs(distanceFromCenter);
|
||||
|
||||
// Convert from a linear alpha curve to a sharp peaked one
|
||||
alpha = _color.a * pow(alpha, 10.0/_scale);
|
||||
alpha = _color.a * pow(alpha, 10.0);
|
||||
|
||||
// Drop everything where the curve falls off to nearly nothing
|
||||
if (alpha <= 0.05) {
|
||||
|
|
|
@ -16,17 +16,15 @@ layout(std140) uniform lineData {
|
|||
vec4 p1;
|
||||
vec4 p2;
|
||||
vec4 color;
|
||||
float scale;
|
||||
float width;
|
||||
};
|
||||
|
||||
out vec4 _color;
|
||||
out float _scale;
|
||||
// the distance from the center in 'quad space'
|
||||
out float distanceFromCenter;
|
||||
|
||||
void main(void) {
|
||||
_color = color;
|
||||
_scale = scale;
|
||||
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
|
@ -42,7 +40,7 @@ void main(void) {
|
|||
// Find the vector from the eye to one of the points
|
||||
vec3 v2 = normalize(p1eye.xyz);
|
||||
// The orthogonal vector is the cross product of these two
|
||||
vec3 orthogonal = cross(v1, v2) * 0.02;
|
||||
vec3 orthogonal = cross(v1, v2) * width;
|
||||
|
||||
// Deteremine which end to emit based on the vertex id (even / odd)
|
||||
vec4 eye = (0 == gl_VertexID % 2) ? p1eye : p2eye;
|
||||
|
|
Loading…
Reference in a new issue