This commit is contained in:
Dmitri K 2016-11-10 15:36:22 -05:00
parent d1ed0a00dd
commit 89c2187f7f
6 changed files with 724 additions and 731 deletions

View File

@ -2,6 +2,7 @@
uniform vec3 lDirection;
uniform bool isSky;
uniform bool isPhong;
uniform bool isPickerColor;
uniform sampler2D tex;
uniform float skyMult;
@ -16,7 +17,10 @@ void
main()
{
vec4 texColor = texture(tex, texCoords);
if(isSky) {
if(isPickerColor){
fColor = ifColor;
} else if(isSky) {
fColor = skyMult * normalize(texColor*texColor*texColor*2/1.41)*2;
} else if(isPhong) {
// Get lighting vectors
@ -40,5 +44,5 @@ main()
//fColor = vec4(fNormal, 1);
} else {
fColor = texColor * ifColor;
}
}
}

View File

@ -8,6 +8,7 @@ uniform vec4 color;
uniform bool isSky;
uniform bool isPhong;
uniform bool isPickerColor;
in vec4 vPosition;
in vec3 vNormal;
@ -30,7 +31,7 @@ main()
ifColor = color;
if(!isPhong && !isSky) {
if(!isPickerColor && !isPhong && !isSky) {
// Get lighting vectors
vec3 LightDirection = normalize(lDirection);
vec3 nfNormal = normalize(fNormal);
@ -50,5 +51,6 @@ main()
ifColor = vec4(color * (0.1 + diffuse + specular), 1);
//ifColor = vec4(fNormal, 1);
}
}

View File

@ -9,7 +9,7 @@ in vec4 vPosition;
void
main()
{
gl_Position = projMatrix * mvMatrix * vPosition;
texCoords = vUv;
gl_Position = projMatrix * mvMatrix * vPosition;
texCoords = vUv;
}

View File

@ -1,15 +0,0 @@
#version 400 core
uniform mat4 mvMatrix;
uniform mat4 projMatrix;
out vec2 texCoords;
in vec2 vUv;
in vec4 vPosition;
void
main()
{
gl_Position = projMatrix * mvMatrix * vPosition;
texCoords = vUv;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,122 +1,123 @@
/****************************************************************************
Copyright (C) 2002-2008 Gilles Debunne. All rights reserved.
This file is part of the QGLViewer library version 2.3.6.
http://www.libqglviewer.com - contact@libqglviewer.com
This file may be used under the terms of the GNU General Public License
versions 2.0 or 3.0 as published by the Free Software Foundation and
appearing in the LICENSE file included in the packaging of this file.
In addition, as a special exception, Gilles Debunne gives you certain
additional rights, described in the file GPL_EXCEPTION in this package.
libQGLViewer uses dual licensing. Commercial/proprietary software must
purchase a libQGLViewer Commercial License.
This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*****************************************************************************/
#ifndef SIMPLEVIEWER_H
#define SIMPLEVIEWER_H
#include <QOpenGLFunctions_4_0_Core>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
#include <QOpenGLTexture>
#include <QMatrix4x4>
#include <QGLViewer/qglviewer.h>
#include "../interfaces/visitor.h"
#include "../glnodes/glnode.h"
#include "../glnodes/scenegroup.h"
#include "../glnodes/shapes.h"
#include <stack>
QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
class Viewer : public QGLViewer,
protected QOpenGLFunctions_4_0_Core,
public Visitor
{
Q_OBJECT
public:
Viewer();
~Viewer();
virtual void visit(SceneGroup &s);
virtual void visit(Cube &s);
public slots:
void cleanup();
void changeColor(QColor);
void setPhong(bool);
signals:
int shapeSelected(int);
protected :
virtual void draw();
virtual void drawSkybox();
virtual void init();
virtual void mouseMoveEvent(QMouseEvent* e);
virtual void mouseReleaseEvent(QMouseEvent* e);
virtual void mousePressEvent(QMouseEvent *e);
SceneGroup root;
std::stack<QMatrix4x4> modelStack;
private:
void initShaders();
void initGeometries();
void deselect();
Shape* pickGeom(int, int);
// shader switching variables and constants;
QOpenGLShaderProgram *colorPickerShaderProgram;
QOpenGLShaderProgram *textureRenderShaderprogram;
QOpenGLShaderProgram *skyboxRenderShaderProgram;
QOpenGLShaderProgram *m_program;
int m_vPositionLocation;
int m_colorLocation;
int m_projMatrixLocation;
int m_mvMatrixLocation;
int s_texCoordsLocation;
int s_vPositionLocation;
int s_mvMatrixLocation;
int s_colorLocation;
int s_projMatrixLocation;
int s_skyboxCubemapLocation;
int s_vUvLocation;
int m_vNormalLocation;
int m_isPhongLoc;
int m_isSkyLoc;
int m_lDirLoc;
int m_skyMultLoc;
float angle_mult;
QOpenGLTexture *s_texture;
SceneGroup* activeCell;
QColor* activeColor;
int activeShape;
enum VAO_IDs { VAO_Cube, NumVAOs };
enum Buffer_IDs { VBO_Cube, NumBuffers };
GLuint m_VAOs[NumVAOs];
GLuint m_Buffers[NumBuffers];
Shape* generateShapeFromIndex(int);
QQuaternion rot;
unsigned int frame;
};
#endif // SIMPLEVIEWER_H
/****************************************************************************
Copyright (C) 2002-2008 Gilles Debunne. All rights reserved.
This file is part of the QGLViewer library version 2.3.6.
http://www.libqglviewer.com - contact@libqglviewer.com
This file may be used under the terms of the GNU General Public License
versions 2.0 or 3.0 as published by the Free Software Foundation and
appearing in the LICENSE file included in the packaging of this file.
In addition, as a special exception, Gilles Debunne gives you certain
additional rights, described in the file GPL_EXCEPTION in this package.
libQGLViewer uses dual licensing. Commercial/proprietary software must
purchase a libQGLViewer Commercial License.
This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*****************************************************************************/
#ifndef SIMPLEVIEWER_H
#define SIMPLEVIEWER_H
#include <QOpenGLFunctions_4_0_Core>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
#include <QOpenGLTexture>
#include <QMatrix4x4>
#include <QGLViewer/qglviewer.h>
#include "../interfaces/visitor.h"
#include "../glnodes/glnode.h"
#include "../glnodes/scenegroup.h"
#include "../glnodes/shapes.h"
#include <stack>
QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
class Viewer : public QGLViewer,
protected QOpenGLFunctions_4_0_Core,
public Visitor
{
Q_OBJECT
public:
Viewer();
~Viewer();
virtual void visit(SceneGroup &s);
virtual void visit(Cube &s);
public slots:
void cleanup();
void changeColor(QColor);
void setPhong(bool);
signals:
int shapeSelected(int);
protected :
virtual void draw();
virtual void drawSkybox();
virtual void init();
virtual void mouseMoveEvent(QMouseEvent* e);
virtual void mouseReleaseEvent(QMouseEvent* e);
virtual void mousePressEvent(QMouseEvent *e);
SceneGroup root;
std::stack<QMatrix4x4> modelStack;
private:
void initShaders();
void initGeometries();
void deselect();
Shape* pickGeom(int, int);
// shader switching variables and constants;
QOpenGLShaderProgram *colorPickerShaderProgram;
QOpenGLShaderProgram *textureRenderShaderprogram;
QOpenGLShaderProgram *skyboxRenderShaderProgram;
QOpenGLShaderProgram *m_program;
int m_vPositionLocation;
int m_colorLocation;
int m_projMatrixLocation;
int m_mvMatrixLocation;
int s_texCoordsLocation;
int s_vPositionLocation;
int s_mvMatrixLocation;
int s_colorLocation;
int s_projMatrixLocation;
int s_skyboxCubemapLocation;
int s_vUvLocation;
int m_vNormalLocation;
int m_isPhongLoc;
int m_isSkyLoc;
int m_lDirLoc;
int m_skyMultLoc;
bool m_pickerColor;
float angle_mult;
QOpenGLTexture *s_texture;
SceneGroup* activeCell;
QColor* activeColor;
int activeShape;
enum VAO_IDs { VAO_Cube, NumVAOs };
enum Buffer_IDs { VBO_Cube, NumBuffers };
GLuint m_VAOs[NumVAOs];
GLuint m_Buffers[NumBuffers];
Shape* generateShapeFromIndex(int);
QQuaternion rot;
unsigned int frame;
};
#endif // SIMPLEVIEWER_H