Commit 78529d77 authored by BrutPitt's avatar BrutPitt
Browse files

ver 1.6.0 WiP - better support for PiP in TransformFeedback emitter (FXAA...

ver 1.6.0 WiP - better support for PiP in TransformFeedback emitter (FXAA bug-fix, when PiP is active)
parent 3f5528e4
......@@ -206,6 +206,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
currentTMat->setPOV(tmpPov);
currentTMat->getTrackball().setDollyPosition(tmpDolly);
currentTMat->applyTransforms();
glViewport(0,0, getUData().scrnRes.x, getUData().scrnRes.y);
}
#endif
......@@ -216,11 +217,6 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, getRenderFBO().getFB(fbIdx));
if(isTFRender)
glViewport(cPit.getViewportSize().x, cPit.getViewportSize().y, cPit.getViewportSize().z, cPit.getViewportSize().w);
else
glViewport(0,0, getUData().scrnRes.x, getUData().scrnRes.y);
// Clear Depth buffer
if(depthBuffActive) {
glEnable(GL_DEPTH_TEST);
......@@ -230,7 +226,8 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
glClearBufferfv(GL_DEPTH , 0, &f);
// clear Color buffer
if(!showAxes()) glClearBufferfv(GL_COLOR, 0, value_ptr(backgroundColor()));
vec4 bkgColor(!isFullScreenPiP ? cPit.getPipBkgrndColor() : backgroundColor());
if(!showAxes()) glClearBufferfv(GL_COLOR, 0, value_ptr(bkgColor));
if(blendActive || showAxes()) {
glEnable(GL_BLEND);
......@@ -289,7 +286,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
/////////////////////////////////////////////
if(useAO()) {
currentTMat->updateBufferData();
getAO()->bindRender(this, fbIdx);
getAO()->bindRender(this, fbIdx, bkgColor);
getAO()->render();
getAO()->releaseRender();
//returnedTex = getAO()->getFBO().getTex(0);
......@@ -299,7 +296,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
/////////////////////////////////////////////
currentTMat->updateBufferData();
getPostRendering()->bindRender(this, fbIdx);
getPostRendering()->bindRender(this, fbIdx, bkgColor);
getPostRendering()->render();
getPostRendering()->releaseRender();
......@@ -843,7 +840,7 @@ GLuint fxaaClass::render(GLuint texIn, bool useFB)
#endif
if(renderEngine->checkFlagUpdate()) {
setUniform2f(_invScrnSize, 1.f/fbo.getSizeX(), 1.f/fbo.getSizeY());
setUniform2f(_invScrnSize, 1.f/fbo.getSizeX(), 1.f/fbo.getSizeY());
updateSettings();
}
......@@ -909,7 +906,7 @@ void postRenderingClass::create() {
}
void postRenderingClass::bindRender(particlesBaseClass *particle, GLuint fbIdx)
void postRenderingClass::bindRender(particlesBaseClass *particle, GLuint fbIdx, const vec4 &bkgColor)
{
particle->updateBufferData();
mmFBO &renderFBO = particle->getRenderFBO();
......@@ -918,8 +915,8 @@ void postRenderingClass::bindRender(particlesBaseClass *particle, GLuint fbIdx)
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo.getFB(0));
const vec4 bkg(particle->backgroundColor());
glClearBufferfv(GL_COLOR, 0, value_ptr(bkg));
//const vec4 bkg(particle->backgroundColor());
glClearBufferfv(GL_COLOR, 0, value_ptr(bkgColor));
#ifdef GLAPP_REQUIRE_OGL45
......@@ -1091,7 +1088,7 @@ void ambientOcclusionClass::create() {
//setUniform3fv(getUniformLocation("ssaoSamples"), kernelSize, (const GLfloat*)ssaoKernel.data());
}
void ambientOcclusionClass::bindRender(particlesBaseClass *particle, GLuint fbIdx)
void ambientOcclusionClass::bindRender(particlesBaseClass *particle, GLuint fbIdx, const vec4 &bkgColor)
{
particle->updateBufferData();
mmFBO &renderFBO = particle->getRenderFBO();
......@@ -1100,8 +1097,8 @@ void ambientOcclusionClass::bindRender(particlesBaseClass *particle, GLuint fbId
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo.getFB(0));
const vec4 bkg(particle->backgroundColor());
glClearBufferfv(GL_COLOR, 0, value_ptr(bkg));
//const vec4 bkg(particle->backgroundColor());
glClearBufferfv(GL_COLOR, 0, value_ptr(bkgColor));
#ifdef GLAPP_REQUIRE_OGL45
glBindTextureUnit( 6, noiseTexture);
......@@ -1213,21 +1210,22 @@ void tfSettinsClass::setViewport(int w, int h) {
w++; h++;
switch(getPIPposition()) {
case pip::lTop:
setViewportSize(ivec4(0, h-szY, szX, szY));
setViewportSize(ivec4(0, h-szY, szX, h));
break;
case pip::lBottom:
setViewportSize(ivec4(0, 0, szX, szY));
setViewportSize(ivec4(0, 0, szX, szY));
break;
case pip::rTop:
setViewportSize(ivec4(w-szX,h-szY, szX, szY));
setViewportSize(ivec4(w-szX, h-szY, w, h));
break;
case pip::rBottom:
setViewportSize(ivec4(w-szX, 0, szX, szY));
setViewportSize(ivec4(w-szX, 0, w, szY));
break;
case pip::splitView:
{
const float zoom = 1.f-getPIPzoom();
setViewportSize(ivec4(float(w)*getPIPzoom(), float(h)*getPIPzoom()*.5, float(w)*zoom, float(h)*zoom));
const float zoom = getPIPzoom();
const float startY = float(h)*zoom*.5;
setViewportSize(ivec4(float(w)*zoom, startY, float(w), float(h)-startY));
}
break;
case pip::noPIP:
......
......@@ -19,6 +19,7 @@
#include <transforms.h>
#endif
#include "emitter.h"
#include "palettes.h"
#define SHADER_PATH "Shaders/"
......@@ -402,6 +403,8 @@ public:
ivec4 &getViewportSize() { return viewportSize; }
void setViewportSize(const ivec4 &v) { viewportSize = v; }
vec4 &getPipBkgrndColor() { return pipBkgrndColor; }
void setPipBkgrndColor(const vec4 &v) { pipBkgrndColor = v; }
private:
struct tfCommonsStruct {
......@@ -431,9 +434,10 @@ private:
float cpMagnitudeInt = .2;
float cpMagnitudeAtten = .25;
bool cpFixDistance = true;
quat qRot = quat(1.0f,0.0f, 0.0f, 0.0f);
quat qRot = quat(1.0f, 0.0f, 0.0f, 0.0f);
int slowMotionDpS = 100; //tfSettings DotPerSec
int slowMotionFSDpS = 5000; //FullScreen DotPerSec
vec4 pipBkgrndColor = vec4(.003f, .003f, .007f, 1.f);
static constexpr float perspNear = .001f;
......@@ -481,7 +485,7 @@ public:
void create();
void bindRender(particlesBaseClass *particle, GLuint fbIdx);
void bindRender(particlesBaseClass *particle, GLuint fbIdx, const vec4 &bkgColor);
void render();
void releaseRender();
......@@ -516,7 +520,7 @@ public:
void create();
void bindRender(particlesBaseClass *particle, GLuint fbIdx);
void bindRender(particlesBaseClass *particle, GLuint fbIdx, const vec4 &bkgColor);
void render();
void releaseRender();
......@@ -1166,7 +1170,7 @@ public:
uParticlesData &getUData() { return uData; }
GLuint render(GLuint fbOut, emitterBaseClass *em, bool eraseBkg = true, bool cpitView = false);
GLuint render(GLuint fbOut, emitterBaseClass *em, bool isFullScreen = true, bool cpitView = false);
GLuint getDstBlend() { return dstBlendAttrib; }
GLuint getSrcBlend() { return srcBlendAttrib; }
......
......@@ -20,12 +20,29 @@
RandomTexture rndTexture;
HLSTexture hlsTexture;
void blitFrameBuffer(const GLuint srcFB, const GLuint dstFB, const ivec4 &srcRect, const ivec4 &dstRect, const GLuint filter=GL_LINEAR)
{
#ifdef GLAPP_REQUIRE_OGL45
glBlitNamedFramebuffer(srcFB, dstFB,
srcRect.x, srcRect.y, srcRect.z, srcRect.w,
dstRect.x, dstRect.y, dstRect.z, dstRect.w,
GL_COLOR_BUFFER_BIT, filter );
#else
glBindFramebuffer(GL_READ_FRAMEBUFFER, srcFB);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dstFB);
glBlitFramebuffer(srcRect.x, srcRect.y, srcRect.z, srcRect.w,
dstRect.x, dstRect.y, dstRect.z, dstRect.w,
GL_COLOR_BUFFER_BIT, filter );
#endif
}
//
////////////////////////////////////////////////////////////////////////////
void glWindow::onInit()
{
glViewport(0,0,theApp->GetWidth(), theApp->GetHeight());
vao = new vaoClass;
//rndTexture.buildTex(1024);
......@@ -43,8 +60,7 @@ void glWindow::onInit()
particlesSystem->shaderPointClass::getUData().pointspriteMinSize = retVal[0];
#endif
vg::vGizmo3D &vgizmo = theWnd->getParticlesSystem()->getTMat()->getTrackball();
vg::vGizmo3D &vgizmo = particlesSystem->getTMat()->getTrackball();
particlesSystem->getTMat()->setPerspective(30.f, float(theApp->GetWidth())/float(theApp->GetHeight()), 0.f, 100.f);
particlesSystem->getTMat()->setView(attractorsList.get()->getPOV(), attractorsList.get()->getTGT());
......@@ -101,7 +117,8 @@ GLint glWindow::onRender()
{
particlesSystem->renderPalette();
particlesSystem->getParticleRenderPtr()->clearFB(0);
if(theApp->getEmitterEngineType() == enumEmitterEngine::emitterEngine_transformFeedback && tfSettinsClass::cockPit() && tfSettinsClass::getPIPposition() == tfSettinsClass::pip::splitView)
particlesSystem->getParticleRenderPtr()->clearFB(0);
#if !defined(GLCHAOSP_LIGHTVER)
......@@ -111,28 +128,16 @@ GLint glWindow::onRender()
GLuint texRendered = particlesSystem->render();
// Motion Blur
if(particlesSystem->getMotionBlur()->Active()) {
#ifdef GLAPP_REQUIRE_OGL45
glBlitNamedFramebuffer(particlesSystem->getMotionBlur()->render(texRendered),
0,
0,0,particlesSystem->getWidth(), particlesSystem->getHeight(),
0,0,theApp->GetWidth(), theApp->GetHeight(),
GL_COLOR_BUFFER_BIT, GL_NEAREST );
#else
glBindFramebuffer(GL_READ_FRAMEBUFFER, particlesSystem->getMotionBlur()->render(texRendered));
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
if(particlesSystem->getMotionBlur()->Active())
blitFrameBuffer(particlesSystem->getMotionBlur()->render(texRendered), 0,
ivec4(0,0,particlesSystem->getWidth(), particlesSystem->getHeight()),
ivec4(0,0,theApp->GetWidth(), theApp->GetHeight()), GL_NEAREST);
glBlitFramebuffer(0,0,particlesSystem->getWidth(), particlesSystem->getHeight(),
0,0,theApp->GetWidth(), theApp->GetHeight(),
GL_COLOR_BUFFER_BIT, GL_NEAREST );
#endif
}
#else
getParticlesSystem()->getTMat()->applyTransforms();
GLuint texRendered = particlesSystem->render();
#endif
glBindFramebuffer(GL_FRAMEBUFFER, 0);
particlesSystem->clearFlagUpdate();
return texRendered;
}
......
......@@ -24,8 +24,6 @@
// Includes all the files for the library
//#include "mmFBO.h"
using namespace std;
......
......@@ -140,8 +140,6 @@ void particlesSystemClass::renderAxes()
GLuint particlesSystemClass::renderSingle()
{
glViewport(0,0, getWidth(), getHeight());
GLuint texRendered;
emitter->preRenderEvents();
......@@ -177,16 +175,18 @@ GLuint particlesSystemClass::renderSingle()
return texRendered;
}
void blitFrameBuffer(const GLuint srcFB, const GLuint dstFB, const ivec4 &srcRect, const ivec4 &dstRect, const GLuint filter=GL_LINEAR);
GLuint particlesSystemClass::renderTF()
{
tfSettinsClass &cPit = getParticleRenderPtr()->getTFSettings();
particlesBaseClass *particles = getParticleRenderPtr();
tfSettinsClass &cPit = particles->getTFSettings();
const int w = getWidth(), h = getHeight();
if(cPit.cockPit() && cPit.getPIPposition() == cPit.pip::splitView) {
const float zoom = cPit.getPIPzoom();
cPit.setViewportSize(ivec4(0, float(h)*(1.f-zoom)*.5, float(w)*zoom, float(h)*zoom));
} else cPit.setViewportSize(ivec4(0,0, w, h));
const bool isDualView = cPit.cockPit() && cPit.getPIPposition() != cPit.pip::noPIP;
const bool isSplitView = cPit.cockPit() && cPit.getPIPposition() == cPit.pip::splitView;
getEmitter()->preRenderEvents();
......@@ -224,25 +224,39 @@ GLuint particlesSystemClass::renderTF()
cpTM->getTrackball().setPosition(vec3(0.f));
cpTM->applyTransforms();
setFlagUpdate();
//Render TF full screen view
GLuint texRendered = renderParticles(true, cPit.cockPit() && !cPit.invertPIP());
texRendered = renderGlowEffect(texRendered);
texRendered = renderGlowEffect(texRendered, isSplitView);
#if !defined(GLCHAOSP_NO_FXAA)
texRendered = renderFXAA(texRendered, isSplitView);
GLuint srcFB = particles->getFXAA()->isOn() ? particles->getFXAA()->getFBO().getFB(0) : particles->getGlowRender()->getFBO().getFB(1);
#else
GLuint srcFB = particles->getGlowRender()->getFBO().getFB(1);
#endif
auto blitFB = [&](const ivec4 &vp) { blitFrameBuffer(srcFB, 0, ivec4(0, 0, w, h), vp); };
if(isSplitView) {
const float zoom = cPit.getPIPzoom();
const float startY = float(h)*(1.f-zoom)*.5;
blitFB( ivec4(0, startY, float(w)*zoom+.5, float(h)-startY) );
}
//Render PiP view
setFlagUpdate();
if(cPit.cockPit() && cPit.getPIPposition() != cPit.pip::noPIP) {
if(isDualView) {
cPit.setViewport(w,h);
texRendered = renderParticles(false, cPit.invertPIP());
texRendered = renderGlowEffect(texRendered);
}
GLuint littleTex = renderParticles(false, cPit.invertPIP());
littleTex = renderGlowEffect(littleTex, true);
#if !defined(GLCHAOSP_NO_FXAA)
//FIXME: currently disabled FXAA on splitView
if(cPit.cockPit() && cPit.getPIPposition() != cPit.pip::splitView) {
glViewport(0,0, w, h);
texRendered = renderFXAA(texRendered);
}
littleTex = renderFXAA(littleTex, true);
#endif
blitFB(cPit.getViewportSize());
}
getEmitter()->postRenderEvents();
return texRendered;
......
......@@ -53,11 +53,11 @@ public:
}
/////////////////////////////////////////////
GLuint renderGlowEffect(GLuint texRendered) {
GLuint renderGlowEffect(GLuint texRendered, bool useFB=false) {
#if !defined(GLCHAOSP_LIGHTVER)
particlesBaseClass *particles = getParticleRenderPtr();
const GLuint fbo = (getMotionBlur()->Active() || particles->getFXAA()->isOn()) ? particles->getGlowRender()->getFBO().getFB(1) : 0;
const GLuint fbo = (useFB || getMotionBlur()->Active() || particles->getFXAA()->isOn()) ? particles->getGlowRender()->getFBO().getFB(1) : 0;
particles->getGlowRender()->render(texRendered, fbo);
return particles->getGlowRender()->getFBO().getTex(1); // used only if FXAA and/or Motionblur
#else
......@@ -80,6 +80,8 @@ public:
/////////////////////////////////////////////
GLuint render() {
glViewport(0,0, getWidth(), getHeight());
//return attractorsList.get()->dtType() && tfSettinsClass::tfMode() ? renderTF() : renderSingle();
return theApp->getEmitterEngineType() == enumEmitterEngine::emitterEngine_transformFeedback ? renderTF() : renderSingle();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment