19#include <entt/core/hashed_string.hpp>
36const MAX_POINT_LIGHTS: u32 = 64u;
39 @location(0) position: vec3f,
40 @location(1) normal: vec3f,
41 @location(2) uv: vec2f,
50 viewProjection: mat4x4f,
53@group(0) @binding(0) var<uniform> light: Light;
54@group(1) @binding(0) var<uniform> object: Object;
59) -> @builtin(position) vec4f {
60 return light.viewProjection * object.model * vec4f(input.position, 1.0);
75 return std::min(
count,
static_cast<uint16_t
>(1));
86 for (
auto &&[e, light] : view.each())
94 lightGPUComponent.shadowTextureIndex = passIndex;
113 const auto &lightBindGroup = bindGroupManager.Get(lightGPUComponent.bindGroupData);
114 renderPass.setBindGroup(0, lightBindGroup.GetBindGroup(), 0,
nullptr);
118 for (
auto &&[e, transform, gpuMesh] : view.each())
122 const auto &transformBindGroup = bindGroupManager.Get(transform.bindGroup);
123 renderPass.setBindGroup(1, transformBindGroup.GetBindGroup(), 0,
nullptr);
124 const auto &pointBuffer = bufferContainer.
Get(gpuMesh.pointBufferId);
125 const auto &pointBufferSize = pointBuffer->GetBuffer().getSize();
126 renderPass.setVertexBuffer(0, pointBuffer->GetBuffer(), 0, pointBufferSize);
127 const auto &indexBuffer = bufferContainer.
Get(gpuMesh.indexBufferId);
128 const auto &indexBufferSize = indexBuffer->GetBuffer().getSize();
129 renderPass.setIndexBuffer(indexBuffer->GetBuffer(), wgpu::IndexFormat::Uint32, 0, indexBufferSize);
130 renderPass.drawIndexed(indexBufferSize /
sizeof(uint32_t), 1, 0, 0, 0);
140 .setType(wgpu::BufferBindingType::Uniform)
142 .setVisibility(wgpu::ShaderStage::Vertex)
146 .setType(wgpu::BufferBindingType::Uniform)
147 .setMinBindingSize(
sizeof(glm::mat4) +
sizeof(glm::mat4))
148 .setVisibility(wgpu::ShaderStage::Vertex)
159 .
setFormat(wgpu::TextureFormat::Depth32Float)
171 const auto validations = shaderDescriptor.
validate();
172 if (!validations.empty())
174 for (
const auto &validation : validations)
178 Log::Error(fmt::format(
"Shader Descriptor Validation Error: {} at {}", validation.message,
179 validation.location));
183 Log::Warning(fmt::format(
"Shader Descriptor Validation Warning: {} at {}", validation.message,
184 validation.location));
static int count
Definition SystemSetTest.cpp:7
Shadow(std::string_view name=SHADOW_PASS_NAME)
Definition Shadow.hpp:69
void perPass(uint16_t passIndex, Engine::Core &core) override
Definition Shadow.hpp:78
uint16_t GetNumberOfPasses(Engine::Core &core) override
Definition Shadow.hpp:71
static Graphic::Resource::Shader CreateShader(Graphic::Resource::Context &graphicContext)
Definition Shadow.hpp:134
void UniqueRenderCallback(wgpu::RenderPassEncoder &renderPass, Engine::Core &core) override
Definition Shadow.hpp:101
The core is the place where all the data of the engine is stored. It contains the registry (entities)...
Definition Core.hpp:33
TResource & GetResource()
Get a reference of a resource.
Definition Core.inl:14
Registry & GetRegistry()
Get the entt::registry that contains all components. It should be used to update component through sy...
Definition Core.hpp:50
Wrapper class providing a convenient interface for entity manipulation with the Core....
Definition Entity.hpp:20
decltype(auto) GetComponents()
Get components of type TComponent from the entity.
Definition Entity.hpp:118
Definition AMultipleExecutionRenderPass.hpp:9
AMultipleExecutionRenderPass(std::string_view name)
Definition AMultipleExecutionRenderPass.hpp:11
const auto & GetOutputs(void) const
Definition ARenderPass.hpp:148
Definition ShaderDescriptor.hpp:21
ShaderDescriptor & setVertexEntryPoint(std::string_view entryPoint)
Definition ShaderDescriptor.hpp:50
ShaderDescriptor & setName(std::string_view name)
Definition ShaderDescriptor.hpp:108
ShaderDescriptor & setFragmentEntryPoint(std::string_view entryPoint)
Definition ShaderDescriptor.hpp:56
ShaderDescriptor & addBindGroupLayout(const Utils::BindGroupLayout &layout)
Definition ShaderDescriptor.hpp:73
std::vector< Utils::ValidationError > validate(void) const override
Validate the ShaderDescriptor and all contained layouts/states.
Definition ShaderDescriptor.hpp:127
ShaderDescriptor & addVertexBufferLayout(const Utils::VertexBufferLayout &layout)
Definition ShaderDescriptor.hpp:62
ShaderDescriptor & setShader(std::string_view source)
Definition ShaderDescriptor.hpp:26
ShaderDescriptor & setOutputDepthFormat(const Utils::DepthStencilState &state)
Definition ShaderDescriptor.hpp:90
static Shader Create(const ShaderDescriptor &descriptor, Context &context)
Definition Shader.hpp:45
Definition BindGroupLayout.hpp:13
BindGroupLayout & addEntry(const TEntry &entry)
Definition BindGroupLayout.hpp:18
Definition BufferBindGroupLayoutEntry.hpp:7
Definition DepthStencilState.hpp:8
DepthStencilState & setDepthWriteEnabled(wgpu::OptionalBool enabled)
Definition DepthStencilState.hpp:35
DepthStencilState & setCompareFunction(wgpu::CompareFunction func)
Definition DepthStencilState.hpp:29
DepthStencilState & setFormat(wgpu::TextureFormat format)
Definition DepthStencilState.hpp:41
Definition VertexBufferLayout.hpp:11
VertexBufferLayout & setArrayStride(uint32_t stride)
Definition VertexBufferLayout.hpp:26
VertexBufferLayout & addVertexAttribute(wgpu::VertexFormat format, uint32_t offset, uint32_t shaderLocation)
Definition VertexBufferLayout.hpp:16
VertexBufferLayout & setStepMode(wgpu::VertexStepMode mode)
Definition VertexBufferLayout.hpp:32
ResourceType & Get(const entt::hashed_string &id)
Get the reference to a stored resource.
Definition ResourceManager.hpp:73
Definition AmbientLight.cpp:6
static constexpr std::string_view SHADOW_SHADER_CONTENT
Definition Shadow.hpp:35
static constexpr std::string_view SHADOW_PASS_OUTPUT
Definition Shadow.hpp:23
static const entt::hashed_string SHADOW_BINDGROUP_TEXTURES_ID
Definition Shadow.hpp:32
static constexpr std::string_view SHADOW_BINDGROUP_TEXTURES_NAME
Definition Shadow.hpp:31
static constexpr std::string_view SHADOW_PASS_NAME
Definition Shadow.hpp:25
static constexpr std::string_view SHADOW_SHADER_NAME
Definition Shadow.hpp:27
static const entt::hashed_string SHADOW_PASS_OUTPUT_ID
Definition Shadow.hpp:24
static const entt::hashed_string SHADOW_SHADER_ID
Definition Shadow.hpp:28
static const entt::hashed_string SHADOW_PASS_ID
Definition Shadow.hpp:26
Object::Resource::ResourceManager< std::unique_ptr< AGPUBuffer > > GPUBufferContainer
GPUBufferContainer is a resource that stores GPUBuffer resources.
Definition GPUBufferContainer.hpp:17
Object::Resource::ResourceManager< BindGroup > BindGroupManager
BindGroupManager is a resource that stores BindGroup resources.
Definition BindGroupManager.hpp:17
void Warning(const T &msg) noexcept
Definition Logger.hpp:49
void Error(const T &msg) noexcept
Definition Logger.hpp:51
Definition GPUDirectionalLight.hpp:11
wgpu::TextureView shadowTextureView
Definition GPUDirectionalLight.hpp:17
static uint32_t GPUSize()
Definition DirectionalLightBuffer.hpp:24
@ Warning
Definition IValidable.hpp:13
@ Error
Definition IValidable.hpp:14