diff --git a/res/shaders-vk/lines.vert.glsl b/res/shaders-vk/lines.vert.glsl index 11128bc9c..bae1fc847 100644 --- a/res/shaders-vk/lines.vert.glsl +++ b/res/shaders-vk/lines.vert.glsl @@ -5,7 +5,7 @@ layout (location = 1) in vec4 a_color; layout(location = 0) out vec4 v_color; -layout(binding = 0) uniform Projview { +layout(set = 0, binding = 0) uniform Projview { mat4 u_projview; }; diff --git a/res/shaders-vk/main.frag.glsl b/res/shaders-vk/main.frag.glsl index e5e0d69c8..48a08f1d2 100644 --- a/res/shaders-vk/main.frag.glsl +++ b/res/shaders-vk/main.frag.glsl @@ -17,7 +17,9 @@ layout (set = 0, binding = 1) uniform Fog { }; void main(){ - vec3 fogColor = texture(u_cubemap, a_dir).rgb; + vec3 dir = a_dir; + dir.z = -dir.z; + vec3 fogColor = texture(u_cubemap, dir).rgb; vec4 tex_color = texture(u_texture0, a_texCoord); float depth = (a_distance/256.0); float alpha = a_color.a * tex_color.a; diff --git a/res/shaders-vk/main.vert.glsl b/res/shaders-vk/main.vert.glsl index a98c2e84a..fd18b545d 100644 --- a/res/shaders-vk/main.vert.glsl +++ b/res/shaders-vk/main.vert.glsl @@ -42,7 +42,7 @@ void main(){ a_color = vec4(pow(light, vec3(u_gamma)),1.0f); a_texCoord = v_texCoord; - vec3 skyLightColor = texture(u_cubemap, vec3(-0.4f, -0.05f, -0.4f)).rgb; + vec3 skyLightColor = texture(u_cubemap, vec3(-0.4f, -0.05f, 0.4f)).rgb; skyLightColor.g *= 0.9; skyLightColor.b *= 0.8; skyLightColor = min(vec3(1.0), skyLightColor*SKY_LIGHT_MUL); diff --git a/res/shaders-vk/ui.vert.glsl b/res/shaders-vk/ui.vert.glsl index 092677507..92b6d90a6 100644 --- a/res/shaders-vk/ui.vert.glsl +++ b/res/shaders-vk/ui.vert.glsl @@ -7,7 +7,7 @@ layout (location = 2) in vec4 v_color; layout(location = 0) out vec2 a_textureCoord; layout(location = 1) out vec4 a_color; -layout(binding = 0) uniform Projview { +layout(set = 0, binding = 0) uniform Projview { mat4 u_projview; }; diff --git a/res/shaders/lines.vert.spv b/res/shaders/lines.vert.spv index e71b8b721..d725fe255 100644 Binary files a/res/shaders/lines.vert.spv and b/res/shaders/lines.vert.spv differ diff --git a/res/shaders/main.frag.spv b/res/shaders/main.frag.spv index 664228c71..835619a93 100644 Binary files a/res/shaders/main.frag.spv and b/res/shaders/main.frag.spv differ diff --git a/res/shaders/main.vert.spv b/res/shaders/main.vert.spv index 43b3ec22c..5c7ef7baf 100644 Binary files a/res/shaders/main.vert.spv and b/res/shaders/main.vert.spv differ diff --git a/res/shaders/ui.vert.spv b/res/shaders/ui.vert.spv index b663c6601..cca97546e 100644 Binary files a/res/shaders/ui.vert.spv and b/res/shaders/ui.vert.spv differ diff --git a/src/assets/asset_loaders.cpp b/src/assets/asset_loaders.cpp index b627e761b..d1b253498 100644 --- a/src/assets/asset_loaders.cpp +++ b/src/assets/asset_loaders.cpp @@ -40,8 +40,10 @@ bool assetload::shader(Assets* assets, const string filename, const string name) { #ifdef USE_VULKAN + path vertexFile = paths->find(filename + ".vert.spv"); + path fragmentFile = paths->find(filename + ".frag.spv"); const ShaderType shaderType = toShaderType(name); - IShader* shader = vulkan::loadShader(filename.string() + ".vert.spv", filename.string() + ".frag.spv", shaderType); + IShader* shader = vulkan::loadShader(vertexFile, fragmentFile, shaderType); #else path vertexFile = paths->find(filename+".glslv"); path fragmentFile = paths->find(filename+".glslf"); diff --git a/src/frontend/BlocksPreview.cpp b/src/frontend/BlocksPreview.cpp index 163dbe58f..6efdea942 100644 --- a/src/frontend/BlocksPreview.cpp +++ b/src/frontend/BlocksPreview.cpp @@ -7,6 +7,7 @@ #include "../graphics/Texture.h" #include "../graphics/Atlas.h" #include "../graphics/Batch3D.h" +#include "../graphics-vk/Batch3D.h" #include "../window/Camera.h" #include "../voxels/Block.h" #include "ContentGfxCache.h" @@ -18,7 +19,7 @@ BlocksPreview::BlocksPreview(IShader* shader, Atlas* atlas, const ContentGfxCache* cache) : shader(shader), atlas(atlas), cache(cache) { - batch = new Batch3D(1024); + batch = new vulkan::Batch3D(1024); } BlocksPreview::~BlocksPreview() { @@ -28,10 +29,10 @@ BlocksPreview::~BlocksPreview() { void BlocksPreview::begin(const Viewport* viewport) { this->viewport = viewport; shader->use(); - shader->uniformMatrix("u_projview", - glm::ortho(0.0f, float(viewport->getWidth()), - 0.0f, float(viewport->getHeight()), - -1000.0f, 1000.0f) * + shader->uniformMatrix("u_projview", + glm::ortho(0.0f, float(viewport->getWidth()), + 0.0f, float(viewport->getHeight()), + -1000.0f, 1000.0f) * glm::lookAt(vec3(2, 2, 2), vec3(0.0f), vec3(0, 1, 0))); atlas->getTexture()->bind(); } diff --git a/src/frontend/BlocksPreview.h b/src/frontend/BlocksPreview.h index 3570e0b6c..08213f2c1 100644 --- a/src/frontend/BlocksPreview.h +++ b/src/frontend/BlocksPreview.h @@ -4,6 +4,10 @@ #include "../typedefs.h" #include +namespace vulkan { + class Batch3D; +} + class Viewport; class IShader; class Atlas; @@ -14,7 +18,7 @@ class ContentGfxCache; class BlocksPreview { IShader* shader; Atlas* atlas; - Batch3D* batch; + vulkan::Batch3D* batch; const ContentGfxCache* const cache; const Viewport* viewport; public: diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 671d5d63f..1c2550586 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -65,9 +65,9 @@ HudRenderer::HudRenderer(Engine* engine, gui(engine->getGUI()), cache(cache) { auto menu = gui->getMenu(); - // blocksPreview = new BlocksPreview(assets->getShader("ui3d"), - // assets->getAtlas("blocks"), - // cache); + blocksPreview = new BlocksPreview(assets->getShader("ui3d"), + assets->getAtlas("blocks"), + cache); uicamera = new Camera(vec3(), 1); uicamera->perspective = false; @@ -92,7 +92,11 @@ HudRenderer::HudRenderer(Engine* engine, return L"fps: "+this->fpsString; }))); panel->add(shared_ptr