mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-22 10:37:00 +08:00
feat: pbr (#20)
* feat: add pbr texture * feat(rendering): add normal mapping support for blocks * fix: normal map load * feat(scripts): add batch nearest neighbor upscale script
This commit is contained in:
@@ -136,6 +136,50 @@ constexpr float NORMALS[6][6][3] = {
|
||||
{0.0f, -1.0f, 0.0f},
|
||||
{0.0f, -1.0f, 0.0f}}};
|
||||
|
||||
constexpr float TANGENTS[6][6][3] = {
|
||||
// ===== front (z = +1) =====
|
||||
{{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f}},
|
||||
// ===== right (x = +1) =====
|
||||
{{0.0f, 0.0f, -1.0f},
|
||||
{0.0f, 0.0f, -1.0f},
|
||||
{0.0f, 0.0f, -1.0f},
|
||||
{0.0f, 0.0f, -1.0f},
|
||||
{0.0f, 0.0f, -1.0f},
|
||||
{0.0f, 0.0f, -1.0f}},
|
||||
// ===== back (z = -1) =====
|
||||
{{-1.0f, 0.0f, 0.0f},
|
||||
{-1.0f, 0.0f, 0.0f},
|
||||
{-1.0f, 0.0f, 0.0f},
|
||||
{-1.0f, 0.0f, 0.0f},
|
||||
{-1.0f, 0.0f, 0.0f},
|
||||
{-1.0f, 0.0f, 0.0f}},
|
||||
// ===== left (x = -1) =====
|
||||
{{0.0f, 0.0f, 1.0f},
|
||||
{0.0f, 0.0f, 1.0f},
|
||||
{0.0f, 0.0f, 1.0f},
|
||||
{0.0f, 0.0f, 1.0f},
|
||||
{0.0f, 0.0f, 1.0f},
|
||||
{0.0f, 0.0f, 1.0f}},
|
||||
// ===== top (y = +1) =====
|
||||
{{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f}},
|
||||
// ===== bottom (y = -1) =====
|
||||
{{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f},
|
||||
{1.0f, 0.0f, 0.0f}}};
|
||||
|
||||
#pragma endregion
|
||||
constexpr float CUBE_VER[24] = {0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0,
|
||||
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0,
|
||||
@@ -211,6 +255,22 @@ constexpr float CROSS_NORMALS[2][6][3] = {
|
||||
{0.0f, 1.0f, 0.0f},
|
||||
{0.0f, 1.0f, 0.0f}}};
|
||||
|
||||
constexpr float CROSS_TANGENTS[2][6][3] = {
|
||||
// ===== Plane 1 =====
|
||||
{{0.7071f, 0.0f, 0.7071f},
|
||||
{0.7071f, 0.0f, 0.7071f},
|
||||
{0.7071f, 0.0f, 0.7071f},
|
||||
{0.7071f, 0.0f, 0.7071f},
|
||||
{0.7071f, 0.0f, 0.7071f},
|
||||
{0.7071f, 0.0f, 0.7071f}},
|
||||
// ===== Plane 2 =====
|
||||
{{-0.7071f, 0.0f, 0.7071f},
|
||||
{-0.7071f, 0.0f, 0.7071f},
|
||||
{-0.7071f, 0.0f, 0.7071f},
|
||||
{-0.7071f, 0.0f, 0.7071f},
|
||||
{-0.7071f, 0.0f, 0.7071f},
|
||||
{-0.7071f, 0.0f, 0.7071f}}};
|
||||
|
||||
#pragma endregion
|
||||
// [-1, 1]
|
||||
constexpr float QUAD_VERTICES[] = {
|
||||
@@ -225,6 +285,7 @@ struct Vertex3D {
|
||||
float layer = 0.0f;
|
||||
float nx = 0.0f, ny = 0.0f, nz = 0.0f;
|
||||
float roughness = 1.0f;
|
||||
float tx = 0.0f, ty = 0.0f, tz = 0.0f;
|
||||
};
|
||||
|
||||
struct Vertex2D {
|
||||
|
||||
Reference in New Issue
Block a user