sead
Loading...
Searching...
No Matches
aglDepthOfField.h
Go to the documentation of this file.
1#pragma once
2
3#include <common/aglIndexStream.h>
4#include <common/aglRenderBuffer.h>
5#include <common/aglRenderTarget.h>
6#include <common/aglShaderEnum.h>
7#include <common/aglTextureSampler.h>
8#include <common/aglVertexAttribute.h>
9#include <common/aglVertexBuffer.h>
10#include <container/seadBuffer.h>
11#include <gfx/seadGraphicsContextMRT.h>
12#include <hostio/seadHostIODummy.h>
13#include <utility/aglDebugTexturePage.h>
14#include <utility/aglParameter.h>
15#include <utility/aglParameterIO.h>
16#include <utility/aglParameterObj.h>
17
18namespace agl {
19
20class RenderBuffer;
21class TextureData;
22
23namespace pfx {
24
25class DepthOfField : public utl::IParameterIO, public sead::hostio::Node
26{
46 static_assert(sizeof(Context) == 0x834, "agl::pfx::DepthOfField::Context size mismatch");
47
48 struct DrawArg
49 {
50 DrawArg(Context& ctx, const RenderBuffer& render_buffer, const TextureData& depth, bool view_depth_, f32 near_, f32 far_);
51
60 };
61 static_assert(sizeof(DrawArg) == 0x20, "agl::pfx::DepthOfField::DrawArg size mismatch");
62
72 static_assert(sizeof(TempVignetting) == 0xCC, "agl::pfx::DepthOfField::TempVignetting size mismatch");
73
79 static_assert(sizeof(Vertex) == 0x10);
80
89 static_assert(sizeof(VignettingShape) == 0x2F0, "agl::pfx::DepthOfField::VignettingShape size mismatch");
90
91public:
109 static_assert(cUniform_Num == 13);
110
120 static_assert(cSampler_Num == 5);
121
123 {
124 cVignettingBlendType_Normal = 0, // op = Add, src = SrcAlpha, dst = InvSrcAlpha
125 cVignettingBlendType_Add, // op = Add, src = SrcAlpha, dst = One
126 cVignettingBlendType_Mult, // op = Add, src = Zero, dst = SrcColor
127 cVignettingBlendType_Screen // op = Add, src = InvDstColor, dst = One
128 };
129
130public:
131 DepthOfField();
132 virtual ~DepthOfField();
133
134 void initialize(s32 ctx_num = 1, sead::Heap* heap = nullptr);
135
136private:
138
139 void initVertex_(sead::Heap* heap);
140 void initIndex_(sead::Heap* heap);
141
142public:
143 bool isEnable() const
144 {
145 return *mEnable;
146 }
147
148 void setEnable(bool enable)
149 {
150 *mEnable = enable;
151 }
152
153 VignettingBlendType getVignettingBlendType() const { return VignettingBlendType(*mVignettingBlend); }
154
155 ShaderMode draw(s32 ctx_index, const RenderBuffer& render_buffer, f32 near, f32 far, ShaderMode mode = cShaderMode_Invalid) const;
156 ShaderMode draw(s32 ctx_index, const RenderBuffer& render_buffer, const TextureData& depth, bool view_depth, f32 near, f32 far, ShaderMode mode = cShaderMode_Invalid) const;
157
158 void allocBuffer(s32 ctx_index, const RenderBuffer& render_buffer) const;
159 void allocBuffer(s32 ctx_index, TextureFormat format, s32 width, s32 height) const;
160 void freeBuffer(s32 ctx_index) const;
161
162private:
163 bool enableDepthOfField_() const;
164 bool enableBlurMipMapPass_() const;
165 bool enableDepthBlur_() const;
166 bool enableDifferntShape_() const;
168
169 void bindRenderBuffer_(RenderBuffer& render_buffer, s32 mip_level_color, s32 mip_level_depth) const;
170
171 void drawKick_(const DrawArg& arg) const;
172
173 ShaderMode drawColorMipMap_(const DrawArg& arg, ShaderMode mode) const;
174 ShaderMode drawDepthMipMap_(const DrawArg& arg, ShaderMode mode) const;
175 ShaderMode drawCompose_(const DrawArg& arg, ShaderMode mode) const;
176 ShaderMode drawVignetting_(const DrawArg& arg, ShaderMode mode) const;
177
178 void uniformComposeParam_(const DrawArg& arg, const ShaderProgram* program) const;
179 void uniformVignettingParam_(const DrawArg& arg, const ShaderProgram* program) const;
180
181 static s32 roundUp_(f32 value)
182 {
183 s32 ivalue = s32(value);
184 if (ivalue != value)
185 if (value >= 0.0f)
186 ivalue++;
187
188 return ivalue;
189 }
190
191 static s32 roundDown_(f32 value)
192 {
193 s32 ivalue = s32(value);
194 if (ivalue != value)
195 if (value < 0.0f)
196 ivalue--;
197
198 return ivalue;
199 }
200
201 sead::Vector4f getTexParam_(const TextureData& data, u32 mip_level = 0) const
202 {
203 sead::Vector4f param;
204 param.x = 0.5f / data.getWidth(mip_level);
205 param.y = 0.5f / data.getHeight(mip_level);
206 param.z = 0.0f; // Unused
207 param.w = 0.0f; // ^^
208 return param;
209 }
210
211public:
212 void setIndirectTextureData(const TextureData* p_texture_data);
213 void setIndirectEnable(bool enable);
214
215 void setIndirectTextureTrans(const sead::Vector2f& trans);
216
217private:
220
221 virtual void postRead_();
222
223private:
253 utl::Parameter<s32> mVignettingBlend; // -> enum VignettingBlendType
271};
272static_assert(sizeof(DepthOfField) == 0x10EC, "agl::pfx::DepthOfField size mismatch");
273
274} }
Definition aglIndexStream.h:10
Definition aglRenderBuffer.h:15
Definition aglRenderTarget.h:66
Definition aglShaderProgram.h:16
Definition aglTextureData.h:11
Definition aglTextureSampler.h:12
Definition aglVertexAttribute.h:13
Definition aglVertexBuffer.h:11
Definition aglDepthOfField.h:26
sead::Vector3f mIndirectTexMtx1
Definition aglDepthOfField.h:268
utl::Parameter< bool > mNearEnable
Definition aglDepthOfField.h:232
utl::DebugTexturePage mDebugTexturePage
Definition aglDepthOfField.h:258
TempVignetting mTempVignetting0
Definition aglDepthOfField.h:255
virtual void postRead_()
Definition aglDepthOfField.cpp:1154
ShaderMode drawColorMipMap_(const DrawArg &arg, ShaderMode mode) const
Definition aglDepthOfField.cpp:629
VignettingBlendType getVignettingBlendType() const
Definition aglDepthOfField.h:153
ShaderMode drawVignetting_(const DrawArg &arg, ShaderMode mode) const
Definition aglDepthOfField.cpp:843
DepthOfField()
Definition aglDepthOfField.cpp:15
static s32 roundUp_(f32 value)
Definition aglDepthOfField.h:181
utl::Parameter< f32 > mIndirectScale
Definition aglDepthOfField.h:251
TextureSampler mIndirectTextureSampler
Definition aglDepthOfField.h:265
ShaderMode drawDepthMipMap_(const DrawArg &arg, ShaderMode mode) const
Definition aglDepthOfField.cpp:698
void freeBuffer(s32 ctx_index) const
Definition aglDepthOfField.cpp:506
bool isEnable() const
Definition aglDepthOfField.h:143
utl::Parameter< bool > mEnableVignettingBlur
Definition aglDepthOfField.h:236
void uniformVignettingParam_(const DrawArg &arg, const ShaderProgram *program) const
Definition aglDepthOfField.cpp:1029
void initIndex_(sead::Heap *heap)
Definition aglDepthOfField.cpp:363
utl::Parameter< bool > mEnableVignettingColor
Definition aglDepthOfField.h:235
s32 _1e8
Definition aglDepthOfField.h:225
void uniformComposeParam_(const DrawArg &arg, const ShaderProgram *program) const
Definition aglDepthOfField.cpp:886
bool enableDifferntShape_() const
Definition aglDepthOfField.cpp:538
utl::Parameter< sead::Vector4f > mColorCtrlDepth
Definition aglDepthOfField.h:247
utl::Parameter< bool > mEnable
Definition aglDepthOfField.h:231
sead::SafeArray< const ShaderProgram *, 2 > mpCurrentProgramDepthMask
Definition aglDepthOfField.h:261
utl::Parameter< f32 > mFarStart
Definition aglDepthOfField.h:242
void initVertex_(sead::Heap *heap)
Definition aglDepthOfField.cpp:251
utl::Parameter< f32 > mFarEnd
Definition aglDepthOfField.h:243
utl::Parameter< f32 > mEnd
Definition aglDepthOfField.h:241
bool enableDepthBlur_() const
Definition aglDepthOfField.cpp:533
utl::Parameter< bool > mEnableColorControl
Definition aglDepthOfField.h:238
utl::Parameter< f32 > mLevel
Definition aglDepthOfField.h:244
utl::Parameter< f32 > mIndirectTexRotate
Definition aglDepthOfField.h:250
bool enableBlurMipMapPass_() const
Definition aglDepthOfField.cpp:528
void bindRenderBuffer_(RenderBuffer &render_buffer, s32 mip_level_color, s32 mip_level_depth) const
Definition aglDepthOfField.cpp:554
bool enableSeparateVignettingPass_() const
Definition aglDepthOfField.cpp:543
f32 _1ec
Definition aglDepthOfField.h:226
ShaderProgram * mpCurrentProgramVignetting
Definition aglDepthOfField.h:263
utl::Parameter< f32 > mSaturateMin
Definition aglDepthOfField.h:246
sead::Buffer< Context > mContext
Definition aglDepthOfField.h:224
void initialize(s32 ctx_num=1, sead::Heap *heap=nullptr)
Definition aglDepthOfField.cpp:76
utl::Parameter< bool > mIndirectEnable
Definition aglDepthOfField.h:239
virtual ~DepthOfField()
Definition aglDepthOfField.cpp:68
void setEnable(bool enable)
Definition aglDepthOfField.h:148
utl::Parameter< sead::Color4f > mFarMulColor
Definition aglDepthOfField.h:257
ShaderMode drawCompose_(const DrawArg &arg, ShaderMode mode) const
Definition aglDepthOfField.cpp:795
void assignShaderProgram_()
Definition aglDepthOfField.cpp:153
void setIndirectTextureData(const TextureData *p_texture_data)
Definition aglDepthOfField.cpp:1103
f32 _1f4
Definition aglDepthOfField.h:228
void drawKick_(const DrawArg &arg) const
Definition aglDepthOfField.cpp:594
sead::Vector4f mIndirectTexParam
Definition aglDepthOfField.h:266
sead::SafeArray< ShaderProgram *, 2 > mpCurrentProgramMipMap
Definition aglDepthOfField.h:260
utl::Parameter< bool > mEnableVignetting2Shape
Definition aglDepthOfField.h:237
void updateIndirectMatrix_()
Definition aglDepthOfField.cpp:1137
TempVignetting mTempVignetting1
Definition aglDepthOfField.h:256
utl::Parameter< bool > mDepthBlur
Definition aglDepthOfField.h:234
static s32 roundDown_(f32 value)
Definition aglDepthOfField.h:191
void allocBuffer(s32 ctx_index, const RenderBuffer &render_buffer) const
Definition aglDepthOfField.cpp:450
sead::SafeArray< VignettingShape, 2 > mVignettingShape
Definition aglDepthOfField.h:269
utl::Parameter< bool > mFarEnable
Definition aglDepthOfField.h:233
sead::Vector4f getTexParam_(const TextureData &data, u32 mip_level=0) const
Definition aglDepthOfField.h:201
utl::Parameter< f32 > mVignettingBlur
Definition aglDepthOfField.h:252
sead::GraphicsContextMRT mGraphicsContext
Definition aglDepthOfField.h:229
Sampler
Definition aglDepthOfField.h:112
@ cSampler_TexColor
Definition aglDepthOfField.h:113
@ cSampler_TexMipMapDepth
Definition aglDepthOfField.h:116
@ cSampler_TexIndirect
Definition aglDepthOfField.h:117
@ cSampler_TexMipMap
Definition aglDepthOfField.h:115
@ cSampler_Num
Definition aglDepthOfField.h:118
@ cSampler_TexDepth
Definition aglDepthOfField.h:114
sead::Vector3f mIndirectTexMtx0
Definition aglDepthOfField.h:267
sead::SafeArray< ShaderProgram *, 2 > mpCurrentProgramNearMask
Definition aglDepthOfField.h:259
utl::Parameter< f32 > mDepthBlurAdd
Definition aglDepthOfField.h:245
void setIndirectEnable(bool enable)
Definition aglDepthOfField.cpp:1110
Uniform
Definition aglDepthOfField.h:93
@ cUniform_MulParam
Definition aglDepthOfField.h:98
@ cUniform_Num
Definition aglDepthOfField.h:107
@ cUniform_FarMulColor
Definition aglDepthOfField.h:106
@ cUniform_TexParam
Definition aglDepthOfField.h:101
@ cUniform_IndirectTexMtx1
Definition aglDepthOfField.h:97
@ cUniform_VignettingTrans
Definition aglDepthOfField.h:104
@ cUniform_IndirectTexMtx0
Definition aglDepthOfField.h:96
@ cUniform_NearFarParam
Definition aglDepthOfField.h:100
@ cUniform_IndirectTexParam
Definition aglDepthOfField.h:95
@ cUniform_AddParam
Definition aglDepthOfField.h:99
@ cUniform_VignettingParam
Definition aglDepthOfField.h:103
@ cUniform_VignettingColor
Definition aglDepthOfField.h:105
@ cUniform_VignettingRadius
Definition aglDepthOfField.h:102
@ cUniform_Param0
Definition aglDepthOfField.h:94
utl::IParameterObj mParameterObj
Definition aglDepthOfField.h:230
u8 _10e8
Definition aglDepthOfField.h:270
ShaderMode draw(s32 ctx_index, const RenderBuffer &render_buffer, const TextureData &depth, bool view_depth, f32 near, f32 far, ShaderMode mode=cShaderMode_Invalid) const
Definition aglDepthOfField.cpp:406
void setIndirectTextureTrans(const sead::Vector2f &trans)
Definition aglDepthOfField.cpp:1119
void applyIndirectTextureData_()
Definition aglDepthOfField.cpp:1125
utl::Parameter< f32 > mStart
Definition aglDepthOfField.h:240
bool mEnableColorBlur
Definition aglDepthOfField.h:227
void allocBuffer(s32 ctx_index, TextureFormat format, s32 width, s32 height) const
Definition aglDepthOfField.cpp:458
const TextureData * mpIndirectTextureData
Definition aglDepthOfField.h:264
utl::Parameter< sead::Vector2f > mIndirectTexScale
Definition aglDepthOfField.h:249
utl::Parameter< sead::Color4f > mVignettingColor
Definition aglDepthOfField.h:254
ShaderMode draw(s32 ctx_index, const RenderBuffer &render_buffer, f32 near, f32 far, ShaderMode mode=cShaderMode_Invalid) const
Definition aglDepthOfField.cpp:400
utl::Parameter< sead::Vector2f > mIndirectTexTrans
Definition aglDepthOfField.h:248
VignettingBlendType
Definition aglDepthOfField.h:123
@ cVignettingBlendType_Add
Definition aglDepthOfField.h:125
@ cVignettingBlendType_Mult
Definition aglDepthOfField.h:126
@ cVignettingBlendType_Normal
Definition aglDepthOfField.h:124
@ cVignettingBlendType_Screen
Definition aglDepthOfField.h:127
sead::SafeArray< ShaderProgram *, 2 > mpCurrentProgramFinal
Definition aglDepthOfField.h:262
utl::Parameter< s32 > mVignettingBlend
Definition aglDepthOfField.h:253
bool enableDepthOfField_() const
Definition aglDepthOfField.cpp:523
Definition aglDebugTexturePage.h:11
Definition aglParameterIO.h:9
Definition aglParameterObj.h:13
Definition aglParameter.h:107
Definition seadBuffer.h:13
Definition seadGraphicsContextMRT.h:12
Definition seadHeap.h:23
Definition seadSafeArray.h:19
Definition seadHostIODummy.h:25
Definition aglDepthOfField.h:23
Definition aglImageFilter2D.h:11
Definition aglDisplayList.cpp:5
TextureFormat
Definition aglTextureEnum.h:10
ShaderMode
Definition aglShaderEnum.h:27
@ cShaderMode_Invalid
Definition aglShaderEnum.h:31
Definition seadHeap.h:14
Definition seadAssert.h:44
Vector2< f32 > Vector2f
Definition seadVector.h:238
SafeStringBase< char > SafeString
Definition seadSafeString.h:409
Vector3< f32 > Vector3f
Definition seadVector.h:239
Vector4< f32 > Vector4f
Definition seadVector.h:240
Definition aglDepthOfField.h:28
TextureSampler mDepthTextureSampler
Definition aglDepthOfField.h:44
TextureSampler mColorTextureSampler
Definition aglDepthOfField.h:42
s32 mIndex
Definition aglDepthOfField.h:30
RenderTargetColor mColorTarget
Definition aglDepthOfField.h:38
TextureData * mpDepthTextureData
Definition aglDepthOfField.h:43
TextureSampler mDepthTargetTextureSampler
Definition aglDepthOfField.h:34
TextureSampler mColorTargetTextureSampler
Definition aglDepthOfField.h:33
TextureData * mpColorTextureData
Definition aglDepthOfField.h:41
RenderBuffer mRenderBuffer
Definition aglDepthOfField.h:37
bool mIsInitialized
Definition aglDepthOfField.h:29
Definition aglDepthOfField.h:49
s32 pass
Definition aglDepthOfField.h:52
DrawArg(Context &ctx, const RenderBuffer &render_buffer, const TextureData &depth, bool view_depth_, f32 near_, f32 far_)
Definition aglDepthOfField.cpp:1161
const RenderBuffer * p_render_buffer
Definition aglDepthOfField.h:54
bool view_depth
Definition aglDepthOfField.h:59
f32 near
Definition aglDepthOfField.h:55
Context * p_ctx
Definition aglDepthOfField.h:53
f32 far
Definition aglDepthOfField.h:56
s32 height
Definition aglDepthOfField.h:58
s32 width
Definition aglDepthOfField.h:57
Definition aglDepthOfField.h:64
utl::Parameter< s32 > mType
Definition aglDepthOfField.h:67
utl::Parameter< sead::Vector2f > mTrans
Definition aglDepthOfField.h:70
TempVignetting(DepthOfField *p_dof, const sead::SafeString &param_name)
Definition aglDepthOfField.cpp:1174
utl::Parameter< sead::Vector2f > mScale
Definition aglDepthOfField.h:69
utl::Parameter< sead::Vector2f > mRange
Definition aglDepthOfField.h:68
Definition aglDepthOfField.h:75
sead::Vector2f position
Definition aglDepthOfField.h:76
sead::Vector2f texcoord
Definition aglDepthOfField.h:77
Definition aglDepthOfField.h:82
VertexAttribute mVertexAttribute
Definition aglDepthOfField.h:86
sead::Buffer< Vertex > mVertex
Definition aglDepthOfField.h:83
IndexStream mIndexStream
Definition aglDepthOfField.h:87
sead::Buffer< u16 > mIndex
Definition aglDepthOfField.h:84
VertexBuffer mVertexBuffer
Definition aglDepthOfField.h:85
Definition seadColor.h:9