Improved particles and trajectory rendering #430
|
@ -886,7 +886,7 @@ namespace SHADE
|
|||
if (AssetID* payload = SHDragDrop::AcceptPayload<AssetID>(SHDragDrop::DRAG_RESOURCE))
|
||||
{
|
||||
Handle<SHTexture> texture = SHResourceManager::LoadOrGet<SHTexture>(*payload);
|
||||
gfxSystem->BuildTextures();
|
||||
gfxSystem->BuildTextures();
|
||||
|
||||
if (texture)
|
||||
{
|
||||
|
@ -901,6 +901,49 @@ namespace SHADE
|
|||
SHDragDrop::EndTarget();
|
||||
}
|
||||
}
|
||||
SHEditorWidgets::InputText("Custom Update Shader",
|
||||
[comp = component]()
|
||||
{
|
||||
auto customShader = comp->GetCustomUpdateShader();
|
||||
|
||||
if (customShader)
|
||||
return customShader->GetName();
|
||||
else
|
||||
return std::string{};
|
||||
|
||||
},
|
||||
[comp = component](std::string const& text)
|
||||
{
|
||||
}, {}, ImGuiSliderFlags_ReadOnly);
|
||||
|
||||
if (SHDragDrop::BeginTarget())
|
||||
{
|
||||
if (AssetID* payload = SHDragDrop::AcceptPayload<AssetID>(SHDragDrop::DRAG_RESOURCE))
|
||||
{
|
||||
Handle<SHVkShaderModule> shaderModule = SHResourceManager::LoadOrGet<SHVkShaderModule>(*payload);
|
||||
|
||||
if (shaderModule)
|
||||
{
|
||||
component->SetCustomUpdateShader(shaderModule);
|
||||
component->SetCustomUpdateShaderAssetID(*payload);
|
||||
}
|
||||
else
|
||||
{
|
||||
SHLOG_WARNING("[] Attempted to load invalid shader! Custom update shader for particles not set. ");
|
||||
}
|
||||
|
||||
SHDragDrop::EndTarget();
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Reset"))
|
||||
{
|
||||
component->SetCustomUpdateShader({});
|
||||
component->SetCustomUpdateShaderAssetID(INVALID_ASSET_ID);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
SHEditorWidgets::CheckBox("Is Passive", [comp = component]() {return comp->GetPassive(); }, [comp = component](bool flag) {comp->SetPassive(flag); });
|
||||
|
|
|
@ -72,11 +72,16 @@ namespace SHADE
|
|||
cpuEmitterData.textureIndex = index;
|
||||
}
|
||||
|
||||
void SHParticleEmitterComponent::SetTextureAssetID(AssetID id)
|
||||
void SHParticleEmitterComponent::SetTextureAssetID(AssetID id) noexcept
|
||||
{
|
||||
textureAssetID = id;
|
||||
}
|
||||
|
||||
void SHParticleEmitterComponent::SetCustomUpdateShaderAssetID(AssetID id) noexcept
|
||||
{
|
||||
customUpdateShaderID = id;
|
||||
}
|
||||
|
||||
void SHParticleEmitterComponent::SetMinSize(float size) noexcept
|
||||
{
|
||||
cpuEmitterData.lifeAndSizeRange.z = size;
|
||||
|
@ -87,7 +92,7 @@ namespace SHADE
|
|||
cpuEmitterData.lifeAndSizeRange.w = size;
|
||||
}
|
||||
|
||||
void SHParticleEmitterComponent::SetCustomShader(Handle<SHVkShaderModule> shaderModule) noexcept
|
||||
void SHParticleEmitterComponent::SetCustomUpdateShader(Handle<SHVkShaderModule> shaderModule) noexcept
|
||||
{
|
||||
customUpdateShader = shaderModule;
|
||||
}
|
||||
|
@ -148,6 +153,11 @@ namespace SHADE
|
|||
return textureAssetID;
|
||||
}
|
||||
|
||||
AssetID SHParticleEmitterComponent::GetCustomUpdateShaderAssetID(void) const noexcept
|
||||
{
|
||||
return customUpdateShaderID;
|
||||
}
|
||||
|
||||
float SHParticleEmitterComponent::GetMinSize(void) const noexcept
|
||||
{
|
||||
return cpuEmitterData.lifeAndSizeRange.z;
|
||||
|
@ -159,7 +169,7 @@ namespace SHADE
|
|||
}
|
||||
|
||||
|
||||
Handle<SHVkShaderModule> SHParticleEmitterComponent::GetCustomShader(void) const noexcept
|
||||
Handle<SHVkShaderModule> SHParticleEmitterComponent::GetCustomUpdateShader(void) const noexcept
|
||||
{
|
||||
return customUpdateShader;
|
||||
}
|
||||
|
|
|
@ -121,6 +121,9 @@ namespace SHADE
|
|||
//! For the emitter to use to give particles their texture
|
||||
AssetID textureAssetID;
|
||||
|
||||
//! Custom update shaders, similarly with textures, will be identified through their AssetID
|
||||
AssetID customUpdateShaderID;
|
||||
|
||||
public:
|
||||
void OnCreate(void) override final;
|
||||
void OnDestroy(void) override final;
|
||||
|
@ -137,11 +140,9 @@ namespace SHADE
|
|||
void SetMaxSpeed (float speed) noexcept;
|
||||
void SetRotationSpeed (float speed) noexcept;
|
||||
void SetTextureIndex (uint32_t index) noexcept;
|
||||
void SetTextureAssetID (AssetID id);
|
||||
void SetMinSize (float size) noexcept;
|
||||
void SetMaxSize (float size) noexcept;
|
||||
void SetCustomShader (Handle<SHVkShaderModule> shaderModule) noexcept;
|
||||
|
||||
void SetCustomUpdateShader (Handle<SHVkShaderModule> shaderModule) noexcept;
|
||||
|
||||
uint32_t GetEmissionCount (void) const noexcept;
|
||||
bool GetPassive (void) const noexcept;
|
||||
|
@ -153,11 +154,19 @@ namespace SHADE
|
|||
float GetMaxSpeed (void) const noexcept;
|
||||
float GetRotationSpeed (void) const noexcept;
|
||||
uint32_t GetTextureIndex (void) const noexcept;
|
||||
AssetID GetTextureAssetID (void) const noexcept;
|
||||
float GetMinSize (void) const noexcept;
|
||||
float GetMaxSize (void) const noexcept;
|
||||
Handle<SHVkShaderModule> GetCustomShader (void) const noexcept;
|
||||
Handle<SHVkShaderModule> GetCustomUpdateShader (void) const noexcept;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* NON-INTERFACE FUNCTIONS */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void SetTextureAssetID(AssetID id) noexcept;
|
||||
void SetCustomUpdateShaderAssetID(AssetID id) noexcept;
|
||||
|
||||
AssetID GetTextureAssetID(void) const noexcept;
|
||||
AssetID GetCustomUpdateShaderAssetID(void) const noexcept;
|
||||
|
||||
|
||||
friend class SHParticleSubSystem;
|
||||
|
||||
|
|
|
@ -446,8 +446,10 @@ namespace SHADE
|
|||
/*-----------------------------------------------------------------------*/
|
||||
for (auto& emitter : emitters)
|
||||
{
|
||||
// If custom update shader is a valid handle in the component
|
||||
if (emitter.customUpdateShader)
|
||||
{
|
||||
// Check if pipeline associated with shader is valid, if not create or get one from the cache
|
||||
if (!emitter.customUpdatePipeline)
|
||||
emitter.customUpdatePipeline = GetCustomUpdatePipeline(emitter.customUpdateShader);
|
||||
|
||||
|
@ -456,7 +458,7 @@ namespace SHADE
|
|||
}
|
||||
else
|
||||
{
|
||||
// bind the pipeline for updating
|
||||
// bind the default upddate pipeline for updating
|
||||
cmdBuffer->BindPipeline(defaultUpdatePipelineData.pipeline);
|
||||
}
|
||||
|
||||
|
|
|
@ -516,6 +516,7 @@ namespace YAML
|
|||
static constexpr std::string_view MAX_SPEED_TAG = "Maximum Speed";
|
||||
static constexpr std::string_view ROTATION_SPEED_TAG = "Rotation Speed";
|
||||
static constexpr std::string_view TEXTURE_ASSET_ID_TAG = "Texture Asset ID";
|
||||
static constexpr std::string_view CUSTOM_UPDATE_SHADER_ASSET_ID_TAG = "Custom Update Shader Asset ID";
|
||||
|
||||
static YAML::Node encode(SHParticleEmitterComponent const& rhs)
|
||||
{
|
||||
|
@ -532,6 +533,7 @@ namespace YAML
|
|||
node[ANGULAR_RANGES_OFFSET_TAG.data()] = rhs.GetAngularRangesAndOffsets();
|
||||
node[ROTATION_SPEED_TAG.data()] = rhs.GetRotationSpeed();
|
||||
node[TEXTURE_ASSET_ID_TAG.data()] = rhs.GetTextureAssetID();
|
||||
node[CUSTOM_UPDATE_SHADER_ASSET_ID_TAG.data()] = rhs.GetCustomUpdateShaderAssetID();
|
||||
|
||||
return node;
|
||||
}
|
||||
|
@ -580,6 +582,18 @@ namespace YAML
|
|||
rhs.SetTextureIndex(texture->TextureArrayIndex);
|
||||
rhs.SetTextureAssetID(id);
|
||||
}
|
||||
|
||||
if (node[CUSTOM_UPDATE_SHADER_ASSET_ID_TAG.data()].IsDefined())
|
||||
{
|
||||
AssetID id = node[CUSTOM_UPDATE_SHADER_ASSET_ID_TAG.data()].as<AssetID>();
|
||||
|
||||
Handle<SHVkShaderModule> shaderModule = SHResourceManager::LoadOrGet<SHVkShaderModule>(id);
|
||||
SHResourceManager::FinaliseChanges();
|
||||
//gfxSystem->BuildTextures();
|
||||
|
||||
rhs.SetCustomUpdateShader(shaderModule);
|
||||
rhs.SetTextureAssetID(id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue