diff --git a/AgentData/lighting_and_skybox_plan.md b/AgentData/lighting_and_skybox_plan.md index 653a631..1d99438 100644 --- a/AgentData/lighting_and_skybox_plan.md +++ b/AgentData/lighting_and_skybox_plan.md @@ -226,8 +226,8 @@ graph LR --- -## Open Questions +## Open Questions (Answered) -1. **Cubemap source** — procedural gradient skybox (no asset needed) vs actual HDR cubemap `.dds` file? -2. **Sampler heap** — does the engine already have a linear sampler registered, or does one need to be created? -3. **Specular** — want Blinn-Phong specular in Phase 2, or just diffuse + ambient for now? +1. **Cubemap source** — **Procedural gradient skybox** chosen because asset loading infrastructure is not yet established. +2. **Sampler heap** — Evaluate what exists. However, with a procedural skybox, we won't need a sampler for Phase 3! (The sky color can be procedurally generated from the reconstructed view direction). +3. **Specular** — **Blinn-Phong** specular, structured in an agnostic way so PBR (physically based rendering) parameters can be plugged in later. diff --git a/Assets/compiled/Triangle.vert.dxil b/Assets/compiled/Triangle.vert.dxil index 7e88767..49c09b1 100644 Binary files a/Assets/compiled/Triangle.vert.dxil and b/Assets/compiled/Triangle.vert.dxil differ diff --git a/Assets/source/Triangle.vert.hlsl b/Assets/source/Triangle.vert.hlsl index 705adce..5569b7d 100644 --- a/Assets/source/Triangle.vert.hlsl +++ b/Assets/source/Triangle.vert.hlsl @@ -1,6 +1,7 @@ struct Output { float4 Color : TEXCOORD0; + float3 Normal : TEXCOORD1; float4 Position : SV_Position; }; @@ -12,14 +13,16 @@ Output main(uint vertexIndex : SV_VertexID) ByteAddressBuffer buffer = ResourceDescriptorHeap[BufferIndex]; - uint stride = 28; + uint stride = 40; uint offset = vertexIndex * stride; float3 pos = asfloat(buffer.Load3(offset)); - float4 col = asfloat(buffer.Load4(offset + 12)); + float3 normal = asfloat(buffer.Load3(offset + 12)); + float4 col = asfloat(buffer.Load4(offset + 24)); //output.Position = float4(pos, 1.0f); output.Position = mul(ViewProjection, mul(Model, float4(pos, 1.0f))); output.Color = col; + output.Normal = normal; return output; } diff --git a/Juliet/include/Graphics/VertexData.h b/Juliet/include/Graphics/VertexData.h index 2de9735..5845e86 100644 --- a/Juliet/include/Graphics/VertexData.h +++ b/Juliet/include/Graphics/VertexData.h @@ -5,6 +5,7 @@ namespace Juliet struct Vertex { float Position[3]; + float Normal[3]; float Color[4]; }; diff --git a/Juliet/src/Graphics/MeshRenderer.cpp b/Juliet/src/Graphics/MeshRenderer.cpp index 250b701..6de922d 100644 --- a/Juliet/src/Graphics/MeshRenderer.cpp +++ b/Juliet/src/Graphics/MeshRenderer.cpp @@ -1,9 +1,9 @@ #include +#include #include #include #include -#include #include #include #include @@ -148,21 +148,6 @@ namespace Juliet MemCopy(ptrOneByte + indexOfByteOffset, g_MeshRenderer.Indices.Data, totalIndexBytes); - // index_t index = 0; - // for (Mesh& mesh : g_MeshRenderer.Meshes) - // { - // // Vertices first - // Vertex* mapVertices = static_cast(map); - // MemCopy(mapVertices + index, vertices + mesh.VertexOffset, mesh.VertexCount * sizeOfVertex); - // - // // Indices next - // uint8* ptrOneByte = static_cast(map); - // uint16* dst = reinterpret_cast(ptrOneByte + indexOfByteOffset); - // MemCopy(dst, indices, mesh.IndexCount * sizeOfIndex); - // - // ++index; - // } - CopyBuffer(cmdList, g_MeshRenderer.VertexBuffer, g_MeshRenderer.LoadCopyBuffer, totalVertexBytes, 0, 0); CopyBuffer(cmdList, g_MeshRenderer.IndexBuffer, g_MeshRenderer.LoadCopyBuffer, totalIndexBytes, 0, indexOfByteOffset); @@ -203,42 +188,41 @@ namespace Juliet { Mesh result = {}; - constexpr Vertex vertexData[] = { - // Front Face (Z = -0.5f) — Red - { { -0.5f, 0.5f, -0.5f }, { 0.8f, 0.2f, 0.2f, 1.0f } }, - { { 0.5f, 0.5f, -0.5f }, { 0.8f, 0.2f, 0.2f, 1.0f } }, - { { 0.5f, -0.5f, -0.5f }, { 0.8f, 0.2f, 0.2f, 1.0f } }, - { { -0.5f, -0.5f, -0.5f }, { 0.8f, 0.2f, 0.2f, 1.0f } }, + constexpr Vertex vertexData[] = { // Front Face (Z = -0.5f) — Red + { { -0.5f, 0.5f, -0.5f }, { 0.0f, 0.0f, -1.0f }, { 0.8f, 0.2f, 0.2f, 1.0f } }, + { { 0.5f, 0.5f, -0.5f }, { 0.0f, 0.0f, -1.0f }, { 0.8f, 0.2f, 0.2f, 1.0f } }, + { { 0.5f, -0.5f, -0.5f }, { 0.0f, 0.0f, -1.0f }, { 0.8f, 0.2f, 0.2f, 1.0f } }, + { { -0.5f, -0.5f, -0.5f }, { 0.0f, 0.0f, -1.0f }, { 0.8f, 0.2f, 0.2f, 1.0f } }, - // Back Face (Z = 0.5f) — Green - { { 0.5f, 0.5f, 0.5f }, { 0.2f, 0.8f, 0.2f, 1.0f } }, - { { -0.5f, 0.5f, 0.5f }, { 0.2f, 0.8f, 0.2f, 1.0f } }, - { { -0.5f, -0.5f, 0.5f }, { 0.2f, 0.8f, 0.2f, 1.0f } }, - { { 0.5f, -0.5f, 0.5f }, { 0.2f, 0.8f, 0.2f, 1.0f } }, + // Back Face (Z = 0.5f) — Green + { { 0.5f, 0.5f, 0.5f }, { 0.0f, 0.0f, 1.0f }, { 0.2f, 0.8f, 0.2f, 1.0f } }, + { { -0.5f, 0.5f, 0.5f }, { 0.0f, 0.0f, 1.0f }, { 0.2f, 0.8f, 0.2f, 1.0f } }, + { { -0.5f, -0.5f, 0.5f }, { 0.0f, 0.0f, 1.0f }, { 0.2f, 0.8f, 0.2f, 1.0f } }, + { { 0.5f, -0.5f, 0.5f }, { 0.0f, 0.0f, 1.0f }, { 0.2f, 0.8f, 0.2f, 1.0f } }, - // Top Face (Y = 0.5f) — Blue - { { -0.5f, 0.5f, 0.5f }, { 0.2f, 0.2f, 0.8f, 1.0f } }, - { { 0.5f, 0.5f, 0.5f }, { 0.2f, 0.2f, 0.8f, 1.0f } }, - { { 0.5f, 0.5f, -0.5f }, { 0.2f, 0.2f, 0.8f, 1.0f } }, - { { -0.5f, 0.5f, -0.5f }, { 0.2f, 0.2f, 0.8f, 1.0f } }, + // Top Face (Y = 0.5f) — Blue + { { -0.5f, 0.5f, 0.5f }, { 0.0f, 1.0f, 0.0f }, { 0.2f, 0.2f, 0.8f, 1.0f } }, + { { 0.5f, 0.5f, 0.5f }, { 0.0f, 1.0f, 0.0f }, { 0.2f, 0.2f, 0.8f, 1.0f } }, + { { 0.5f, 0.5f, -0.5f }, { 0.0f, 1.0f, 0.0f }, { 0.2f, 0.2f, 0.8f, 1.0f } }, + { { -0.5f, 0.5f, -0.5f }, { 0.0f, 1.0f, 0.0f }, { 0.2f, 0.2f, 0.8f, 1.0f } }, - // Bottom Face (Y = -0.5f) — Yellow - { { -0.5f, -0.5f, -0.5f }, { 0.8f, 0.8f, 0.2f, 1.0f } }, - { { 0.5f, -0.5f, -0.5f }, { 0.8f, 0.8f, 0.2f, 1.0f } }, - { { 0.5f, -0.5f, 0.5f }, { 0.8f, 0.8f, 0.2f, 1.0f } }, - { { -0.5f, -0.5f, 0.5f }, { 0.8f, 0.8f, 0.2f, 1.0f } }, + // Bottom Face (Y = -0.5f) — Yellow + { { -0.5f, -0.5f, -0.5f }, { 0.0f, -1.0f, 0.0f }, { 0.8f, 0.8f, 0.2f, 1.0f } }, + { { 0.5f, -0.5f, -0.5f }, { 0.0f, -1.0f, 0.0f }, { 0.8f, 0.8f, 0.2f, 1.0f } }, + { { 0.5f, -0.5f, 0.5f }, { 0.0f, -1.0f, 0.0f }, { 0.8f, 0.8f, 0.2f, 1.0f } }, + { { -0.5f, -0.5f, 0.5f }, { 0.0f, -1.0f, 0.0f }, { 0.8f, 0.8f, 0.2f, 1.0f } }, - // Right Face (X = 0.5f) — Cyan - { { 0.5f, 0.5f, -0.5f }, { 0.2f, 0.8f, 0.8f, 1.0f } }, - { { 0.5f, 0.5f, 0.5f }, { 0.2f, 0.8f, 0.8f, 1.0f } }, - { { 0.5f, -0.5f, 0.5f }, { 0.2f, 0.8f, 0.8f, 1.0f } }, - { { 0.5f, -0.5f, -0.5f }, { 0.2f, 0.8f, 0.8f, 1.0f } }, + // Right Face (X = 0.5f) — Cyan + { { 0.5f, 0.5f, -0.5f }, { 1.0f, 0.0f, 0.0f }, { 0.2f, 0.8f, 0.8f, 1.0f } }, + { { 0.5f, 0.5f, 0.5f }, { 1.0f, 0.0f, 0.0f }, { 0.2f, 0.8f, 0.8f, 1.0f } }, + { { 0.5f, -0.5f, 0.5f }, { 1.0f, 0.0f, 0.0f }, { 0.2f, 0.8f, 0.8f, 1.0f } }, + { { 0.5f, -0.5f, -0.5f }, { 1.0f, 0.0f, 0.0f }, { 0.2f, 0.8f, 0.8f, 1.0f } }, - // Left Face (X = -0.5f) — Magenta - { { -0.5f, 0.5f, 0.5f }, { 0.8f, 0.2f, 0.8f, 1.0f } }, - { { -0.5f, 0.5f, -0.5f }, { 0.8f, 0.2f, 0.8f, 1.0f } }, - { { -0.5f, -0.5f, -0.5f }, { 0.8f, 0.2f, 0.8f, 1.0f } }, - { { -0.5f, -0.5f, 0.5f }, { 0.8f, 0.2f, 0.8f, 1.0f } } + // Left Face (X = -0.5f) — Magenta + { { -0.5f, 0.5f, 0.5f }, { -1.0f, 0.0f, 0.0f }, { 0.8f, 0.2f, 0.8f, 1.0f } }, + { { -0.5f, 0.5f, -0.5f }, { -1.0f, 0.0f, 0.0f }, { 0.8f, 0.2f, 0.8f, 1.0f } }, + { { -0.5f, -0.5f, -0.5f }, { -1.0f, 0.0f, 0.0f }, { 0.8f, 0.2f, 0.8f, 1.0f } }, + { { -0.5f, -0.5f, 0.5f }, { -1.0f, 0.0f, 0.0f }, { 0.8f, 0.2f, 0.8f, 1.0f } } }; constexpr size_t cubeVertexCount = ArraySize(vertexData); result.VertexCount = cubeVertexCount;