bug fixes
This commit is contained in:
parent
378806c0a0
commit
021ba006a0
@ -112,7 +112,7 @@ void main(void) {
|
||||
#endif
|
||||
|
||||
#ifdef AMBIENT_LIGHT
|
||||
outColor = vec4(diffuse*0.1f, 1);
|
||||
outColor = vec4(ambient+diffuse*0.1f, 1);
|
||||
#else
|
||||
vec3 light = phongLighting(diffuse, specular, materialNs, lightColor, normal, lightDirInView, halfVecInView);
|
||||
outColor = vec4(light*shadow*(1+cos(1.57 + att*1.57)), 1);
|
||||
|
@ -10,9 +10,6 @@
|
||||
void ForwardModule::renderGL(Camera* myCamera, Scene* scene)
|
||||
{
|
||||
// bind target
|
||||
renderTarget->bindFBO();
|
||||
if(clearBeforeDrawing)
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
for(const Pass &p : passes)
|
||||
@ -141,9 +138,3 @@ void ForwardModule::compileShaders(Scene* scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ForwardModule::setRenderTarget(const FrameBuffer* target)
|
||||
{
|
||||
if(target != NULL)
|
||||
renderTarget = target;
|
||||
}
|
||||
|
@ -19,10 +19,7 @@ class PhongEntity;
|
||||
class ForwardModule : public Module
|
||||
{
|
||||
public:
|
||||
ForwardModule() :
|
||||
shaderSources(NULL),
|
||||
renderTarget(FrameBuffer::screen),
|
||||
clearBeforeDrawing(false)
|
||||
ForwardModule() : shaderSources(NULL)
|
||||
{
|
||||
ambientLight.initAmbientLight();
|
||||
}
|
||||
@ -36,9 +33,6 @@ public:
|
||||
void setShaderSource(ShaderSource* source);
|
||||
void compileShaders(Scene* scene);
|
||||
|
||||
void setRenderTarget(const FrameBuffer* target);
|
||||
void setClearBeforeDrawing(bool clear) {clearBeforeDrawing = clear;}
|
||||
|
||||
private:
|
||||
struct Pass
|
||||
{
|
||||
@ -61,12 +55,8 @@ private:
|
||||
std::vector<Pass> passes;
|
||||
ShaderSource* shaderSources;
|
||||
|
||||
const FrameBuffer* renderTarget;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
||||
bool clearBeforeDrawing;
|
||||
};
|
||||
|
||||
#endif // FORWARDMODULE_H
|
||||
|
@ -3,9 +3,8 @@
|
||||
|
||||
class Shader;
|
||||
|
||||
class Material
|
||||
struct Material
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief bindAttributes should send the material attribute to the specified shader as a uniform
|
||||
* if the shader is NULL, we can assume that modern opengl is not available and try to apply the material differently (glMaterial)
|
||||
|
@ -17,7 +17,7 @@ const char* const Mesh::flagStr[Mesh::NB_FLAGS] =
|
||||
|
||||
"TANGENT_SPACE",
|
||||
"BILLBOARD",
|
||||
"SHADOWED"
|
||||
"SHADOWED",
|
||||
|
||||
"COLOR_TEXTURE",
|
||||
"ALPHA_MASK",
|
||||
|
@ -6,22 +6,19 @@
|
||||
|
||||
class Texture;
|
||||
|
||||
class PhongMaterial : public Material
|
||||
struct PhongMaterial : public Material
|
||||
{
|
||||
public: // TODO add setters for this
|
||||
glm::vec3 ambient;
|
||||
glm::vec3 diffuse;
|
||||
glm::vec3 specular;
|
||||
float shininess;
|
||||
bool castShadow;
|
||||
private:
|
||||
Texture* ambient_texture;
|
||||
Texture* diffuse_texture;
|
||||
Texture* specular_texture;
|
||||
Texture* normal_map;
|
||||
Texture* alpha_mask;
|
||||
|
||||
public:
|
||||
enum TextureSlots
|
||||
{
|
||||
DIFFUSE_SLOT,
|
||||
@ -50,12 +47,6 @@ public:
|
||||
virtual void bindAttributes(Shader* myShader = NULL);
|
||||
|
||||
virtual unsigned int getFlags();
|
||||
|
||||
void setAmbientTexture(Texture* myTexture) {ambient_texture = myTexture;}
|
||||
void setDiffuseTexture(Texture* myTexture) {diffuse_texture = myTexture;}
|
||||
void setSpecularTexture(Texture* myTexture) {specular_texture = myTexture;}
|
||||
void setNormalMap(Texture* myNormalMap) {normal_map = myNormalMap;}
|
||||
void setAlphaMask(Texture* myAlphaMask) {alpha_mask = myAlphaMask;}
|
||||
};
|
||||
|
||||
#endif // PHONGMATERIAL_H
|
||||
|
@ -24,7 +24,6 @@ SimplePipeline::SimplePipeline(ShaderSource *forwardSource)
|
||||
{
|
||||
ForwardModule *forward = new ForwardModule();
|
||||
forward->setShaderSource(forwardSource);
|
||||
forward->setClearBeforeDrawing(false);
|
||||
modules.push_back(forward);
|
||||
}
|
||||
else
|
||||
@ -36,19 +35,17 @@ void SimplePipeline::renderGL(Scene *scene)
|
||||
glClearColor(m_clearColor.r, m_clearColor.g, m_clearColor.b, 1);
|
||||
glClearDepth(1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
for(Module *m : modules)
|
||||
{
|
||||
glFinish();
|
||||
m->renderGL(m_camera, scene);
|
||||
}
|
||||
glViewport(0, 0, width, height);
|
||||
modules[0]->renderGL(m_camera, scene);
|
||||
}
|
||||
|
||||
void SimplePipeline::resizeGL(int w, int h)
|
||||
{
|
||||
width = w;
|
||||
height = h;
|
||||
if(m_camera != NULL)
|
||||
m_camera->resize(w, h);
|
||||
for(Module *m : modules)
|
||||
m->resize(w, h);
|
||||
modules[0]->resize(w, h);
|
||||
}
|
||||
|
||||
void SimplePipeline::refreshScene(Scene *scene)
|
||||
|
@ -39,6 +39,9 @@ class SimplePipeline : public Pipeline
|
||||
Camera *m_camera;
|
||||
glm::vec3 m_clearColor;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
||||
public:
|
||||
SimplePipeline(ShaderSource *forwardSource = NULL);
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include "shader.h"
|
||||
#include "mesh.h"
|
||||
#include "light.h"
|
||||
@ -52,11 +53,8 @@ Shader* ShaderSource::compile(const std::vector<const char*> &defines)
|
||||
{
|
||||
std::string header = "#version 330 core";
|
||||
|
||||
for(int i=0; i<Light::NB_FLAGS; ++i)
|
||||
{
|
||||
for(const char* def : defines)
|
||||
header += "\n#define "+std::string(def);
|
||||
}
|
||||
|
||||
header += "\n#line 1\n";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user