Merge branch 'master' of github.com:Faerbit/swp
This commit is contained in:
commit
d827948747
@ -7,6 +7,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.0</scale>
|
<scale>1.0</scale>
|
||||||
<mass>8.0</mass>
|
<mass>8.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -21,6 +24,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>1.0</yOffset>
|
<yOffset>1.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.5</scale>
|
<scale>1.5</scale>
|
||||||
<mass>25.0</mass>
|
<mass>25.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -35,6 +41,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.0</scale>
|
<scale>1.0</scale>
|
||||||
<mass>0.0</mass>
|
<mass>0.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -49,6 +58,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.0</scale>
|
<scale>1.0</scale>
|
||||||
<mass>0.0</mass>
|
<mass>0.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -87,6 +99,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.5</scale>
|
<scale>1.5</scale>
|
||||||
<mass>0.0</mass>
|
<mass>0.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -95,6 +110,9 @@
|
|||||||
<xOffset>2.0</xOffset>
|
<xOffset>2.0</xOffset>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.5</scale>
|
<scale>1.5</scale>
|
||||||
<mass>0.0</mass>
|
<mass>0.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -103,6 +121,9 @@
|
|||||||
<xOffset>1.0</xOffset>
|
<xOffset>1.0</xOffset>
|
||||||
<yOffset>3.0</yOffset>
|
<yOffset>3.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.5</scale>
|
<scale>1.5</scale>
|
||||||
<mass>0.0</mass>
|
<mass>0.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -117,6 +138,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>3</yOffset>
|
<yOffset>3</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.0</scale>
|
<scale>1.0</scale>
|
||||||
<mass>1.0</mass>
|
<mass>1.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -125,6 +149,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>2</yOffset>
|
<yOffset>2</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.0</scale>
|
<scale>1.0</scale>
|
||||||
<mass>0.0</mass>
|
<mass>0.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -139,6 +166,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>20.0</yOffset>
|
<yOffset>20.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.5</scale>
|
<scale>1.5</scale>
|
||||||
<mass>0.0</mass>
|
<mass>0.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -153,6 +183,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>20.0</yOffset>
|
<yOffset>20.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.5</scale>
|
<scale>1.5</scale>
|
||||||
<mass>0.0</mass>
|
<mass>0.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -161,6 +194,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>18.0</yOffset>
|
<yOffset>18.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.5</scale>
|
<scale>1.5</scale>
|
||||||
<mass>0.0</mass>
|
<mass>0.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -169,6 +205,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>15.0</yOffset>
|
<yOffset>15.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.5</scale>
|
<scale>1.5</scale>
|
||||||
<mass>0.0</mass>
|
<mass>0.0</mass>
|
||||||
</object>
|
</object>
|
||||||
@ -177,6 +216,9 @@
|
|||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>12.0</yOffset>
|
<yOffset>12.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.5</scale>
|
<scale>1.5</scale>
|
||||||
<mass>0.0</mass>
|
<mass>0.0</mass>
|
||||||
</object>
|
</object>
|
||||||
|
@ -47,7 +47,6 @@ vec2 poissonDisk[16] = vec2[](
|
|||||||
);
|
);
|
||||||
|
|
||||||
float sampleDirectionalShadow(sampler2DShadow shadowMap, vec4 shadowCoord) {
|
float sampleDirectionalShadow(sampler2DShadow shadowMap, vec4 shadowCoord) {
|
||||||
float nearPlane = 0.1;
|
|
||||||
float visibility = 1.0;
|
float visibility = 1.0;
|
||||||
float bias = 0.001*tan(acos(clamp(dot(vNormal, -directionalLightVector), 0.0, 1.0)));
|
float bias = 0.001*tan(acos(clamp(dot(vNormal, -directionalLightVector), 0.0, 1.0)));
|
||||||
bias = clamp(bias, 0.0, 0.01);
|
bias = clamp(bias, 0.0, 0.01);
|
||||||
@ -121,7 +120,7 @@ void main()
|
|||||||
vec3 finalColor = specularColor + diffuseColor + ambientColor;
|
vec3 finalColor = specularColor + diffuseColor + ambientColor;
|
||||||
float distanceCameraCenter = distance(cameraCenter, vec3(fragPosition));
|
float distanceCameraCenter = distance(cameraCenter, vec3(fragPosition));
|
||||||
float fogFactor = clamp((1.0 - ((farPlane - 35.0) -distanceCameraCenter)/30.0), 0.0, 1.0);
|
float fogFactor = clamp((1.0 - ((farPlane - 35.0) -distanceCameraCenter)/30.0), 0.0, 1.0);
|
||||||
fogFactor *= clamp((1.0-((fragPosition.y-8.0)/30.0)), 0.0, 1.0);
|
fogFactor *= clamp((1.0-((fragPosition.y-40.0)/30.0)), 0.0, 1.0);
|
||||||
|
|
||||||
vec4 texture = texture(uTexture, vTexCoord).rgba;
|
vec4 texture = texture(uTexture, vTexCoord).rgba;
|
||||||
oColor = vec4(finalColor, 1.0f)*texture;
|
oColor = vec4(finalColor, 1.0f)*texture;
|
||||||
|
20
graphics.cc
20
graphics.cc
@ -61,6 +61,15 @@ void Graphics::init(Level* level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
framebuffer_cube = SharedFrameBufferObject(new FrameBufferObject());
|
framebuffer_cube = SharedFrameBufferObject(new FrameBufferObject());
|
||||||
|
|
||||||
|
depthTexture_cube = SharedTexture2D( new Texture2D(windowSize, GL_DEPTH_COMPONENT16));
|
||||||
|
depthTexture_cube->setMinFilter(GL_NEAREST);
|
||||||
|
depthTexture_cube->setMagFilter(GL_NEAREST);
|
||||||
|
depthTexture_cube->setWrapS(GL_CLAMP_TO_EDGE);
|
||||||
|
depthTexture_cube->setWrapT(GL_CLAMP_TO_EDGE);
|
||||||
|
depthTexture_cube->setCompareMode(GL_COMPARE_REF_TO_TEXTURE);
|
||||||
|
framebuffer_cube2 = SharedFrameBufferObject(new FrameBufferObject());
|
||||||
|
framebuffer_cube2->setDepthTexture(depthTexture_cube);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWwindow* Graphics::getWindow() {
|
GLFWwindow* Graphics::getWindow() {
|
||||||
@ -86,11 +95,20 @@ void Graphics::render()
|
|||||||
for (unsigned int i_pointlight = 0; i_pointlight<1 && i_pointlight<level->getLights()->size(); i_pointlight++) {
|
for (unsigned int i_pointlight = 0; i_pointlight<1 && i_pointlight<level->getLights()->size(); i_pointlight++) {
|
||||||
// render each side of the cube
|
// render each side of the cube
|
||||||
for (int i_face = 0; i_face<6; i_face++) {
|
for (int i_face = 0; i_face<6; i_face++) {
|
||||||
|
framebuffer_cube2->bind();
|
||||||
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
framebuffer_cube->bind();
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i_face, depth_cubeMaps.at(i_pointlight)->getObjectName(), 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i_face, depth_cubeMaps.at(i_pointlight)->getObjectName(), 0);
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * glm::lookAt(level->getLights()->at(i_pointlight).getPosition(),
|
glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * glm::lookAt(level->getLights()->at(i_pointlight).getPosition(),
|
||||||
level->getLights()->at(i_pointlight).getPosition() + looking_directions[i_face], glm::vec3(0.0f, 1.0f, 0.0f));
|
level->getLights()->at(i_pointlight).getPosition() + looking_directions[i_face], glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
//level->render(depthShader, false, &depthViewProjectionMatrix_face);
|
level->render(depthShader, false, &depthViewProjectionMatrix_face);
|
||||||
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer_cube->getObjectName());
|
||||||
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer_cube2->getObjectName());
|
||||||
|
glBlitFramebuffer(0, 0, cube_size, cube_size, cube_size, cube_size, 0, 0, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||||
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer_cube2->getObjectName());
|
||||||
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer_cube->getObjectName());
|
||||||
|
glBlitFramebuffer(0, 0, cube_size, cube_size, 0, 0, cube_size, cube_size, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||||
if (!framebuffer_cube->isFrameBufferObjectComplete()) {
|
if (!framebuffer_cube->isFrameBufferObjectComplete()) {
|
||||||
printf("Framebuffer incomplete, unknown error occured during shadow generation!\n");
|
printf("Framebuffer incomplete, unknown error occured during shadow generation!\n");
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@ class Graphics {
|
|||||||
ACGL::OpenGL::SharedFrameBufferObject framebuffer;
|
ACGL::OpenGL::SharedFrameBufferObject framebuffer;
|
||||||
std::vector<ACGL::OpenGL::SharedTextureCubeMap> depth_cubeMaps;
|
std::vector<ACGL::OpenGL::SharedTextureCubeMap> depth_cubeMaps;
|
||||||
ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube;
|
ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube;
|
||||||
|
ACGL::OpenGL::SharedFrameBufferObject framebuffer_cube2;
|
||||||
|
ACGL::OpenGL::SharedTexture2D depthTexture_cube;
|
||||||
static const int cube_size;
|
static const int cube_size;
|
||||||
Level* level;
|
Level* level;
|
||||||
};
|
};
|
||||||
|
8
level.cc
8
level.cc
@ -221,7 +221,11 @@ void Level::load() {
|
|||||||
* glm::rotate(compRot.z, glm::vec3(0.0f, 0.0f, 1.0f))
|
* glm::rotate(compRot.z, glm::vec3(0.0f, 0.0f, 1.0f))
|
||||||
* glm::vec4(objectOffset, 0);
|
* glm::vec4(objectOffset, 0);
|
||||||
glm::vec3 objectPosition = compPos + glm::vec3(rotatedObjectOffset.x,rotatedObjectOffset.y,rotatedObjectOffset.z);
|
glm::vec3 objectPosition = compPos + glm::vec3(rotatedObjectOffset.x,rotatedObjectOffset.y,rotatedObjectOffset.z);
|
||||||
Object* object = new Object(model, material, objectPosition, compRot);
|
glm::vec3 objectRot;
|
||||||
|
errorCheck(xmlObject->FirstChildElement("xRot")->QueryFloatText(&objectRot[0]));
|
||||||
|
errorCheck(xmlObject->FirstChildElement("yRot")->QueryFloatText(&objectRot[1]));
|
||||||
|
errorCheck(xmlObject->FirstChildElement("zRot")->QueryFloatText(&objectRot[2]));
|
||||||
|
Object* object = new Object(model, material, objectPosition, compRot+objectRot);
|
||||||
objects.push_back(object);
|
objects.push_back(object);
|
||||||
//create an identifier for this object
|
//create an identifier for this object
|
||||||
std::vector<int> objectIdentifier = std::vector<int>(4);
|
std::vector<int> objectIdentifier = std::vector<int>(4);
|
||||||
@ -425,7 +429,7 @@ void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
|
|||||||
glm::mat4* viewProjectionMatrix, std::vector<glm::mat4>* shadowVPs) {
|
glm::mat4* viewProjectionMatrix, std::vector<glm::mat4>* shadowVPs) {
|
||||||
for(unsigned int i = 0; i<objects.size(); i++) {
|
for(unsigned int i = 0; i<objects.size(); i++) {
|
||||||
// do not project shadow of skydome
|
// do not project shadow of skydome
|
||||||
if(lightingPass || objects.at(i) != skydome) {
|
if(lightingPass || (objects.at(i) != skydome && i!=0)) {
|
||||||
objects.at(i)->render(shader, lightingPass, viewProjectionMatrix, shadowVPs);
|
objects.at(i)->render(shader, lightingPass, viewProjectionMatrix, shadowVPs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user