Skip to content

Commit

Permalink
ver 1.6.0 WiP - splitView: side by side cockpit and standard view
Browse files Browse the repository at this point in the history
  • Loading branch information
BrutPitt committed Jul 7, 2020
1 parent 04d6a21 commit d7d20cd
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 121 deletions.
38 changes: 26 additions & 12 deletions src/src/ShadersClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void shaderPointClass::initShader()
// particlesBase
//
////////////////////////////////////////////////////////////////////////////////
GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool isFullScreenPiP, bool cpitView)
GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool isFullScreenPiP, bool cpitView)
{
setFlagUpdate();
const GLsizei shadowDetail = theApp->useDetailedShadows() ? GLsizei(2) : GLsizei(1);
Expand All @@ -112,9 +112,11 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool

getUPlanes().buildInvMV_forPlanes(this); // checkPlanes and eventually build invMat

tfSettinsClass &cPit = getTFSettings();

if(checkFlagUpdate()) {
//getUData().scrnRes = vec2((isTFRender && cPit.getPIPposition() == cPit.pip::splitView) ? getRenderFBO().getSizeX()<<1 : getRenderFBO().getSizeX(), (isTFRender && cPit.getPIPposition() == cPit.pip::splitView) ? getRenderFBO().getSizeY()<<1 : getRenderFBO().getSizeY());
getUData().scrnRes = vec2(getRenderFBO().getSizeX(), getRenderFBO().getSizeY());
//getUData().scrnRes = vec2(vp.w, vp.h);
getUData().invScrnRes = 1.f/getUData().scrnRes;
getUData().ySizeRatio = theApp->isParticlesSizeConstant() ? 1.0 : float(getUData().scrnRes.y/1024.0);
getUData().ptSizeRatio = 1.0/(length(getUData().scrnRes) / getUData().scrnRes.x);
Expand All @@ -129,7 +131,6 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
float distAtt = getUData().pointDistAtten; // FIXME: use external setting so don't save and restore below
if(isTFRender) getUData().pointDistAtten = 0.f; // no distance attenuation on cpitView

tfSettinsClass &cPit = getTFSettings();
getUData().elapsedTime = cPit.getUdata().elapsedTime;

getUData().lifeTime = tfSettinsClass::getPIPposition() && cPit.cockPit() ? std::max(cPit.getLifeTimeCP(),cPit.getLifeTime()) :
Expand All @@ -138,7 +139,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
cpitView ? cPit.getLifeTimeAttenCP() : cPit.getLifeTimeAtten(); // if PiP get max for both to sync view

getUData().smoothDistance= cPit.getSmoothDistance();
getUData().vpReSize = isFullScreenPiP ? 1.0 : cPit.getPIPzoom()*.5;
getUData().vpReSize = isFullScreenPiP || cPit.getPIPposition() == cPit.pip::splitView ? 1.0 : cPit.getPIPzoom()*.5;

getUData().zNear = currentTMat->getPerspNear();
getUData().zFar = currentTMat->getPerspFar();
Expand Down Expand Up @@ -184,9 +185,10 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
setLightDir(normalize(getLightDir()) * (dist*(theApp->useDetailedShadows() ? 1.5f : 1.5f /* 2/2.5*/) + dist*.1f));
}
//if(shadowDetail>1) glViewport(0,0, getUData().scrnRes.x*shadowDetail, getUData().scrnRes.y*shadowDetail);
ivec4 vp;
if(isTFRender) glGetIntegerv(GL_VIEWPORT, (GLint *) value_ptr(vp)); // partial reverted: https://github.com/BrutPitt/glChAoS.P/commit/4bcfc6dd577255ac9460fcc656bcf6796e917c46#
else vp = {0, 0, int(getUData().scrnRes.x), int(getUData().scrnRes.y) };

//ivec4 vp;
//if(isTFRender) glGetIntegerv(GL_VIEWPORT, (GLint *) value_ptr(vp)); // partial reverted: https://github.com/BrutPitt/glChAoS.P/commit/4bcfc6dd577255ac9460fcc656bcf6796e917c46#
//else vp = {0, 0, int(getUData().scrnRes.x), int(getUData().scrnRes.y) };

glViewport(0,0, getUData().scrnRes.x*shadowDetail, getUData().scrnRes.y*shadowDetail);

Expand All @@ -205,7 +207,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
emitter->renderEvents();

getShadow()->releaseRender();
glViewport(vp.x,vp.y, vp.z, vp.w);
//glViewport(vp.x,vp.y, vp.z, vp.w);

//FIXME: POV.z+Dolly.z (shadow) ==> look UP
currentTMat->setPOV(tmpPov);
Expand All @@ -221,6 +223,11 @@ 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);
Expand All @@ -237,6 +244,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
glBlendFunc(getSrcBlend(), getDstBlend());
}


// Normal Render
/////////////////////////////////////////////
bindPipeline();
Expand Down Expand Up @@ -317,6 +325,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
// FIXME: use external setting so don't save and restore below ==> look UP
if(isTFRender) getUData().pointDistAtten = distAtt;

//glViewport(0,0, getUData().scrnRes.x, getUData().scrnRes.y);

return returnedTex;
}
Expand Down Expand Up @@ -1205,7 +1214,7 @@ void shadowClass::releaseRender()
tfSettinsClass::tfCommonsStruct tfSettinsClass::tfCommons;

void tfSettinsClass::setViewport(int w, int h) {
float szX = float(w)*getPIPzoom()*.5+.5, szY = float(h)*getPIPzoom()*.5+.5;
float szX = float(w)*getPIPzoom()+.5, szY = float(h)*getPIPzoom()+.5;
w++; h++;
switch(getPIPposition()) {
case pip::lTop:
Expand All @@ -1218,13 +1227,18 @@ void tfSettinsClass::setViewport(int w, int h) {
setViewportSize(ivec4(w-szX,h-szY, szX, szY));
break;
case pip::rBottom:
setViewportSize(ivec4(w-szX,0 , szX, szY));
setViewportSize(ivec4(w-szX, 0, szX, 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));
}
break;
default:
case pip::noPIP:
default:
setViewportSize(ivec4(0,0, w, h));
break;
}
glViewport(getViewportSize().x, getViewportSize().y, getViewportSize().z, getViewportSize().w);
}

17 changes: 8 additions & 9 deletions src/src/ShadersClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,43 +399,42 @@ struct uTFData {
//void setMaxEmissionFrame(int i) { maxEmissionFrame = i; } //getEmittedParticles
//static int getMaxEmissionFrame() { return maxEmissionFrame; }

ivec4 &getViewportSize() { return viewportSize; }
void setViewportSize(const ivec4 &v) { viewportSize = v; }

private:

struct tfCommonsStruct {
bool isTFMode = false; // TransformFeedback Mode
bool isCockPit = false;
int pipPosition = noPIP;
float perspAngle = 65.f;
float perspAngle = 60.f;
bool invertPip = false;
ivec4 viewportSize = ivec4(0, 0, 100, 100);
float pipZoom = .5; // 1.0 -> 1/4 Window
} static tfCommons;

ivec4 viewportSize = ivec4(0, 0, 100, 100);
float smoothDistance = .250;
float lifeTime = 75.0;
float lifeTimeAtten = .3;
float lifeTimeCP = 75.0;
float lifeTimeAttenCP = .3;
float magnitude = 2.0;
float magnitudeInt = .2;
float magnitude = 1.5;
float magnitudeInt = .25;
float magnitudeAtten = .15;
float movePositionTail = 0;
bool isInvertView = false;
float tailPosition = .25;
float emitterPointSize = 1;
float cpPointSize = 7.f;
float cpMagnitude = 3.0;
float cpMagnitudeInt = .1;
float cpMagnitude = 1.0;
float cpMagnitudeInt = .2;
float cpMagnitudeAtten = .25;
bool cpFixDistance = true;
quat qRot = quat(1.0f,0.0f, 0.0f, 0.0f);
int slowMotionDpS = 100; //tfSettings DotPerSec
int slowMotionFSDpS = 5000; //FullScreen DotPerSec

static ivec4 &getViewportSize() { return tfCommons.viewportSize; }
static void setViewportSize(const ivec4 &v) { tfCommons.viewportSize = v; }

static constexpr float perspNear = .001f;

//Feedback Data
Expand Down
9 changes: 5 additions & 4 deletions src/src/configFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,11 +718,12 @@ void loadSettings(Config &cfg, particlesSystemClass *pSys, int typeToIgnore = lo
if(attractorsList.get()->dtType()) {
tfSettinsClass::tfMode(c.get_or("tfModeOn", false));
tfSettinsClass::cockPit( c.get_or("cpitOn" , false));
tfSettinsClass::setPerspAngle( c.get_or("cpitFOVangle" , 60.f ));
tfSettinsClass::setPIPzoom( c.get_or("cpitPiPsize" , .5f ));
tfSettinsClass::invertPIP( c.get_or("cpitPiPinvert" , false));
tfSettinsClass::setPIPposition( c.get_or("cpitPiPpos" , int(tfSettinsClass::pip::noPIP)));

tfSettinsClass::cockPit(false); // OVERRIDE start anyway OFF // FIXME:???
tfSettinsClass::setPerspAngle( c.get_or("cpitFOVangle" , tfSettinsClass::getPerspAngle() ));
tfSettinsClass::setPIPzoom( c.get_or("cpitPiPsize" , tfSettinsClass::getPIPzoom() ));
tfSettinsClass::setPIPposition( c.get_or("cpitPiPpos" , tfSettinsClass::getPIPposition() ));
tfSettinsClass::invertPIP( c.get_or("cpitPiPinvert" , tfSettinsClass::invertPIP() ));
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/src/glWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ GLint glWindow::onRender()
{
particlesSystem->renderPalette();

glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glViewport(0,0, particlesSystem->getWidth(), particlesSystem->getHeight());
glClearBufferfv(GL_COLOR, 0, value_ptr(particlesSystem->getParticleRenderPtr()->backgroundColor()));

#if !defined(GLCHAOSP_LIGHTVER)

particlesSystem->renderAxes();
Expand Down Expand Up @@ -130,7 +134,6 @@ GLint glWindow::onRender()
getParticlesSystem()->getTMat()->applyTransforms();
GLuint texRendered = particlesSystem->render();
#endif
//glBindFramebuffer(GL_FRAMEBUFFER, 0); // bind both FRAMEBUFFERS to default

particlesSystem->clearFlagUpdate();
return texRendered;
Expand All @@ -145,7 +148,7 @@ void glWindow::onIdle()
////////////////////////////////////////////////////////////////////////////
void glWindow::onReshape(GLint w, GLint h)
{
glViewport(0,0,w,h);
//glViewport(0,0,w,h);

theApp->SetWidth(w); theApp->SetHeight(h);
particlesSystem->getTMat()->getTrackball().viewportSize(w, h);
Expand Down
17 changes: 10 additions & 7 deletions src/src/partSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,14 @@ GLuint particlesSystemClass::renderSingle()

GLuint particlesSystemClass::renderTF()
{
const int w = getWidth(), h = getHeight();
glViewport(0,0, w, h);

tfSettinsClass &cPit = getParticleRenderPtr()->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));

getEmitter()->preRenderEvents();

const vec3 vecA(vec3(attractorsList.get()->getCurrent() ));
Expand All @@ -199,7 +202,7 @@ GLuint particlesSystemClass::renderTF()

transformsClass *cpTM = getCockPitTMat();

cpTM->setPerspective(tfSettinsClass::getPerspAngle(), float(w) / float(h),
cpTM->setPerspective(tfSettinsClass::getPerspAngle(), float(cPit.getPIPposition() == cPit.pip::splitView ? w>>1 : w) / float(h),
tfSettinsClass::getPerspNear(),
getTMat()->getPerspFar());

Expand All @@ -222,18 +225,18 @@ GLuint particlesSystemClass::renderTF()
cpTM->applyTransforms();

//Render TF full screen view
GLuint texRendered = renderParticles(true, !cPit.invertPIP());
GLuint texRendered = renderParticles(true, cPit.cockPit() && !cPit.invertPIP());
texRendered = renderGlowEffect(texRendered);

//Render PiP view
setFlagUpdate();
if(cPit.getPIPposition() != cPit.pip::noPIP) {
if(cPit.cockPit() && cPit.getPIPposition() != cPit.pip::noPIP) {
cPit.setViewport(w,h);

texRendered = renderParticles(false, cPit.invertPIP());
texRendered = renderGlowEffect(texRendered);
glViewport(0,0, w, h);
}
glViewport(0,0, w, h);

#if !defined(GLCHAOSP_NO_FXAA)
texRendered = renderFXAA(texRendered);
Expand Down
5 changes: 2 additions & 3 deletions src/src/partSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ class particlesSystemClass : public shaderPointClass

/////////////////////////////////////////////
GLuint render() {
return attractorsList.get()->dtType() && tfSettinsClass::tfMode() && tfSettinsClass::cockPit() ?
renderTF() :
renderSingle();
//return attractorsList.get()->dtType() && tfSettinsClass::tfMode() ? renderTF() : renderSingle();
return theApp->getEmitterEngineType() == enumEmitterEngine::emitterEngine_transformFeedback ? renderTF() : renderSingle();
}
/////////////////////////////////////////////
void renderPalette() { // ColorMaps: rebuilds texture only if settings are changed
Expand Down
Loading

0 comments on commit d7d20cd

Please sign in to comment.