44 geomModule._defines.emplace_back(
"verticalBlur uint(PushData0[1].x)" );
45 geomModule._defines.emplace_back(
"layerCount int(PushData0[1].y)" );
46 geomModule._defines.emplace_back(
"layerOffsetRead int(PushData0[1].z)" );
47 geomModule._defines.emplace_back(
"layerOffsetWrite int(PushData0[1].w)" );
49 geomModule._defines.emplace_back(
"layerOffsetWrite int(PushData0[1].w)" );
51 fragModule._defines.emplace_back(
"LAYERED" );
52 fragModule._defines.emplace_back(
"layer uint(PushData0[0].x)" );
53 fragModule._defines.emplace_back(
"size PushData0[0].yz" );
54 fragModule._defines.emplace_back(
"kernelSize int(PushData0[0].w)" );
55 fragModule._defines.emplace_back(
"verticalBlur uint(PushData0[1].x)" );
58 shaderDescriptor.
_modules.push_back(vertModule);
59 shaderDescriptor.
_modules.push_back(geomModule);
60 shaderDescriptor.
_modules.push_back(fragModule);
64 blurDepthMapShader.waitForReady(
true);
79 std::array<vec2<F32>*, 12> blurSizeConstants = {
95 for (
size_t i = 1u; i < blurSizeConstants.size(); ++i )
97 blurSizeConstants[i]->set((*blurSizeConstants[i - 1]) * 0.5f);
117 colourDescriptor._dataType = texDescriptor._dataType;
118 colourDescriptor._baseFormat = texDescriptor._baseFormat;
119 colourDescriptor._layerCount = 1u;
127 depthDescriptor._layerCount = 1u;
136 desc.
_name =
"Single_ShadowMap_Draw";
146 blurMapDescriptor._dataType = texDescriptor._dataType;
147 blurMapDescriptor._baseFormat = texDescriptor._baseFormat;
148 blurMapDescriptor._layerCount = 1u;
157 desc.
_name =
"Single_Blur";
179 const vec3<F32> lightPos = light.positionCache();
180 const F32 farPlane = light.range() * 1.2f;
183 const mat4<F32> viewMatrix = shadowCameras[0]->lookAt(lightPos, lightPos + light.directionCache() * farPlane);
184 const mat4<F32> projectionMatrix = shadowCameras[0]->setProjection(1.0f, 90.0f,
vec2<F32>(0.01f, farPlane));
185 shadowCameras[0]->updateLookAt();
205 auto cmd = GFX::EnqueueCommand<GFX::BeginDebugScopeCommand>(bufferInOut);
207 cmd->_scopeId = lightIndex;
209 _context.
context().
kernel().renderPassManager()->doCustomPass(shadowCameras[0], params, bufferInOut, memCmdInOut);
232 GFX::EnqueueCommand<GFX::EndDebugScopeCommand>(bufferInOut);
250 beginRenderPassCmd._name =
"DO_SM_BLUR_PASS_HORIZONTAL";
253 GFX::EnqueueCommand<GFX::BindPipelineCommand>(bufferInOut)->_pipeline =
_blurPipeline;
255 auto cmd = GFX::EnqueueCommand<GFX::BindShaderResourcesCommand>(bufferInOut);
258 Set( binding.
_data, shadowAtt->texture(), shadowAtt->_descriptor._sampler );
266 GFX::EnqueueCommand<GFX::SendPushConstantsCommand>(bufferInOut)->_fastData =
_shaderConstants;
268 GFX::EnqueueCommand<GFX::DrawCommand>(bufferInOut)->_drawCommands.emplace_back();
270 GFX::EnqueueCommand<GFX::EndRenderPassCommand>(bufferInOut);
273 beginRenderPassCmd._target = handle.
_targetID;
274 beginRenderPassCmd._name =
"DO_SM_BLUR_PASS_VERTICAL";
279 auto cmd = GFX::EnqueueCommand<GFX::BindShaderResourcesCommand>(bufferInOut);
282 Set( binding.
_data, blurAtt->texture(), blurAtt->_descriptor._sampler );
291 GFX::EnqueueCommand<GFX::SendPushConstantsCommand>( bufferInOut )->_fastData =
_shaderConstants;
293 GFX::EnqueueCommand<GFX::DrawCommand>(bufferInOut)->_drawCommands.emplace_back();
295 GFX::EnqueueCommand<GFX::EndRenderPassCommand>(bufferInOut);
#define WAIT_FOR_CONDITION(...)
#define PROFILE_SCOPE_AUTO(CATEGORY)
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
GFXRTPool & renderTargetPool() noexcept
Pipeline * newPipeline(const PipelineDescriptor &descriptor)
Create and return a new graphics pipeline. This is only used for caching and doesn't use the object a...
const RenderStateBlock & get2DStateBlock() const noexcept
RenderTargetHandle allocateRT(const RenderTargetDescriptor &descriptor)
bool deallocateRT(RenderTargetHandle &handle)
A light object placed in the scene at a certain position.
void setShadowFloatValue(const U8 index, const F32 newValue) noexcept
void setShadowLightPos(const U8 index, const vec3< F32 > &newValue) noexcept
void setShadowVPMatrix(const U8 index, const mat4< F32 > &newValue) noexcept
const mat4< F32 > & getShadowVPMatrix(const U8 index) const noexcept
U16 getShadowArrayOffset() const noexcept
PlatformContext & context() noexcept
Kernel & kernel() noexcept
Configuration & config() noexcept
Handle< Texture > texture() const
RTAttachment * getAttachment(RTAttachmentType type, RTColourAttachmentSlot slot=RTColourAttachmentSlot::SLOT_0) const
bool updateSampleCount(U8 newSampleCount)
Change msaa sampel count for all attachments.
vec2< U16 > getResolution() const noexcept
static const RenderTargetHandle & getShadowMap(LightType type)
static vector< Camera * > & shadowCameras(const ShadowType type) noexcept
void render(const Camera &playerCamera, Light &light, U16 lightIndex, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut) override
RenderTargetHandle _blurBuffer
SingleShadowMapGenerator(GFXDevice &context)
void blurTarget(U16 layerOffset, GFX::CommandBuffer &bufferInOut)
RenderTargetHandle _drawBufferDepth
~SingleShadowMapGenerator() override
Handle< ShaderProgram > _blurDepthMapShader
PushConstantsStruct _shaderConstants
void updateMSAASampleCount(U8 sampleCount) override
static mat4< T > Multiply(const mat4< T > &matrixA, const mat4< T > &matrixB) noexcept
ret = A * B
void set(const T *v) noexcept
set the 2 components of the vector manually using a source pointer to a (large enough) array
constexpr U8 MAX_SHADOW_CASTING_SPOT_LIGHTS
FColour4 WHITE
Random stuff added for convenience.
FORCE_INLINE T * EnqueueCommand(CommandBuffer &buffer)
constexpr Optick::Category::Type Graphics
Str StringFormat(const char *fmt, Args &&...args)
Handle console commands that start with a forward slash.
FORCE_INLINE void DestroyResource(Handle< T > &handle, const bool immediate=false)
static constexpr U32 RT_DEPTH_ATTACHMENT_IDX
static const mat4< F32 > MAT4_BIAS_ZERO_ONE_Z
constexpr F32 to_F32(const T value)
void Set(DescriptorSetBindingData &dataInOut, ShaderBuffer *buffer, const BufferRange range) noexcept
DescriptorSetBinding & AddBinding(DescriptorSet &setInOut, U8 slot, U16 stageVisibilityMask)
FORCE_INLINE Handle< T > CreateResource(const ResourceDescriptor< T > &descriptor, bool &wasInCache, std::atomic_uint &taskCounter)
RTClearEntry DEFAULT_CLEAR_ENTRY
FORCE_INLINE T * Get(const Handle< T > handle)
constexpr auto to_base(const Type value) -> Type
struct Divide::Configuration::Rendering::ShadowMapping shadowMapping
struct Divide::Configuration::Rendering rendering
static NO_INLINE void printfn(const char *format, T &&... args)
DescriptorSetBindingData _data
RTDrawDescriptor _descriptor
RenderTargetID _destination
PrimitiveTopology _primitiveTopology
Handle< ShaderProgram > _shaderProgramHandle
RenderStateBlock _stateBlock
vector< ShaderModuleDescriptor > _modules
ModuleDefines _globalDefines
bool _layeredRendering
Set to true to bind all image layers to the render target (e.g. for Geometry Shader layered rendering...
const SceneGraphNode * _sourceNode
RTDrawDescriptor _targetDescriptorMainPass
RenderStagePass _stagePass
RTClearDescriptor _clearDescriptorMainPass
InternalRTAttachmentDescriptors _attachments
TextureWrap _wrapU
Texture wrap mode (Or S-R-T)
U8 _anisotropyLevel
The value must be in the range [0...255] and is automatically clamped by the max HW supported level.
TextureMipSampling _mipSampling