From: Peter Schaefer Date: Thu, 16 Apr 2015 08:44:38 +0000 (+0200) Subject: updated .gitignore X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=1b458b727432b522f69eab376f6c7125ff4cfad1;p=cgue_weave.git updated .gitignore renamed ShaderVariables started SkyBox (not Working) added Box & SkyBox (Plane) started new ModelMatrixType (matM) --- diff --git a/.gitignore b/.gitignore index e4baabc..593d577 100644 --- a/.gitignore +++ b/.gitignore @@ -6,12 +6,12 @@ *.opensdf build-* -bin/*.exe -bin/*.pdb +*.exe +*.pdb +*.ilk +*.bsc + Submission* -Debug/*.ilk -Debug/*.exe -Debug/*.pdb RES *.[Cc]ache \ No newline at end of file diff --git a/CGUE2015_Weave.sln b/CGUE2015_Weave.sln index e9d1777..e49e506 100644 --- a/CGUE2015_Weave.sln +++ b/CGUE2015_Weave.sln @@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shader", "shader", "{75179E shader\basicTexture_VS.hlsl = shader\basicTexture_VS.hlsl shader\lightingTexture_FS.hlsl = shader\lightingTexture_FS.hlsl shader\perspective_VS.hlsl = shader\perspective_VS.hlsl + shader\skybox_FS.hlsl = shader\skybox_FS.hlsl + shader\skybox_VS.hlsl = shader\skybox_VS.hlsl EndProjectSection EndProject Global diff --git a/Weave/Game.cpp b/Weave/Game.cpp index 31eab2f..8269c86 100644 --- a/Weave/Game.cpp +++ b/Weave/Game.cpp @@ -44,6 +44,7 @@ Game::Game() : playing(true) //Allg Shader Shader* shader1 = new Shader("basicTexture_VS.hlsl", "lightingTexture_FS.hlsl"); + Shader* shaderSky = new Shader("skybox_VS.hlsl", "skybox_FS.hlsl"); //Player SceneObject* tmp_playerObject = new SceneObject(shader1, translate(vec3(1.f, 0.f, 1.f)), "Player.dae", "model_player.png"); @@ -91,6 +92,8 @@ Game::Game() : playing(true) //import("level_test.dae", tmp_Scene, shader1); + //tmp_Scene->addObject(new SceneObject(shaderSky, glm::mat4(1.0f), "SkyBox.dae", "model_skybox.png")); + } diff --git a/Weave/Graphix/GLM.h b/Weave/Graphix/GLM.h index 4cf1186..4c95c5e 100644 --- a/Weave/Graphix/GLM.h +++ b/Weave/Graphix/GLM.h @@ -34,3 +34,5 @@ using glm::sign; float VektorAbs(const vec3& vek); + +//#include "matM.h" diff --git a/Weave/Graphix/Model.cpp b/Weave/Graphix/Model.cpp index aa1998b..b237e91 100644 --- a/Weave/Graphix/Model.cpp +++ b/Weave/Graphix/Model.cpp @@ -127,13 +127,13 @@ void Model::useTexture(Texture* _texture, Shader* _shader) const { int unit = 0; _texture->bind(unit); - glUniform1i(_shader->getUniformLocation("ColorTexture"), unit); + glUniform1i(_shader->getUniformLocation("uColorTexture"), unit); } } void Model::useMMatrix(const mat4& _model, Shader* _shader) const { - glUniformMatrix4fv(_shader->getUniformLocation("model"), 1, GL_FALSE, value_ptr(_model)); + glUniformMatrix4fv(_shader->getUniformLocation("uModel"), 1, GL_FALSE, value_ptr(_model)); } void Model::drawModel(Shader* _shader, Texture* _texture, const mat4& _model) const @@ -157,9 +157,9 @@ unsigned int Model::bindShader(Shader* _shader) glGenVertexArrays(1, &vao); glBindVertexArray(vao); - bindBuffer(vertexBuffer, _shader->getAttribLocation("position")); - bindBuffer(uvBuffer, _shader->getAttribLocation("uv"), 2); - bindBuffer(normalBuffer, _shader->getAttribLocation("normal")); + bindBuffer(vertexBuffer, _shader->getAttribLocation("aPosition")); + bindBuffer(uvBuffer, _shader->getAttribLocation("aUV"), 2); + bindBuffer(normalBuffer, _shader->getAttribLocation("aNormal")); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); diff --git a/Weave/Graphix/Model.h b/Weave/Graphix/Model.h index cdf6c91..778becb 100644 --- a/Weave/Graphix/Model.h +++ b/Weave/Graphix/Model.h @@ -21,6 +21,7 @@ public: __declspec(deprecated) Model(const string& modelpath, unsigned int index=0); Model(const aiMesh* mesh); + __declspec(deprecated) Model(unsigned int numvertices, unsigned int numfaces, float *vertex, float *uvs, float *normals, unsigned int *index); virtual ~Model(); diff --git a/Weave/Graphix/ViewPort.cpp b/Weave/Graphix/ViewPort.cpp index d37eb43..418c1d8 100644 --- a/Weave/Graphix/ViewPort.cpp +++ b/Weave/Graphix/ViewPort.cpp @@ -35,14 +35,14 @@ void ViewPort::useViewPort() const void ViewPort::bindView(Shader* shader) const{ shader->useShader(); - glUniformMatrix4fv(shader->getUniformLocation("projection"), 1, false, value_ptr(projection)); - glUniformMatrix4fv(shader->getUniformLocation("view"), 1, false, value_ptr(view)); + glUniformMatrix4fv(shader->getUniformLocation("uProjection"), 1, false, value_ptr(projection)); + glUniformMatrix4fv(shader->getUniformLocation("uView"), 1, false, value_ptr(view)); } void ViewPort::bindView(Shader* shader, vec3 pos) const{ shader->useShader(); - glUniformMatrix4fv(shader->getUniformLocation("projection"), 1, false, value_ptr(projection)); - glUniformMatrix4fv(shader->getUniformLocation("view"), 1, false, value_ptr(translate(view,-pos))); + glUniformMatrix4fv(shader->getUniformLocation("uProjection"), 1, false, value_ptr(projection)); + glUniformMatrix4fv(shader->getUniformLocation("uView"), 1, false, value_ptr(translate(view,-pos))); } void ViewPort::rotateView(float angle_x, float angle_y){ diff --git a/Weave/Graphix/matM.cpp b/Weave/Graphix/matM.cpp new file mode 100644 index 0000000..85e4f07 --- /dev/null +++ b/Weave/Graphix/matM.cpp @@ -0,0 +1,60 @@ +#include "matM.h" + +#include "GLM.h" + + +matM::matM() +{ +} + + +matM::~matM() +{ +} + +void matM::transform() +{ +} + +void matM::rotate() +{ +} + +void matM::rotateC() +{ +} + +void matM::skale() +{ +} + +void matM::skaleC() +{ +} + + +void matM::setPosition() +{ +} + + +mat4 matM::getMat4() const +{ + return mat4(1.f); +} + +matM::operator mat4() const +{ + return mat4(1.f); +} + + +vec3 matM::getPosition() const +{ + return vec3(0.f); +} + +matM::operator vec3() const +{ + return vec3(0.f); +} diff --git a/Weave/Graphix/matM.h b/Weave/Graphix/matM.h new file mode 100644 index 0000000..fbfbb0d --- /dev/null +++ b/Weave/Graphix/matM.h @@ -0,0 +1,31 @@ +#pragma once + +#include "glm\glm.hpp" + +using glm::mat4; +using glm::vec3; + +class matM +{ +public: + matM(); + ~matM(); + + void transform(); + void rotate(); + void rotateC(); + void skale(); + void skaleC(); + + void setPosition(); + + mat4 getMat4() const; + operator mat4() const; + + vec3 getPosition() const; + operator vec3() const; + +private: + mat4 matrix; +}; + diff --git a/Weave/Message.cpp b/Weave/Message.cpp index 82af28e..1d1d020 100644 --- a/Weave/Message.cpp +++ b/Weave/Message.cpp @@ -19,7 +19,7 @@ void Message::error(string _msg) { cerr << currentDateTime() << " E " << _msg << endl; system("pause"); - exit(-1); +// exit(-1); } void Message::warning(string _msg) diff --git a/models/SkyBox.blend b/models/SkyBox.blend new file mode 100644 index 0000000..c549e10 Binary files /dev/null and b/models/SkyBox.blend differ diff --git a/models/SkyBox.blend1 b/models/SkyBox.blend1 new file mode 100644 index 0000000..55de0ed Binary files /dev/null and b/models/SkyBox.blend1 differ diff --git a/models/SkyBox.dae b/models/SkyBox.dae new file mode 100644 index 0000000..a98e098 --- /dev/null +++ b/models/SkyBox.dae @@ -0,0 +1,71 @@ + + + + + Blender User + Blender 2.73.0 commit date:2015-01-20, commit time:18:16, hash:bbf09d9 + + 2015-04-16T10:05:45 + 2015-04-16T10:05:45 + + Z_UP + + + + + + + -1 -1 0 1 -1 0 -1 1 0 1 1 0 + + + + + + + + + + 0 0 1 0 0 1 + + + + + + + + + + 0.9999001 9.998e-5 0.9999001 0.9999001 9.998e-5 0.9999001 1.0004e-4 9.998e-5 0.9999001 9.998e-5 9.998e-5 0.9999001 + + + + + + + + + + + + + + + 3 3 +

1 0 0 3 0 1 2 0 2 0 1 3 1 1 4 2 1 5

+
+
+
+
+ + + + + 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 1 + + + + + + + +
\ No newline at end of file diff --git a/models/box/box.blend b/models/box/box.blend new file mode 100644 index 0000000..783ffa4 Binary files /dev/null and b/models/box/box.blend differ diff --git a/models/box/box.blend1 b/models/box/box.blend1 new file mode 100644 index 0000000..83b4df4 Binary files /dev/null and b/models/box/box.blend1 differ diff --git a/models/box/box.dae b/models/box/box.dae new file mode 100644 index 0000000..5dd63d4 --- /dev/null +++ b/models/box/box.dae @@ -0,0 +1,212 @@ + + + + + Blender User + Blender 2.66.1 r55078 + + 2014-05-04T16:54:05 + 2014-05-04T16:54:05 + + Z_UP + + + + + + + 49.13434 + 1.777778 + 0.1 + 100 + + + + + + + + + + 1 1 1 + 1 + 0 + 0.00111109 + + + + + 0.000999987 + 1 + 0.1 + 0.1 + 1 + 1 + 1 + 2 + 0 + 1 + 1 + 1 + 1 + 1 + 0 + 2880 + 2 + 30.002 + 1.000799 + 0.04999995 + 29.99998 + 1 + 2 + 0 + 0 + 1 + 1 + 1 + 1 + 8192 + 1 + 1 + 0 + 1 + 1 + 1 + 3 + 0 + 0 + 0 + 0 + 45 + 0 + 1 + 1 + 1 + 3 + 0.15 + 75 + 1 + 1 + 0 + 1 + 1 + 0 + + + + + + + + + + + + 0 0 0 1 + + + 0 0 0 1 + + + 0.64 0.64 0.64 1 + + + 0.5 0.5 0.5 1 + + + 50 + + + 1 + + + + + + 1 + + + + 1 + + + + + + + + + + + + 1 1 -1 1 -1 -1 -1 -0.9999998 -1 -0.9999997 1 -1 1 0.9999995 1 0.9999994 -1.000001 1 -1 -0.9999997 1 -1 1 1 + + + + + + + + + + 0 0 -1 0 0 1 1 -2.83122e-7 0 -2.83122e-7 -1 0 -1 2.23517e-7 -1.3411e-7 2.38419e-7 1 2.08616e-7 + + + + + + + + + + 0 0 0 -1 -1 -0.9999999 -0.9999998 2.38419e-7 2.38419e-7 0.9999998 -1 1 -1 1.78814e-7 -3.57628e-7 -2.98023e-7 0 0 -2.38419e-7 1 -1 1 -1 0 0 0 -3.57628e-7 1 -1 1 -1 0 0 0 1.78814e-7 1 1 1 1 0 2.38419e-7 0 0 -1 -0.9999998 -1 -1 0 + + + + + + + + + + + + + + + 4 4 4 4 4 4 +

0 0 0 1 0 1 2 0 2 3 0 3 4 1 4 7 1 5 6 1 6 5 1 7 0 2 8 4 2 9 5 2 10 1 2 11 1 3 12 5 3 13 6 3 14 2 3 15 2 4 16 6 4 17 7 4 18 3 4 19 4 5 20 0 5 21 3 5 22 7 5 23

+
+
+ 1 +
+
+ + + + + 0.6858805 -0.3173701 0.6548619 7.481132 0.7276338 0.3124686 -0.6106656 -6.50764 -0.01081678 0.8953432 0.4452454 5.343665 0 0 0 1 + + + + -0.2908646 -0.7711008 0.5663932 4.076245 0.9551712 -0.1998834 0.2183912 1.005454 -0.05518906 0.6045247 0.7946723 5.903862 0 0 0 1 + + + + 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/shader/basicTexture_FS.hlsl b/shader/basicTexture_FS.hlsl index daaefbc..1d8048d 100644 --- a/shader/basicTexture_FS.hlsl +++ b/shader/basicTexture_FS.hlsl @@ -3,12 +3,11 @@ //in worldNormal; in vec2 fUVs; -out vec4 color; +out vec4 FragmentColor; -uniform sampler2D ColorTexture; +uniform sampler2D uColorTexture; void main() { - vec3 uvColor = texture(ColorTexture, fUVs).rgb; - color = vec4(uvColor, 0.7); + FragmentColor = vec4(texture(uColorTexture, fUVs).rgb, 0.7); } \ No newline at end of file diff --git a/shader/basicTexture_VS.hlsl b/shader/basicTexture_VS.hlsl index 3b2d055..bd3bd42 100644 --- a/shader/basicTexture_VS.hlsl +++ b/shader/basicTexture_VS.hlsl @@ -1,19 +1,18 @@ //Vertex Shader #version 330 -in vec3 normal, position; -//in vec3 lightposition -in vec2 uv; +in vec3 aNormal, aPosition; +//in vec3 lightPosition +in vec2 aUV; out vec3 worldNormal, worldLightPoint1; out vec2 fUVs; -out float visNormal, SpecularCosPoint1, SpecularCosDirection1; +out float SpecularCosPoint1, SpecularCosDirection1; -uniform mat4 projection, view, model; -uniform int inv = 1; +uniform mat4 uProjection, uView, uModel; -uniform int bloom = 1; -uniform int transp = 1; +uniform int uEnableBloom = 1; +uniform int uEnableTransp = 1; void main() { @@ -25,18 +24,16 @@ void main() vec3 DirectionalLightDirection1 = normalize(vec3(-2.0f, -2.0f, -2.0f)); - fUVs = uv; - vec4 world_position = model * vec4(position, 1); - worldLightPoint1 = PointLightPosition1 - world_position.xyz; + fUVs = aUV; + vec4 world_Position = uModel * vec4(aPosition, 1); + worldLightPoint1 = PointLightPosition1 - world_Position.xyz; - gl_Position = projection * view * world_position; - worldNormal = (model * inv * vec4(normal, 0.0f)).xyz; -// visNormal = (view * vec4(worldNormal, 0.0f)).z; + gl_Position = uProjection * uView * world_Position; + worldNormal = (uModel * vec4(aNormal, 0.0f)).xyz; + SpecularCosPoint1 = clamp(dot(vec3(0.0f, 0.0f, -1.0f), normalize((uProjection * uView * vec4(reflect(-PointLightPosition1, worldNormal), 0.0f)).xyz)), 0, 1); + SpecularCosDirection1 = clamp(dot(vec3(0.0f, 0.0f, -1.0f), normalize((uProjection * uView * vec4(reflect(-DirectionalLightDirection1, worldNormal), 0.0f)).xyz)), 0, 1); - SpecularCosPoint1 = clamp(dot(vec3(0.0f, 0.0f, -1.0f), normalize((projection * view * vec4(reflect(-PointLightPosition1, worldNormal), 0.0f)).xyz)), 0, 1); - SpecularCosDirection1 = clamp(dot(vec3(0.0f, 0.0f, -1.0f), normalize((projection * view * vec4(reflect(-DirectionalLightDirection1, worldNormal), 0.0f)).xyz)), 0, 1); - - //worldNormal = vec3(SpecularCos, SpecularCos, SpecularCos); + //worldnormal = vec3(SpecularCos, SpecularCos, SpecularCos); } \ No newline at end of file diff --git a/shader/basic_FS.hlsl b/shader/basic_FS.hlsl index fd96435..d17d213 100644 --- a/shader/basic_FS.hlsl +++ b/shader/basic_FS.hlsl @@ -1,7 +1,7 @@ //Fragment Shader #version 330 -out vec4 color; +out vec4 FragmentColor; void main(){ - color = vec4(0,0.3,0,0.6); + FragmentColor = vec4(0, 0.3, 0, 0.6); } \ No newline at end of file diff --git a/shader/basic_VS.hlsl b/shader/basic_VS.hlsl index 15e757e..2d4c11c 100644 --- a/shader/basic_VS.hlsl +++ b/shader/basic_VS.hlsl @@ -1,12 +1,11 @@ //Vertex Shader #version 330 -in vec3 position; -uniform mat4 projection; -uniform mat4 model; -uniform mat4 view; +in vec3 aPosition; +uniform mat4 uProjection; +uniform mat4 uModel; +uniform mat4 uView; void main(){ - //gl_Position = projection * model * vec4(position, 1); - gl_Position = projection * view * model * vec4(position, 1); + gl_Position = uProjection * uView * uModel * vec4(aPosition, 1); } \ No newline at end of file diff --git a/shader/lightingTexture_FS.hlsl b/shader/lightingTexture_FS.hlsl index e36e627..24faf93 100644 --- a/shader/lightingTexture_FS.hlsl +++ b/shader/lightingTexture_FS.hlsl @@ -4,21 +4,16 @@ in vec3 worldNormal, worldLightPoint1; in vec2 fUVs; in float visNormal, SpecularCosPoint1, SpecularCosDirection1; -out vec4 color; +out vec4 FragmentColor; -uniform sampler2D ColorTexture; +uniform sampler2D uColorTexture; void main() { - //if (visNormal < -0.2) - //{ - // discard; - //} + float specularConst = 3.0f; vec3 normal = normalize(worldNormal); - vec4 uvColor = texture(ColorTexture, fUVs); - - + vec4 uvColor = texture(uColorTexture, fUVs); vec3 PointLightDirection1 = normalize(worldLightPoint1); @@ -35,22 +30,19 @@ void main() float squaredist1 = worldLightPoint1.x * worldLightPoint1.x + worldLightPoint1.y * worldLightPoint1.y + worldLightPoint1.z * worldLightPoint1.z; - - //if (uvColor.a < 0.3) // discard; - - color = vec4(uvColor.rgb * (AmbientLightColor + FragmentColor = vec4(uvColor.rgb * (AmbientLightColor + PointLightColor1 * (cosThetaPoint1 + pow(SpecularCosPoint1, specularConst)) / squaredist1 + DirectionalLightColor1 * (cosThetaDirection1 + pow(SpecularCosDirection1, specularConst)) ), uvColor.a); - //color = vec4(worldNormal, 1.0f); - //color = vec4(length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, 1.0f); + //FragmentColor = vec4(worldNormal, 1.0f); + //FragmentColor = vec4(length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, 1.0f); - //vec3 uvColor = texture(ColorTexture, fUVs).rgb; - //color = vec4(uvColor, 1.0); + //vec3 uvColor = texture(uColorTexture, fUVs).rgb; + //FragmentColor = vec4(uvColor, 1.0); } diff --git a/shader/perspective_VS.hlsl b/shader/perspective_VS.hlsl index 032eeef..52dfb82 100644 --- a/shader/perspective_VS.hlsl +++ b/shader/perspective_VS.hlsl @@ -1,12 +1,12 @@ //Vertex Shader #version 330 -in vec3 position; -uniform mat4 projection; -uniform mat4 view; -uniform mat4 model; +in vec3 aPosition; +uniform mat4 uProjection; +uniform mat4 uView; +uniform mat4 uModel; void main(){ - gl_Position = projection * view * model * vec4(position, 1); - //gl_Position = projection * view * model * vec4(vertexPosition, 1); + gl_Position = uProjection * uView * uModel * vec4(aPosition, 1); + //gl_Position = uProjection * uView * uModel * vec4(vertexPosition, 1); } \ No newline at end of file diff --git a/shader/skybox_FS.hlsl b/shader/skybox_FS.hlsl new file mode 100644 index 0000000..1e1c0cc --- /dev/null +++ b/shader/skybox_FS.hlsl @@ -0,0 +1,10 @@ +//Fragment Shader +#version 330 +uniform samplerCube uColorTexture; + +smooth in vec3 eyeDirection; +out vec4 FragmentColor; + +void main(){ + FragmentColor = texture(uColorTexture, eyeDirection); +} diff --git a/shader/skybox_VS.hlsl b/shader/skybox_VS.hlsl new file mode 100644 index 0000000..9c2cf3c --- /dev/null +++ b/shader/skybox_VS.hlsl @@ -0,0 +1,18 @@ +//Vertex Shader +#version 330 + +in vec3 position; +uniform mat4 projection; +uniform mat4 model; +uniform mat4 view; + +smooth out vec3 eyeDirection; + +void main() { + mat4 invProjection = inverse(projection); + mat3 invModelview = mat3(1);// transpose(mat3(model)); + vec3 unprojected = (invProjection * vec4(position, 1)).xyz; + eyeDirection = invModelview * unprojected; + + gl_Position = vec4(position,1); +} \ No newline at end of file diff --git a/textures/model_skybox.png b/textures/model_skybox.png new file mode 100644 index 0000000..beb0696 Binary files /dev/null and b/textures/model_skybox.png differ