53 , _sceneRenderState( sceneRenderState )
54 , _renderTarget( renderTarget )
56 , _passIndex( passIndex )
57 , _passVariant( passVariant )
63 _gfxContext( context.gfx() ),
64 _config( context.config() ),
84 occlusionCullField.
_name =
"HiZ Occlusion Cull";
85 occlusionCullField.
_data = &_occlusionCull;
89 _editorComponent.registerField(
MOV( occlusionCullField ) );
93 vaxisField.
_name =
"Show Debug Axis";
94 vaxisField.
_data = &_showAxis;
98 _editorComponent.registerField(
MOV( vaxisField ) );
102 receivesShadowsField.
_name =
"Receives Shadows";
103 receivesShadowsField.
_data = &_receiveShadows;
107 _editorComponent.registerField(
MOV( receivesShadowsField ) );
111 castsShadowsField.
_name =
"Casts Shadows";
112 castsShadowsField.
_data = &_castsShadows;
116 _editorComponent.registerField(
MOV( castsShadowsField ) );
118 _editorComponent.onChangedCbk( [
this](
const std::string_view field )
120 if ( field ==
"Show Axis" )
124 else if ( field ==
"Receives Shadows" )
128 else if ( field ==
"Casts Shadows" )
134 const SceneNode& node = _parentSGN->getNode();
140 occlusionCull(
false );
155 if ( material == INVALID_HANDLE<Material> )
169 materialField.
_name =
"Material";
170 materialField.
_data = mat;
174 _editorComponent.registerField(
MOV( materialField ) );
177 lockLodField.
_name =
"Rendered LOD Level";
184 _editorComponent.registerField(
MOV( lockLodField ) );
187 lockLodLevelField.
_name =
"Lock LoD Level";
194 _editorComponent.registerField(
MOV( lockLodLevelField ) );
197 renderLodField.
_name =
"Lock LoD";
202 _editorComponent.registerField(
MOV( renderLodField ) );
205 mat->properties().isInstanced( mat->properties().isInstanced() || isInstanced() );
211 _renderRange.min = std::max( minRange, 0.f );
216 _renderRange.max = std::min( maxRange, 1.0f * g_renderRangeLimit );
223 auto& packagesPerVariant = packagesPerPassType[
to_base( pass )];
224 for (
auto& packagesPerPassIndex : packagesPerVariant )
226 for (
auto& pacakgesPerIndex : packagesPerPassIndex )
247 for (
auto& packagesPerVariant : packagesPerPassType )
249 for (
auto& packagesPerPassIndex : packagesPerVariant )
251 for (
auto& pacakgesPerIndex : packagesPerPassIndex )
266 PROFILE_TAG(
"Node", (_parentSGN->name().c_str()) );
269 bool shaderJustFinishedLoading =
false;
272 if ( shaderJustFinishedLoading )
274 _parentSGN->SendEvent(
300 rebuildDrawCommands(
true );
306 for (
U32 i = 0u; i < childCount; ++i )
317 if ( lodIndex < _lodIndexOffsets.size() )
319 _lodIndexOffsets[lodIndex] = { indexOffset, indexCount };
385 const auto& [_, level] = _lodLockLevels[
to_base( renderStage )];
403 const F32 distSQtoCenterClamped = std::max( distSQtoCenter,
EPSILON_F32 );
406 if ( distSQtoCenterClamped <=
to_F32(
SQUARED( lodThresholds[i] ) ) )
419 const bool refreshData )
427 U8 drawCmdOptions = 0u;
492 if ( pkg.pipelineCmd()._pipeline ==
nullptr )
510 pipelineDescriptor.
_stateBlock = mat->getOrCreateRenderStateBlock( renderStagePass );
515 pkg.descriptorSetCmd()._set = mat->getDescriptorSet( renderStagePass );
526 state0.enabled(
true );
534 state0.enabled(
true );
540 state1.enabled(
true );
546 state2.enabled(
true );
564 if ( bindingEntry.
_slot == slot )
566 bindingEntry.
_data = data;
586 updateBinding( pkg.descriptorSetCmd()._set, 10, data);
600 updateBinding( pkg.descriptorSetCmd()._set, 11, data );
621 pkg.stagePassBaseIndex(
BaseIndex( stagePass ) );
623 pkg.drawCmdOffset( cmdOffset +
to_U32( cmdsInOut.size() ) );
628 const bool autoIndex = offset != 0u || count != 0u;
633 cmdsInOut.push_back( gCmd.
_cmd );
635 iCmd.
baseInstance = isInstanced() ? 0u : (iBufferEntry + 1u);
648 bufferInOut.
add( pkg->pipelineCmd() );
649 bufferInOut.
add( pkg->descriptorSetCmd() );
650 bufferInOut.
add( pkg->pushConstantsCmd() );
652 U32 startOffset = pkg->drawCmdOffset();
660 GFX::EnqueueCommand<GFX::DrawCommand>( bufferInOut )->_drawCommands =
_drawCommands.
_data;
677 return entry._package;
688 return entry._package;
694 return entry._package;
704 std::pair<Handle<Texture>,
SamplerDescriptor> temp = { INVALID_HANDLE<Texture>, {} };
745 std::pair<Handle<Texture>,
SamplerDescriptor> temp = { INVALID_HANDLE<Texture>, {} };
783 if ( probePool !=
nullptr )
786 const auto& probes = probePool->
getLocked();
790 for (
const auto& probe : probes )
804 [&position](
const auto& a,
const auto& b )
noexcept ->
bool
806 return a->distanceSqTo( position ) < b->distanceSqTo( position );
812 if ( probe->getBounds().containsPoint( position ) )
815 probe->queueRefresh();
833 if ( _context.editor().inEditMode() )
835 colour =
UColour4( 255, 255, 255, 255 );
886 const SceneNode& node = _parentSGN->getNode();
905 if ( !AABB && !Sphere && !
OBB )
910 const SceneNode& node = _parentSGN->getNode();
927 descriptor.
box = obb;
950 switch ( data.
_type )
955 assert( tComp !=
nullptr );
#define PROFILE_SCOPE_AUTO(CATEGORY)
#define PROFILE_TAG(NAME,...)
static void prepareRender(SceneGraphNode *node, RenderingComponent &rComp, RenderPackage &pkg, GFX::MemoryBarrierCommand &postDrawMemCmd, const CameraSnapshot &cameraSnapshot, const RenderStagePass &renderStagePass, const bool refreshData)
vec3< F32 > nearestPoint(const vec3< F32 > &pos) const noexcept
vec3< F32 > getCenter() const noexcept
const vec3< F32 > & getMax() const noexcept
const vec3< F32 > & getMin() const noexcept
bool containsPoint(const vec3< F32 > &point) const noexcept
const vec3< F32 > & getCenter() const noexcept
F32 getRadius() const noexcept
void showAABB(bool state)
const BoundingBox & getBoundingBox() const noexcept
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
GFXRTPool & renderTargetPool() noexcept
void debugDrawSphere(const I64 ID, IM::SphereDescriptor descriptor) 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...
void debugDrawOBB(const I64 ID, IM::OBBDescriptor descriptor) noexcept
void debugDrawBox(const I64 ID, IM::BoxDescriptor descriptor) noexcept
void debugDrawLines(const I64 ID, IM::LineDescriptor descriptor) noexcept
RenderTarget * getRenderTarget(const RenderTargetID target) const
PlatformContext & context() noexcept
Kernel & kernel() noexcept
ProjectManager & parent() noexcept
Handle< Texture > texture() const
RTAttachmentDescriptor _descriptor
static void OnRenderingComponentCreation(RenderingComponent *rComp)
static void OnRenderingComponentDestruction(RenderingComponent *rComp)
RTAttachment * getAttachment(RTAttachmentType type, RTColourAttachmentSlot slot=RTColourAttachmentSlot::SLOT_0) const
RefractorType _refractorType
std::pair< Handle< Texture >, SamplerDescriptor > _reflectionPlanar
RenderCallback _refractionCallback
void OnData(const ECS::CustomEvent &data) override
std::array< std::pair< size_t, size_t >, MAX_LOD_LEVEL > _lodIndexOffsets
std::array< PackagesPerVariant, to_base(RenderPassType::COUNT)> PackagesPerPassType
bool renderOptionEnabled(RenderOptions option) const noexcept
Returns true if the specified render option is enabled.
IM::LineDescriptor _skeletonLinesDescriptor
std::array< PackagesPerPassType, to_base(RenderStage::COUNT)> _renderPackages
std::pair< Handle< Texture >, SamplerDescriptor > _refractionPlanar
void drawSelectionGizmo()
Draw some kind of selection doodad. May differ if editor is running or not.
vector< EnvironmentProbeComponent * > _envProbes
DrawCommands _drawCommands
void setLoDIndexOffset(U8 lodIndex, size_t indexOffset, size_t indexCount) noexcept
std::array< std::pair< bool, U8 >, to_base(RenderStage::COUNT)> _lodLockLevels
ReflectorType _reflectorType
static constexpr U8 MAX_LOD_LEVEL
std::array< PackagesPerPassIndex, to_base(RenderStagePass::VariantType::COUNT)> PackagesPerVariant
RenderCallback _reflectionCallback
void setMinRenderRange(F32 minRange) noexcept
vector< PackageEntry > PackagesPerIndex
U8 getLoDLevelInternal(const F32 distSQtoCenter, RenderStage renderStage, vec4< U16 > lodThresholds)
SharedMutex _renderPackagesLock
RenderPackage & getDrawPackage(const RenderStagePass &renderStagePass)
bool updateRefraction(U16 refractionIndex, bool inBudget, Camera *camera, const SceneRenderState &renderState, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
void instantiateMaterial(Handle< Material > material)
void toggleBoundsDraw(bool showAABB, bool showBS, bool showOBB, bool recursive)
IM::OBBDescriptor _selectionGizmoDescriptor
RenderingComponent(SceneGraphNode *parentSGN, PlatformContext &context)
std::array< PackagesPerIndex, to_base(RenderStagePass::PassIndex::COUNT)> PackagesPerPassIndex
U8 getLoDLevel(RenderStage renderStage) const noexcept
void retrieveDrawCommands(const RenderStagePass &stagePass, const U32 cmdOffset, DrawCommandContainer &cmdsInOut)
void getCommandBuffer(RenderPackage *const pkg, GFX::CommandBuffer &bufferInOut)
void updateReflectRefractDescriptors(bool reflectState, bool refractState)
bool canDraw(const RenderStagePass &renderStagePass)
Handle< Material > _materialInstance
void drawBounds(bool AABB, bool OBB, bool Sphere)
void getMaterialData(NodeMaterialData &dataOut) const
void updateNearestProbes(const vec3< F32 > &position)
void drawDebugAxis()
Draw the axis arrow gizmo.
std::array< U8, to_base(RenderStage::COUNT)> _lodLevels
bool hasDrawCommands() noexcept
bool _selectionGizmoDirty
bool prepareDrawPackage(const CameraSnapshot &cameraSnapshot, const SceneRenderState &sceneRenderState, const RenderStagePass &renderStagePass, GFX::MemoryBarrierCommand &postDrawMemCmd, bool refreshData)
IM::LineDescriptor _axisGizmoLinesDescriptor
~RenderingComponent() override
void onParentUsageChanged(NodeUsageContext context) const
void toggleRenderOption(RenderOptions option, bool state, bool recursive=true)
bool updateReflection(U16 reflectionIndex, bool inBudget, Camera *camera, const SceneRenderState &renderState, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
void postRender(const SceneRenderState &sceneRenderState, const RenderStagePass &renderStagePass, GFX::CommandBuffer &bufferInOut)
Called after the parent node was rendered.
U16 _reflectionProbeIndex
U32 _indirectionBufferEntry
void setMaxRenderRange(F32 maxRange) noexcept
virtual void OnData(const ECS::CustomEvent &data)
void unlockProbeList() const noexcept
const EnvironmentProbeList & getLocked() const noexcept
static U16 SkyProbeLayerIndex() noexcept
void lockProbeList() const noexcept
@ RENDER_WIREFRAME
Render wireframe for all scene geometry.
@ RENDER_OBB
Show/hide oriented bounding boxes.
@ RENDER_SKELETONS
Render skeletons for animated geometry.
@ RENDER_AABB
Show/hide axis aligned bounding boxes.
@ RENDER_BSPHERES
Show/hide bounding spheres.
@ RENDER_GEOMETRY
Show/hide geometry.
bool isEnabledOption(RenderOptions option) const noexcept
vec4< U16 > & lodThresholds() noexcept
static const SamplerDescriptor DefaultSampler() noexcept
static Handle< Texture > DefaultTexture2D() noexcept
void setTranslation(const vec3< U > &v) noexcept
void set(std::initializer_list< T > matrix) noexcept
T distanceSquared(const vec3 &v) const noexcept
compute the vector's squared distance to another specified vector
constexpr bool ENABLE_EDITOR
constexpr U8 MAX_REFLECTIVE_PROBES_PER_PASS
Maximum number of environment probes we are allowed to update per frame.
constexpr Optick::Category::Type Scene
constexpr I16 g_renderRangeLimit
Handle console commands that start with a forward slash.
NodeUsageContext
Usage context affects lighting, navigation, physics, etc.
std::lock_guard< mutex > LockGuard
static constexpr bool IsDepthPass(const RenderStagePass stagePass) noexcept
constexpr U32 to_U32(const T value)
FORCE_INLINE void DestroyResource(Handle< T > &handle, const bool immediate=false)
constexpr T SQUARED(T input) noexcept
static const vec3< F32 > WORLD_X_AXIS
Handle< GFX::CommandBuffer > GetCommandBuffer(RenderPackage &pkg)
static const vec3< F32 > WORLD_Z_AXIS
constexpr F32 to_F32(const T value)
constexpr F32 EPSILON_F32
std::shared_lock< mutex > SharedLock
void Set(DescriptorSetBindingData &dataInOut, ShaderBuffer *buffer, const BufferRange range) noexcept
constexpr U64 _ID(const char *const str, const U64 value=val_64_const) noexcept
DescriptorSetBinding & AddBinding(DescriptorSet &setInOut, U8 slot, U16 stageVisibilityMask)
SGNComponent::Registrar< T, C > BaseComponentType
constexpr U8 to_U8(const T value)
::value constexpr T CLAMPED(T n, T min, T max) noexcept
FORCE_INLINE constexpr bool Is3DObject(const SceneNodeType type) noexcept
mat3< T > GetMatrix(const Quaternion< T > &q) noexcept
static constexpr U8 BaseIndex(const RenderStage stage, const RenderPassType passType) noexcept
static const vec3< F32 > VECTOR3_ZERO
void Clear(RenderPackage &pkg) noexcept
FORCE_INLINE T * Get(const Handle< T > handle)
Project const SceneEntry & entry
static const vec3< F32 > WORLD_Y_AXIS
eastl::fixed_vector< IndirectIndexedDrawCommand, Config::MAX_VISIBLE_NODES, false > DrawCommandContainer
constexpr auto to_base(const Type value) -> Type
DescriptorSetBindingData _data
std::array< DescriptorSetBinding, MAX_BINDINGS_PER_DESCRIPTOR_SET > _bindings
vec2< F32 > _range
Used by slider_type as a min / max range or dropdown as selected_index / count.
PushConstantType _basicType
PushConstantSize _basicTypeSize
EditorComponentFieldType _type
static constexpr RTColourAttachmentSlot ALBEDO
static constexpr RTColourAttachmentSlot MODULATE
static constexpr RTColourAttachmentSlot ACCUMULATION
static constexpr RTColourAttachmentSlot REVEALAGE
IndirectIndexedDrawCommand _cmd
vec3< F32 > _positionStart
PrimitiveTopology _primitiveTopology
AttributeMap _vertexFormat
Handle< ShaderProgram > _shaderProgramHandle
RTBlendStates _blendStates
RenderStateBlock _stateBlock
SamplerDescriptor _sampler
std::array< BlendingSettings, to_base(RTColourAttachmentSlot::COUNT)> _settings
RenderCbkParams(GFXDevice &context, const SceneGraphNode *sgn, const SceneRenderState &sceneRenderState, const RenderTargetID &renderTarget, const U16 passIndex, const U8 passVariant, Camera *camera) noexcept
bool _primitiveRestartEnabled
static RenderTargetID REFLECTION_CUBE
static std::array< RenderTargetID, Config::MAX_REFRACTIVE_NODES_IN_VIEW > REFRACTION_PLANAR
static std::array< RenderTargetID, Config::MAX_REFLECTIVE_NODES_IN_VIEW > REFLECTION_PLANAR
GenericDrawCommandContainer _data
eastl::fixed_vector< SceneGraphNode *, 32, true > _data
Divide::SGNComponent * _sourceCmp