fixed issue with old cards

This commit is contained in:
Anselme 2015-07-02 13:08:05 +02:00
parent 2d4e2b9727
commit 8d3331dce1
7 changed files with 29 additions and 26 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
build/*
build*
*.user

View File

@ -5,7 +5,7 @@
#include <glew/glew.h>
#include <vector>
#define MAX_LIGHTS 8
#define MAX_LIGHTS 4
class Shader;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>757</width>
<height>492</height>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
@ -40,8 +40,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>757</width>
<height>21</height>
<width>400</width>
<height>20</height>
</rect>
</property>
</widget>

View File

@ -65,7 +65,8 @@ Scene* MyGLWidget::buildScene()
void MyGLWidget::initializeGL()
{
makeCurrent();
if(renderer != NULL)
delete(renderer);
renderer = new SparrowRenderer(width(), height());
Scene* scene = buildScene();
controller = new FocusController(new glm::vec3(0));

View File

@ -6,9 +6,9 @@ uniform vec3 materialKs;
uniform float materialNs;
uniform int nbDirLights;
uniform vec3 dirLights[16];
uniform vec3 dirLights[8];
uniform int nbPointLights;
uniform vec3 pointLights[16];
uniform vec3 pointLights[8];
// texture
uniform sampler2D baseTexture;
@ -17,8 +17,8 @@ uniform sampler2D baseTexture;
in vec3 varNormal;
in vec2 varTexCoord;
in vec3 lightDirInView[8];
in vec3 halfVecInView[8];
in vec3 lightDirInView[4];
in vec3 halfVecInView[4];
// resultat
layout(location = 0)out vec4 outColor;
@ -41,9 +41,9 @@ void main(void) {
int i;
vec3 kd = vec3(texture2D(baseTexture, varTexCoord));
vec3 light = 0.1f*kd;
for(i=0; i<nbDirLights && i<8; ++i)
for(i=0; i<nbDirLights && i<4; ++i)
light += computeLight(kd, materialKs, materialNs, dirLights[i*2+1], varNormal, lightDirInView[i], halfVecInView[i]);
for(i=0; i<nbPointLights && i+nbDirLights<8; ++i)
for(i=0; i<nbPointLights && i+nbDirLights<4; ++i)
light += computeLight(kd, materialKs, materialNs, pointLights[i*2+1], varNormal, lightDirInView[nbDirLights+i], halfVecInView[nbDirLights+i]);
outColor = vec4(light, 1);

View File

@ -7,16 +7,16 @@ uniform mat4 normalMatrix;
uniform mat4 viewMatrix;
uniform int nbDirLights;
uniform vec3 dirLights[16];
uniform vec3 dirLights[8];
uniform int nbPointLights;
uniform vec3 pointLights[16];
uniform vec3 pointLights[8];
layout(location = 0)in vec3 inPosition;
layout(location = 1)in vec3 inNormal;
layout(location = 2)in vec4 inTexCoord;
out vec3 lightDirInView[8];
out vec3 halfVecInView[8];
out vec3 lightDirInView[4];
out vec3 halfVecInView[4];
out vec3 varNormal;
out vec2 varTexCoord;
@ -35,9 +35,9 @@ void computePointLightingVectorsInView(in vec3 posInView, in vec3 lightPosition,
void main(void) {
int i;
for(i=0; i<nbDirLights && i<8; ++i)
for(i=0; i<nbDirLights && i<4; ++i)
computeDirectionnalLightingVectorsInView(vec3(modelViewMatrix*vec4(inPosition, 1.0)), dirLights[i*2], lightDirInView[i], halfVecInView[i]);
for(i=0; i<nbPointLights && i+nbDirLights<8; ++i)
for(i=0; i<nbPointLights && i+nbDirLights<4; ++i)
computePointLightingVectorsInView(vec3(modelViewMatrix*vec4(inPosition, 1.0)), pointLights[i*2], lightDirInView[nbDirLights+i], halfVecInView[nbDirLights+i]);
// normales corrigees (en fonction de la vue)

View File

@ -4,9 +4,7 @@
#
#-------------------------------------------------
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
QT += core gui opengl widgets
TARGET = sparrowRenderer
TEMPLATE = app
@ -15,9 +13,13 @@ CONFIG += c++11
INCLUDEPATH += ../cpp_dependencies/include
win32 {
LIBS += -L../../cpp_dependencies/lib/win32
LIBS += -lglew32
}
linux {
LIBS += -L../../cpp_dependencies/lib/linux
LIBS += -lGLEW -lGLU
}
LIBS += -lglew32
SOURCES += main.cpp\
mainwindow.cpp \
@ -27,7 +29,7 @@ SOURCES += main.cpp\
camera.cpp \
scene.cpp \
gridmesh.cpp \
texture.cpp \
texture.cpp \
phongmaterial.cpp \
scenecontroller.cpp \
sphere.cpp \
@ -48,8 +50,8 @@ HEADERS += mainwindow.h \
glassert.h \
scene.h \
material.h \
gridmesh.h \
texture.h \
gridmesh.h \
texture.h \
phongmaterial.h \
scenecontroller.h \
sphere.h \