From: Peter Schaefer Date: Tue, 12 May 2015 22:19:19 +0000 (+0200) Subject: fixed build MeshTree (but is very slow) X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=7b6b8f1d9d9d31de1aea1ed7090eef3707c0f8db;p=cgue_weave.git fixed build MeshTree (but is very slow) new SkyBox --- diff --git a/CGUE2015_Weave.sln b/CGUE2015_Weave.sln index abd53b7..8ce27c3 100644 --- a/CGUE2015_Weave.sln +++ b/CGUE2015_Weave.sln @@ -13,9 +13,10 @@ 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_color_FS.hlsl = shader\skybox_color_FS.hlsl - shader\skybox_FS.hlsl = shader\skybox_FS.hlsl shader\skybox_VS.hlsl = shader\skybox_VS.hlsl + shader\skyplane_color_FS.hlsl = shader\skyplane_color_FS.hlsl + shader\skyplane_FS.hlsl = shader\skyplane_FS.hlsl + shader\skyplane_VS.hlsl = shader\skyplane_VS.hlsl EndProjectSection EndProject Global diff --git a/Weave/Game.cpp b/Weave/Game.cpp index f3bee9b..4098fa0 100644 --- a/Weave/Game.cpp +++ b/Weave/Game.cpp @@ -48,7 +48,7 @@ Game::Game() : playing(true) // load LVL - SceneObject* tmp_world = new SceneObject(shader1, scale(vec3(2.5f,1.f,2.5f)), vec4(4.0f, 1.0f, 1.0f, 2.0f), "level_test.dae", "model_levelTest_2D.png"); + SceneObject* tmp_world = new SceneObject(shader1, scale(vec3(2.5f,1.f,2.5f)), vec4(4.0f, 1.0f, 1.0f, 2.0f), "level_test.dae", "model_levelTest_2D.jpg"); tmp_world->ignore = true; current_world->addObject(tmp_world); @@ -69,6 +69,7 @@ Game::Game() : playing(true) //current_world->addObject(new SceneObject(shader1, translate(vec3(-3.f, .4f, 0.f))*scale(vec3(3.f)), "cow/cow.dae", "model_cow_2D.jpg")); current_world->addObject(new SceneObject(shader1, translate(vec3(-3.f, .4f, 0.f))*scale(vec3(.32f)), vec4(3.0f, 0.5f, 0.4f, 1.5f), "duck.dae", "model_duck_2D.png")); current_world->addObject(new SceneObject(shader1, translate(vec3(-5.f, .4f, 0.f))*scale(vec3(.32f)), vec4(3.0f, 3.f, 0.4f, 1.5f), "duck.dae", "model_duck_2D.png")); + current_world->addObject(new SceneObject(shader1, translate(vec3(-5.f, 3.f, 0.f))*scale(vec3(.32f)), vec4(3.0f, 3.f, 0.4f, 1.5f), "SkyBox.dae", "model_SkyBox_2D.jpg")); current_world->addObject(new EventBox(translate(vec3(3.f, .4f, 0.f)),EB_LOSTZONE)); current_world->addObject(new EventBox(translate(vec3(3.f, .4f, -15.f)), EB_WINZONE)); diff --git a/Weave/Graphix/Model/IMesh.cpp b/Weave/Graphix/Model/IMesh.cpp index a87d788..5ea54e6 100644 --- a/Weave/Graphix/Model/IMesh.cpp +++ b/Weave/Graphix/Model/IMesh.cpp @@ -1,9 +1,7 @@ #include "IMesh.h" #include -#include -#include -#include + #include "../../GLM.h" @@ -63,7 +61,7 @@ IMesh::IMesh(const aiMesh* _mesh, const mat4& _transformation) : modelMat(_trans root->getBBmm(min, max); updateBB(min, max); #else - updateBB(numvertices, vertex); + updateBB(numvertices, vertex,modelMat); #endif genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex); @@ -102,73 +100,6 @@ void IMesh::useModelMat(const mat4& _model, Shader* _shader) const // //} - -bool IMesh::import(const string& _modelpath, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, uint _mindex) const -{ - Assimp::Importer importer; - - const aiScene* scene = importer.ReadFile("../models/" + _modelpath, aiProcess_GenUVCoords | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType); //aiProcess_PreTransformVertices - if (!scene) - { - Message::error("The file " + _modelpath + " couldn't be read.\n" + importer.GetErrorString()); - return false; - } - - if (!scene->HasMeshes() || scene->mNumMeshes <= _mindex) - { - Message::error("The file " + _modelpath + " doesn't contain any nodes."); - return false; - } - - return import(scene->mMeshes[_mindex], numvertices, numfaces, vertex, uvs, normals, index); -} - -bool IMesh::import(const aiMesh* mesh, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index) const -{ - - numvertices = mesh->mNumVertices; - numfaces = mesh->mNumFaces; - vertex = new float[numvertices * 3]; - uvs = new float[numvertices * 2]; - index = new uint[numfaces * 3]; - normals = new float[numvertices * 3]; - //aiFace* faces = mesh->mFaces; - - - //load vertices from Mesh - for (uint i = 0; i < numvertices; i++) - { - vertex[3 * i] = mesh->mVertices[i].x; - vertex[3 * i + 1] = mesh->mVertices[i].y; - vertex[3 * i + 2] = mesh->mVertices[i].z; - } - - //load UVs from Mesh - for (uint i = 0; i < numvertices; i++) - { - uvs[2 * i] = mesh->mTextureCoords[0][i].x;//[i]->x; - uvs[2 * i + 1] = mesh->mTextureCoords[0][i].y;//[i]->y; - } - - //load indices from Mesh - for (uint i = 0; i < numfaces; i++) - { - index[3 * i] = mesh->mFaces[i].mIndices[0]; - index[3 * i + 1] = mesh->mFaces[i].mIndices[1]; - index[3 * i + 2] = mesh->mFaces[i].mIndices[2]; - } - - //load normals from Mesh - for (uint i = 0; i < numvertices; i++) - { - normals[3 * i] = mesh->mNormals[i].x; - normals[3 * i + 1] = mesh->mNormals[i].y; - normals[3 * i + 2] = mesh->mNormals[i].z; - } - - return true; -} - Overlap IMesh::checkColS2O(const mat4& _mMat, const Model* _model, const mat4& _modelMat) const { //Outer BBox @@ -245,6 +176,16 @@ Node* IMesh::buildMeshTree(const list& _triList, vec3 center, vec3 size) //catch if list has only two elements => 2 LEAFS if (_triList.size() == 2) return new Node(center, size, _triList.front(), _triList.back()); + if (_triList.size() == 3) + { + vec3 nC, nS; + list tmpList = _triList; + Node* tmpNode = tmpList.front(); + tmpList.pop_front(); + getPSfromNodeList(nC, nS, tmpList); + + return new Node(center, size, tmpNode, buildMeshTree(tmpList, nC, nS)); + } //find longest dist vec3 sort = sortVec3(size); diff --git a/Weave/Graphix/Model/IMesh.h b/Weave/Graphix/Model/IMesh.h index 6fb78e8..4a3c6e1 100644 --- a/Weave/Graphix/Model/IMesh.h +++ b/Weave/Graphix/Model/IMesh.h @@ -9,7 +9,6 @@ class Shader; class Texture; -struct aiMesh; class IMesh : public Model { @@ -74,11 +73,6 @@ protected: float *vertex = nullptr, *normals = nullptr, *uvs = nullptr; uint *index = nullptr; - // Mesh Speichern? - bool import(const std::string& modelpath, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index , uint mindex = 0) const; - bool import(const aiMesh* mesh, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index) const; - - Node* root; diff --git a/Weave/Graphix/Model/Model.cpp b/Weave/Graphix/Model/Model.cpp index f7bae80..dec4283 100644 --- a/Weave/Graphix/Model/Model.cpp +++ b/Weave/Graphix/Model/Model.cpp @@ -8,6 +8,10 @@ #include "../Graphix.h" +#include +#include +#include + #include "BBox.h" #include "SkyBox.h" #include "IMetaMesh.h" @@ -512,6 +516,74 @@ float Model::getPDistHit(const vec3& _P, const vec3& _direction) const return 1; } + +bool Model::import(const string& _modelpath, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, uint _mindex) +{ + Assimp::Importer importer; + + const aiScene* scene = importer.ReadFile("../models/" + _modelpath, aiProcess_GenUVCoords | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType); //aiProcess_PreTransformVertices + if (!scene) + { + Message::error("The file " + _modelpath + " couldn't be read.\n" + importer.GetErrorString()); + return false; + } + + if (!scene->HasMeshes() || scene->mNumMeshes <= _mindex) + { + Message::error("The file " + _modelpath + " doesn't contain any nodes."); + return false; + } + + return import(scene->mMeshes[_mindex], numvertices, numfaces, vertex, uvs, normals, index); +} + +bool Model::import(const aiMesh* mesh, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index) +{ + + numvertices = mesh->mNumVertices; + numfaces = mesh->mNumFaces; + vertex = new float[numvertices * 3]; + uvs = new float[numvertices * 2]; + index = new uint[numfaces * 3]; + normals = new float[numvertices * 3]; + //aiFace* faces = mesh->mFaces; + + + //load vertices from Mesh + for (uint i = 0; i < numvertices; i++) + { + vertex[3 * i] = mesh->mVertices[i].x; + vertex[3 * i + 1] = mesh->mVertices[i].y; + vertex[3 * i + 2] = mesh->mVertices[i].z; + } + + //load UVs from Mesh + for (uint i = 0; i < numvertices; i++) + { + uvs[2 * i] = mesh->mTextureCoords[0][i].x;//[i]->x; + uvs[2 * i + 1] = mesh->mTextureCoords[0][i].y;//[i]->y; + } + + //load indices from Mesh + for (uint i = 0; i < numfaces; i++) + { + index[3 * i] = mesh->mFaces[i].mIndices[0]; + index[3 * i + 1] = mesh->mFaces[i].mIndices[1]; + index[3 * i + 2] = mesh->mFaces[i].mIndices[2]; + } + + //load normals from Mesh + for (uint i = 0; i < numvertices; i++) + { + normals[3 * i] = mesh->mNormals[i].x; + normals[3 * i + 1] = mesh->mNormals[i].y; + normals[3 * i + 2] = mesh->mNormals[i].z; + } + + return true; +} + + Model* Model::BoundingBox = nullptr; Model* Model::SkyBoxModel = nullptr; std::unordered_map Model::IMetaModel; diff --git a/Weave/Graphix/Model/Model.h b/Weave/Graphix/Model/Model.h index 106bf0e..a45e2bb 100644 --- a/Weave/Graphix/Model/Model.h +++ b/Weave/Graphix/Model/Model.h @@ -9,6 +9,7 @@ class Shader; class Texture; class Overlap; +struct aiMesh; typedef unsigned int uint; @@ -71,6 +72,11 @@ public: const vec3 normal; }; + + // Mesh Speichern? + static bool import(const std::string& modelpath, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, uint mindex = 0); + static bool import(const aiMesh* mesh, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index); + protected: Model(); virtual ~Model(); diff --git a/Weave/Graphix/Model/SkyBox.cpp b/Weave/Graphix/Model/SkyBox.cpp index ab1a57d..30d4ed5 100644 --- a/Weave/Graphix/Model/SkyBox.cpp +++ b/Weave/Graphix/Model/SkyBox.cpp @@ -3,6 +3,7 @@ #include "GL/glew.h" #include "../Graphix.h" #include "../../GLM.h" +#include "../Shader.h" SkyBox::SkyBox() @@ -10,15 +11,20 @@ SkyBox::SkyBox() numvertices = 4; numfaces = 2; - float vertex[] { -1.f, - 1.f, 0.f, 1.f, - 1.f, 0.f, - 1.f, 1.f, 0.f, 1.f, 1.f, 0.f }; - uint index[] { 1,3,2,0,1,2}; + float *vertex = nullptr, *normals = nullptr, *uvs = nullptr; + uint *index = nullptr; - //import("skybox.dae", numvertices, numfaces, vertex, uvs, normals, index, 0); + //float vertex[] { -1.f, - 1.f, 0.f, 1.f, - 1.f, 0.f, - 1.f, 1.f, 0.f, 1.f, 1.f, 0.f }; + //uint index[] { 1,3,2,0,1,2}; + + import("SkyBox.dae", numvertices, numfaces, vertex, uvs, normals, index, 0); genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex); + //genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals); + genBuffer(uvBuffer, numvertices * 2 * sizeof(float), (void*)uvs); genBuffer(indexBuffer, numfaces * 3 * sizeof(uint), (void*)index); -// delete vertex, index; + delete vertex, index, normals, uvs; } @@ -28,18 +34,27 @@ SkyBox::~SkyBox() void SkyBox::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) const { - glDisable(GL_DEPTH_TEST); + //_shader->useShader(); + //GLint OldCullFaceMode; + //glGetIntegerv(GL_CULL_FACE_MODE, &OldCullFaceMode); + GLint OldDepthFuncMode; + glGetIntegerv(GL_DEPTH_FUNC, &OldDepthFuncMode); + //glCullFace(GL_FRONT); + glDepthFunc(GL_LEQUAL); + //glDisable(GL_DEPTH_TEST); Model::drawModel(_shader, _texture, _modelMat); - glEnable(GL_DEPTH_TEST); + //glEnable(GL_DEPTH_TEST); + //glCullFace(OldCullFaceMode); + glDepthFunc(OldDepthFuncMode); } -void SkyBox::useModelMat(const mat4& _model, Shader* _shader) const -{ -} +//void SkyBox::useModelMat(const mat4& _model, Shader* _shader) const +//{ +//} -void SkyBox::useTexture(Texture* _texture, Shader* _shader) const -{ -} +//void SkyBox::useTexture(Texture* _texture, Shader* _shader) const +//{ +//} void SkyBox::drawBBox(const mat4& _modelMat, const vec4& _color) const { diff --git a/Weave/Graphix/Model/SkyBox.h b/Weave/Graphix/Model/SkyBox.h index 0941718..7faa03e 100644 --- a/Weave/Graphix/Model/SkyBox.h +++ b/Weave/Graphix/Model/SkyBox.h @@ -13,12 +13,11 @@ public: void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const override; //uncommend following lines to use default Loaders - void useModelMat(const mat4& model, Shader* shader) const override; - void useTexture(Texture* texture, Shader* shader) const override; + //void useModelMat(const mat4& model, Shader* shader) const override; + //void useTexture(Texture* texture, Shader* shader) const override; void drawBBox(const mat4& modelMat, const vec4& color = vec4(0.f)) const override; operator std::string() const override; }; - diff --git a/Weave/Graphix/Texture.cpp b/Weave/Graphix/Texture.cpp index 2793649..bec14b7 100644 --- a/Weave/Graphix/Texture.cpp +++ b/Weave/Graphix/Texture.cpp @@ -11,7 +11,6 @@ using std::string; using std::unordered_map; - Texture::Texture(const string& _path, const vec4& _material) : path(_path), handle(-1), TEXTURE_TYPE(-1), material(_material) { //Message::info("Error from before?"); diff --git a/Weave/Scene/Scene.cpp b/Weave/Scene/Scene.cpp index 3f6ef29..62fb940 100644 --- a/Weave/Scene/Scene.cpp +++ b/Weave/Scene/Scene.cpp @@ -150,12 +150,11 @@ void Scene::draw() const viewPort.bindView(*i, lookat->getPosition() + vec3(0.0f, 1.0f, 0.0f)); } - SkyBox.draw(); - for (auto i = SceneObjects.cbegin(); i != SceneObjects.cend(); ++i) { (*i)->draw(); } + SkyBox.draw(); } void Scene::addObject(SceneObject* _add) diff --git a/Weave/Scene/Sky.cpp b/Weave/Scene/Sky.cpp index b27ceba..e089c40 100644 --- a/Weave/Scene/Sky.cpp +++ b/Weave/Scene/Sky.cpp @@ -6,8 +6,9 @@ #include "../GLM.h" -Sky::Sky() : SceneObject(new Shader("skybox_VS.hlsl","skybox_color_FS.hlsl"), mat4(1.f), vec4(1.f), Model::getSkyBoxModel(), "") -{ +Sky::Sky() : SceneObject(new Shader("skybox_VS.hlsl","basicTexture_FS.hlsl"), scale(vec3(20.f)), vec4(1.f), Model::getSkyBoxModel(), "model_skybox_2D.jpg") +{ + modelMat[3][3] = 0; } diff --git a/models/SkyBox.blend b/models/SkyBox.blend index 3a63f80..f20ec97 100644 Binary files a/models/SkyBox.blend and b/models/SkyBox.blend differ diff --git a/models/SkyBox.blend1 b/models/SkyBox.blend1 index c549e10..d3948a4 100644 Binary files a/models/SkyBox.blend1 and b/models/SkyBox.blend1 differ diff --git a/models/SkyBox.dae b/models/SkyBox.dae index 6b67929..95fc6f0 100644 --- a/models/SkyBox.dae +++ b/models/SkyBox.dae @@ -5,53 +5,86 @@ Blender User Blender 2.73.0 commit date:2015-01-20, commit time:18:16, hash:bbf09d9 - 2015-04-21T11:48:56 - 2015-04-21T11:48:56 + 2015-05-12T23:50:25 + 2015-05-12T23:50:25 Z_UP + + + + + + + 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 0 1 -1 0 -1 1 0 1 1 0 + + -1 -1.000001 -0.9999997 -1 -0.9999994 1 -1 1.000001 0.9999992 -1 0.9999993 -1.000001 1 -1.000001 -0.9999989 0.9999999 -0.9999988 1.000001 1 1.000001 0.9999992 1 0.9999998 -1 - + - - 0 0 1 0 0 1 + + 1 0 0 -1 0 0 -2.98023e-7 1 -1.13249e-6 0 -1.01328e-6 -1 2.38418e-7 -1 7.7486e-7 -2.38419e-7 6.55651e-7 1 1 0 0 -1 0 -1.19209e-7 2.38419e-7 1 -5.96046e-7 3.57628e-7 -6.55651e-7 -1 1.19209e-7 -1 6.55651e-7 -3.57628e-7 7.7486e-7 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 + + 0.496875 0.668125 0.246875 0.668125 0.246875 0.338125 0.996875 0.3381249 0.996875 0.668125 0.746875 0.668125 0.246875 0.338125 0.2468749 0.008125007 0.4968749 0.008125007 0.246875 0.668125 -0.003124952 0.6681251 -0.003124952 0.3381251 0.246875 0.668125 0.496875 0.668125 0.4968751 0.998125 0.746875 0.668125 0.496875 0.668125 0.496875 0.338125 0.496875 0.338125 0.496875 0.668125 0.246875 0.338125 0.746875 0.338125 0.996875 0.3381249 0.746875 0.668125 0.496875 0.338125 0.246875 0.338125 0.4968749 0.008125007 0.246875 0.338125 0.246875 0.668125 -0.003124952 0.3381251 0.2468751 0.9981251 0.246875 0.668125 0.4968751 0.998125 0.746875 0.338125 0.746875 0.668125 0.496875 0.338125 - + - - + + - - - - - 3 3 -

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

+ + + + + 3 3 3 3 3 3 3 3 3 3 3 3 +

3 0 0 2 0 1 1 0 2 5 1 3 6 1 4 7 1 5 1 2 6 5 2 7 4 2 8 2 3 9 6 3 10 5 3 11 2 4 12 3 4 13 7 4 14 7 5 15 3 5 16 0 5 17 0 6 18 3 6 19 1 6 20 4 7 21 5 7 22 7 7 23 0 8 24 1 8 25 4 8 26 1 9 27 2 9 28 5 9 29 6 10 30 2 10 31 7 10 32 4 11 33 7 11 34 0 11 35

@@ -59,9 +92,15 @@ - - 2 0 0 0 0 -8.74228e-8 -2 0 0 2 -8.74228e-8 0 0 0 0 1 - + + 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 + + + + + + + diff --git a/shader/basicTexture_VS.hlsl b/shader/basicTexture_VS.hlsl index 78881cc..f017f1f 100644 --- a/shader/basicTexture_VS.hlsl +++ b/shader/basicTexture_VS.hlsl @@ -10,7 +10,7 @@ out vec2 fUVs; out vec3 PointLightPosition1, DirectionalLightDirection1; //uniform vec3 PointLightPosition1, DirectionalLightDirection1; -uniform mat4 uProjection, uView, uModel; +uniform mat4 uProjection, uView, uModel=mat4(1.f); uniform int uEnableBloom = 1; uniform int uEnableTransp = 1; diff --git a/shader/skybox_FS.hlsl b/shader/skybox_FS.hlsl deleted file mode 100644 index 1e1c0cc..0000000 --- a/shader/skybox_FS.hlsl +++ /dev/null @@ -1,10 +0,0 @@ -//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 index 2b85546..f30317d 100644 --- a/shader/skybox_VS.hlsl +++ b/shader/skybox_VS.hlsl @@ -1,21 +1,16 @@ //Vertex Shader #version 330 -in vec3 aPosition; +in vec3 aNormal, aPosition; +in vec2 aUV; -uniform mat4 uInvProjection; -uniform mat4 uModel; -uniform mat4 uView; +out vec2 fUVs; -smooth out vec3 eyeDirection; +uniform mat4 uProjection, uView, uModel=mat4(1.f); -void main() { -// mat4 invProjection = inverse(uProjection); - mat3 invModelview = transpose(mat3(uView)); - vec3 unprojected = (uInvProjection * vec4(aPosition, 1)).xyz; - eyeDirection = invModelview * unprojected; - //eyeDirection = unprojected; - //eyeDirection = aPosition; +void main() +{ - gl_Position = vec4(aPosition,1); + fUVs = aUV; + gl_Position = (uProjection * uView * uModel * vec4(aPosition, 1.f)).xyww; } \ No newline at end of file diff --git a/shader/skybox_color_FS.hlsl b/shader/skybox_color_FS.hlsl deleted file mode 100644 index 1724745..0000000 --- a/shader/skybox_color_FS.hlsl +++ /dev/null @@ -1,9 +0,0 @@ -//Fragment Shader -#version 330 - -smooth in vec3 eyeDirection; -out vec4 FragmentColor; - -void main(){ - FragmentColor = vec4((eyeDirection+vec3(2.f))/4, 0.5); -} diff --git a/shader/skyplane_FS.hlsl b/shader/skyplane_FS.hlsl new file mode 100644 index 0000000..1e1c0cc --- /dev/null +++ b/shader/skyplane_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/skyplane_VS.hlsl b/shader/skyplane_VS.hlsl new file mode 100644 index 0000000..2b85546 --- /dev/null +++ b/shader/skyplane_VS.hlsl @@ -0,0 +1,21 @@ +//Vertex Shader +#version 330 + +in vec3 aPosition; + +uniform mat4 uInvProjection; +uniform mat4 uModel; +uniform mat4 uView; + +smooth out vec3 eyeDirection; + +void main() { +// mat4 invProjection = inverse(uProjection); + mat3 invModelview = transpose(mat3(uView)); + vec3 unprojected = (uInvProjection * vec4(aPosition, 1)).xyz; + eyeDirection = invModelview * unprojected; + //eyeDirection = unprojected; + //eyeDirection = aPosition; + + gl_Position = vec4(aPosition,1); +} \ No newline at end of file diff --git a/shader/skyplane_color_FS.hlsl b/shader/skyplane_color_FS.hlsl new file mode 100644 index 0000000..1724745 --- /dev/null +++ b/shader/skyplane_color_FS.hlsl @@ -0,0 +1,9 @@ +//Fragment Shader +#version 330 + +smooth in vec3 eyeDirection; +out vec4 FragmentColor; + +void main(){ + FragmentColor = vec4((eyeDirection+vec3(2.f))/4, 0.5); +} diff --git a/textures/model_levelTest_2D.jpg b/textures/model_levelTest_2D.jpg new file mode 100644 index 0000000..07c2123 Binary files /dev/null and b/textures/model_levelTest_2D.jpg differ diff --git a/textures/model_skybox_2D.jpg b/textures/model_skybox_2D.jpg new file mode 100644 index 0000000..695846a Binary files /dev/null and b/textures/model_skybox_2D.jpg differ diff --git a/textures/model_skybox_2D.png b/textures/model_skybox_2D.png new file mode 100644 index 0000000..d70e4cb Binary files /dev/null and b/textures/model_skybox_2D.png differ diff --git a/textures/model_skybox_CUBE.png b/textures/model_skybox_CUBE.png deleted file mode 100644 index beb0696..0000000 Binary files a/textures/model_skybox_CUBE.png and /dev/null differ diff --git a/textures/skybox_2D.jpg b/textures/skybox_2D.jpg new file mode 100644 index 0000000..dfbc845 Binary files /dev/null and b/textures/skybox_2D.jpg differ diff --git a/textures/skybox_CUBE.jpg b/textures/skybox_CUBE.jpg deleted file mode 100644 index dfbc845..0000000 Binary files a/textures/skybox_CUBE.jpg and /dev/null differ