mirror of
https://github.com/bailwillharr/engine.git
synced 2024-09-21 04:51:18 +00:00
Fix sphere normals
This commit is contained in:
parent
6e45aba65b
commit
165d2687a8
11
res/engine/shaders/showNormals.frag
Normal file
11
res/engine/shaders/showNormals.frag
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#version 450
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 fragNorm;
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 outColor;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 baseColor = fragNorm;
|
||||||
|
outColor = vec4(baseColor, 1.0);
|
||||||
|
}
|
||||||
|
|
21
res/engine/shaders/showNormals.vert
Normal file
21
res/engine/shaders/showNormals.vert
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#version 450
|
||||||
|
|
||||||
|
layout(binding = 0) uniform UBO {
|
||||||
|
mat4 proj;
|
||||||
|
} ubo;
|
||||||
|
|
||||||
|
layout( push_constant ) uniform Constants {
|
||||||
|
mat4 model;
|
||||||
|
mat4 view;
|
||||||
|
} constants;
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 inPosition;
|
||||||
|
layout(location = 1) in vec3 inNorm;
|
||||||
|
layout(location = 2) in vec2 inUV;
|
||||||
|
|
||||||
|
layout(location = 0) out vec3 fragNorm;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = ubo.proj * constants.view * constants.model * vec4(inPosition, 1.0);
|
||||||
|
fragNorm = mat3(transpose(inverse(constants.model))) * inNorm;
|
||||||
|
}
|
@ -79,8 +79,8 @@ namespace engine {
|
|||||||
vertParams.hasUV0 = true;
|
vertParams.hasUV0 = true;
|
||||||
auto texturedShader = std::make_unique<resources::Shader>(
|
auto texturedShader = std::make_unique<resources::Shader>(
|
||||||
gfx(),
|
gfx(),
|
||||||
getResourcePath("engine/shaders/texture.vert").c_str(),
|
getResourcePath("engine/shaders/textured.vert").c_str(),
|
||||||
getResourcePath("engine/shaders/texture.frag").c_str(),
|
getResourcePath("engine/shaders/textured.frag").c_str(),
|
||||||
vertParams,
|
vertParams,
|
||||||
false,
|
false,
|
||||||
true
|
true
|
||||||
|
@ -1120,7 +1120,7 @@ namespace engine {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (const char* ext : extensions) {
|
for ([[maybe_unused]] const char* ext : extensions) {
|
||||||
DEBUG("Using Vulkan instance extension: {}", ext);
|
DEBUG("Using Vulkan instance extension: {}", ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,10 @@ Texture::Texture(GFXDevice* gfxDevice, const std::string& path, Filtering filter
|
|||||||
int width, height;
|
int width, height;
|
||||||
auto texbuf = util::readImageFile(path, &width, &height);
|
auto texbuf = util::readImageFile(path, &width, &height);
|
||||||
|
|
||||||
gfx::TextureFilter minFilter, magFilter;
|
gfx::TextureFilter minFilter = gfx::TextureFilter::NEAREST;
|
||||||
gfx::MipmapSetting mipmapSetting;
|
gfx::TextureFilter magFilter = gfx::TextureFilter::NEAREST;
|
||||||
bool anisotropyEnable;
|
gfx::MipmapSetting mipmapSetting = gfx::MipmapSetting::OFF;
|
||||||
|
bool anisotropyEnable = false;
|
||||||
|
|
||||||
if (useLinearMagFilter) {
|
if (useLinearMagFilter) {
|
||||||
magFilter = gfx::TextureFilter::LINEAR;
|
magFilter = gfx::TextureFilter::LINEAR;
|
||||||
|
@ -76,8 +76,8 @@ void playGame()
|
|||||||
uint32_t enemy = myScene->createEntity("enemy");
|
uint32_t enemy = myScene->createEntity("enemy");
|
||||||
auto enemyRenderable = myScene->addComponent<engine::RenderableComponent>(enemy);
|
auto enemyRenderable = myScene->addComponent<engine::RenderableComponent>(enemy);
|
||||||
enemyRenderable->material = std::make_unique<engine::resources::Material>(app.getResource<engine::resources::Shader>("engine.textured"));
|
enemyRenderable->material = std::make_unique<engine::resources::Material>(app.getResource<engine::resources::Shader>("engine.textured"));
|
||||||
enemyRenderable->material->m_texture = grassTexture;
|
enemyRenderable->material->m_texture = app.getResource<engine::resources::Texture>("engine.white");
|
||||||
enemyRenderable->mesh = genSphereMesh(app.gfx(), 5.0f, 50, false);
|
enemyRenderable->mesh = genSphereMesh(app.gfx(), 5.0f, 500, false);
|
||||||
auto enemyT = myScene->getComponent<engine::TransformComponent>(enemy);
|
auto enemyT = myScene->getComponent<engine::TransformComponent>(enemy);
|
||||||
enemyT->position.x += 5.0f;
|
enemyT->position.x += 5.0f;
|
||||||
enemyT->position.y += 2.0f;
|
enemyT->position.y += 2.0f;
|
||||||
|
@ -68,11 +68,9 @@ std::unique_ptr<engine::resources::Mesh> genSphereMesh(engine::GFXDevice* gfx, f
|
|||||||
|
|
||||||
vec3 vector1 = (vertices.end() - 1)->pos - (vertices.end() - 2)->pos;
|
vec3 vector1 = (vertices.end() - 1)->pos - (vertices.end() - 2)->pos;
|
||||||
vec3 vector2 = (vertices.end() - 2)->pos - (vertices.end() - 3)->pos;
|
vec3 vector2 = (vertices.end() - 2)->pos - (vertices.end() - 3)->pos;
|
||||||
vec3 norm = normalize(cross(vector1, vector2));
|
vec3 norm = normalize(cross(vector2, vector1));
|
||||||
|
|
||||||
// TODO: FIX NORMALS
|
// NORMALS HAVE BEEN FIXED
|
||||||
if (!windInside)
|
|
||||||
norm = -norm;
|
|
||||||
|
|
||||||
if (flipNormals)
|
if (flipNormals)
|
||||||
norm = -norm;
|
norm = -norm;
|
||||||
|
Loading…
Reference in New Issue
Block a user