diff --git a/qglview/glrendererbase.cpp b/qglview/glrendererbase.cpp
index 33964f0..71d5543 100644
--- a/qglview/glrendererbase.cpp
+++ b/qglview/glrendererbase.cpp
@@ -89,7 +89,7 @@ void GLRendererBase::setupShadersLights(int lights_count) {
#define BIND_TEXTURE(ch, map) if (rp.prev_tex[ch] != mat.map.bitmap_id) { \
rp.prev_tex[ch] = mat.map.bitmap_id; \
glActiveTextureChannel(ch); glBindTexture(GL_TEXTURE_2D, mat.map.bitmap_id); \
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, view.anisotropicLevel_);}
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, view.feature(QGLView::qglAnisotropicLevel).toInt());}
void GLRendererBase::setupTextures(GLObjectBase & o, GLRendererBase::RenderingParameters & rp, bool first_object) {
if (first_object) {
@@ -141,14 +141,14 @@ void GLRendererBase::setupLights(int pass, int lights_per_pass) {
void GLRendererBase::applyFilteringParameters() {
- if (view.linearFiltering_) {
+ if (view.isFeatureEnabled(QGLView::qglLinearFiltering)) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
}
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, view.anisotropicLevel_);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, view.feature(QGLView::qglAnisotropicLevel).toInt());
}
diff --git a/qglview/glshaders.cpp b/qglview/glshaders.cpp
index 1b92e20..a9d94cc 100644
--- a/qglview/glshaders.cpp
+++ b/qglview/glshaders.cpp
@@ -65,6 +65,7 @@ const char qgl_structs[] =
" float constantAttenuation;\n"
" float linearAttenuation;\n"
" float quadraticAttenuation;\n"
+ " sampler2DShadow shadow;\n"
"};\n"
"struct QGLMap {\n"
" float offset;\n"
diff --git a/qglview/mainwindow.cpp b/qglview/mainwindow.cpp
index 5415008..5cb6103 100644
--- a/qglview/mainwindow.cpp
+++ b/qglview/mainwindow.cpp
@@ -38,7 +38,6 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
view->setMouseSelectionEnabled(true);
view->setSelectionHaloEnabled(true);
view->setHoverHaloEnabled(true);
- view->setAccomodationEnabled(false);
view->setHoverHaloFillAlpha(0.);
view->setSelectionHaloFillAlpha(0.);
view->setBackColor(Qt::lightGray);
@@ -181,8 +180,9 @@ void MainWindow::changeEvent(QEvent * e) {
void MainWindow::timerEvent(QTimerEvent * ) {
static double t = 0.;
- view->light(view->lightsCount() - 1)->setPos(view->camera().worldPos());
- ((RendererSimple*)(view->renderer()))->mpos = view->mapFromGlobal(QCursor::pos());
+ if (checkCameraLight->isChecked())
+ view->light(view->lightsCount() - 1)->setPos(view->camera().worldPos());
+ //((RendererSimple*)(view->renderer()))->mpos = view->mapFromGlobal(QCursor::pos());
//qDebug() << view->camera().angles();
//cam_mat.rotate(e->y(), 0., 1., 0.);
//view->camera().setTransform(cam_mat);
diff --git a/qglview/mainwindow.h b/qglview/mainwindow.h
index 244ee3a..d72e6ed 100644
--- a/qglview/mainwindow.h
+++ b/qglview/mainwindow.h
@@ -69,15 +69,16 @@ private slots:
void on_actionExit_triggered() {close();}
void on_spinFOV_valueChanged(double val) {view->setFOV(val);}
- void on_spinAccom_valueChanged(double val) {view->setAccomodationTime(val);}
- void on_spinAccomMS_valueChanged(double val) {view->setAccomodationMaxSpeed(val);}
- void on_spinCubemapSize_valueChanged(double val) {view->setDynamicReflectionsMapSize(val);}
- void on_spinShadowmapSize_valueChanged(double val) {view->setShadowMapSize(val);}
+ void on_spinAccom_valueChanged(double val) {view->setFeature(QGLView::qglEyeAccomodationTime, val);}
+ void on_spinAccomMS_valueChanged(double val) {view->setFeature(QGLView::qglEyeAccomodationMaxSpeed, val);}
+ void on_spinCubemapSize_valueChanged(double val) {view->setFeature(QGLView::qglDynamicReflectionsMapSize, val);}
+ void on_spinShadowmapSize_valueChanged(double val) {view->setFeature(QGLView::qglShadowsMapSize, val);}
void on_spinHaloFillAlpha_valueChanged(double val) {view->setSelectionHaloFillAlpha(val);}
- void on_spinMotionBlurFactor_valueChanged(double val) {view->setMotionBlurFactor(val);}
- void on_spinMotionBlurSteps_valueChanged(int val) {view->setMotionBlurSteps(val);}
- void on_spinMotionBloomFactor_valueChanged(double val) {view->setBloomFactor(val);}
- void on_spinMotionBloomRadius_valueChanged(int val) {view->setBloomRadius(val);}
+ void on_spinMotionBlurFactor_valueChanged(double val) {view->setFeature(QGLView::qglMotionBlurFactor, val);}
+ void on_spinMotionBlurSteps_valueChanged(int val) {view->setFeature(QGLView::qglMotionBlurSteps, val);}
+ void on_spinBloomFactor_valueChanged(double val) {view->setFeature(QGLView::qglBloomFactor, val);}
+ void on_spinBloomRadius_valueChanged(int val) {view->setFeature(QGLView::qglBloomRadius, val);}
+ void on_spinBloomThreshold_valueChanged(double val) {view->setFeature(QGLView::qglBloomThreshold, val);}
//void on_spinSliderShine_valueChanged(double val) {obj->material().shine_strength = val; obj->setMaterial(obj->material(), true);}
//void on_spinSliderRough_valueChanged(double val) {obj->material().shine = val; obj->setMaterial(obj->material(), true);}
void on_pushButton_clicked() {view->removeLight(view->lightsCount() - 1); setWindowTitle(QString::number(view->lightsCount()));}
@@ -87,16 +88,16 @@ private slots:
void on_comboViewRenderMode_currentIndexChanged(int val) {static int modes[] = {GL_POINT, GL_LINE, GL_FILL}; view->setRenderMode((GLObjectBase::RenderMode)modes[val]);}
//void on_comboLight_currentIndexChanged(int val) {obj->material().light_model = (Material::LightModel)val; obj->setMaterial(obj->material(), true);}
void on_checkSelectionHalo_toggled(bool val) {view->setSelectionHaloEnabled(val);}
- void on_checkDynamicReflections_toggled(bool val) {view->setDynamicReflectionsEnabled(val);}
- void on_checkHDR_toggled(bool val) {view->setHDREnabled(val);}
- void on_checkAccomodation_toggled(bool val) {view->setAccomodationEnabled(val);}
- void on_checkBloom_toggled(bool val) {view->setBloomEnabled(val);}
- void on_checkFXAA_toggled(bool val) {view->setFXAAEnabled(val);}
- void on_checkMSAA_toggled(bool val) {view->setMultisamplingEnabled(val);}
- void on_checkShadows_toggled(bool val) {view->setShadowsEnabled(val);}
- void on_checkSoftShadows_toggled(bool val) {view->setSoftShadowsEnabled(val);}
+ void on_checkDynamicReflections_toggled(bool val) {view->setFeature(QGLView::qglDynamicReflectionsEnabled, val);}
+ void on_checkHDR_toggled(bool val) {view->setFeature(QGLView::qglHDR, val);}
+ void on_checkAccomodation_toggled(bool val) {view->setFeature(QGLView::qglEyeAccomodationEnabled, val);}
+ void on_checkBloom_toggled(bool val) {view->setFeature(QGLView::qglBloomEnabled, val);}
+ void on_checkFXAA_toggled(bool val) {view->setFeature(QGLView::qglFXAA, val);}
+ void on_checkMSAA_toggled(bool val) {view->setFeature(QGLView::qglMSAA, val);}
+ void on_checkShadows_toggled(bool val) {view->setFeature(QGLView::qglShadowsEnabled, val);}
+ void on_checkSoftShadows_toggled(bool val) {view->setFeature(QGLView::qglShadowsSoftEnabled, val);}
void on_checkCameraOrbit_toggled(bool val) {view->setCameraOrbit(val);}
- void on_checkMotionBlur_toggled(bool val) {view->setMotionBlurEnabled(val);}
+ void on_checkMotionBlur_toggled(bool val) {view->setFeature(QGLView::qglMotionBlurEnabled, val);}
void on_colorAmbient_colorChanged(QColor color) {view->setAmbientColor(color);}
void on_colorHalo_colorChanged(QColor color) {view->setSelectionHaloColor(color);}
void on_view_glKeyPressEvent(QKeyEvent * e);
diff --git a/qglview/mainwindow.ui b/qglview/mainwindow.ui
index bf3fc4e..d462580 100644
--- a/qglview/mainwindow.ui
+++ b/qglview/mainwindow.ui
@@ -6,8 +6,8 @@
0
0
- 1246
- 851
+ 1131
+ 772
@@ -108,14 +108,14 @@
- -
+
-
motion blur factor
- -
+
-
motion blur steps
@@ -213,7 +213,7 @@
- -
+
-
0.000000000000000
@@ -238,7 +238,7 @@
- -
+
-
1.000000000000000
@@ -270,7 +270,7 @@
- -
+
-
bloom radius
@@ -278,7 +278,7 @@
-
-
+
0.000000000000000
@@ -302,8 +302,8 @@
- -
-
+
-
+
1.000000000000000
@@ -327,6 +327,38 @@
+ -
+
+
+ bloom threshold
+
+
+
+ -
+
+
+ 0.000000000000000
+
+
+ 1.000000000000000
+
+
+ 0.900000000000000
+
+
+ 1
+
+
+ 0.100000000000000
+
+
+ 1.000000000000000
+
+
+ false
+
+
+
-
@@ -438,106 +470,107 @@
-
-
-
- orbit camera
+
+
+ 20
-
- true
-
-
-
- -
-
-
- selection halo
-
-
- true
-
-
-
- -
-
-
- bad accumulation
-
-
-
- -
-
-
- dynamic reflections
-
-
-
- -
-
-
- HDR
-
-
-
- -
-
-
- false
-
-
- accomodation
-
-
- true
-
-
-
- -
-
-
- false
-
-
- bloom
-
-
-
- -
-
-
- motion blur
-
-
-
- -
-
-
- FXAA
-
-
-
- -
-
-
- MSAA
-
-
-
- -
-
-
- shadows
-
-
-
- -
-
-
- false
-
-
- soft shadows
-
-
+
-
+
+
+ dynamic reflections
+
+
+
+ -
+
+
+ bad accumulation
+
+
+
+ -
+
+
+ selection halo
+
+
+ true
+
+
+
+ -
+
+
+ shadows
+
+
+
+ -
+
+
+ false
+
+
+ soft shadows
+
+
+
+ -
+
+
+ orbit camera
+
+
+ true
+
+
+
+ -
+
+
+ accomodation
+
+
+ true
+
+
+
+ -
+
+
+ bloom
+
+
+
+ -
+
+
+ motion blur
+
+
+
+ -
+
+
+ FXAA
+
+
+
+ -
+
+
+ MSAA
+
+
+
+ -
+
+
+ Follow camera light
+
+
+
+
-
@@ -699,38 +732,6 @@
-
- checkHDR
- toggled(bool)
- checkAccomodation
- setEnabled(bool)
-
-
- 112
- 570
-
-
- 111
- 593
-
-
-
-
- checkHDR
- toggled(bool)
- checkBloom
- setEnabled(bool)
-
-
- 167
- 570
-
-
- 163
- 616
-
-
-
checkShadows
toggled(bool)
diff --git a/qglview/qglview.cpp b/qglview/qglview.cpp
index 373c625..4dba552 100644
--- a/qglview/qglview.cpp
+++ b/qglview/qglview.cpp
@@ -37,11 +37,12 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) {
ambientColor_ = QColor(10, 10, 10);
lastPos = QPoint(-1, -1);
lineWidth_ = 1.;
- linearFiltering_ = cameraOrbit_ = lightEnabled_ = true;
+ max_anisotropic = 1;
+ max_texture_chanels = 8;
+ cameraOrbit_ = lightEnabled_ = true;
shaders_supported = selecting_ = customMouseMove_ = false;
sel_button = Qt::LeftButton;
sel_mod = Qt::NoModifier;
- anisotropicLevel_ = 8;
renderer_ = 0;
fps_cnt = 0;
fps_tm = fps_ = 0.;
@@ -51,19 +52,30 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) {
fogMode_ = Exp;
hoverHaloFill_ = 0.333;
selectionHaloFill_ = 0.5;
- shadow_map_size = dynamic_cubemap_size = 512;
//lmode = Simple;
shader_select = shader_halo = 0;
- cur_luminance = 1.;
- m_bloomFactor = 0.5;
- m_bloomRadius = 8;
- accom_time = 16.;
- accom_max_speed = 0.2;
- m_motionBlurFactor = 1.;
- m_motionBlurSteps = 8;
- mouse_first = mouseSelect_ = accomodation_ = hoverHalo_ = selectionHalo_ = true;
- fogEnabled_ = is_init = grabMouse_ = mouseRotate_ = mouseThis_ = shaders_bind = m_motionBlurEnabled =
- shadows_ = shadows_soft = dynamic_reflections = hdr_ = bloom_ = msaa_ = fxaa_ = changed_ = false;
+ setFeature(qglMSAA, false);
+ setFeature(qglFXAA, false);
+ setFeature(qglLinearFiltering, true);
+ setFeature(qglAnisotropicLevel, 8);
+ setFeature(qglHDR, false);
+ setFeature(qglEyeAccomodationEnabled, false);
+ setFeature(qglEyeAccomodationTime, 16.);
+ setFeature(qglEyeAccomodationMaxSpeed, 0.2);
+ setFeature(qglBloomEnabled, false);
+ setFeature(qglBloomThreshold, 0.9);
+ setFeature(qglBloomFactor, 1.);
+ setFeature(qglBloomRadius, 8);
+ setFeature(qglMotionBlurEnabled, false);
+ setFeature(qglMotionBlurFactor, 1.);
+ setFeature(qglMotionBlurSteps, 8);
+ setFeature(qglShadowsEnabled, false);
+ setFeature(qglShadowsMapSize, 512);
+ setFeature(qglShadowsSoftEnabled, false);
+ setFeature(qglDynamicReflectionsEnabled, false);
+ setFeature(qglDynamicReflectionsMapSize, 512);
+ mouse_first = mouseSelect_ = hoverHalo_ = selectionHalo_ = true;
+ fogEnabled_ = is_init = grabMouse_ = mouseRotate_ = mouseThis_ = shaders_bind = changed_ = false;
rmode = GLObjectBase::Fill;
sel_mode = QGLView::SingleSelection;
sel_pen = QPen(Qt::black, 1, Qt::DashLine);
@@ -73,8 +85,6 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) {
emit cameraPosChanged(camera().pos());
//camera().aim_ = camera().pos_;
ktm_.restart();
- sh_lm_diff << "Phong_diffuse" << "Cook_Torrance_diffuse" << "Minnaert_diffuse" << "Strauss_diffuse" << "Oren_Nayar_diffuse";
- sh_lm_spec << "Phong_specular" << "Cook_Torrance_specular" << "Minnaert_specular" << "Strauss_specular" << "Oren_Nayar_specular";
}
@@ -400,7 +410,7 @@ void QGLView::renderSelection() {
void QGLView::renderShadow() {
glPushMatrix();
- renderSingleShadow(objects_);
+ //renderSingleShadow(objects_);
glPopMatrix();
}
@@ -434,7 +444,7 @@ void QGLView::renderSingleSelection(GLObjectBase & o) {
renderSingleSelection(*i);
}
-
+/**
void QGLView::renderSingleShadow(GLObjectBase & o) {
if (!o.isInit()) {
o.init();
@@ -449,7 +459,7 @@ void QGLView::renderSingleShadow(GLObjectBase & o) {
foreach (GLObjectBase * i, o.children_)
renderSingleSelection(*i);
}
-
+*/
void QGLView::collectLights() {
lights_.clear();
@@ -483,6 +493,8 @@ void QGLView::collectObjectLights(GLObjectBase * o) {
void QGLView::checkCaps() {
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropic);
+ glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_texture_chanels);
+ //qDebug() << max_texture_chanels;
shaders_supported = QGLShaderProgram::hasOpenGLShaderPrograms();
}
@@ -495,7 +507,7 @@ void QGLView::reloadThisShaders() {
}
-inline void QGLView::applyFog() {
+void QGLView::applyFog() {
GLfloat fog_col[4] = {float(fogColor_.redF()), float(fogColor_.greenF()), float(fogColor_.blueF()), .0f};
if (fogEnabled_) {
glEnable(GL_FOG);
diff --git a/qglview/qglview.h b/qglview/qglview.h
index 93cd415..5b95234 100644
--- a/qglview/qglview.h
+++ b/qglview/qglview.h
@@ -47,8 +47,6 @@ class QGLView: public QGraphicsView, public QGLViewBase
Q_PROPERTY (double FOV READ FOV WRITE setFOV)
Q_PROPERTY (double depthStart READ depthStart WRITE setDepthStart)
Q_PROPERTY (double depthEnd READ depthEnd WRITE setDepthEnd)
- Q_PROPERTY (bool linearFiltering READ linearFiltering WRITE setLinearFiltering)
- Q_PROPERTY (int anisotropicLevel READ anisotropicLevel WRITE setAnisotropicLevel)
Q_PROPERTY (QColor ambientColor READ ambientColor WRITE setAmbientColor)
Q_PROPERTY (QColor fogColor READ fogColor WRITE setFogColor)
Q_PROPERTY (double fogDensity READ fogDensity WRITE setFogDensity)
@@ -68,23 +66,6 @@ class QGLView: public QGraphicsView, public QGLViewBase
Q_PROPERTY (QColor selectionHaloColor READ selectionHaloColor WRITE setSelectionHaloColor)
Q_PROPERTY (double selectionHaloFillAlpha READ selectionHaloFillAlpha WRITE setSelectionHaloFillAlpha)
//Q_PROPERTY (LightingMode lightingMode READ lightingMode WRITE setLightingMode)
- Q_PROPERTY (bool shadowsEnabled READ isShadowsEnabled WRITE setShadowsEnabled)
- Q_PROPERTY (bool softShadowsEnabled READ isSoftShadowsEnabled WRITE setSoftShadowsEnabled)
- Q_PROPERTY (int shadowMapSize READ shadowMapSize WRITE setShadowMapSize)
- Q_PROPERTY (bool dynamicReflectionsEnabled READ isDynamicReflectionsEnabled WRITE setDynamicReflectionsEnabled)
- Q_PROPERTY (int dynamicReflectionsMapSize READ dynamicReflectionsMapSize WRITE setDynamicReflectionsMapSize)
- Q_PROPERTY (bool HDREnabled READ isHDREnabled WRITE setHDREnabled)
- Q_PROPERTY (bool bloomEnabled READ isBloomEnabled WRITE setBloomEnabled)
- Q_PROPERTY (double bloomFactor READ bloomFactor WRITE setBloomFactor)
- Q_PROPERTY (int bloomRadius READ bloomRadius WRITE setBloomRadius)
- Q_PROPERTY (bool multisamplingEnabled READ isMultisamplingEnabled WRITE setMultisamplingEnabled)
- Q_PROPERTY (bool FXAAEnabled READ isFXAAEnabled WRITE setFXAAEnabled)
- Q_PROPERTY (bool accomodationEnabled READ isAccomodationEnabled WRITE setAccomodationEnabled)
- Q_PROPERTY (double accomodationTime READ accomodationTime WRITE setAccomodationTime)
- Q_PROPERTY (double accomodationMaxSpeed READ accomodationMaxSpeed WRITE setAccomodationMaxSpeed)
- Q_PROPERTY (bool motionBlurEnabled READ isMotionBlurEnabled WRITE setMotionBlurEnabled)
- Q_PROPERTY (double motionBlurFactor READ motionBlurFactor WRITE setMotionBlurFactor)
- Q_PROPERTY (int motionBlurSteps READ motionBlurSteps WRITE setMotionBlurSteps)
Q_PROPERTY (Qt::MouseButton selectionButton READ selectionButton WRITE setSelectionButton)
Q_PROPERTY (Qt::KeyboardModifier selectionModifier READ selectionModifier WRITE setSelectionModifier)
Q_PROPERTY (SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
@@ -97,6 +78,28 @@ public:
enum FogMode {Linear = GL_LINEAR, Exp = GL_EXP, Exp2 = GL_EXP2};
enum SelectionMode {NoSelection, SingleSelection, MultiSelection};
+ enum Feature {
+ qglMSAA,
+ qglFXAA,
+ qglLinearFiltering,
+ qglAnisotropicLevel,
+ qglHDR,
+ qglEyeAccomodationEnabled,
+ qglEyeAccomodationTime,
+ qglEyeAccomodationMaxSpeed,
+ qglBloomEnabled,
+ qglBloomThreshold,
+ qglBloomFactor,
+ qglBloomRadius,
+ qglMotionBlurEnabled,
+ qglMotionBlurFactor,
+ qglMotionBlurSteps,
+ qglShadowsEnabled,
+ qglShadowsMapSize,
+ qglShadowsSoftEnabled,
+ qglDynamicReflectionsEnabled,
+ qglDynamicReflectionsMapSize
+ };
Q_ENUMS (FogMode)
Q_ENUMS (SelectionMode)
@@ -118,11 +121,7 @@ public:
double depthStart() const {return camera().depth_start;}
double depthEnd() const {return camera().depth_end;}
double currentFPS() const {return fps_;}
- bool linearFiltering() const {return linearFiltering_;}
- int anisotropicLevel() const {return anisotropicLevel_;}
int maxAnisotropicLevel() const {return max_anisotropic;}
- int shadowMapSize() const {return shadow_map_size;}
- int dynamicReflectionsMapSize() const {return dynamic_cubemap_size;}
QColor ambientColor() const {return ambientColor_;}
QColor fogColor() const {return fogColor_;}
@@ -143,26 +142,14 @@ public:
bool isSelectionHaloEnabled() const {return selectionHalo_;}
QColor selectionHaloColor() const {return selectionHaloColor_;}
double selectionHaloFillAlpha() const {return selectionHaloFill_;}
- bool isMotionBlurEnabled() const {return m_motionBlurEnabled;}
- bool isShadowsEnabled() const {return shadows_;}
- bool isSoftShadowsEnabled() const {return shadows_soft;}
- bool isDynamicReflectionsEnabled() const {return dynamic_reflections;}
- bool isHDREnabled() const {return hdr_;}
- bool isBloomEnabled() const {return bloom_;}
- bool isMultisamplingEnabled() const {return msaa_;}
- bool isFXAAEnabled() const {return fxaa_;}
- bool isAccomodationEnabled() const {return accomodation_;}
+
+ QVariant feature(Feature f) const {return features_.value(int(f));}
+ QVariant setFeature(Feature f, const QVariant & value) {QVariant ret = features_.value(int(f)); features_[int(f)] = value; return ret;}
+ bool isFeatureEnabled(Feature f) const {return features_[int(f)].toBool();}
int renderMode() const {return (int)rmode;}
void setRenderMode(int mode) {rmode = (GLObjectBase::RenderMode)mode;}
- double bloomFactor() const {return m_bloomFactor;}
- int bloomRadius() const {return m_bloomRadius;}
- double accomodationTime() const {return accom_time;}
- double accomodationMaxSpeed() const {return accom_max_speed;}
- double motionBlurFactor() const {return m_motionBlurFactor;}
- int motionBlurSteps() const {return m_motionBlurSteps;}
-
void addObject(QGraphicsItem * o) {scene()->addItem(o);}
void addObject(QWidget * o, Qt::WindowFlags f = Qt::Widget);
void addObject(GLObjectBase * o);
@@ -211,16 +198,16 @@ protected:
void initializeGL();
void paintGL();
void resizeGL(int width, int height);
- virtual void mousePressEvent(QMouseEvent * e);
- virtual void mouseMoveEvent(QMouseEvent * e);
- virtual void mouseReleaseEvent(QMouseEvent * e);
- virtual void wheelEvent(QWheelEvent * e);
- virtual void leaveEvent(QEvent * );
- virtual void keyPressEvent(QKeyEvent * e) {emit glKeyPressEvent(e); if (e->key() > 0) keys_.insert(e->key());}
- virtual void keyReleaseEvent(QKeyEvent * e) {emit glKeyReleaseEvent(e); keys_.remove(e->key());}
- virtual void focusOutEvent(QFocusEvent *) {keys_.clear();}
+ void mousePressEvent(QMouseEvent * e);
+ void mouseMoveEvent(QMouseEvent * e);
+ void mouseReleaseEvent(QMouseEvent * e);
+ void wheelEvent(QWheelEvent * e);
+ void leaveEvent(QEvent * );
+ void keyPressEvent(QKeyEvent * e) {emit glKeyPressEvent(e); if (e->key() > 0) keys_.insert(e->key());}
+ void keyReleaseEvent(QKeyEvent * e) {emit glKeyReleaseEvent(e); keys_.remove(e->key());}
+ void focusOutEvent(QFocusEvent *) {keys_.clear();}
- inline void applyFog();
+ void applyFog();
void renderSelection();
void renderShadow();
@@ -232,7 +219,7 @@ private:
void objectsCountInternal(int * cnt, GLObjectBase * where) {++(*cnt); foreach (GLObjectBase * i, where->children_) objectsCountInternal(cnt, i);}
void removeObjectInternal(GLObjectBase * o, GLObjectBase * where) {foreach (GLObjectBase * i, where->children_) {if (o == i) where->removeChild(i); else removeObjectInternal(o, i);}}
void renderSingleSelection(GLObjectBase & o);
- void renderSingleShadow(GLObjectBase & o);
+ //void renderSingleShadow(GLObjectBase & o);
void renderHalo(const GLObjectBase * obj, const int iid, const QColor & color, const double & fill);
QList collectGraphicItems();
void collectGraphicItems(QList & list, QGraphicsItem * o);
@@ -253,25 +240,24 @@ private:
QTime time, ktm_;
QPen sel_pen;
QBrush sel_brush;
- GLint max_anisotropic, anisotropicLevel_;
+ GLint max_anisotropic, max_texture_chanels;
GLObjectBase::RenderMode rmode;
//LightingMode lmode;
GLObjectBase * sel_obj, * hov_obj;
GLFramebuffer fbo_selection;
QGLShaderProgram * shader_select, * shader_halo;
- QStringList sh_lm_diff, sh_lm_spec;
GLRendererBase * renderer_;
SelectionMode sel_mode;
Qt::MouseButton sel_button;
Qt::KeyboardModifier sel_mod;
GLRendererBase::RenderingParameters start_rp;
- double lineWidth_, linearFiltering_, accom_time, accom_max_speed, cur_luminance, m_bloomFactor;
+ QHash features_;
+ double lineWidth_;
double fogDensity_, fogStart_, fogEnd_, fps_, fps_tm, hoverHaloFill_, selectionHaloFill_, m_motionBlurFactor;
- int timer, fps_cnt, sh_id_loc, shadow_map_size, dynamic_cubemap_size, motion_blur_steps, m_motionBlurSteps, m_bloomRadius;
+ int timer, fps_cnt, sh_id_loc;
bool is_init, fogEnabled_, lightEnabled_, grabMouse_, mouse_first, mouseRotate_, mouseSelect_, customMouseMove_;
bool shaders_supported, changed_, cameraOrbit_;
- bool hoverHalo_, selectionHalo_, mouseThis_, shaders_bind, shadows_, shadows_soft, selecting_;
- bool dynamic_reflections, hdr_, bloom_, msaa_, fxaa_, accomodation_, m_motionBlurEnabled;
+ bool hoverHalo_, selectionHalo_, mouseThis_, shaders_bind, selecting_;
public slots:
void setBackColor(const QColor & arg) {backColor_ = arg;}
@@ -279,8 +265,6 @@ public slots:
void setFOV(const double & arg) {camera().fov_ = arg;}
void setDepthStart(const double & arg) {camera().depth_start = arg;}
void setDepthEnd(const double & arg) {camera().depth_end = arg;}
- void setLinearFiltering(const bool & arg) {linearFiltering_ = arg;}
- void setAnisotropicLevel(const int & arg) {anisotropicLevel_ = arg;}
void setAmbientColor(const QColor & arg) {ambientColor_ = arg;}
void setFogColor(const QColor & arg) {fogColor_ = arg;}
void setFogDensity(const double & arg) {fogDensity_ = arg;}
@@ -301,23 +285,6 @@ public slots:
void setSelectionHaloColor(const QColor & arg) {selectionHaloColor_ = arg;}
void setSelectionHaloFillAlpha(const double & arg) {selectionHaloFill_ = arg;}
//void setLightingMode(const LightingMode & arg) {lmode = arg;}
- void setShadowsEnabled(const bool & arg) {shadows_ = arg;}
- void setSoftShadowsEnabled(const bool & arg) {shadows_soft = arg;}
- void setShadowMapSize(const int & arg) {shadow_map_size = arg; changed_ = true;}
- void setDynamicReflectionsMapSize(const int & arg) {dynamic_cubemap_size = arg; changed_ = true;}
- void setAccomodationTime(const double & arg) {accom_time = arg;}
- void setAccomodationMaxSpeed(const double & arg) {accom_max_speed = arg;}
- void setDynamicReflectionsEnabled(const bool & arg) {dynamic_reflections = arg;}
- void setHDREnabled(const bool & arg) {hdr_ = arg; changed_ = true;}
- void setBloomEnabled(const bool & arg) {bloom_ = arg; changed_ = true;}
- void setMultisamplingEnabled(const bool & arg) {msaa_ = arg;}
- void setFXAAEnabled(const bool & arg) {fxaa_ = arg;}
- void setAccomodationEnabled(const bool & arg) {accomodation_ = arg;}
- void setBloomFactor(double bloomFactor) {m_bloomFactor = bloomFactor;}
- void setBloomRadius(int bloomRadius) {m_bloomRadius = bloomRadius;}
- void setMotionBlurEnabled(bool motionBlurEnabled) {m_motionBlurEnabled = motionBlurEnabled;}
- void setMotionBlurFactor(double motionBlurFactor) {m_motionBlurFactor = motionBlurFactor;}
- void setMotionBlurSteps(int motionBlurSteps) {m_motionBlurSteps = motionBlurSteps;}
void reloadShaders() {if (renderer_ != 0) renderer_->reloadShaders(); reloadThisShaders();}
void deselect() {sel_obj = 0;}
diff --git a/qglview/renderer_deferred_shading.cpp b/qglview/renderer_deferred_shading.cpp
index d9757bb..2ff2f32 100644
--- a/qglview/renderer_deferred_shading.cpp
+++ b/qglview/renderer_deferred_shading.cpp
@@ -157,7 +157,7 @@ void RendererDeferredShading::renderScene() {
glActiveTextureChannel(0);
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
- if (view.isAccomodationEnabled()) {
+ if (view.isFeatureEnabled(QGLView::qglEyeAccomodationEnabled)) {
fbo_hsmall.bind();
fbo_hsmall.setWriteBuffer(0);
shader_small->bind();
@@ -176,8 +176,8 @@ void RendererDeferredShading::renderScene() {
if (max[2] < hcontent[i].z) max[2] = hcontent[i].z;
}
GLfloat mluma = (0.299 * max[0]) + (0.587 * max[1]) + (0.114 * max[2]);
- double nexp = mluma / 16., dexp = nexp - exposure_, mestep = exposure_ * view.accomodationMaxSpeed();
- dexp /= view.accomodationTime();
+ double nexp = mluma / 16., dexp = nexp - exposure_, mestep = exposure_ * view.feature(QGLView::qglEyeAccomodationMaxSpeed).toDouble();
+ dexp /= view.feature(QGLView::qglEyeAccomodationTime).toDouble();
if (dexp > 0. && dexp > mestep/4) dexp = mestep/4;
if (dexp < 0. && dexp < -mestep) dexp = -mestep;
exposure_ += dexp;
@@ -198,7 +198,7 @@ void RendererDeferredShading::renderScene() {
piSwap(wi, ri);
}
- if (view.isMotionBlurEnabled()) {
+ if (view.isFeatureEnabled(QGLView::qglMotionBlurEnabled)) {
fbo_out.setWriteBuffer(wi);
glActiveTextureChannel(1);
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(4));
@@ -207,15 +207,15 @@ void RendererDeferredShading::renderScene() {
shader_motion_blur->setUniformValue("dt", QVector2D(1. / fbo_out.width(), 1. / fbo_out.height()));
shader_motion_blur->setUniformValue("t0", 0);
shader_motion_blur->setUniformValue("ts", 1);
- shader_motion_blur->setUniformValue("factor", GLfloat(view.motionBlurFactor()));
- shader_motion_blur->setUniformValue("steps", view.motionBlurSteps());
+ shader_motion_blur->setUniformValue("factor", GLfloat(view.feature(QGLView::qglMotionBlurFactor).toDouble()));
+ shader_motion_blur->setUniformValue("steps", view.feature(QGLView::qglMotionBlurSteps).toInt());
glDrawQuad(shader_motion_blur);
glActiveTextureChannel(0);
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(wi));
piSwap(wi, ri);
}
- if (view.isBloomEnabled()) {
+ if (view.isFeatureEnabled(QGLView::qglBloomEnabled)) {
fbo_out.setWriteBuffer(2);
fbo_out.setReadBuffer(ri);
glBlitFramebuffer(0, 0, fbo_out.width(), fbo_out.height(), 0, 0, fbo_out.width(), fbo_out.height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
@@ -223,7 +223,8 @@ void RendererDeferredShading::renderScene() {
fbo_out.setWriteBuffer(wi);
shader_bloom_0->bind();
shader_bloom_0->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
- shader_bloom_0->setUniformValue("factor", GLfloat(view.bloomFactor()));
+ shader_bloom_0->setUniformValue("factor", GLfloat(view.feature(QGLView::qglBloomFactor).toDouble()));
+ shader_bloom_0->setUniformValue("threshold", GLfloat(view.feature(QGLView::qglBloomThreshold).toDouble()));
shader_bloom_0->setUniformValue("t0", 0);
glDrawQuad(shader_bloom_0);
glActiveTextureChannel(0);
@@ -231,13 +232,16 @@ void RendererDeferredShading::renderScene() {
shader_bloom_1->bind();
shader_bloom_1->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
+ shader_bloom_1->setUniformValue("dt", QVector2D(1. / fbo_out.width(), 1. / fbo_out.height()));
shader_bloom_1->setUniformValue("t0", 0);
- int radius = view.bloomRadius();
+ int radius = view.feature(QGLView::qglBloomRadius).toInt();
int passes = qMax(int(ceil(log2(radius))), 1);
int crad = 1;
for (int p = 0; p < passes; ++p) {
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
fbo_out.setWriteBuffer(wi);
+ if (p == passes - 1)
+ crad = piMax(1, radius - crad);
shader_bloom_1->setUniformValue("radius", crad);
glDrawQuad(shader_bloom_1);
piSwap(wi, ri);
@@ -262,7 +266,7 @@ void RendererDeferredShading::renderScene() {
glReleaseShaders();
fbo_out.release();
- if (view.isFXAAEnabled()) {
+ if (view.isFeatureEnabled(QGLView::qglFXAA)) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
shader_fxaa->bind();
@@ -272,7 +276,7 @@ void RendererDeferredShading::renderScene() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
glDrawQuad();
- if (view.isFXAAEnabled())
+ if (view.isFeatureEnabled(QGLView::qglFXAA))
shader_fxaa->release();
prev_proj = mproj;
prev_view = mview;
diff --git a/qglview/renderer_deferred_shading.h b/qglview/renderer_deferred_shading.h
index c00dc50..c33264c 100644
--- a/qglview/renderer_deferred_shading.h
+++ b/qglview/renderer_deferred_shading.h
@@ -42,7 +42,7 @@ protected:
private:
typedef QPair ShaderPair;
- int cplc, BUG[8], lights_per_pass;
+ int cplc, lights_per_pass;
double exposure_;
GLFramebuffer fbo_g, fbo_out, fbo_hsmall;
QGLShaderProgram * shader_fxaa, * shader_ds_0, * shader_ds_1, * shader_hdr, * shader_small;
diff --git a/qglview/renderer_simple.cpp b/qglview/renderer_simple.cpp
index 402a469..484dec9 100644
--- a/qglview/renderer_simple.cpp
+++ b/qglview/renderer_simple.cpp
@@ -48,10 +48,10 @@ void RendererSimple::resizeFBO(int w, int h) {
void RendererSimple::renderScene() {
int passes = (view.lightsCount() - 1) / 8 + 1;
//QMatrix4x4 pm = getGLMatrix(GL_PROJECTION_MATRIX), mvm = getGLMatrix(GL_MODELVIEW_MATRIX), pmvm = pm * mvm, lpm, lmvm, lpmvm;
- glSetCapEnabled(GL_MULTISAMPLE, view.isMultisamplingEnabled());
+ glSetCapEnabled(GL_MULTISAMPLE, view.isFeatureEnabled(QGLView::qglMSAA));
if (passes < 1) passes = 1;
//glEnable(GL_FOG);
- if (view.isFXAAEnabled()) fbo.bind();
+ if (view.isFeatureEnabled(QGLView::qglFXAA)) fbo.bind();
//glEnable(GL_TEXTURE_2D);
if (passes > 1) {
fbo.bind();
@@ -104,7 +104,7 @@ void RendererSimple::renderScene() {
glDrawQuad();
}
}
- if (view.isFXAAEnabled() || passes > 1) {
+ if (view.isFeatureEnabled(QGLView::qglFXAA) || passes > 1) {
fbo.release();
//glClearFramebuffer();
glActiveTextureChannel(0);
@@ -112,7 +112,7 @@ void RendererSimple::renderScene() {
glSetLightEnabled(false);
glSetCapEnabled(GL_BLEND, false);
glDisableDepth();
- if (view.isFXAAEnabled()) {
+ if (view.isFeatureEnabled(QGLView::qglFXAA)) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
shader_fxaa->bind();
diff --git a/qglview/shaders/bloom_pass_0.frag b/qglview/shaders/bloom_pass_0.frag
index da476dc..abd5404 100644
--- a/qglview/shaders/bloom_pass_0.frag
+++ b/qglview/shaders/bloom_pass_0.frag
@@ -1,8 +1,8 @@
#version 150
uniform sampler2D t0;
-uniform float factor = 1.;
+uniform float factor = 1., threshold = 0.8;
void main(void) {
- qgl_FragData[0].rgb = max(texelFetch(t0, ivec2(gl_FragCoord.xy), 0).rgb - vec3(0.8), vec3(0.)) * factor;
+ qgl_FragData[0].rgb = max(texelFetch(t0, ivec2(gl_FragCoord.xy), 0).rgb - vec3(threshold), vec3(0.)) * factor;
}
diff --git a/qglview/shaders/bloom_pass_1.frag b/qglview/shaders/bloom_pass_1.frag
index da79a3b..12ad08b 100644
--- a/qglview/shaders/bloom_pass_1.frag
+++ b/qglview/shaders/bloom_pass_1.frag
@@ -2,12 +2,34 @@
uniform sampler2D t0;
uniform int radius = 2;
+uniform vec2 dt;
void main(void) {
- ivec2 tc = ivec2(gl_FragCoord.xy);
+ vec2 tc = qgl_FragTexture.xy;
float r = float(radius);
int o = radius, o2 = radius * 2;
- vec3 scol = (texelFetch(t0, tc, 0).rgb * 3. +
+ vec3 scol = (texture(t0, tc).rgb * 3. +
+ texture(t0, tc + dt * vec2( o, 0 )).rgb * 2. +
+ texture(t0, tc + dt * vec2( 0, o )).rgb * 2. +
+ texture(t0, tc + dt * vec2( -o, 0 )).rgb * 2. +
+ texture(t0, tc + dt * vec2( 0, -o)).rgb * 2. +
+ texture(t0, tc + dt * vec2( o, o )).rgb * 1.5 +
+ texture(t0, tc + dt * vec2( o, -o)).rgb * 1.5 +
+ texture(t0, tc + dt * vec2( -o, -o )).rgb * 1.5 +
+ texture(t0, tc + dt * vec2( -o, o )).rgb * 1.5 +
+ texture(t0, tc + dt * vec2( o2, 0 )).rgb +
+ texture(t0, tc + dt * vec2( 0, o2)).rgb +
+ texture(t0, tc + dt * vec2(-o2, 0 )).rgb +
+ texture(t0, tc + dt * vec2( 0, -o2)).rgb +
+ texture(t0, tc + dt * vec2( o2, o )).rgb +
+ texture(t0, tc + dt * vec2( o2, -o)).rgb +
+ texture(t0, tc + dt * vec2(-o2, -o )).rgb +
+ texture(t0, tc + dt * vec2(-o2, o )).rgb +
+ texture(t0, tc + dt * vec2( o, o2)).rgb +
+ texture(t0, tc + dt * vec2( o, -o2)).rgb +
+ texture(t0, tc + dt * vec2( -o, -o2)).rgb +
+ texture(t0, tc + dt * vec2( -o, o2)).rgb) / 29.;
+ /*vec3 scol = (texelFetch(t0, tc, 0).rgb * 3. +
texelFetch(t0, tc + ivec2( o, 0 ), 0).rgb * 2. +
texelFetch(t0, tc + ivec2( 0, o ), 0).rgb * 2. +
texelFetch(t0, tc + ivec2( -o, 0 ), 0).rgb * 2. +
@@ -27,7 +49,7 @@ void main(void) {
texelFetch(t0, tc + ivec2( o, o2), 0).rgb +
texelFetch(t0, tc + ivec2( o, -o2), 0).rgb +
texelFetch(t0, tc + ivec2( -o, -o2), 0).rgb +
- texelFetch(t0, tc + ivec2( -o, o2), 0).rgb) / 29.;
+ texelFetch(t0, tc + ivec2( -o, o2), 0).rgb) / 29.;*/
qgl_FragData[0].rgb = scol;
//qgl_FragData[0].rgb = vec3(r/10.);
}
diff --git a/qglview/shaders/dsl_pass_0.frag b/qglview/shaders/dsl_pass_0.frag
index 519285d..e3945ad 100644
--- a/qglview/shaders/dsl_pass_0.frag
+++ b/qglview/shaders/dsl_pass_0.frag
@@ -49,7 +49,7 @@ void main(void) {
qgl_FragData[1] = vec4(n.xyz / 2. + vec3(0.5), specularity);
qgl_FragData[2] = vec4(spec.rgb, hei);
qgl_FragData[3] = vec4(self.rgb, pos.w);
- qgl_FragData[4] = vec4(speed,0);
+ qgl_FragData[4] = vec4(speed.xy, 0, 0);
//gl_FragData[0] = vec4(et.xyz, pos.w);
//gl_FragDepth = gl_FragCoord.z - clamp(hei / pos.z / pos.z / (abs(n.z) + 1), -0.01, 0.01);
diff --git a/qglview/shaders/dsl_pass_1.frag b/qglview/shaders/dsl_pass_1.frag
index 3e590ff..44343c3 100644
--- a/qglview/shaders/dsl_pass_1.frag
+++ b/qglview/shaders/dsl_pass_1.frag
@@ -72,11 +72,11 @@ void main(void) {
//li = vec3(0.);
si = vec3(0.);
- float posz = z_near * z_far / (texture2D(td, tc).r * (z_far - z_near) - z_far);
+ float posz = z_near * z_far / (texelFetch(td, tc, 0).r * (z_far - z_near) - z_far);
pos = vec4(sp, 0., 1) * mat_proji;
pos.xy *= v3.w;
pos.z = posz;
- pos.xyz += n * height;
+ //pos.xyz += n * height;
//pos.xyz = v3.xyz;
//pos = v3;
//pos = vec4(sp, 0, 1.) * mat_proji;
@@ -88,12 +88,12 @@ void main(void) {
sh_pow = 1. / max((1. - v1.w), 0.0001);
sh_mul = max(1. - v1.w, 0.0001);
- for (int i = 0; i < 16; ++i)
+ for (int i = 0; i < 1; ++i)
calcLight(i, n, v, v2);
qgl_FragData[0].rgb = li * dc + si * v2.rgb + v3.rgb + texture(t_pp, tc).rgb;
//qgl_FragData[0].rgb = vec3(abs(lpos.xyz - pos.xyz)/10);
- //qgl_FragData[0].rgb = si.rgb;
+ //qgl_FragData[0].rgb = vec3(ldist/1000);
//qgl_FragData[0].rgb = vec3(length(v4.xyz)/10);
//qgl_FragData[0].a = 0.;
}
diff --git a/qglview/shaders/hdr.frag b/qglview/shaders/hdr.frag
index 52196d1..0400a7e 100644
--- a/qglview/shaders/hdr.frag
+++ b/qglview/shaders/hdr.frag
@@ -16,12 +16,14 @@ vec3 Uncharted2Tonemap(vec3 x) {
}
void main(void) {
+ qgl_FragData[0].rgb = texelFetch(t0, ivec2(gl_FragCoord.xy), 0).rgb;
+ return;
vec3 inColor = texelFetch(t0, ivec2(gl_FragCoord.xy), 0).rgb;
inColor *= exposure;
float ExposureBias = 1;
vec3 curr = Uncharted2Tonemap(ExposureBias*inColor);
vec3 whiteScale = 1 / Uncharted2Tonemap(vec3(tW));
vec3 color = curr * whiteScale;
- vec3 retColor = pow(color, vec3(1 / 2.2));
+ vec3 retColor = pow(color, vec3(1 / 1.2));
qgl_FragData[0].rgb = retColor;
}