mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 12:35:19 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into groups
This commit is contained in:
commit
dbf887fc34
13 changed files with 620 additions and 276 deletions
|
@ -44,6 +44,8 @@ function(AUTOSCRIBE_SHADER SHADER_FILE)
|
||||||
set(SHADER_TARGET ${SHADER_TARGET}_vert.h)
|
set(SHADER_TARGET ${SHADER_TARGET}_vert.h)
|
||||||
elseif(${SHADER_EXT} STREQUAL .slf)
|
elseif(${SHADER_EXT} STREQUAL .slf)
|
||||||
set(SHADER_TARGET ${SHADER_TARGET}_frag.h)
|
set(SHADER_TARGET ${SHADER_TARGET}_frag.h)
|
||||||
|
elseif(${SHADER_EXT} STREQUAL .slg)
|
||||||
|
set(SHADER_TARGET ${SHADER_TARGET}_geom.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SHADER_TARGET "${SHADERS_DIR}/${SHADER_TARGET}")
|
set(SHADER_TARGET "${SHADERS_DIR}/${SHADER_TARGET}")
|
||||||
|
@ -87,7 +89,7 @@ macro(AUTOSCRIBE_SHADER_LIB)
|
||||||
#message(${HIFI_LIBRARIES_SHADER_INCLUDE_FILES})
|
#message(${HIFI_LIBRARIES_SHADER_INCLUDE_FILES})
|
||||||
|
|
||||||
file(GLOB_RECURSE SHADER_INCLUDE_FILES src/*.slh)
|
file(GLOB_RECURSE SHADER_INCLUDE_FILES src/*.slh)
|
||||||
file(GLOB_RECURSE SHADER_SOURCE_FILES src/*.slv src/*.slf)
|
file(GLOB_RECURSE SHADER_SOURCE_FILES src/*.slv src/*.slf src/*.slg)
|
||||||
|
|
||||||
#make the shader folder
|
#make the shader folder
|
||||||
set(SHADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/shaders/${TARGET_NAME}")
|
set(SHADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/shaders/${TARGET_NAME}")
|
||||||
|
|
|
@ -171,6 +171,7 @@ static QTimer pingTimer;
|
||||||
static const QString SNAPSHOT_EXTENSION = ".jpg";
|
static const QString SNAPSHOT_EXTENSION = ".jpg";
|
||||||
static const QString SVO_EXTENSION = ".svo";
|
static const QString SVO_EXTENSION = ".svo";
|
||||||
static const QString SVO_JSON_EXTENSION = ".svo.json";
|
static const QString SVO_JSON_EXTENSION = ".svo.json";
|
||||||
|
static const QString JSON_EXTENSION = ".json";
|
||||||
static const QString JS_EXTENSION = ".js";
|
static const QString JS_EXTENSION = ".js";
|
||||||
static const QString FST_EXTENSION = ".fst";
|
static const QString FST_EXTENSION = ".fst";
|
||||||
static const QString FBX_EXTENSION = ".fbx";
|
static const QString FBX_EXTENSION = ".fbx";
|
||||||
|
@ -202,13 +203,16 @@ static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStanda
|
||||||
|
|
||||||
Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
||||||
|
|
||||||
|
static const QString MARKETPLACE_CDN_HOSTNAME = "mpassets.highfidelity.com";
|
||||||
|
|
||||||
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions {
|
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions {
|
||||||
{ SNAPSHOT_EXTENSION, &Application::acceptSnapshot },
|
{ SNAPSHOT_EXTENSION, &Application::acceptSnapshot },
|
||||||
{ SVO_EXTENSION, &Application::importSVOFromURL },
|
{ SVO_EXTENSION, &Application::importSVOFromURL },
|
||||||
{ SVO_JSON_EXTENSION, &Application::importSVOFromURL },
|
{ SVO_JSON_EXTENSION, &Application::importSVOFromURL },
|
||||||
|
{ AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl },
|
||||||
|
{ JSON_EXTENSION, &Application::importJSONFromURL },
|
||||||
{ JS_EXTENSION, &Application::askToLoadScript },
|
{ JS_EXTENSION, &Application::askToLoadScript },
|
||||||
{ FST_EXTENSION, &Application::askToSetAvatarUrl },
|
{ FST_EXTENSION, &Application::askToSetAvatarUrl }
|
||||||
{ AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DeadlockWatchdogThread : public QThread {
|
class DeadlockWatchdogThread : public QThread {
|
||||||
|
@ -1969,7 +1973,22 @@ void Application::resizeGL() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::importJSONFromURL(const QString& urlString) {
|
||||||
|
// we only load files that terminate in just .json (not .svo.json and not .ava.json)
|
||||||
|
// if they come from the High Fidelity Marketplace Assets CDN
|
||||||
|
|
||||||
|
QUrl jsonURL { urlString };
|
||||||
|
|
||||||
|
if (jsonURL.host().endsWith(MARKETPLACE_CDN_HOSTNAME)) {
|
||||||
|
emit svoImportRequested(urlString);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Application::importSVOFromURL(const QString& urlString) {
|
bool Application::importSVOFromURL(const QString& urlString) {
|
||||||
|
|
||||||
emit svoImportRequested(urlString);
|
emit svoImportRequested(urlString);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4806,7 +4825,17 @@ bool Application::askToSetAvatarUrl(const QString& url) {
|
||||||
|
|
||||||
bool Application::askToLoadScript(const QString& scriptFilenameOrURL) {
|
bool Application::askToLoadScript(const QString& scriptFilenameOrURL) {
|
||||||
QMessageBox::StandardButton reply;
|
QMessageBox::StandardButton reply;
|
||||||
QString message = "Would you like to run this script:\n" + scriptFilenameOrURL;
|
|
||||||
|
QString shortName = scriptFilenameOrURL;
|
||||||
|
|
||||||
|
QUrl scriptURL { scriptFilenameOrURL };
|
||||||
|
|
||||||
|
if (scriptURL.host().endsWith(MARKETPLACE_CDN_HOSTNAME)) {
|
||||||
|
shortName = shortName.mid(shortName.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString message = "Would you like to run this script:\n" + shortName;
|
||||||
|
|
||||||
reply = OffscreenUi::question(getWindow(), "Run Script", message, QMessageBox::Yes | QMessageBox::No);
|
reply = OffscreenUi::question(getWindow(), "Run Script", message, QMessageBox::Yes | QMessageBox::No);
|
||||||
|
|
||||||
if (reply == QMessageBox::Yes) {
|
if (reply == QMessageBox::Yes) {
|
||||||
|
|
|
@ -380,6 +380,7 @@ private:
|
||||||
|
|
||||||
void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false);
|
void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false);
|
||||||
|
|
||||||
|
bool importJSONFromURL(const QString& urlString);
|
||||||
bool importSVOFromURL(const QString& urlString);
|
bool importSVOFromURL(const QString& urlString);
|
||||||
|
|
||||||
bool nearbyEntitiesAreReadyForPhysics();
|
bool nearbyEntitiesAreReadyForPhysics();
|
||||||
|
|
|
@ -55,12 +55,14 @@ void Line3DOverlay::render(RenderArgs* args) {
|
||||||
batch->setModelTransform(_transform);
|
batch->setModelTransform(_transform);
|
||||||
|
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
geometryCache->bindSimpleProgram(*batch, false, false, true, true);
|
|
||||||
if (getIsDashedLine()) {
|
if (getIsDashedLine()) {
|
||||||
// TODO: add support for color to renderDashedLine()
|
// TODO: add support for color to renderDashedLine()
|
||||||
|
geometryCache->bindSimpleProgram(*batch, false, false, true, true);
|
||||||
geometryCache->renderDashedLine(*batch, _start, _end, colorv4, _geometryCacheID);
|
geometryCache->renderDashedLine(*batch, _start, _end, colorv4, _geometryCacheID);
|
||||||
|
} else if (_glow > 0.0f) {
|
||||||
|
geometryCache->renderGlowLine(*batch, _start, _end, colorv4, _glow, _glowWidth, _geometryCacheID);
|
||||||
} else {
|
} else {
|
||||||
|
geometryCache->bindSimpleProgram(*batch, false, false, true, true);
|
||||||
geometryCache->renderLine(*batch, _start, _end, colorv4, _geometryCacheID);
|
geometryCache->renderLine(*batch, _start, _end, colorv4, _geometryCacheID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +70,7 @@ void Line3DOverlay::render(RenderArgs* args) {
|
||||||
|
|
||||||
const render::ShapeKey Line3DOverlay::getShapeKey() {
|
const render::ShapeKey Line3DOverlay::getShapeKey() {
|
||||||
auto builder = render::ShapeKey::Builder().withOwnPipeline();
|
auto builder = render::ShapeKey::Builder().withOwnPipeline();
|
||||||
if (getAlpha() != 1.0f) {
|
if (getAlpha() != 1.0f || _glow > 0.0f) {
|
||||||
builder.withTranslucent();
|
builder.withTranslucent();
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
@ -94,6 +96,19 @@ void Line3DOverlay::setProperties(const QVariantMap& properties) {
|
||||||
if (end.isValid()) {
|
if (end.isValid()) {
|
||||||
setEnd(vec3FromVariant(end));
|
setEnd(vec3FromVariant(end));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto glow = properties["glow"];
|
||||||
|
if (glow.isValid()) {
|
||||||
|
setGlow(glow.toFloat());
|
||||||
|
if (_glow > 0.0f) {
|
||||||
|
_alpha = 0.5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto glowWidth = properties["glow"];
|
||||||
|
if (glowWidth.isValid()) {
|
||||||
|
setGlow(glowWidth.toFloat());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant Line3DOverlay::getProperty(const QString& property) {
|
QVariant Line3DOverlay::getProperty(const QString& property) {
|
||||||
|
|
|
@ -30,10 +30,14 @@ public:
|
||||||
// getters
|
// getters
|
||||||
const glm::vec3& getStart() const { return _start; }
|
const glm::vec3& getStart() const { return _start; }
|
||||||
const glm::vec3& getEnd() const { return _end; }
|
const glm::vec3& getEnd() const { return _end; }
|
||||||
|
const float& getGlow() const { return _glow; }
|
||||||
|
const float& getGlowWidth() const { return _glowWidth; }
|
||||||
|
|
||||||
// setters
|
// setters
|
||||||
void setStart(const glm::vec3& start) { _start = start; }
|
void setStart(const glm::vec3& start) { _start = start; }
|
||||||
void setEnd(const glm::vec3& end) { _end = end; }
|
void setEnd(const glm::vec3& end) { _end = end; }
|
||||||
|
void setGlow(const float& glow) { _glow = glow; }
|
||||||
|
void setGlowWidth(const float& glowWidth) { _glowWidth = glowWidth; }
|
||||||
|
|
||||||
void setProperties(const QVariantMap& properties) override;
|
void setProperties(const QVariantMap& properties) override;
|
||||||
QVariant getProperty(const QString& property) override;
|
QVariant getProperty(const QString& property) override;
|
||||||
|
@ -43,6 +47,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
glm::vec3 _start;
|
glm::vec3 _start;
|
||||||
glm::vec3 _end;
|
glm::vec3 _end;
|
||||||
|
float _glow { 0.0 };
|
||||||
|
float _glowWidth { 0.0 };
|
||||||
int _geometryCacheID;
|
int _geometryCacheID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,40 +25,45 @@ GLShader::~GLShader() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GLSL version
|
||||||
|
static const std::string glslVersion {
|
||||||
|
"#version 410 core"
|
||||||
|
};
|
||||||
|
|
||||||
|
// Shader domain
|
||||||
|
static const size_t NUM_SHADER_DOMAINS = 3;
|
||||||
|
|
||||||
|
// GL Shader type enums
|
||||||
|
// Must match the order of type specified in gpu::Shader::Type
|
||||||
|
static const std::array<GLenum, NUM_SHADER_DOMAINS> SHADER_DOMAINS { {
|
||||||
|
GL_VERTEX_SHADER,
|
||||||
|
GL_FRAGMENT_SHADER,
|
||||||
|
GL_GEOMETRY_SHADER,
|
||||||
|
} };
|
||||||
|
|
||||||
|
// Domain specific defines
|
||||||
|
// Must match the order of type specified in gpu::Shader::Type
|
||||||
|
static const std::array<std::string, NUM_SHADER_DOMAINS> DOMAIN_DEFINES { {
|
||||||
|
"#define GPU_VERTEX_SHADER",
|
||||||
|
"#define GPU_PIXEL_SHADER",
|
||||||
|
"#define GPU_GEOMETRY_SHADER",
|
||||||
|
} };
|
||||||
|
|
||||||
|
// Versions specific of the shader
|
||||||
|
static const std::array<std::string, GLShader::NumVersions> VERSION_DEFINES { {
|
||||||
|
""
|
||||||
|
} };
|
||||||
|
|
||||||
GLShader* compileBackendShader(const Shader& shader) {
|
GLShader* compileBackendShader(const Shader& shader) {
|
||||||
// Any GLSLprogram ? normally yes...
|
// Any GLSLprogram ? normally yes...
|
||||||
const std::string& shaderSource = shader.getSource().getCode();
|
const std::string& shaderSource = shader.getSource().getCode();
|
||||||
|
|
||||||
// GLSL version
|
|
||||||
const std::string glslVersion = {
|
|
||||||
"#version 410 core"
|
|
||||||
};
|
|
||||||
|
|
||||||
// Shader domain
|
|
||||||
const int NUM_SHADER_DOMAINS = 2;
|
|
||||||
const GLenum SHADER_DOMAINS[NUM_SHADER_DOMAINS] = {
|
|
||||||
GL_VERTEX_SHADER,
|
|
||||||
GL_FRAGMENT_SHADER
|
|
||||||
};
|
|
||||||
GLenum shaderDomain = SHADER_DOMAINS[shader.getType()];
|
GLenum shaderDomain = SHADER_DOMAINS[shader.getType()];
|
||||||
|
|
||||||
// Domain specific defines
|
|
||||||
const std::string domainDefines[NUM_SHADER_DOMAINS] = {
|
|
||||||
"#define GPU_VERTEX_SHADER",
|
|
||||||
"#define GPU_PIXEL_SHADER"
|
|
||||||
};
|
|
||||||
|
|
||||||
// Versions specific of the shader
|
|
||||||
const std::string versionDefines[GLShader::NumVersions] = {
|
|
||||||
""
|
|
||||||
};
|
|
||||||
|
|
||||||
GLShader::ShaderObjects shaderObjects;
|
GLShader::ShaderObjects shaderObjects;
|
||||||
|
|
||||||
for (int version = 0; version < GLShader::NumVersions; version++) {
|
for (int version = 0; version < GLShader::NumVersions; version++) {
|
||||||
auto& shaderObject = shaderObjects[version];
|
auto& shaderObject = shaderObjects[version];
|
||||||
|
|
||||||
std::string shaderDefines = glslVersion + "\n" + domainDefines[shader.getType()] + "\n" + versionDefines[version];
|
std::string shaderDefines = glslVersion + "\n" + DOMAIN_DEFINES[shader.getType()] + "\n" + VERSION_DEFINES[version];
|
||||||
|
|
||||||
bool result = compileShader(shaderDomain, shaderSource, shaderDefines, shaderObject.glshader, shaderObject.glprogram);
|
bool result = compileShader(shaderDomain, shaderSource, shaderDefines, shaderObject.glshader, shaderObject.glprogram);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
|
@ -31,6 +31,13 @@ Shader::Shader(Type type, const Pointer& vertex, const Pointer& pixel):
|
||||||
_shaders[PIXEL] = pixel;
|
_shaders[PIXEL] = pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Shader::Shader(Type type, const Pointer& vertex, const Pointer& geometry, const Pointer& pixel) :
|
||||||
|
_type(type) {
|
||||||
|
_shaders.resize(3);
|
||||||
|
_shaders[VERTEX] = vertex;
|
||||||
|
_shaders[GEOMETRY] = geometry;
|
||||||
|
_shaders[PIXEL] = pixel;
|
||||||
|
}
|
||||||
|
|
||||||
Shader::~Shader()
|
Shader::~Shader()
|
||||||
{
|
{
|
||||||
|
@ -44,6 +51,10 @@ Shader::Pointer Shader::createPixel(const Source& source) {
|
||||||
return Pointer(new Shader(PIXEL, source));
|
return Pointer(new Shader(PIXEL, source));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Shader::Pointer Shader::createGeometry(const Source& source) {
|
||||||
|
return Pointer(new Shader(GEOMETRY, source));
|
||||||
|
}
|
||||||
|
|
||||||
Shader::Pointer Shader::createProgram(const Pointer& vertexShader, const Pointer& pixelShader) {
|
Shader::Pointer Shader::createProgram(const Pointer& vertexShader, const Pointer& pixelShader) {
|
||||||
if (vertexShader && vertexShader->getType() == VERTEX &&
|
if (vertexShader && vertexShader->getType() == VERTEX &&
|
||||||
pixelShader && pixelShader->getType() == PIXEL) {
|
pixelShader && pixelShader->getType() == PIXEL) {
|
||||||
|
@ -52,6 +63,15 @@ Shader::Pointer Shader::createProgram(const Pointer& vertexShader, const Pointer
|
||||||
return Pointer();
|
return Pointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Shader::Pointer Shader::createProgram(const Pointer& vertexShader, const Pointer& geometryShader, const Pointer& pixelShader) {
|
||||||
|
if (vertexShader && vertexShader->getType() == VERTEX &&
|
||||||
|
geometryShader && geometryShader->getType() == GEOMETRY &&
|
||||||
|
pixelShader && pixelShader->getType() == PIXEL) {
|
||||||
|
return Pointer(new Shader(PROGRAM, vertexShader, geometryShader, pixelShader));
|
||||||
|
}
|
||||||
|
return Pointer();
|
||||||
|
}
|
||||||
|
|
||||||
void Shader::defineSlots(const SlotSet& uniforms, const SlotSet& buffers, const SlotSet& textures, const SlotSet& samplers, const SlotSet& inputs, const SlotSet& outputs) {
|
void Shader::defineSlots(const SlotSet& uniforms, const SlotSet& buffers, const SlotSet& textures, const SlotSet& samplers, const SlotSet& inputs, const SlotSet& outputs) {
|
||||||
_uniforms = uniforms;
|
_uniforms = uniforms;
|
||||||
_buffers = buffers;
|
_buffers = buffers;
|
||||||
|
|
|
@ -110,8 +110,10 @@ public:
|
||||||
|
|
||||||
static Pointer createVertex(const Source& source);
|
static Pointer createVertex(const Source& source);
|
||||||
static Pointer createPixel(const Source& source);
|
static Pointer createPixel(const Source& source);
|
||||||
|
static Pointer createGeometry(const Source& source);
|
||||||
|
|
||||||
static Pointer createProgram(const Pointer& vertexShader, const Pointer& pixelShader);
|
static Pointer createProgram(const Pointer& vertexShader, const Pointer& pixelShader);
|
||||||
|
static Pointer createProgram(const Pointer& vertexShader, const Pointer& geometryShader, const Pointer& pixelShader);
|
||||||
|
|
||||||
|
|
||||||
~Shader();
|
~Shader();
|
||||||
|
@ -163,6 +165,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
Shader(Type type, const Source& source);
|
Shader(Type type, const Source& source);
|
||||||
Shader(Type type, const Pointer& vertex, const Pointer& pixel);
|
Shader(Type type, const Pointer& vertex, const Pointer& pixel);
|
||||||
|
Shader(Type type, const Pointer& vertex, const Pointer& geometry, const Pointer& pixel);
|
||||||
|
|
||||||
Shader(const Shader& shader); // deep copy of the sysmem shader
|
Shader(const Shader& shader); // deep copy of the sysmem shader
|
||||||
Shader& operator=(const Shader& shader); // deep copy of the sysmem texture
|
Shader& operator=(const Shader& shader); // deep copy of the sysmem texture
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
|
|
||||||
#include "GeometryCache.h"
|
#include "GeometryCache.h"
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QtCore/QThreadPool>
|
||||||
#include <QThreadPool>
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtNetwork/QNetworkReply>
|
||||||
|
|
||||||
#include <FSTReader.h>
|
#include <FSTReader.h>
|
||||||
#include <NumericalConstants.h>
|
#include <NumericalConstants.h>
|
||||||
|
@ -33,6 +35,9 @@
|
||||||
#include "simple_vert.h"
|
#include "simple_vert.h"
|
||||||
#include "simple_textured_frag.h"
|
#include "simple_textured_frag.h"
|
||||||
#include "simple_textured_unlit_frag.h"
|
#include "simple_textured_unlit_frag.h"
|
||||||
|
#include "glowLine_vert.h"
|
||||||
|
#include "glowLine_geom.h"
|
||||||
|
#include "glowLine_frag.h"
|
||||||
|
|
||||||
#include "grid_frag.h"
|
#include "grid_frag.h"
|
||||||
|
|
||||||
|
@ -43,9 +48,9 @@ const int GeometryCache::UNKNOWN_ID = -1;
|
||||||
|
|
||||||
static const int VERTICES_PER_TRIANGLE = 3;
|
static const int VERTICES_PER_TRIANGLE = 3;
|
||||||
|
|
||||||
static const gpu::Element POSITION_ELEMENT{ gpu::VEC3, gpu::FLOAT, gpu::XYZ };
|
static const gpu::Element POSITION_ELEMENT { gpu::VEC3, gpu::FLOAT, gpu::XYZ };
|
||||||
static const gpu::Element NORMAL_ELEMENT{ gpu::VEC3, gpu::FLOAT, gpu::XYZ };
|
static const gpu::Element NORMAL_ELEMENT { gpu::VEC3, gpu::FLOAT, gpu::XYZ };
|
||||||
static const gpu::Element COLOR_ELEMENT{ gpu::VEC4, gpu::NUINT8, gpu::RGBA };
|
static const gpu::Element COLOR_ELEMENT { gpu::VEC4, gpu::NUINT8, gpu::RGBA };
|
||||||
|
|
||||||
static gpu::Stream::FormatPointer SOLID_STREAM_FORMAT;
|
static gpu::Stream::FormatPointer SOLID_STREAM_FORMAT;
|
||||||
static gpu::Stream::FormatPointer INSTANCED_SOLID_STREAM_FORMAT;
|
static gpu::Stream::FormatPointer INSTANCED_SOLID_STREAM_FORMAT;
|
||||||
|
@ -266,7 +271,7 @@ void GeometryCache::buildShapes() {
|
||||||
{
|
{
|
||||||
Index baseVertex = (Index)(_shapeVertices->getSize() / SHAPE_VERTEX_STRIDE);
|
Index baseVertex = (Index)(_shapeVertices->getSize() / SHAPE_VERTEX_STRIDE);
|
||||||
ShapeData& shapeData = _shapes[Line];
|
ShapeData& shapeData = _shapes[Line];
|
||||||
shapeData.setupVertices(_shapeVertices, VertexVector{
|
shapeData.setupVertices(_shapeVertices, VertexVector {
|
||||||
vec3(-0.5, 0, 0), vec3(-0.5f, 0, 0),
|
vec3(-0.5, 0, 0), vec3(-0.5f, 0, 0),
|
||||||
vec3(0.5f, 0, 0), vec3(0.5f, 0, 0)
|
vec3(0.5f, 0, 0), vec3(0.5f, 0, 0)
|
||||||
});
|
});
|
||||||
|
@ -312,8 +317,7 @@ render::ShapePipelinePointer GeometryCache::_simplePipeline;
|
||||||
render::ShapePipelinePointer GeometryCache::_simpleWirePipeline;
|
render::ShapePipelinePointer GeometryCache::_simpleWirePipeline;
|
||||||
|
|
||||||
GeometryCache::GeometryCache() :
|
GeometryCache::GeometryCache() :
|
||||||
_nextID(0)
|
_nextID(0) {
|
||||||
{
|
|
||||||
buildShapes();
|
buildShapes();
|
||||||
GeometryCache::_simplePipeline =
|
GeometryCache::_simplePipeline =
|
||||||
std::make_shared<render::ShapePipeline>(getSimplePipeline(), nullptr,
|
std::make_shared<render::ShapePipeline>(getSimplePipeline(), nullptr,
|
||||||
|
@ -327,17 +331,17 @@ GeometryCache::GeometryCache() :
|
||||||
);
|
);
|
||||||
GeometryCache::_simpleWirePipeline =
|
GeometryCache::_simpleWirePipeline =
|
||||||
std::make_shared<render::ShapePipeline>(getSimplePipeline(false, false, true, true), nullptr,
|
std::make_shared<render::ShapePipeline>(getSimplePipeline(false, false, true, true), nullptr,
|
||||||
[](const render::ShapePipeline&, gpu::Batch& batch) { }
|
[](const render::ShapePipeline&, gpu::Batch& batch) {}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
GeometryCache::~GeometryCache() {
|
GeometryCache::~GeometryCache() {
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "GeometryCache::~GeometryCache()... ";
|
qCDebug(renderutils) << "GeometryCache::~GeometryCache()... ";
|
||||||
qCDebug(renderutils) << " _registeredLine3DVBOs.size():" << _registeredLine3DVBOs.size();
|
qCDebug(renderutils) << " _registeredLine3DVBOs.size():" << _registeredLine3DVBOs.size();
|
||||||
qCDebug(renderutils) << " _line3DVBOs.size():" << _line3DVBOs.size();
|
qCDebug(renderutils) << " _line3DVBOs.size():" << _line3DVBOs.size();
|
||||||
qCDebug(renderutils) << " BatchItemDetails... population:" << GeometryCache::BatchItemDetails::population;
|
qCDebug(renderutils) << " BatchItemDetails... population:" << GeometryCache::BatchItemDetails::population;
|
||||||
#endif //def WANT_DEBUG
|
#endif //def WANT_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupBatchInstance(gpu::Batch& batch, gpu::BufferPointer colorBuffer) {
|
void setupBatchInstance(gpu::Batch& batch, gpu::BufferPointer colorBuffer) {
|
||||||
|
@ -433,9 +437,9 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con
|
||||||
|
|
||||||
if (details.isCreated) {
|
if (details.isCreated) {
|
||||||
details.clear();
|
details.clear();
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "updateVertices()... RELEASING REGISTERED";
|
qCDebug(renderutils) << "updateVertices()... RELEASING REGISTERED";
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 2 + 3; // vertices + normals
|
const int FLOATS_PER_VERTEX = 2 + 3; // vertices + normals
|
||||||
|
@ -477,7 +481,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con
|
||||||
int* colorDataAt = colorData;
|
int* colorDataAt = colorData;
|
||||||
|
|
||||||
const glm::vec3 NORMAL(0.0f, 0.0f, 1.0f);
|
const glm::vec3 NORMAL(0.0f, 0.0f, 1.0f);
|
||||||
foreach (const glm::vec2& point, points) {
|
foreach(const glm::vec2& point, points) {
|
||||||
*(vertex++) = point.x;
|
*(vertex++) = point.x;
|
||||||
*(vertex++) = point.y;
|
*(vertex++) = point.y;
|
||||||
*(vertex++) = NORMAL.x;
|
*(vertex++) = NORMAL.x;
|
||||||
|
@ -492,18 +496,18 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con
|
||||||
delete[] vertexData;
|
delete[] vertexData;
|
||||||
delete[] colorData;
|
delete[] colorData;
|
||||||
|
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "new registered linestrip buffer made -- _registeredVertices.size():" << _registeredVertices.size();
|
qCDebug(renderutils) << "new registered linestrip buffer made -- _registeredVertices.size():" << _registeredVertices.size();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, const glm::vec4& color) {
|
void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, const glm::vec4& color) {
|
||||||
BatchItemDetails& details = _registeredVertices[id];
|
BatchItemDetails& details = _registeredVertices[id];
|
||||||
if (details.isCreated) {
|
if (details.isCreated) {
|
||||||
details.clear();
|
details.clear();
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "updateVertices()... RELEASING REGISTERED";
|
qCDebug(renderutils) << "updateVertices()... RELEASING REGISTERED";
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 3 + 3; // vertices + normals
|
const int FLOATS_PER_VERTEX = 3 + 3; // vertices + normals
|
||||||
|
@ -545,7 +549,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
|
||||||
int* colorDataAt = colorData;
|
int* colorDataAt = colorData;
|
||||||
|
|
||||||
const glm::vec3 NORMAL(0.0f, 0.0f, 1.0f);
|
const glm::vec3 NORMAL(0.0f, 0.0f, 1.0f);
|
||||||
foreach (const glm::vec3& point, points) {
|
foreach(const glm::vec3& point, points) {
|
||||||
*(vertex++) = point.x;
|
*(vertex++) = point.x;
|
||||||
*(vertex++) = point.y;
|
*(vertex++) = point.y;
|
||||||
*(vertex++) = point.z;
|
*(vertex++) = point.z;
|
||||||
|
@ -561,9 +565,9 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
|
||||||
delete[] vertexData;
|
delete[] vertexData;
|
||||||
delete[] colorData;
|
delete[] colorData;
|
||||||
|
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "new registered linestrip buffer made -- _registeredVertices.size():" << _registeredVertices.size();
|
qCDebug(renderutils) << "new registered linestrip buffer made -- _registeredVertices.size():" << _registeredVertices.size();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, const QVector<glm::vec2>& texCoords, const glm::vec4& color) {
|
void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, const QVector<glm::vec2>& texCoords, const glm::vec4& color) {
|
||||||
|
@ -571,9 +575,9 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
|
||||||
|
|
||||||
if (details.isCreated) {
|
if (details.isCreated) {
|
||||||
details.clear();
|
details.clear();
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "updateVertices()... RELEASING REGISTERED";
|
qCDebug(renderutils) << "updateVertices()... RELEASING REGISTERED";
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 3 + 3 + 2; // vertices + normals + tex coords
|
const int FLOATS_PER_VERTEX = 3 + 3 + 2; // vertices + normals + tex coords
|
||||||
|
@ -640,9 +644,9 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
|
||||||
delete[] vertexData;
|
delete[] vertexData;
|
||||||
delete[] colorData;
|
delete[] colorData;
|
||||||
|
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "new registered linestrip buffer made -- _registeredVertices.size():" << _registeredVertices.size();
|
qCDebug(renderutils) << "new registered linestrip buffer made -- _registeredVertices.size():" << _registeredVertices.size();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::renderVertices(gpu::Batch& batch, gpu::Primitive primitiveType, int id) {
|
void GeometryCache::renderVertices(gpu::Batch& batch, gpu::Primitive primitiveType, int id) {
|
||||||
|
@ -665,15 +669,15 @@ void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int
|
||||||
if (lastKey != key) {
|
if (lastKey != key) {
|
||||||
details.clear();
|
details.clear();
|
||||||
_lastRegisteredBevelRects[id] = key;
|
_lastRegisteredBevelRects[id] = key;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "renderBevelCornersRect()... RELEASING REGISTERED";
|
qCDebug(renderutils) << "renderBevelCornersRect()... RELEASING REGISTERED";
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
else {
|
else {
|
||||||
qCDebug(renderutils) << "renderBevelCornersRect()... REUSING PREVIOUSLY REGISTERED";
|
qCDebug(renderutils) << "renderBevelCornersRect()... REUSING PREVIOUSLY REGISTERED";
|
||||||
}
|
}
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!details.isCreated) {
|
if (!details.isCreated) {
|
||||||
|
@ -767,15 +771,15 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co
|
||||||
if (lastKey != key) {
|
if (lastKey != key) {
|
||||||
details.clear();
|
details.clear();
|
||||||
_lastRegisteredQuad2D[id] = key;
|
_lastRegisteredQuad2D[id] = key;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "renderQuad() 2D ... RELEASING REGISTERED";
|
qCDebug(renderutils) << "renderQuad() 2D ... RELEASING REGISTERED";
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
else {
|
else {
|
||||||
qCDebug(renderutils) << "renderQuad() 2D ... REUSING PREVIOUSLY REGISTERED";
|
qCDebug(renderutils) << "renderQuad() 2D ... REUSING PREVIOUSLY REGISTERED";
|
||||||
}
|
}
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 2 + 3; // vertices + normals
|
const int FLOATS_PER_VERTEX = 2 + 3; // vertices + normals
|
||||||
|
@ -856,15 +860,15 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co
|
||||||
if (lastKey != key) {
|
if (lastKey != key) {
|
||||||
details.clear();
|
details.clear();
|
||||||
_lastRegisteredQuad2DTexture[id] = key;
|
_lastRegisteredQuad2DTexture[id] = key;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "renderQuad() 2D+texture ... RELEASING REGISTERED";
|
qCDebug(renderutils) << "renderQuad() 2D+texture ... RELEASING REGISTERED";
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
else {
|
else {
|
||||||
qCDebug(renderutils) << "renderQuad() 2D+texture ... REUSING PREVIOUSLY REGISTERED";
|
qCDebug(renderutils) << "renderQuad() 2D+texture ... REUSING PREVIOUSLY REGISTERED";
|
||||||
}
|
}
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 2 + 3 + 2; // vertices + normals + tex coords
|
const int FLOATS_PER_VERTEX = 2 + 3 + 2; // vertices + normals + tex coords
|
||||||
|
@ -938,15 +942,15 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co
|
||||||
if (lastKey != key) {
|
if (lastKey != key) {
|
||||||
details.clear();
|
details.clear();
|
||||||
_lastRegisteredQuad3D[id] = key;
|
_lastRegisteredQuad3D[id] = key;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "renderQuad() 3D ... RELEASING REGISTERED";
|
qCDebug(renderutils) << "renderQuad() 3D ... RELEASING REGISTERED";
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
else {
|
else {
|
||||||
qCDebug(renderutils) << "renderQuad() 3D ... REUSING PREVIOUSLY REGISTERED";
|
qCDebug(renderutils) << "renderQuad() 3D ... REUSING PREVIOUSLY REGISTERED";
|
||||||
}
|
}
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 3 + 3; // vertices + normals
|
const int FLOATS_PER_VERTEX = 3 + 3; // vertices + normals
|
||||||
|
@ -1010,7 +1014,7 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons
|
||||||
const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight,
|
const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight,
|
||||||
const glm::vec4& color, int id) {
|
const glm::vec4& color, int id) {
|
||||||
|
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "renderQuad() vec3 + texture VBO...";
|
qCDebug(renderutils) << "renderQuad() vec3 + texture VBO...";
|
||||||
qCDebug(renderutils) << " topLeft:" << topLeft;
|
qCDebug(renderutils) << " topLeft:" << topLeft;
|
||||||
qCDebug(renderutils) << " bottomLeft:" << bottomLeft;
|
qCDebug(renderutils) << " bottomLeft:" << bottomLeft;
|
||||||
|
@ -1019,11 +1023,11 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons
|
||||||
qCDebug(renderutils) << " texCoordTopLeft:" << texCoordTopLeft;
|
qCDebug(renderutils) << " texCoordTopLeft:" << texCoordTopLeft;
|
||||||
qCDebug(renderutils) << " texCoordBottomRight:" << texCoordBottomRight;
|
qCDebug(renderutils) << " texCoordBottomRight:" << texCoordBottomRight;
|
||||||
qCDebug(renderutils) << " color:" << color;
|
qCDebug(renderutils) << " color:" << color;
|
||||||
#endif //def WANT_DEBUG
|
#endif //def WANT_DEBUG
|
||||||
|
|
||||||
bool registered = (id != UNKNOWN_ID);
|
bool registered = (id != UNKNOWN_ID);
|
||||||
Vec3PairVec4Pair key(Vec3Pair(topLeft, bottomRight),
|
Vec3PairVec4Pair key(Vec3Pair(topLeft, bottomRight),
|
||||||
Vec4Pair(glm::vec4(texCoordTopLeft.x,texCoordTopLeft.y,texCoordBottomRight.x,texCoordBottomRight.y),
|
Vec4Pair(glm::vec4(texCoordTopLeft.x, texCoordTopLeft.y, texCoordBottomRight.x, texCoordBottomRight.y),
|
||||||
color));
|
color));
|
||||||
|
|
||||||
BatchItemDetails& details = registered ? _registeredQuad3DTextures[id] : _quad3DTextures[key];
|
BatchItemDetails& details = registered ? _registeredQuad3DTextures[id] : _quad3DTextures[key];
|
||||||
|
@ -1034,15 +1038,15 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons
|
||||||
if (lastKey != key) {
|
if (lastKey != key) {
|
||||||
details.clear();
|
details.clear();
|
||||||
_lastRegisteredQuad3DTexture[id] = key;
|
_lastRegisteredQuad3DTexture[id] = key;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "renderQuad() 3D+texture ... RELEASING REGISTERED";
|
qCDebug(renderutils) << "renderQuad() 3D+texture ... RELEASING REGISTERED";
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
else {
|
else {
|
||||||
qCDebug(renderutils) << "renderQuad() 3D+texture ... REUSING PREVIOUSLY REGISTERED";
|
qCDebug(renderutils) << "renderQuad() 3D+texture ... REUSING PREVIOUSLY REGISTERED";
|
||||||
}
|
}
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 3 + 3 + 2; // vertices + normals + tex coords
|
const int FLOATS_PER_VERTEX = 3 + 3 + 2; // vertices + normals + tex coords
|
||||||
|
@ -1114,9 +1118,9 @@ void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start,
|
||||||
if (_lastRegisteredDashedLines[id] != key) {
|
if (_lastRegisteredDashedLines[id] != key) {
|
||||||
details.clear();
|
details.clear();
|
||||||
_lastRegisteredDashedLines[id] = key;
|
_lastRegisteredDashedLines[id] = key;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "renderDashedLine()... RELEASING REGISTERED";
|
qCDebug(renderutils) << "renderDashedLine()... RELEASING REGISTERED";
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1209,13 +1213,13 @@ void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start,
|
||||||
delete[] vertexData;
|
delete[] vertexData;
|
||||||
delete[] colorData;
|
delete[] colorData;
|
||||||
|
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
if (registered) {
|
if (registered) {
|
||||||
qCDebug(renderutils) << "new registered dashed line buffer made -- _registeredVertices:" << _registeredDashedLines.size();
|
qCDebug(renderutils) << "new registered dashed line buffer made -- _registeredVertices:" << _registeredDashedLines.size();
|
||||||
} else {
|
} else {
|
||||||
qCDebug(renderutils) << "new dashed lines buffer made -- _dashedLines:" << _dashedLines.size();
|
qCDebug(renderutils) << "new dashed lines buffer made -- _dashedLines:" << _dashedLines.size();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.setInputFormat(details.streamFormat);
|
batch.setInputFormat(details.streamFormat);
|
||||||
|
@ -1227,41 +1231,39 @@ void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start,
|
||||||
int GeometryCache::BatchItemDetails::population = 0;
|
int GeometryCache::BatchItemDetails::population = 0;
|
||||||
|
|
||||||
GeometryCache::BatchItemDetails::BatchItemDetails() :
|
GeometryCache::BatchItemDetails::BatchItemDetails() :
|
||||||
verticesBuffer(NULL),
|
verticesBuffer(NULL),
|
||||||
colorBuffer(NULL),
|
colorBuffer(NULL),
|
||||||
streamFormat(NULL),
|
streamFormat(NULL),
|
||||||
stream(NULL),
|
stream(NULL),
|
||||||
vertices(0),
|
vertices(0),
|
||||||
vertexSize(0),
|
vertexSize(0),
|
||||||
isCreated(false)
|
isCreated(false) {
|
||||||
{
|
|
||||||
population++;
|
population++;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "BatchItemDetails()... population:" << population << "**********************************";
|
qCDebug(renderutils) << "BatchItemDetails()... population:" << population << "**********************************";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GeometryCache::BatchItemDetails::BatchItemDetails(const GeometryCache::BatchItemDetails& other) :
|
GeometryCache::BatchItemDetails::BatchItemDetails(const GeometryCache::BatchItemDetails& other) :
|
||||||
verticesBuffer(other.verticesBuffer),
|
verticesBuffer(other.verticesBuffer),
|
||||||
colorBuffer(other.colorBuffer),
|
colorBuffer(other.colorBuffer),
|
||||||
streamFormat(other.streamFormat),
|
streamFormat(other.streamFormat),
|
||||||
stream(other.stream),
|
stream(other.stream),
|
||||||
vertices(other.vertices),
|
vertices(other.vertices),
|
||||||
vertexSize(other.vertexSize),
|
vertexSize(other.vertexSize),
|
||||||
isCreated(other.isCreated)
|
isCreated(other.isCreated) {
|
||||||
{
|
|
||||||
population++;
|
population++;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "BatchItemDetails()... population:" << population << "**********************************";
|
qCDebug(renderutils) << "BatchItemDetails()... population:" << population << "**********************************";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GeometryCache::BatchItemDetails::~BatchItemDetails() {
|
GeometryCache::BatchItemDetails::~BatchItemDetails() {
|
||||||
population--;
|
population--;
|
||||||
clear();
|
clear();
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "~BatchItemDetails()... population:" << population << "**********************************";
|
qCDebug(renderutils) << "~BatchItemDetails()... population:" << population << "**********************************";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::BatchItemDetails::clear() {
|
void GeometryCache::BatchItemDetails::clear() {
|
||||||
|
@ -1297,15 +1299,15 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm
|
||||||
if (lastKey != key) {
|
if (lastKey != key) {
|
||||||
details.clear();
|
details.clear();
|
||||||
_lastRegisteredLine3D[id] = key;
|
_lastRegisteredLine3D[id] = key;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "renderLine() 3D ... RELEASING REGISTERED line";
|
qCDebug(renderutils) << "renderLine() 3D ... RELEASING REGISTERED line";
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
else {
|
else {
|
||||||
qCDebug(renderutils) << "renderLine() 3D ... REUSING PREVIOUSLY REGISTERED line";
|
qCDebug(renderutils) << "renderLine() 3D ... REUSING PREVIOUSLY REGISTERED line";
|
||||||
}
|
}
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 3 + 3; // vertices + normals
|
const int FLOATS_PER_VERTEX = 3 + 3; // vertices + normals
|
||||||
|
@ -1338,7 +1340,7 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm
|
||||||
const glm::vec3 NORMAL(1.0f, 0.0f, 0.0f);
|
const glm::vec3 NORMAL(1.0f, 0.0f, 0.0f);
|
||||||
float vertexBuffer[vertices * FLOATS_PER_VERTEX] = {
|
float vertexBuffer[vertices * FLOATS_PER_VERTEX] = {
|
||||||
p1.x, p1.y, p1.z, NORMAL.x, NORMAL.y, NORMAL.z,
|
p1.x, p1.y, p1.z, NORMAL.x, NORMAL.y, NORMAL.z,
|
||||||
p2.x, p2.y, p2.z, NORMAL.x, NORMAL.y, NORMAL.z};
|
p2.x, p2.y, p2.z, NORMAL.x, NORMAL.y, NORMAL.z };
|
||||||
|
|
||||||
const int NUM_COLOR_SCALARS = 2;
|
const int NUM_COLOR_SCALARS = 2;
|
||||||
int colors[NUM_COLOR_SCALARS] = { compactColor1, compactColor2 };
|
int colors[NUM_COLOR_SCALARS] = { compactColor1, compactColor2 };
|
||||||
|
@ -1346,13 +1348,13 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm
|
||||||
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
|
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
|
||||||
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
||||||
|
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
if (id == UNKNOWN_ID) {
|
if (id == UNKNOWN_ID) {
|
||||||
qCDebug(renderutils) << "new renderLine() 3D VBO made -- _line3DVBOs.size():" << _line3DVBOs.size();
|
qCDebug(renderutils) << "new renderLine() 3D VBO made -- _line3DVBOs.size():" << _line3DVBOs.size();
|
||||||
} else {
|
} else {
|
||||||
qCDebug(renderutils) << "new registered renderLine() 3D VBO made -- _registeredLine3DVBOs.size():" << _registeredLine3DVBOs.size();
|
qCDebug(renderutils) << "new registered renderLine() 3D VBO made -- _registeredLine3DVBOs.size():" << _registeredLine3DVBOs.size();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is what it takes to render a quad
|
// this is what it takes to render a quad
|
||||||
|
@ -1386,15 +1388,15 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm
|
||||||
if (lastKey != key) {
|
if (lastKey != key) {
|
||||||
details.clear();
|
details.clear();
|
||||||
_lastRegisteredLine2D[id] = key;
|
_lastRegisteredLine2D[id] = key;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(renderutils) << "renderLine() 2D ... RELEASING REGISTERED line";
|
qCDebug(renderutils) << "renderLine() 2D ... RELEASING REGISTERED line";
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
else {
|
else {
|
||||||
qCDebug(renderutils) << "renderLine() 2D ... REUSING PREVIOUSLY REGISTERED line";
|
qCDebug(renderutils) << "renderLine() 2D ... REUSING PREVIOUSLY REGISTERED line";
|
||||||
}
|
}
|
||||||
#endif // def WANT_DEBUG
|
#endif // def WANT_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 2;
|
const int FLOATS_PER_VERTEX = 2;
|
||||||
|
@ -1430,13 +1432,103 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm
|
||||||
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
|
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
|
||||||
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
||||||
|
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
if (id == UNKNOWN_ID) {
|
if (id == UNKNOWN_ID) {
|
||||||
qCDebug(renderutils) << "new renderLine() 2D VBO made -- _line3DVBOs.size():" << _line2DVBOs.size();
|
qCDebug(renderutils) << "new renderLine() 2D VBO made -- _line3DVBOs.size():" << _line2DVBOs.size();
|
||||||
} else {
|
} else {
|
||||||
qCDebug(renderutils) << "new registered renderLine() 2D VBO made -- _registeredLine2DVBOs.size():" << _registeredLine2DVBOs.size();
|
qCDebug(renderutils) << "new registered renderLine() 2D VBO made -- _registeredLine2DVBOs.size():" << _registeredLine2DVBOs.size();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is what it takes to render a quad
|
||||||
|
batch.setInputFormat(details.streamFormat);
|
||||||
|
batch.setInputStream(0, *details.stream);
|
||||||
|
batch.draw(gpu::LINES, 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||||
|
const glm::vec4& color, float glowIntensity, float glowWidth, int id) {
|
||||||
|
if (glowIntensity <= 0) {
|
||||||
|
renderLine(batch, p1, p2, color, id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compile the shaders
|
||||||
|
static std::once_flag once;
|
||||||
|
std::call_once(once, [&] {
|
||||||
|
auto state = std::make_shared<gpu::State>();
|
||||||
|
auto VS = gpu::Shader::createVertex(std::string(glowLine_vert));
|
||||||
|
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_NONE);
|
||||||
|
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
||||||
|
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);
|
||||||
|
_glowLinePipeline = gpu::Pipeline::create(program, state);
|
||||||
|
});
|
||||||
|
|
||||||
|
batch.setPipeline(_glowLinePipeline);
|
||||||
|
|
||||||
|
Vec3Pair key(p1, p2);
|
||||||
|
bool registered = (id != UNKNOWN_ID);
|
||||||
|
BatchItemDetails& details = registered ? _registeredLine3DVBOs[id] : _line3DVBOs[key];
|
||||||
|
|
||||||
|
int compactColor = ((int(color.x * 255.0f) & 0xFF)) |
|
||||||
|
((int(color.y * 255.0f) & 0xFF) << 8) |
|
||||||
|
((int(color.z * 255.0f) & 0xFF) << 16) |
|
||||||
|
((int(color.w * 255.0f) & 0xFF) << 24);
|
||||||
|
|
||||||
|
// if this is a registered quad, and we have buffers, then check to see if the geometry changed and rebuild if needed
|
||||||
|
if (registered && details.isCreated) {
|
||||||
|
Vec3Pair& lastKey = _lastRegisteredLine3D[id];
|
||||||
|
if (lastKey != key) {
|
||||||
|
details.clear();
|
||||||
|
_lastRegisteredLine3D[id] = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int FLOATS_PER_VERTEX = 3 + 3; // vertices + normals
|
||||||
|
const int NUM_POS_COORDS = 3;
|
||||||
|
const int VERTEX_NORMAL_OFFSET = NUM_POS_COORDS * sizeof(float);
|
||||||
|
const int vertices = 2;
|
||||||
|
if (!details.isCreated) {
|
||||||
|
details.isCreated = true;
|
||||||
|
details.vertices = vertices;
|
||||||
|
details.vertexSize = FLOATS_PER_VERTEX;
|
||||||
|
|
||||||
|
auto verticesBuffer = std::make_shared<gpu::Buffer>();
|
||||||
|
auto colorBuffer = std::make_shared<gpu::Buffer>();
|
||||||
|
auto streamFormat = std::make_shared<gpu::Stream::Format>();
|
||||||
|
auto stream = std::make_shared<gpu::BufferStream>();
|
||||||
|
|
||||||
|
details.verticesBuffer = verticesBuffer;
|
||||||
|
details.colorBuffer = colorBuffer;
|
||||||
|
details.streamFormat = streamFormat;
|
||||||
|
details.stream = stream;
|
||||||
|
|
||||||
|
details.streamFormat->setAttribute(gpu::Stream::POSITION, 0, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0);
|
||||||
|
details.streamFormat->setAttribute(gpu::Stream::NORMAL, 0, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), VERTEX_NORMAL_OFFSET);
|
||||||
|
details.streamFormat->setAttribute(gpu::Stream::COLOR, 1, gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA));
|
||||||
|
|
||||||
|
details.stream->addBuffer(details.verticesBuffer, 0, details.streamFormat->getChannels().at(0)._stride);
|
||||||
|
details.stream->addBuffer(details.colorBuffer, 0, details.streamFormat->getChannels().at(1)._stride);
|
||||||
|
|
||||||
|
const glm::vec3 NORMAL(1.0f, 0.0f, 0.0f);
|
||||||
|
float vertexBuffer[vertices * FLOATS_PER_VERTEX] = {
|
||||||
|
p1.x, p1.y, p1.z, NORMAL.x, NORMAL.y, NORMAL.z,
|
||||||
|
p2.x, p2.y, p2.z, NORMAL.x, NORMAL.y, NORMAL.z };
|
||||||
|
|
||||||
|
const int NUM_COLOR_SCALARS = 2;
|
||||||
|
int colors[NUM_COLOR_SCALARS] = { compactColor, compactColor };
|
||||||
|
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
|
||||||
|
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is what it takes to render a quad
|
// this is what it takes to render a quad
|
||||||
|
@ -1562,7 +1654,7 @@ void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool cul
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool culled, bool unlit, bool depthBiased) {
|
gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool culled, bool unlit, bool depthBiased) {
|
||||||
SimpleProgramKey config{ textured, culled, unlit, depthBiased };
|
SimpleProgramKey config { textured, culled, unlit, depthBiased };
|
||||||
|
|
||||||
// Compile the shaders
|
// Compile the shaders
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
|
|
|
@ -259,6 +259,9 @@ public:
|
||||||
void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
void renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||||
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
|
const glm::vec4& color1, const glm::vec4& color2, int id = UNKNOWN_ID);
|
||||||
|
|
||||||
|
void renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
|
||||||
|
const glm::vec4& color, float glowIntensity = 1.0f, float glowWidth = 0.05f, int id = UNKNOWN_ID);
|
||||||
|
|
||||||
void renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color,
|
void renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color,
|
||||||
int id = UNKNOWN_ID)
|
int id = UNKNOWN_ID)
|
||||||
{ renderDashedLine(batch, start, end, color, 0.05f, 0.025f, id); }
|
{ renderDashedLine(batch, start, end, color, 0.05f, 0.025f, id); }
|
||||||
|
@ -403,6 +406,7 @@ private:
|
||||||
gpu::ShaderPointer _unlitShader;
|
gpu::ShaderPointer _unlitShader;
|
||||||
static render::ShapePipelinePointer _simplePipeline;
|
static render::ShapePipelinePointer _simplePipeline;
|
||||||
static render::ShapePipelinePointer _simpleWirePipeline;
|
static render::ShapePipelinePointer _simpleWirePipeline;
|
||||||
|
gpu::PipelinePointer _glowLinePipeline;
|
||||||
QHash<SimpleProgramKey, gpu::PipelinePointer> _simplePrograms;
|
QHash<SimpleProgramKey, gpu::PipelinePointer> _simplePrograms;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
35
libraries/render-utils/src/glowLine.slf
Normal file
35
libraries/render-utils/src/glowLine.slf
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2016/07/05
|
||||||
|
// Copyright 2013-2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
layout(location = 0) in vec4 inColor;
|
||||||
|
layout(location = 1) in vec3 inLineDistance;
|
||||||
|
|
||||||
|
out vec4 _fragColor;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
vec2 d = inLineDistance.xy;
|
||||||
|
d.y = abs(d.y);
|
||||||
|
d.x = abs(d.x);
|
||||||
|
if (d.x > 1.0) {
|
||||||
|
d.x = (d.x - 1.0) / 0.02;
|
||||||
|
} else {
|
||||||
|
d.x = 0.0;
|
||||||
|
}
|
||||||
|
float alpha = 1.0 - length(d);
|
||||||
|
if (alpha <= 0.0) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
alpha = pow(alpha, 10.0);
|
||||||
|
if (alpha < 0.05) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
_fragColor = vec4(inColor.rgb, alpha);
|
||||||
|
}
|
106
libraries/render-utils/src/glowLine.slg
Normal file
106
libraries/render-utils/src/glowLine.slg
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2016/07/05
|
||||||
|
// Copyright 2013-2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
#extension GL_EXT_geometry_shader4 : enable
|
||||||
|
|
||||||
|
<@include gpu/Transform.slh@>
|
||||||
|
<$declareStandardCameraTransform()$>
|
||||||
|
|
||||||
|
layout(location = 0) in vec4 inColor[];
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 outColor;
|
||||||
|
layout(location = 1) out vec3 outLineDistance;
|
||||||
|
|
||||||
|
layout(lines) in;
|
||||||
|
layout(triangle_strip, max_vertices = 24) out;
|
||||||
|
|
||||||
|
vec3 ndcToEyeSpace(in vec4 v) {
|
||||||
|
TransformCamera cam = getTransformCamera();
|
||||||
|
vec4 u = cam._projectionInverse * v;
|
||||||
|
return u.xyz / u.w;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 toScreenSpace(in vec4 v)
|
||||||
|
{
|
||||||
|
TransformCamera cam = getTransformCamera();
|
||||||
|
vec4 u = cam._projection * cam._view * v;
|
||||||
|
return u.xy / u.w;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3[2] getOrthogonals(in vec3 n, float scale) {
|
||||||
|
float yDot = abs(dot(n, vec3(0, 1, 0)));
|
||||||
|
|
||||||
|
vec3 result[2];
|
||||||
|
if (yDot < 0.9) {
|
||||||
|
result[0] = normalize(cross(n, vec3(0, 1, 0)));
|
||||||
|
} else {
|
||||||
|
result[0] = normalize(cross(n, vec3(1, 0, 0)));
|
||||||
|
}
|
||||||
|
// The cross of result[0] and n is orthogonal to both, which are orthogonal to each other
|
||||||
|
result[1] = cross(result[0], n);
|
||||||
|
result[0] *= scale;
|
||||||
|
result[1] *= scale;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec2 orthogonal(vec2 v) {
|
||||||
|
vec2 result = v.yx;
|
||||||
|
result.y *= -1.0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec2 endpoints[2];
|
||||||
|
vec3 eyeSpace[2];
|
||||||
|
TransformCamera cam = getTransformCamera();
|
||||||
|
for (int i = 0; i < 2; ++i) {
|
||||||
|
eyeSpace[i] = ndcToEyeSpace(gl_PositionIn[i]);
|
||||||
|
endpoints[i] = gl_PositionIn[i].xy / gl_PositionIn[i].w;
|
||||||
|
}
|
||||||
|
vec2 lineNormal = normalize(endpoints[1] - endpoints[0]);
|
||||||
|
vec2 lineOrthogonal = orthogonal(lineNormal);
|
||||||
|
lineNormal *= 0.02;
|
||||||
|
lineOrthogonal *= 0.02;
|
||||||
|
|
||||||
|
gl_Position = gl_PositionIn[0];
|
||||||
|
gl_Position.xy -= lineNormal;
|
||||||
|
gl_Position.xy -= lineOrthogonal;
|
||||||
|
outColor = inColor[0];
|
||||||
|
outLineDistance = vec3(-1.02, -1, gl_Position.z);
|
||||||
|
EmitVertex();
|
||||||
|
|
||||||
|
gl_Position = gl_PositionIn[0];
|
||||||
|
gl_Position.xy -= lineNormal;
|
||||||
|
gl_Position.xy += lineOrthogonal;
|
||||||
|
outColor = inColor[0];
|
||||||
|
outLineDistance = vec3(-1.02, 1, gl_Position.z);
|
||||||
|
EmitVertex();
|
||||||
|
|
||||||
|
gl_Position = gl_PositionIn[1];
|
||||||
|
gl_Position.xy += lineNormal;
|
||||||
|
gl_Position.xy -= lineOrthogonal;
|
||||||
|
outColor = inColor[1];
|
||||||
|
outLineDistance = vec3(1.02, -1, gl_Position.z);
|
||||||
|
EmitVertex();
|
||||||
|
|
||||||
|
gl_Position = gl_PositionIn[1];
|
||||||
|
gl_Position.xy += lineNormal;
|
||||||
|
gl_Position.xy += lineOrthogonal;
|
||||||
|
outColor = inColor[1];
|
||||||
|
outLineDistance = vec3(1.02, 1, gl_Position.z);
|
||||||
|
EmitVertex();
|
||||||
|
|
||||||
|
EndPrimitive();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
26
libraries/render-utils/src/glowLine.slv
Normal file
26
libraries/render-utils/src/glowLine.slv
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
// Generated on <$_SCRIBE_DATE$>
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2016/07/05
|
||||||
|
// Copyright 2013-2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
|
<@include gpu/Color.slh@>
|
||||||
|
<@include gpu/Transform.slh@>
|
||||||
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 _color;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
_color = inColor;
|
||||||
|
|
||||||
|
// standard transform
|
||||||
|
TransformCamera cam = getTransformCamera();
|
||||||
|
TransformObject obj = getTransformObject();
|
||||||
|
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
|
||||||
|
}
|
Loading…
Reference in a new issue