mitiru::effects
Namespace catalog extracted from docs/API_CATALOG.md (12 types, 91 items).
Namespace catalog extracted from docs/API_CATALOG.md (12 types, 91 items).
| Name | Kind | Items |
|---|---|---|
Bloom | class | 4 |
CameraEffects | class | 11 |
Dissolve | class | 8 |
GpuParticleBase | class | 12 |
GpuParticleDx11 | class | 7 |
GpuParticleDx12 | class | 5 |
EmissionShape | enum | 4 |
EmissionBurst | struct | 3 |
CurveKey | struct | 2 |
ParameterCurve | struct | 3 |
ParticleEmitter | struct | 22 |
ScreenShake | class | 10 |
class Bloom 4
float threshold = 0.8ffloat intensity = 1.0fint blurPasses = 3void apply(std::vector<uint8_t>& pixels, int width, int height) constclass CameraEffects 11
void setTarget(const sgc::Vec2f& target) noexceptvoid setSmoothSpeed(float speed) noexceptvoid zoomTo(float targetZoom, float duration = 0.5f)void setBounds(float minX, float minY, float maxX, float maxY) noexceptvoid clearBounds() noexceptvoid update(float dt)[[nodiscard]] sgc::Vec2f offset() const noexcept[[nodiscard]] float zoom() const noexcept[[nodiscard]] bool isZooming() const noexceptvoid setPosition(const sgc::Vec2f& pos) noexceptvoid setZoom(float z) noexceptclass Dissolve 8
void start(float duration = 1.0f)void update(float dt)[[nodiscard]] bool isComplete() const noexcept[[nodiscard]] bool isActive() const noexcept[[nodiscard]] float threshold() const noexcept[[nodiscard]] static float pixelNoise(int x, int y) noexcept[[nodiscard]] bool isPixelVisible(int x, int y) const noexceptvoid reset() noexceptclass GpuParticleBase : public IGpuParticleSystem 12
void setEmitter(const ParticleEmitter& emitter) override[[nodiscard]] const ParticleEmitter& emitter() const noexcept overridevoid emit(const sgc::Vec3f& position, const sgc::Vec3f& velocity, float lifetime, const sgc::Colorf& color, float size) overridevoid emitFromEmitter(float dt) overridevoid burst(std::uint32_t count) override[[nodiscard]] std::uint32_t activeCount() const noexcept override[[nodiscard]] std::uint32_t maxCount() const noexcept overridevoid clear() override[[nodiscard]] bool isValid() const noexcept overridestatic constexpr std::string_view PARTICLE_COMPUTE_HLSL = R"( struct Particle { float3 position; float3 velocity; float3 acceleration; float4 color; float size; float lifetime; float age; }; cbuffer SimConstants : register(b0) { float deltaTime; float3 gravity; float drag; uint maxParticles; uint activeParticles; float padding; }; StructuredBuffer<Particle> particlesIn : register(t0); RWStructuredBuffer<Particle> particlesOut : register(u0); [numthreads(256, 1, 1)] void CSMain(uint3 dtid : SV_DispatchThreadID) { uint idx = dtid.x; if (idx >= activeParticles) { return; } Particle p = particlesIn[idx]; // 寿命チェック p.age += deltaTime; if (p.age >= p.lifetime) { // 死亡パーティクルはサイズ0にして無効化 p.size = 0; p.color.a = 0; particlesOut[idx] = p; return; } // 物理シミュレーション float3 accel = gravity + p.acceleration; p.velocity += accel * deltaTime; p.velocity *= (1.0 - drag * deltaTime); p.position += p.velocity * deltaTime; // ライフタイム比率に基づくフェード float normalizedAge = p.age / p.lifetime; p.color.a *= (1.0 - normalizedAge * normalizedAge); particlesOut[idx] = p; } )"static constexpr std::string_view PARTICLE_VS_HLSL = R"( struct Particle { float3 position; float3 velocity; float3 acceleration; float4 color; float size; float lifetime; float age; }; cbuffer RenderConstants : register(b0) { float4x4 viewProjection; float3 cameraRight; float pad0; float3 cameraUp; float pad1; }; StructuredBuffer<Particle> particles : register(t0); struct VSOutput { float4 position : SV_Position; float4 color : COLOR; float2 texCoord : TEXCOORD; }; VSOutput VSMain(uint vertexId : SV_VertexID, uint instanceId : SV_InstanceID) { VSOutput output; Particle p = particles[instanceId]; // クアッド頂点(三角形ストリップ順) // 0: (-1,-1), 1: (1,-1), 2: (-1,1), 3: (1,1) // 三角形リスト: 0,2,1, 1,2,3 static const float2 quadVerts[6] = { float2(-1, -1), float2(-1, 1), float2(1, -1), float2(1, -1), float2(-1, 1), float2(1, 1) }; float2 corner = quadVerts[vertexId]; float halfSize = p.size * 0.5; // ビルボード展開 float3 worldPos = p.position + cameraRight * corner.x * halfSize + cameraUp * corner.y * halfSize; output.position = mul(viewProjection, float4(worldPos, 1.0)); output.color = p.color; output.texCoord = corner * 0.5 + 0.5; return output; } )"static constexpr std::string_view PARTICLE_PS_HLSL = R"( struct PSInput { float4 position : SV_Position; float4 color : COLOR; float2 texCoord : TEXCOORD; }; float4 PSMain(PSInput input) : SV_Target { // 円形マスク(ソフトエッジ) float2 center = input.texCoord - 0.5; float dist = length(center) * 2.0; float alpha = saturate(1.0 - dist * dist); float4 color = input.color; color.a *= alpha; // アルファが極小のフラグメントを破棄する if (color.a < 0.001) { discard; } return color; } )"class GpuParticleDx11 : public GpuParticleBase 7
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>explicit GpuParticleDx11(ID3D11Device* device, ID3D11DeviceContext* context, std::uint32_t maxParticles = MAX_GPU_PARTICLES)void update(float dt) overridevoid render(const mitiru::render::Camera3D& camera) overridestatic constexpr std::string_view DX12_PARTICLE_COMPUTE_HLSL = R"( struct Particle { float3 position; float3 velocity; float3 acceleration; float4 color; float size; float lifetime; float age; }; struct DrawArgs { uint vertexCountPerInstance; uint instanceCount; uint startVertexLocation; uint startInstanceLocation; }; cbuffer SimConstants : register(b0) { float deltaTime; float3 gravity; float drag; uint maxParticles; uint activeParticles; float padding; }; StructuredBuffer<Particle> particlesIn : register(t0); RWStructuredBuffer<Particle> particlesOut : register(u0); RWStructuredBuffer<DrawArgs> drawArgs : register(u1); [numthreads(256, 1, 1)] void CSMain(uint3 dtid : SV_DispatchThreadID) { // 最初のスレッドがドローアーギュメントを初期化する if (dtid.x == 0) { DrawArgs args; args.vertexCountPerInstance = 6; args.instanceCount = 0; args.startVertexLocation = 0; args.startInstanceLocation = 0; drawArgs[0] = args; } GroupMemoryBarrierWithGroupSync(); uint idx = dtid.x; if (idx >= activeParticles) { return; } Particle p = particlesIn[idx]; // 寿命チェック p.age += deltaTime; if (p.age >= p.lifetime) { p.size = 0; p.color.a = 0; particlesOut[idx] = p; return; } // 物理シミュレーション float3 accel = gravity + p.acceleration; p.velocity += accel * deltaTime; p.velocity *= (1.0 - drag * deltaTime); p.position += p.velocity * deltaTime; // ライフタイム比率に基づくフェード float normalizedAge = p.age / p.lifetime; p.color.a *= (1.0 - normalizedAge * normalizedAge); particlesOut[idx] = p; // 生存パーティクルのインスタンスカウントをインクリメントする if (p.size > 0 && p.color.a > 0.001) { uint dummy; InterlockedAdd(drawArgs[0].instanceCount, 1, dummy); } } )"static constexpr std::string_view DX12_PARTICLE_VS_HLSL = R"( struct Particle { float3 position; float3 velocity; float3 acceleration; float4 color; float size; float lifetime; float age; }; cbuffer RenderConstants : register(b0) { float4x4 viewProjection; float3 cameraRight; float pad0; float3 cameraUp; float pad1; }; StructuredBuffer<Particle> particles : register(t0); struct VSOutput { float4 position : SV_Position; float4 color : COLOR; float2 texCoord : TEXCOORD; }; VSOutput VSMain(uint vertexId : SV_VertexID, uint instanceId : SV_InstanceID) { VSOutput output; Particle p = particles[instanceId]; static const float2 quadVerts[6] = { float2(-1, -1), float2(-1, 1), float2(1, -1), float2(1, -1), float2(-1, 1), float2(1, 1) }; float2 corner = quadVerts[vertexId]; float halfSize = p.size * 0.5; float3 worldPos = p.position + cameraRight * corner.x * halfSize + cameraUp * corner.y * halfSize; output.position = mul(viewProjection, float4(worldPos, 1.0)); output.color = p.color; output.texCoord = corner * 0.5 + 0.5; return output; } )"static constexpr std::string_view DX12_PARTICLE_PS_HLSL = R"( struct PSInput { float4 position : SV_Position; float4 color : COLOR; float2 texCoord : TEXCOORD; }; float4 PSMain(PSInput input) : SV_Target { float2 center = input.texCoord - 0.5; float dist = length(center) * 2.0; float alpha = saturate(1.0 - dist * dist); float4 color = input.color; color.a *= alpha; if (color.a < 0.001) { discard; } return color; } )"class GpuParticleDx12 : public GpuParticleBase 5
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>explicit GpuParticleDx12(ID3D12Device* device, ID3D12CommandQueue* commandQueue, std::uint32_t maxParticles = MAX_GPU_PARTICLES)~GpuParticleDx12() overridevoid update(float dt) overridevoid render(const mitiru::render::Camera3D& camera) overrideenum EmissionShape : std::uint8_t 4
PointSphereConeBoxstruct EmissionBurst 3
float time = 0.0fstd::uint32_t count = 10float repeatInterval = 0struct CurveKey 2
float t = 0.0ffloat value = 1.0fstruct ParameterCurve 3
std::uint32_t keyCount = 0void addKey(float t, float value) noexcept[[nodiscard]] float evaluate(float t) const noexceptstruct ParticleEmitter 22
EmissionShape shape = EmissionShape::Pointfloat sphereRadius = 1.0ffloat coneAngle = 0.523599ffloat coneRadius = 0.0ffloat ratePerSecond = 100.0fstd::uint32_t burstCount = 0float initialSpeed = 5.0ffloat initialSpeedVariance = 1.0ffloat lifetime = 2.0ffloat lifetimeVariance = 0.5ffloat initialSize = 0.1ffloat initialSizeVariance = 0.02ffloat drag = 0.1fParameterCurve sizeOverLifetimeParameterCurve alphaOverLifetimevoid addBurst(float time, std::uint32_t count, float interval = 0) noexcepttemplate <typename Rng> [[nodiscard]] sgc::Vec3f samplePosition(Rng& rng) const noexcepttemplate <typename Rng> [[nodiscard]] sgc::Vec3f sampleVelocity(Rng& rng, const sgc::Vec3f& emitPos) const noexcepttemplate <typename Rng> [[nodiscard]] float sampleLifetime(Rng& rng) const noexcepttemplate <typename Rng> [[nodiscard]] float sampleSize(Rng& rng) const noexcept[[nodiscard]] sgc::Colorf evaluateColor(float normalizedAge) const noexcept[[nodiscard]] float evaluateSize(float normalizedAge) const noexceptclass ScreenShake 10
float trauma = 0.0ffloat traumaDecay = 2.0ffloat maxOffset = 20.0ffloat maxRotation = 0.05fvoid addTrauma(float amount)void update(float dt)[[nodiscard]] sgc::Vec2f offset() const noexcept[[nodiscard]] float rotation() const noexcept[[nodiscard]] float intensity() const noexceptvoid reset() noexceptSourced from docs/API_CATALOG.md, auto-generated by tools/generate_api_catalog.py.