fixed issue with old cards
This commit is contained in:
parent
2d4e2b9727
commit
8d3331dce1
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
build/*
|
build*
|
||||||
*.user
|
*.user
|
2
lights.h
2
lights.h
@ -5,7 +5,7 @@
|
|||||||
#include <glew/glew.h>
|
#include <glew/glew.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define MAX_LIGHTS 8
|
#define MAX_LIGHTS 4
|
||||||
|
|
||||||
class Shader;
|
class Shader;
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>757</width>
|
<width>400</width>
|
||||||
<height>492</height>
|
<height>300</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -40,8 +40,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>757</width>
|
<width>400</width>
|
||||||
<height>21</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -65,7 +65,8 @@ Scene* MyGLWidget::buildScene()
|
|||||||
|
|
||||||
void MyGLWidget::initializeGL()
|
void MyGLWidget::initializeGL()
|
||||||
{
|
{
|
||||||
makeCurrent();
|
if(renderer != NULL)
|
||||||
|
delete(renderer);
|
||||||
renderer = new SparrowRenderer(width(), height());
|
renderer = new SparrowRenderer(width(), height());
|
||||||
Scene* scene = buildScene();
|
Scene* scene = buildScene();
|
||||||
controller = new FocusController(new glm::vec3(0));
|
controller = new FocusController(new glm::vec3(0));
|
||||||
|
12
phong.frag
12
phong.frag
@ -6,9 +6,9 @@ uniform vec3 materialKs;
|
|||||||
uniform float materialNs;
|
uniform float materialNs;
|
||||||
|
|
||||||
uniform int nbDirLights;
|
uniform int nbDirLights;
|
||||||
uniform vec3 dirLights[16];
|
uniform vec3 dirLights[8];
|
||||||
uniform int nbPointLights;
|
uniform int nbPointLights;
|
||||||
uniform vec3 pointLights[16];
|
uniform vec3 pointLights[8];
|
||||||
|
|
||||||
// texture
|
// texture
|
||||||
uniform sampler2D baseTexture;
|
uniform sampler2D baseTexture;
|
||||||
@ -17,8 +17,8 @@ uniform sampler2D baseTexture;
|
|||||||
in vec3 varNormal;
|
in vec3 varNormal;
|
||||||
in vec2 varTexCoord;
|
in vec2 varTexCoord;
|
||||||
|
|
||||||
in vec3 lightDirInView[8];
|
in vec3 lightDirInView[4];
|
||||||
in vec3 halfVecInView[8];
|
in vec3 halfVecInView[4];
|
||||||
|
|
||||||
// resultat
|
// resultat
|
||||||
layout(location = 0)out vec4 outColor;
|
layout(location = 0)out vec4 outColor;
|
||||||
@ -41,9 +41,9 @@ void main(void) {
|
|||||||
int i;
|
int i;
|
||||||
vec3 kd = vec3(texture2D(baseTexture, varTexCoord));
|
vec3 kd = vec3(texture2D(baseTexture, varTexCoord));
|
||||||
vec3 light = 0.1f*kd;
|
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]);
|
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]);
|
light += computeLight(kd, materialKs, materialNs, pointLights[i*2+1], varNormal, lightDirInView[nbDirLights+i], halfVecInView[nbDirLights+i]);
|
||||||
|
|
||||||
outColor = vec4(light, 1);
|
outColor = vec4(light, 1);
|
||||||
|
12
phong.vert
12
phong.vert
@ -7,16 +7,16 @@ uniform mat4 normalMatrix;
|
|||||||
uniform mat4 viewMatrix;
|
uniform mat4 viewMatrix;
|
||||||
|
|
||||||
uniform int nbDirLights;
|
uniform int nbDirLights;
|
||||||
uniform vec3 dirLights[16];
|
uniform vec3 dirLights[8];
|
||||||
uniform int nbPointLights;
|
uniform int nbPointLights;
|
||||||
uniform vec3 pointLights[16];
|
uniform vec3 pointLights[8];
|
||||||
|
|
||||||
layout(location = 0)in vec3 inPosition;
|
layout(location = 0)in vec3 inPosition;
|
||||||
layout(location = 1)in vec3 inNormal;
|
layout(location = 1)in vec3 inNormal;
|
||||||
layout(location = 2)in vec4 inTexCoord;
|
layout(location = 2)in vec4 inTexCoord;
|
||||||
|
|
||||||
out vec3 lightDirInView[8];
|
out vec3 lightDirInView[4];
|
||||||
out vec3 halfVecInView[8];
|
out vec3 halfVecInView[4];
|
||||||
|
|
||||||
out vec3 varNormal;
|
out vec3 varNormal;
|
||||||
out vec2 varTexCoord;
|
out vec2 varTexCoord;
|
||||||
@ -35,9 +35,9 @@ void computePointLightingVectorsInView(in vec3 posInView, in vec3 lightPosition,
|
|||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
int i;
|
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]);
|
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]);
|
computePointLightingVectorsInView(vec3(modelViewMatrix*vec4(inPosition, 1.0)), pointLights[i*2], lightDirInView[nbDirLights+i], halfVecInView[nbDirLights+i]);
|
||||||
|
|
||||||
// normales corrigees (en fonction de la vue)
|
// normales corrigees (en fonction de la vue)
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core gui opengl
|
QT += core gui opengl widgets
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
|
||||||
|
|
||||||
TARGET = sparrowRenderer
|
TARGET = sparrowRenderer
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
@ -15,9 +13,13 @@ CONFIG += c++11
|
|||||||
INCLUDEPATH += ../cpp_dependencies/include
|
INCLUDEPATH += ../cpp_dependencies/include
|
||||||
win32 {
|
win32 {
|
||||||
LIBS += -L../../cpp_dependencies/lib/win32
|
LIBS += -L../../cpp_dependencies/lib/win32
|
||||||
|
LIBS += -lglew32
|
||||||
|
}
|
||||||
|
linux {
|
||||||
|
LIBS += -L../../cpp_dependencies/lib/linux
|
||||||
|
LIBS += -lGLEW -lGLU
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBS += -lglew32
|
|
||||||
|
|
||||||
SOURCES += main.cpp\
|
SOURCES += main.cpp\
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user