mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
ecc6d41523
9 changed files with 63 additions and 44 deletions
|
@ -4,6 +4,9 @@ project(hifi)
|
|||
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{QT_CMAKE_PREFIX_PATH})
|
||||
|
||||
# set our Base SDK to 10.7
|
||||
set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk)
|
||||
|
||||
# Find includes in corresponding build directories
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
|
|
|
@ -59,7 +59,7 @@ void main(void) {
|
|||
vec3 offset = center + rotation * (radius * sampleKernel[i]);
|
||||
vec4 projected = gl_ProjectionMatrix * vec4(offset, 1.0);
|
||||
float depth = texCoordToViewSpaceZ(projected.xy * 0.5 / projected.w + vec2(0.5, 0.5));
|
||||
occlusion += 1.0 - step(offset.z, depth); // * step(abs(center.z - depth), radius);
|
||||
occlusion += 1.0 - step(offset.z, depth);
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(occlusion, occlusion, occlusion, 0.0) / 16.0;
|
||||
|
|
|
@ -11,15 +11,14 @@
|
|||
// the original texture
|
||||
uniform sampler2D originalTexture;
|
||||
|
||||
// the scale for the blur kernel
|
||||
uniform vec2 blurScale;
|
||||
|
||||
void main(void) {
|
||||
float ds = dFdx(gl_TexCoord[0].s);
|
||||
float dt = dFdy(gl_TexCoord[0].t);
|
||||
vec4 sum = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
sum += texture2D(originalTexture, gl_TexCoord[0].st +
|
||||
vec2(ds, dt) * vec2(-2.0 + float(i), -2.0 + float(j)));
|
||||
}
|
||||
}
|
||||
gl_FragColor = sum / 16.0;
|
||||
vec2 minExtents = gl_TexCoord[0].st + blurScale * vec2(-0.5, -0.5);
|
||||
vec2 maxExtents = gl_TexCoord[0].st + blurScale * vec2(1.5, 1.5);
|
||||
gl_FragColor = (texture2D(originalTexture, minExtents) +
|
||||
texture2D(originalTexture, vec2(maxExtents.s, minExtents.t)) +
|
||||
texture2D(originalTexture, vec2(minExtents.s, maxExtents.t)) +
|
||||
texture2D(originalTexture, maxExtents)) * 0.25;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,8 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels) :
|
|||
_falseColorizeBySource = false;
|
||||
_dataSourceID = UNKNOWN_NODE_ID;
|
||||
_voxelServerCount = 0;
|
||||
|
||||
_viewFrustum = Application::getInstance()->getViewFrustum();
|
||||
}
|
||||
|
||||
void VoxelSystem::nodeDeleted(VoxelNode* node) {
|
||||
|
@ -394,7 +396,7 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) {
|
|||
int voxelsUpdated = 0;
|
||||
bool shouldRender = false; // assume we don't need to render it
|
||||
// if it's colored, we might need to render it!
|
||||
shouldRender = node->calculateShouldRender(Application::getInstance()->getViewFrustum());
|
||||
shouldRender = node->calculateShouldRender(_viewFrustum);
|
||||
|
||||
node->setShouldRender(shouldRender);
|
||||
// let children figure out their renderness
|
||||
|
@ -813,10 +815,8 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData)
|
|||
}
|
||||
|
||||
void VoxelSystem::falseColorizeInView() {
|
||||
ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum();
|
||||
|
||||
_nodeCount = 0;
|
||||
_tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum);
|
||||
_tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)_viewFrustum);
|
||||
qDebug("setting in view false color for %d nodes\n", _nodeCount);
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
|
@ -942,15 +942,13 @@ bool VoxelSystem::getDistanceFromViewRangeOperation(VoxelNode* node, void* extra
|
|||
}
|
||||
|
||||
void VoxelSystem::falseColorizeDistanceFromView() {
|
||||
ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum();
|
||||
|
||||
_nodeCount = 0;
|
||||
_maxDistance = 0.0;
|
||||
_minDistance = FLT_MAX;
|
||||
_tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation, (void*) viewFrustum);
|
||||
_tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation, (void*) _viewFrustum);
|
||||
qDebug("determining distance range for %d nodes\n", _nodeCount);
|
||||
_nodeCount = 0;
|
||||
_tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation, (void*) viewFrustum);
|
||||
_tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation, (void*) _viewFrustum);
|
||||
qDebug("setting in distance false color for %d nodes\n", _nodeCount);
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
|
@ -960,6 +958,7 @@ void VoxelSystem::falseColorizeDistanceFromView() {
|
|||
class removeOutOfViewArgs {
|
||||
public:
|
||||
VoxelSystem* thisVoxelSystem;
|
||||
ViewFrustum* thisViewFrustum;
|
||||
VoxelNodeBag dontRecurseBag;
|
||||
unsigned long nodesScanned;
|
||||
unsigned long nodesRemoved;
|
||||
|
@ -969,6 +968,7 @@ public:
|
|||
|
||||
removeOutOfViewArgs(VoxelSystem* voxelSystem) :
|
||||
thisVoxelSystem(voxelSystem),
|
||||
thisViewFrustum(voxelSystem->getViewFrustum()),
|
||||
dontRecurseBag(),
|
||||
nodesScanned(0),
|
||||
nodesRemoved(0),
|
||||
|
@ -997,7 +997,7 @@ bool VoxelSystem::removeOutOfViewOperation(VoxelNode* node, void* extraData) {
|
|||
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
|
||||
VoxelNode* childNode = node->getChildAtIndex(i);
|
||||
if (childNode) {
|
||||
ViewFrustum::location inFrustum = childNode->inFrustum(*Application::getInstance()->getViewFrustum());
|
||||
ViewFrustum::location inFrustum = childNode->inFrustum(*args->thisViewFrustum);
|
||||
switch (inFrustum) {
|
||||
case ViewFrustum::OUTSIDE: {
|
||||
args->nodesOutside++;
|
||||
|
@ -1031,9 +1031,9 @@ bool VoxelSystem::isViewChanging() {
|
|||
bool result = false; // assume the best
|
||||
|
||||
// If our viewFrustum has changed since our _lastKnowViewFrustum
|
||||
if (!_lastKnowViewFrustum.matches(Application::getInstance()->getViewFrustum())) {
|
||||
if (!_lastKnowViewFrustum.matches(_viewFrustum)) {
|
||||
result = true;
|
||||
_lastKnowViewFrustum = *Application::getInstance()->getViewFrustum(); // save last known
|
||||
_lastKnowViewFrustum = *_viewFrustum; // save last known
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1047,9 +1047,9 @@ bool VoxelSystem::hasViewChanged() {
|
|||
}
|
||||
|
||||
// If our viewFrustum has changed since our _lastKnowViewFrustum
|
||||
if (!_lastStableViewFrustum.matches(Application::getInstance()->getViewFrustum())) {
|
||||
if (!_lastStableViewFrustum.matches(_viewFrustum)) {
|
||||
result = true;
|
||||
_lastStableViewFrustum = *Application::getInstance()->getViewFrustum(); // save last stable
|
||||
_lastStableViewFrustum = *_viewFrustum; // save last stable
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1403,7 +1403,7 @@ void VoxelSystem::falseColorizeOccluded() {
|
|||
myCoverageMap.erase();
|
||||
|
||||
FalseColorizeOccludedArgs args;
|
||||
args.viewFrustum = Application::getInstance()->getViewFrustum();
|
||||
args.viewFrustum = _viewFrustum;
|
||||
args.map = &myCoverageMap;
|
||||
args.totalVoxels = 0;
|
||||
args.coloredVoxels = 0;
|
||||
|
@ -1525,7 +1525,7 @@ void VoxelSystem::falseColorizeOccludedV2() {
|
|||
VoxelProjectedPolygon::intersects_calls = 0;
|
||||
|
||||
FalseColorizeOccludedArgs args;
|
||||
args.viewFrustum = Application::getInstance()->getViewFrustum();
|
||||
args.viewFrustum = _viewFrustum;
|
||||
args.mapV2 = &myCoverageMapV2;
|
||||
args.totalVoxels = 0;
|
||||
args.coloredVoxels = 0;
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
void simulate(float deltaTime) { };
|
||||
void render(bool texture);
|
||||
|
||||
ViewFrustum* getViewFrustum() const {return _viewFrustum;}
|
||||
void setViewFrustum(ViewFrustum* viewFrustum) {_viewFrustum = viewFrustum;}
|
||||
unsigned long getVoxelsUpdated() const {return _voxelsUpdated;};
|
||||
unsigned long getVoxelsRendered() const {return _voxelsInReadArrays;};
|
||||
|
||||
|
@ -182,6 +184,7 @@ private:
|
|||
|
||||
ViewFrustum _lastKnowViewFrustum;
|
||||
ViewFrustum _lastStableViewFrustum;
|
||||
ViewFrustum* _viewFrustum;
|
||||
|
||||
int newTreeToArrays(VoxelNode *currentNode);
|
||||
void cleanupRemovedVoxels();
|
||||
|
|
|
@ -32,15 +32,6 @@ void AmbientOcclusionEffect::init() {
|
|||
_occlusionProgram->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/ambient_occlusion.frag");
|
||||
_occlusionProgram->link();
|
||||
|
||||
_blurProgram = new ProgramObject();
|
||||
_blurProgram->addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/ambient_occlusion.vert");
|
||||
_blurProgram->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/occlusion_blur.frag");
|
||||
_blurProgram->link();
|
||||
|
||||
_blurProgram->bind();
|
||||
_blurProgram->setUniformValue("originalTexture", 0);
|
||||
_blurProgram->release();
|
||||
|
||||
// create the sample kernel: an array of spherically distributed offset vectors
|
||||
const int SAMPLE_KERNEL_SIZE = 16;
|
||||
QVector3D sampleKernel[SAMPLE_KERNEL_SIZE];
|
||||
|
@ -83,6 +74,17 @@ void AmbientOcclusionEffect::init() {
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
_blurProgram = new ProgramObject();
|
||||
_blurProgram->addShaderFromSourceFile(QGLShader::Vertex, "resources/shaders/ambient_occlusion.vert");
|
||||
_blurProgram->addShaderFromSourceFile(QGLShader::Fragment, "resources/shaders/occlusion_blur.frag");
|
||||
_blurProgram->link();
|
||||
|
||||
_blurProgram->bind();
|
||||
_blurProgram->setUniformValue("originalTexture", 0);
|
||||
_blurProgram->release();
|
||||
|
||||
_blurScaleLocation = _blurProgram->uniformLocation("blurScale");
|
||||
}
|
||||
|
||||
void AmbientOcclusionEffect::render() {
|
||||
|
@ -131,6 +133,7 @@ void AmbientOcclusionEffect::render() {
|
|||
glBindTexture(GL_TEXTURE_2D, freeFBO->texture());
|
||||
|
||||
_blurProgram->bind();
|
||||
_blurProgram->setUniformValue(_blurScaleLocation, 1.0f / size.width(), 1.0f / size.height());
|
||||
|
||||
renderFullscreenQuad();
|
||||
|
||||
|
@ -138,7 +141,6 @@ void AmbientOcclusionEffect::render() {
|
|||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
//glEnable(GL_BLEND);
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
|
|
@ -32,6 +32,7 @@ private:
|
|||
int _noiseScaleLocation;
|
||||
|
||||
ProgramObject* _blurProgram;
|
||||
int _blurScaleLocation;
|
||||
|
||||
GLuint _rotationTextureID;
|
||||
};
|
||||
|
|
|
@ -64,12 +64,11 @@ GLuint TextureCache::getPermutationNormalTextureID() {
|
|||
|
||||
QOpenGLFramebufferObject* TextureCache::getPrimaryFramebufferObject() {
|
||||
if (_primaryFramebufferObject == NULL) {
|
||||
QSize size = Application::getInstance()->getGLWidget()->size();
|
||||
_primaryFramebufferObject = new QOpenGLFramebufferObject(size);
|
||||
Application::getInstance()->getGLWidget()->installEventFilter(this);
|
||||
|
||||
_primaryFramebufferObject = createFramebufferObject();
|
||||
|
||||
glGenTextures(1, &_primaryDepthTextureID);
|
||||
glBindTexture(GL_TEXTURE_2D, _primaryDepthTextureID);
|
||||
QSize size = Application::getInstance()->getGLWidget()->size();
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size.width(), size.height(),
|
||||
0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -91,16 +90,14 @@ GLuint TextureCache::getPrimaryDepthTextureID() {
|
|||
|
||||
QOpenGLFramebufferObject* TextureCache::getSecondaryFramebufferObject() {
|
||||
if (_secondaryFramebufferObject == NULL) {
|
||||
_secondaryFramebufferObject = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size());
|
||||
Application::getInstance()->getGLWidget()->installEventFilter(this);
|
||||
_secondaryFramebufferObject = createFramebufferObject();
|
||||
}
|
||||
return _secondaryFramebufferObject;
|
||||
}
|
||||
|
||||
QOpenGLFramebufferObject* TextureCache::getTertiaryFramebufferObject() {
|
||||
if (_tertiaryFramebufferObject == NULL) {
|
||||
_tertiaryFramebufferObject = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size());
|
||||
Application::getInstance()->getGLWidget()->installEventFilter(this);
|
||||
_tertiaryFramebufferObject = createFramebufferObject();
|
||||
}
|
||||
return _tertiaryFramebufferObject;
|
||||
}
|
||||
|
@ -124,3 +121,15 @@ bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QOpenGLFramebufferObject* TextureCache::createFramebufferObject() {
|
||||
QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(Application::getInstance()->getGLWidget()->size());
|
||||
Application::getInstance()->getGLWidget()->installEventFilter(this);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, fbo->texture());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
return fbo;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
QOpenGLFramebufferObject* createFramebufferObject();
|
||||
|
||||
GLuint _permutationNormalTextureID;
|
||||
|
||||
QOpenGLFramebufferObject* _primaryFramebufferObject;
|
||||
|
|
Loading…
Reference in a new issue