Added normals to vertexdata
This commit is contained in:
@@ -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.
|
||||
|
||||
Binary file not shown.
@@ -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;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Juliet
|
||||
struct Vertex
|
||||
{
|
||||
float Position[3];
|
||||
float Normal[3];
|
||||
float Color[4];
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <Graphics/MeshRenderer.h>
|
||||
|
||||
#include <Core/HAL/Filesystem/Filesystem.h>
|
||||
#include <Core/Logging/LogManager.h>
|
||||
#include <Core/Logging/LogTypes.h>
|
||||
#include <Core/Math/Matrix.h>
|
||||
#include <Core/HAL/Filesystem/Filesystem.h>
|
||||
#include <Graphics/GraphicsDevice.h>
|
||||
#include <Graphics/Mesh.h>
|
||||
#include <Graphics/VertexData.h>
|
||||
@@ -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<Vertex*>(map);
|
||||
// MemCopy(mapVertices + index, vertices + mesh.VertexOffset, mesh.VertexCount * sizeOfVertex);
|
||||
//
|
||||
// // Indices next
|
||||
// uint8* ptrOneByte = static_cast<uint8*>(map);
|
||||
// uint16* dst = reinterpret_cast<uint16*>(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 } },
|
||||
{ { 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 } },
|
||||
{ { -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 } },
|
||||
{ { -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 } },
|
||||
{ { 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 } }
|
||||
{ { -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;
|
||||
|
||||
Reference in New Issue
Block a user