mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:37:58 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into animation_server_jurisdictions
Conflicts: libraries/voxels/src/JurisdictionMap.h
This commit is contained in:
commit
04440d30d8
19 changed files with 2177 additions and 67 deletions
28
interface/resources/shaders/diffuse.frag
Normal file
28
interface/resources/shaders/diffuse.frag
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#version 120
|
||||||
|
|
||||||
|
//
|
||||||
|
// diffuse.frag
|
||||||
|
// fragment shader
|
||||||
|
//
|
||||||
|
// Created by Andrzej Kapolka on 8/14/13.
|
||||||
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
// the texture containing the original color
|
||||||
|
uniform sampler2D originalTexture;
|
||||||
|
|
||||||
|
// the texture containing the diffused color
|
||||||
|
uniform sampler2D diffusedTexture;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
float ds = dFdx(gl_TexCoord[0].s);
|
||||||
|
float dt = dFdy(gl_TexCoord[0].t);
|
||||||
|
gl_FragColor = (texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(-ds, -dt)) +
|
||||||
|
texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(0.0, -dt)) +
|
||||||
|
texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(ds, -dt)) +
|
||||||
|
texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(ds, 0.0)) +
|
||||||
|
texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(ds, dt)) +
|
||||||
|
texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(0.0, dt)) +
|
||||||
|
texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(-ds, dt)) +
|
||||||
|
texture2D(diffusedTexture, gl_TexCoord[0].st + vec2(-ds, 0.0))) / 8.5 + texture2D(originalTexture, gl_TexCoord[0].st) * 0.1;
|
||||||
|
}
|
17
interface/resources/shaders/glow_add.frag
Normal file
17
interface/resources/shaders/glow_add.frag
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#version 120
|
||||||
|
|
||||||
|
//
|
||||||
|
// glow_add.frag
|
||||||
|
// fragment shader
|
||||||
|
//
|
||||||
|
// Created by Andrzej Kapolka on 8/14/13.
|
||||||
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
// the texture containing the original color
|
||||||
|
uniform sampler2D originalTexture;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
vec4 color = texture2D(originalTexture, gl_TexCoord[0].st);
|
||||||
|
gl_FragColor = color * (1.0 + color.a);
|
||||||
|
}
|
20
interface/resources/shaders/glow_add_separate.frag
Normal file
20
interface/resources/shaders/glow_add_separate.frag
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#version 120
|
||||||
|
|
||||||
|
//
|
||||||
|
// glow_add_separate.frag
|
||||||
|
// fragment shader
|
||||||
|
//
|
||||||
|
// Created by Andrzej Kapolka on 8/14/13.
|
||||||
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
// the texture containing the original color
|
||||||
|
uniform sampler2D originalTexture;
|
||||||
|
|
||||||
|
// the texture containing the blurred color
|
||||||
|
uniform sampler2D blurredTexture;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
vec4 blurred = texture2D(blurredTexture, gl_TexCoord[0].st);
|
||||||
|
gl_FragColor = blurred * blurred.a + texture2D(originalTexture, gl_TexCoord[0].st) * (1.0 + blurred.a * 0.5);
|
||||||
|
}
|
|
@ -4,25 +4,21 @@
|
||||||
// vertical_blur.frag
|
// vertical_blur.frag
|
||||||
// fragment shader
|
// fragment shader
|
||||||
//
|
//
|
||||||
// Created by Andrzej Kapolka on 8/8/13.
|
// Created by Andrzej Kapolka on 8/14/13.
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
// the texture containing the original color
|
|
||||||
uniform sampler2D originalTexture;
|
|
||||||
|
|
||||||
// the texture containing the horizontally blurred color
|
// the texture containing the horizontally blurred color
|
||||||
uniform sampler2D horizontallyBlurredTexture;
|
uniform sampler2D originalTexture;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
float dt = dFdy(gl_TexCoord[0].t);
|
float dt = dFdy(gl_TexCoord[0].t);
|
||||||
vec4 blurred = (texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -7.5)) +
|
gl_FragColor = (texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * -7.5)) +
|
||||||
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -5.5)) +
|
texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * -5.5)) +
|
||||||
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -3.5)) +
|
texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * -3.5)) +
|
||||||
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -1.5)) +
|
texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * -1.5)) +
|
||||||
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 1.5)) +
|
texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * 1.5)) +
|
||||||
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 3.5)) +
|
texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * 3.5)) +
|
||||||
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 5.5)) +
|
texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * 5.5)) +
|
||||||
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 7.5))) / 8.0;
|
texture2D(originalTexture, gl_TexCoord[0].st + vec2(0.0, dt * 7.5))) / 8.0;
|
||||||
gl_FragColor = blurred * blurred.a + texture2D(originalTexture, gl_TexCoord[0].st) * (1.0 + blurred.a * 0.5);
|
|
||||||
}
|
}
|
||||||
|
|
28
interface/resources/shaders/vertical_blur_add.frag
Normal file
28
interface/resources/shaders/vertical_blur_add.frag
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#version 120
|
||||||
|
|
||||||
|
//
|
||||||
|
// vertical_blur_add.frag
|
||||||
|
// fragment shader
|
||||||
|
//
|
||||||
|
// Created by Andrzej Kapolka on 8/8/13.
|
||||||
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
// the texture containing the original color
|
||||||
|
uniform sampler2D originalTexture;
|
||||||
|
|
||||||
|
// the texture containing the horizontally blurred color
|
||||||
|
uniform sampler2D horizontallyBlurredTexture;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
float dt = dFdy(gl_TexCoord[0].t);
|
||||||
|
vec4 blurred = (texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -7.5)) +
|
||||||
|
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -5.5)) +
|
||||||
|
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -3.5)) +
|
||||||
|
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -1.5)) +
|
||||||
|
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 1.5)) +
|
||||||
|
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 3.5)) +
|
||||||
|
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 5.5)) +
|
||||||
|
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 7.5))) / 8.0;
|
||||||
|
gl_FragColor = blurred * blurred.a + texture2D(originalTexture, gl_TexCoord[0].st) * (1.0 + blurred.a * 0.5);
|
||||||
|
}
|
|
@ -1553,7 +1553,6 @@ void Application::chooseVoxelPaintColor() {
|
||||||
const int MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE = 1500;
|
const int MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE = 1500;
|
||||||
struct SendVoxelsOperationArgs {
|
struct SendVoxelsOperationArgs {
|
||||||
unsigned char* newBaseOctCode;
|
unsigned char* newBaseOctCode;
|
||||||
Application* app;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) {
|
bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) {
|
||||||
|
@ -1585,7 +1584,8 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) {
|
||||||
codeColorBuffer[bytesInCode + GREEN_INDEX] = node->getColor()[GREEN_INDEX];
|
codeColorBuffer[bytesInCode + GREEN_INDEX] = node->getColor()[GREEN_INDEX];
|
||||||
codeColorBuffer[bytesInCode + BLUE_INDEX ] = node->getColor()[BLUE_INDEX ];
|
codeColorBuffer[bytesInCode + BLUE_INDEX ] = node->getColor()[BLUE_INDEX ];
|
||||||
|
|
||||||
args->app->_voxelEditSender.queueVoxelEditMessage(PACKET_TYPE_SET_VOXEL_DESTRUCTIVE, codeColorBuffer, codeAndColorLength);
|
getInstance()->_voxelEditSender.queueVoxelEditMessage(PACKET_TYPE_SET_VOXEL_DESTRUCTIVE,
|
||||||
|
codeColorBuffer, codeAndColorLength);
|
||||||
|
|
||||||
delete[] codeColorBuffer;
|
delete[] codeColorBuffer;
|
||||||
}
|
}
|
||||||
|
@ -1769,7 +1769,6 @@ void Application::importVoxels() {
|
||||||
// the server as an set voxel message, this will also rebase the voxels to the new location
|
// the server as an set voxel message, this will also rebase the voxels to the new location
|
||||||
unsigned char* calculatedOctCode = NULL;
|
unsigned char* calculatedOctCode = NULL;
|
||||||
SendVoxelsOperationArgs args;
|
SendVoxelsOperationArgs args;
|
||||||
args.app = this;
|
|
||||||
|
|
||||||
// we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the
|
// we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the
|
||||||
// voxel size/position details.
|
// voxel size/position details.
|
||||||
|
@ -1818,7 +1817,6 @@ void Application::pasteVoxels() {
|
||||||
// Recurse the clipboard tree, where everything is root relative, and send all the colored voxels to
|
// Recurse the clipboard tree, where everything is root relative, and send all the colored voxels to
|
||||||
// the server as an set voxel message, this will also rebase the voxels to the new location
|
// the server as an set voxel message, this will also rebase the voxels to the new location
|
||||||
SendVoxelsOperationArgs args;
|
SendVoxelsOperationArgs args;
|
||||||
args.app = this;
|
|
||||||
|
|
||||||
// we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the
|
// we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the
|
||||||
// voxel size/position details. If we don't have an actual selectedNode then use the mouseVoxel to create a
|
// voxel size/position details. If we don't have an actual selectedNode then use the mouseVoxel to create a
|
||||||
|
@ -1899,6 +1897,7 @@ void Application::initMenu() {
|
||||||
_renderAvatarBalls->setChecked(false);
|
_renderAvatarBalls->setChecked(false);
|
||||||
renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode()));
|
renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode()));
|
||||||
renderMenu->addAction("Cycle Face Mode", &_myAvatar.getHead().getFace(), SLOT(cycleRenderMode()));
|
renderMenu->addAction("Cycle Face Mode", &_myAvatar.getHead().getFace(), SLOT(cycleRenderMode()));
|
||||||
|
renderMenu->addAction("Cycle Glow Mode", &_glowEffect, SLOT(cycleRenderMode()));
|
||||||
(_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true);
|
(_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true);
|
||||||
_renderFrameTimerOn->setChecked(false);
|
_renderFrameTimerOn->setChecked(false);
|
||||||
(_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true);
|
(_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true);
|
||||||
|
|
|
@ -474,7 +474,7 @@ private:
|
||||||
VoxelSceneStats _voxelSceneStats;
|
VoxelSceneStats _voxelSceneStats;
|
||||||
int parseVoxelStats(unsigned char* messageData, ssize_t messageLength, sockaddr senderAddress);
|
int parseVoxelStats(unsigned char* messageData, ssize_t messageLength, sockaddr senderAddress);
|
||||||
|
|
||||||
std::map<uint16_t,JurisdictionMap> _voxelServerJurisdictions;
|
std::map<uint16_t, JurisdictionMap> _voxelServerJurisdictions;
|
||||||
|
|
||||||
std::vector<VoxelFade> _voxelFades;
|
std::vector<VoxelFade> _voxelFades;
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,9 +14,12 @@
|
||||||
#include "GlowEffect.h"
|
#include "GlowEffect.h"
|
||||||
#include "ProgramObject.h"
|
#include "ProgramObject.h"
|
||||||
|
|
||||||
static ProgramObject* createBlurProgram(const QString& direction) {
|
GlowEffect::GlowEffect() : _renderMode(BLUR_ADD_MODE) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static ProgramObject* createProgram(const QString& name) {
|
||||||
ProgramObject* program = new ProgramObject();
|
ProgramObject* program = new ProgramObject();
|
||||||
program->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/" + direction + "_blur.frag");
|
program->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/" + name + ".frag");
|
||||||
program->link();
|
program->link();
|
||||||
|
|
||||||
program->bind();
|
program->bind();
|
||||||
|
@ -28,12 +31,25 @@ static ProgramObject* createBlurProgram(const QString& direction) {
|
||||||
|
|
||||||
void GlowEffect::init() {
|
void GlowEffect::init() {
|
||||||
switchToResourcesParentIfRequired();
|
switchToResourcesParentIfRequired();
|
||||||
_horizontalBlurProgram = createBlurProgram("horizontal");
|
|
||||||
_verticalBlurProgram = createBlurProgram("vertical");
|
|
||||||
|
|
||||||
_verticalBlurProgram->bind();
|
_addProgram = createProgram("glow_add");
|
||||||
_verticalBlurProgram->setUniformValue("horizontallyBlurredTexture", 1);
|
_horizontalBlurProgram = createProgram("horizontal_blur");
|
||||||
_verticalBlurProgram->release();
|
_verticalBlurAddProgram = createProgram("vertical_blur_add");
|
||||||
|
_verticalBlurProgram = createProgram("vertical_blur");
|
||||||
|
_addSeparateProgram = createProgram("glow_add_separate");
|
||||||
|
_diffuseProgram = createProgram("diffuse");
|
||||||
|
|
||||||
|
_verticalBlurAddProgram->bind();
|
||||||
|
_verticalBlurAddProgram->setUniformValue("horizontallyBlurredTexture", 1);
|
||||||
|
_verticalBlurAddProgram->release();
|
||||||
|
|
||||||
|
_addSeparateProgram->bind();
|
||||||
|
_addSeparateProgram->setUniformValue("blurredTexture", 1);
|
||||||
|
_addSeparateProgram->release();
|
||||||
|
|
||||||
|
_diffuseProgram->bind();
|
||||||
|
_diffuseProgram->setUniformValue("diffusedTexture", 1);
|
||||||
|
_diffuseProgram->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlowEffect::prepare() {
|
void GlowEffect::prepare() {
|
||||||
|
@ -43,8 +59,8 @@ void GlowEffect::prepare() {
|
||||||
_isEmpty = true;
|
_isEmpty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlowEffect::begin(float amount) {
|
void GlowEffect::begin(float intensity) {
|
||||||
glBlendColor(0.0f, 0.0f, 0.0f, amount);
|
glBlendColor(0.0f, 0.0f, 0.0f, intensity);
|
||||||
_isEmpty = false;
|
_isEmpty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +109,42 @@ void GlowEffect::render() {
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (_renderMode == ADD_MODE) {
|
||||||
|
_addProgram->bind();
|
||||||
|
renderFullscreenQuad();
|
||||||
|
_addProgram->release();
|
||||||
|
|
||||||
|
} else if (_renderMode == DIFFUSE_ADD_MODE) {
|
||||||
|
// diffuse into the secondary/tertiary (alternating between frames)
|
||||||
|
QOpenGLFramebufferObject* oldDiffusedFBO =
|
||||||
|
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject();
|
||||||
|
QOpenGLFramebufferObject* newDiffusedFBO =
|
||||||
|
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject();
|
||||||
|
if ((_isOddFrame = !_isOddFrame)) {
|
||||||
|
qSwap(oldDiffusedFBO, newDiffusedFBO);
|
||||||
|
}
|
||||||
|
newDiffusedFBO->bind();
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, oldDiffusedFBO->texture());
|
||||||
|
|
||||||
|
_diffuseProgram->bind();
|
||||||
|
renderFullscreenQuad();
|
||||||
|
_diffuseProgram->release();
|
||||||
|
|
||||||
|
newDiffusedFBO->release();
|
||||||
|
|
||||||
|
// add diffused texture to the primary
|
||||||
|
glBindTexture(GL_TEXTURE_2D, newDiffusedFBO->texture());
|
||||||
|
|
||||||
|
_addSeparateProgram->bind();
|
||||||
|
renderFullscreenQuad();
|
||||||
|
_addSeparateProgram->release();
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
|
} else { // _renderMode == BLUR_ADD_MODE || _renderMode == BLUR_PERSIST_ADD_MODE
|
||||||
// render the primary to the secondary with the horizontal blur
|
// render the primary to the secondary with the horizontal blur
|
||||||
QOpenGLFramebufferObject* secondaryFBO =
|
QOpenGLFramebufferObject* secondaryFBO =
|
||||||
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject();
|
Application::getInstance()->getTextureCache()->getSecondaryFramebufferObject();
|
||||||
|
@ -105,14 +156,49 @@ void GlowEffect::render() {
|
||||||
|
|
||||||
secondaryFBO->release();
|
secondaryFBO->release();
|
||||||
|
|
||||||
|
if (_renderMode == BLUR_ADD_MODE) {
|
||||||
// render the secondary to the screen with the vertical blur
|
// render the secondary to the screen with the vertical blur
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, secondaryFBO->texture());
|
glBindTexture(GL_TEXTURE_2D, secondaryFBO->texture());
|
||||||
|
|
||||||
|
_verticalBlurAddProgram->bind();
|
||||||
|
renderFullscreenQuad();
|
||||||
|
_verticalBlurAddProgram->release();
|
||||||
|
|
||||||
|
} else { // _renderMode == BLUR_PERSIST_ADD_MODE
|
||||||
|
// render the secondary to the tertiary with horizontal blur and persistence
|
||||||
|
QOpenGLFramebufferObject* tertiaryFBO =
|
||||||
|
Application::getInstance()->getTextureCache()->getTertiaryFramebufferObject();
|
||||||
|
tertiaryFBO->bind();
|
||||||
|
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_ONE_MINUS_CONSTANT_ALPHA, GL_CONSTANT_ALPHA);
|
||||||
|
const float PERSISTENCE_SMOOTHING = 0.9f;
|
||||||
|
glBlendColor(0.0f, 0.0f, 0.0f, PERSISTENCE_SMOOTHING);
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, secondaryFBO->texture());
|
||||||
|
|
||||||
_verticalBlurProgram->bind();
|
_verticalBlurProgram->bind();
|
||||||
renderFullscreenQuad();
|
renderFullscreenQuad();
|
||||||
_verticalBlurProgram->release();
|
_verticalBlurProgram->release();
|
||||||
|
|
||||||
|
glBlendColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
// now add the tertiary to the primary buffer
|
||||||
|
tertiaryFBO->release();
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, tertiaryFBO->texture());
|
||||||
|
|
||||||
|
_addSeparateProgram->bind();
|
||||||
|
renderFullscreenQuad();
|
||||||
|
_addSeparateProgram->release();
|
||||||
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
|
@ -126,3 +212,7 @@ void GlowEffect::render() {
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GlowEffect::cycleRenderMode() {
|
||||||
|
_renderMode = (RenderMode)((_renderMode + 1) % RENDER_MODE_COUNT);
|
||||||
|
}
|
||||||
|
|
|
@ -9,26 +9,51 @@
|
||||||
#ifndef __interface__GlowEffect__
|
#ifndef __interface__GlowEffect__
|
||||||
#define __interface__GlowEffect__
|
#define __interface__GlowEffect__
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
class ProgramObject;
|
class ProgramObject;
|
||||||
|
|
||||||
class GlowEffect {
|
/// A generic full screen glow effect.
|
||||||
|
class GlowEffect : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
GlowEffect();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
/// Prepares the glow effect for rendering the current frame. To be called before rendering the scene.
|
||||||
void prepare();
|
void prepare();
|
||||||
|
|
||||||
void begin(float amount = 1.0f);
|
/// Starts using the glow effect.
|
||||||
|
/// \param intensity the desired glow intensity, from zero to one
|
||||||
|
void begin(float intensity = 1.0f);
|
||||||
|
|
||||||
|
/// Stops using the glow effect.
|
||||||
void end();
|
void end();
|
||||||
|
|
||||||
|
/// Renders the glow effect. To be called after rendering the scene.
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void cycleRenderMode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ProgramObject* _horizontalBlurProgram;
|
enum RenderMode { ADD_MODE, BLUR_ADD_MODE, BLUR_PERSIST_ADD_MODE, DIFFUSE_ADD_MODE, RENDER_MODE_COUNT };
|
||||||
ProgramObject* _verticalBlurProgram;
|
|
||||||
|
|
||||||
bool _isEmpty;
|
RenderMode _renderMode;
|
||||||
|
ProgramObject* _addProgram;
|
||||||
|
ProgramObject* _horizontalBlurProgram;
|
||||||
|
ProgramObject* _verticalBlurAddProgram;
|
||||||
|
ProgramObject* _verticalBlurProgram;
|
||||||
|
ProgramObject* _addSeparateProgram;
|
||||||
|
ProgramObject* _diffuseProgram;
|
||||||
|
|
||||||
|
bool _isEmpty; ///< set when nothing in the scene is currently glowing
|
||||||
|
bool _isOddFrame; ///< controls the alternation between texture targets in diffuse add mode
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__interface__GlowEffect__) */
|
#endif /* defined(__interface__GlowEffect__) */
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "TextureCache.h"
|
#include "TextureCache.h"
|
||||||
|
|
||||||
TextureCache::TextureCache() : _permutationNormalTextureID(0),
|
TextureCache::TextureCache() : _permutationNormalTextureID(0),
|
||||||
_primaryFramebufferObject(NULL), _secondaryFramebufferObject(NULL) {
|
_primaryFramebufferObject(NULL), _secondaryFramebufferObject(NULL), _tertiaryFramebufferObject(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCache::~TextureCache() {
|
TextureCache::~TextureCache() {
|
||||||
|
@ -27,6 +27,9 @@ TextureCache::~TextureCache() {
|
||||||
if (_secondaryFramebufferObject != NULL) {
|
if (_secondaryFramebufferObject != NULL) {
|
||||||
delete _secondaryFramebufferObject;
|
delete _secondaryFramebufferObject;
|
||||||
}
|
}
|
||||||
|
if (_tertiaryFramebufferObject != NULL) {
|
||||||
|
delete _tertiaryFramebufferObject;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint TextureCache::getPermutationNormalTextureID() {
|
GLuint TextureCache::getPermutationNormalTextureID() {
|
||||||
|
@ -72,6 +75,14 @@ QOpenGLFramebufferObject* TextureCache::getSecondaryFramebufferObject() {
|
||||||
return _secondaryFramebufferObject;
|
return _secondaryFramebufferObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QOpenGLFramebufferObject* TextureCache::getTertiaryFramebufferObject() {
|
||||||
|
if (_tertiaryFramebufferObject == NULL) {
|
||||||
|
_tertiaryFramebufferObject = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size());
|
||||||
|
Application::getInstance()->getGLWidget()->installEventFilter(this);
|
||||||
|
}
|
||||||
|
return _tertiaryFramebufferObject;
|
||||||
|
}
|
||||||
|
|
||||||
bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
|
bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
|
||||||
if (event->type() == QEvent::Resize) {
|
if (event->type() == QEvent::Resize) {
|
||||||
QSize size = static_cast<QResizeEvent*>(event)->size();
|
QSize size = static_cast<QResizeEvent*>(event)->size();
|
||||||
|
@ -83,6 +94,10 @@ bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
|
||||||
delete _secondaryFramebufferObject;
|
delete _secondaryFramebufferObject;
|
||||||
_secondaryFramebufferObject = NULL;
|
_secondaryFramebufferObject = NULL;
|
||||||
}
|
}
|
||||||
|
if (_tertiaryFramebufferObject != NULL && _tertiaryFramebufferObject->size() != size) {
|
||||||
|
delete _tertiaryFramebufferObject;
|
||||||
|
_tertiaryFramebufferObject = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ public:
|
||||||
|
|
||||||
QOpenGLFramebufferObject* getPrimaryFramebufferObject();
|
QOpenGLFramebufferObject* getPrimaryFramebufferObject();
|
||||||
QOpenGLFramebufferObject* getSecondaryFramebufferObject();
|
QOpenGLFramebufferObject* getSecondaryFramebufferObject();
|
||||||
|
QOpenGLFramebufferObject* getTertiaryFramebufferObject();
|
||||||
|
|
||||||
virtual bool eventFilter(QObject* watched, QEvent* event);
|
virtual bool eventFilter(QObject* watched, QEvent* event);
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ private:
|
||||||
|
|
||||||
QOpenGLFramebufferObject* _primaryFramebufferObject;
|
QOpenGLFramebufferObject* _primaryFramebufferObject;
|
||||||
QOpenGLFramebufferObject* _secondaryFramebufferObject;
|
QOpenGLFramebufferObject* _secondaryFramebufferObject;
|
||||||
|
QOpenGLFramebufferObject* _tertiaryFramebufferObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__interface__TextureCache__) */
|
#endif /* defined(__interface__TextureCache__) */
|
||||||
|
|
|
@ -29,6 +29,10 @@ void PacketSender::queuePacket(sockaddr& address, unsigned char* packetData, ssi
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PacketSender::process() {
|
bool PacketSender::process() {
|
||||||
|
if (_packets.size() == 0) {
|
||||||
|
const uint64_t SEND_THREAD_SLEEP_INTERVAL = (1000 * 1000)/60; // check at 60fps
|
||||||
|
usleep(SEND_THREAD_SLEEP_INTERVAL);
|
||||||
|
}
|
||||||
while (_packets.size() > 0) {
|
while (_packets.size() > 0) {
|
||||||
NetworkPacket& packet = _packets.front();
|
NetworkPacket& packet = _packets.front();
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,10 @@ void ReceivedPacketProcessor::queuePacket(sockaddr& address, unsigned char* pack
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReceivedPacketProcessor::process() {
|
bool ReceivedPacketProcessor::process() {
|
||||||
|
if (_packets.size() == 0) {
|
||||||
|
const uint64_t RECEIVED_THREAD_SLEEP_INTERVAL = (1000 * 1000)/60; // check at 60fps
|
||||||
|
usleep(RECEIVED_THREAD_SLEEP_INTERVAL);
|
||||||
|
}
|
||||||
while (_packets.size() > 0) {
|
while (_packets.size() > 0) {
|
||||||
NetworkPacket& packet = _packets.front();
|
NetworkPacket& packet = _packets.front();
|
||||||
processPacket(packet.getAddress(), packet.getData(), packet.getLength());
|
processPacket(packet.getAddress(), packet.getData(), packet.getLength());
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
// copy assignment
|
// copy assignment
|
||||||
JurisdictionMap& JurisdictionMap::operator=(const JurisdictionMap& other) {
|
JurisdictionMap& JurisdictionMap::operator=(const JurisdictionMap& other) {
|
||||||
copyContents(other);
|
copyContents(other);
|
||||||
//printf("JurisdictionMap COPY ASSIGNMENT %p from %p\n", this, &other);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +29,6 @@ JurisdictionMap::JurisdictionMap(JurisdictionMap&& other) : _rootOctalCode(NULL)
|
||||||
init(other._rootOctalCode, other._endNodes);
|
init(other._rootOctalCode, other._endNodes);
|
||||||
other._rootOctalCode = NULL;
|
other._rootOctalCode = NULL;
|
||||||
other._endNodes.clear();
|
other._endNodes.clear();
|
||||||
//printf("JurisdictionMap MOVE CONSTRUCTOR %p from %p\n", this, &other);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// move assignment
|
// move assignment
|
||||||
|
@ -38,7 +36,6 @@ JurisdictionMap& JurisdictionMap::operator=(JurisdictionMap&& other) {
|
||||||
init(other._rootOctalCode, other._endNodes);
|
init(other._rootOctalCode, other._endNodes);
|
||||||
other._rootOctalCode = NULL;
|
other._rootOctalCode = NULL;
|
||||||
other._endNodes.clear();
|
other._endNodes.clear();
|
||||||
//printf("JurisdictionMap MOVE ASSIGNMENT %p from %p\n", this, &other);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,10 +43,9 @@ JurisdictionMap& JurisdictionMap::operator=(JurisdictionMap&& other) {
|
||||||
// Copy constructor
|
// Copy constructor
|
||||||
JurisdictionMap::JurisdictionMap(const JurisdictionMap& other) : _rootOctalCode(NULL) {
|
JurisdictionMap::JurisdictionMap(const JurisdictionMap& other) : _rootOctalCode(NULL) {
|
||||||
copyContents(other);
|
copyContents(other);
|
||||||
//printf("JurisdictionMap COPY CONSTRUCTOR %p from %p\n", this, &other);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JurisdictionMap::copyContents(unsigned char* rootCodeIn, const std::vector<unsigned char*> endNodesIn) {
|
void JurisdictionMap::copyContents(unsigned char* rootCodeIn, const std::vector<unsigned char*>& endNodesIn) {
|
||||||
unsigned char* rootCode;
|
unsigned char* rootCode;
|
||||||
std::vector<unsigned char*> endNodes;
|
std::vector<unsigned char*> endNodes;
|
||||||
if (rootCodeIn) {
|
if (rootCodeIn) {
|
||||||
|
@ -78,7 +74,6 @@ void JurisdictionMap::copyContents(const JurisdictionMap& other) {
|
||||||
|
|
||||||
JurisdictionMap::~JurisdictionMap() {
|
JurisdictionMap::~JurisdictionMap() {
|
||||||
clear();
|
clear();
|
||||||
//printf("JurisdictionMap DESTRUCTOR %p\n",this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JurisdictionMap::clear() {
|
void JurisdictionMap::clear() {
|
||||||
|
@ -101,19 +96,16 @@ JurisdictionMap::JurisdictionMap() : _rootOctalCode(NULL) {
|
||||||
|
|
||||||
std::vector<unsigned char*> emptyEndNodes;
|
std::vector<unsigned char*> emptyEndNodes;
|
||||||
init(rootCode, emptyEndNodes);
|
init(rootCode, emptyEndNodes);
|
||||||
//printf("JurisdictionMap DEFAULT CONSTRUCTOR %p\n",this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JurisdictionMap::JurisdictionMap(const char* filename) : _rootOctalCode(NULL) {
|
JurisdictionMap::JurisdictionMap(const char* filename) : _rootOctalCode(NULL) {
|
||||||
clear(); // clean up our own memory
|
clear(); // clean up our own memory
|
||||||
readFromFile(filename);
|
readFromFile(filename);
|
||||||
//printf("JurisdictionMap INI FILE CONSTRUCTOR %p\n",this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JurisdictionMap::JurisdictionMap(unsigned char* rootOctalCode, const std::vector<unsigned char*>& endNodes)
|
JurisdictionMap::JurisdictionMap(unsigned char* rootOctalCode, const std::vector<unsigned char*>& endNodes)
|
||||||
: _rootOctalCode(NULL) {
|
: _rootOctalCode(NULL) {
|
||||||
init(rootOctalCode, endNodes);
|
init(rootOctalCode, endNodes);
|
||||||
//printf("JurisdictionMap OCTCODE CONSTRUCTOR %p\n",this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JurisdictionMap::JurisdictionMap(const char* rootHexCode, const char* endNodesHexCodes) {
|
JurisdictionMap::JurisdictionMap(const char* rootHexCode, const char* endNodesHexCodes) {
|
||||||
|
@ -130,7 +122,6 @@ JurisdictionMap::JurisdictionMap(const char* rootHexCode, const char* endNodesHe
|
||||||
//printOctalCode(endNodeOctcode);
|
//printOctalCode(endNodeOctcode);
|
||||||
_endNodes.push_back(endNodeOctcode);
|
_endNodes.push_back(endNodeOctcode);
|
||||||
}
|
}
|
||||||
//printf("JurisdictionMap HEX STRING CONSTRUCTOR %p\n",this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
JurisdictionMap(const JurisdictionMap& other); // copy constructor
|
JurisdictionMap(const JurisdictionMap& other); // copy constructor
|
||||||
|
|
||||||
// standard assignment
|
// standard assignment
|
||||||
JurisdictionMap& operator= (JurisdictionMap const &other); // copy assignment
|
JurisdictionMap& operator=(const JurisdictionMap& other); // copy assignment
|
||||||
|
|
||||||
#ifdef HAS_MOVE_SEMANTICS
|
#ifdef HAS_MOVE_SEMANTICS
|
||||||
// move constructor and assignment
|
// move constructor and assignment
|
||||||
|
@ -48,7 +48,7 @@ public:
|
||||||
unsigned char* getEndNodeOctalCode(int index) const { return _endNodes[index]; }
|
unsigned char* getEndNodeOctalCode(int index) const { return _endNodes[index]; }
|
||||||
int getEndNodeCount() const { return _endNodes.size(); }
|
int getEndNodeCount() const { return _endNodes.size(); }
|
||||||
|
|
||||||
void copyContents(unsigned char* rootCodeIn, const std::vector<unsigned char*> endNodesIn);
|
void copyContents(unsigned char* rootCodeIn, const std::vector<unsigned char*>& endNodesIn);
|
||||||
|
|
||||||
int unpackFromMessage(unsigned char* sourceBuffer, int availableBytes);
|
int unpackFromMessage(unsigned char* sourceBuffer, int availableBytes);
|
||||||
int packIntoMessage(unsigned char* destinationBuffer, int availableBytes);
|
int packIntoMessage(unsigned char* destinationBuffer, int availableBytes);
|
||||||
|
|
Loading…
Reference in a new issue