@@ -36,13 +36,16 @@ SamplerDescriptor MakeSamplerDescriptor(MinMagFilter filter,
36
36
// / @param entity_transform The local transform of the entity.
37
37
// / @return A quad in uv coordinates representing the whole |subpass_size|.
38
38
std::array<Point, 4 > CalculateUVs (const ISize& subpass_size,
39
+ const Matrix& scale,
39
40
const Matrix& effect_transform,
40
41
const Matrix& entity_transform) {
41
42
Rect pass_rect =
42
- Rect::MakeSize (subpass_size).TransformBounds (effect_transform);
43
+ Rect::MakeSize (subpass_size).TransformBounds (scale * effect_transform);
44
+ Vector3 translated_origin =
45
+ effect_transform * entity_transform.Invert () * Vector3 (0 , 0 , 1 );
43
46
Matrix transform = Matrix::MakeScale ({1 .0f / pass_rect.size .width ,
44
47
1 .0f / pass_rect.size .height , 1 .0f }) *
45
- entity_transform. Invert ( );
48
+ Matrix::MakeTranslation (translated_origin );
46
49
return pass_rect.GetTransformedPoints (transform);
47
50
}
48
51
@@ -69,11 +72,9 @@ std::shared_ptr<Texture> MakeDownsampleSubpass(
69
72
[&](const ContentContext& renderer, RenderPass& pass) {
70
73
HostBuffer& host_buffer = pass.GetTransientsBuffer ();
71
74
72
- std::array<Point, 4 > uvs =
73
- CalculateUVs (subpass_size,
74
- Matrix::MakeScale ({downsample.x , downsample.y , 1.0 }) *
75
- effect_transform,
76
- entity_transform);
75
+ std::array<Point, 4 > uvs = CalculateUVs (
76
+ subpass_size, Matrix::MakeScale ({downsample.x , downsample.y , 1.0 }),
77
+ effect_transform, entity_transform);
77
78
78
79
Command cmd;
79
80
DEBUG_COMMAND_INFO (cmd, " Gaussian blur downsample" );
@@ -128,11 +129,9 @@ std::shared_ptr<Texture> MakeBlurSubpass(
128
129
129
130
HostBuffer& host_buffer = pass.GetTransientsBuffer ();
130
131
131
- std::array<Point, 4 > uvs =
132
- CalculateUVs (subpass_size,
133
- Matrix::MakeScale ({downsample.x , downsample.y , 1.0 }) *
134
- effect_transform,
135
- entity_transform);
132
+ std::array<Point, 4 > uvs = CalculateUVs (
133
+ subpass_size, Matrix::MakeScale ({downsample.x , downsample.y , 1.0 }),
134
+ effect_transform, entity_transform);
136
135
137
136
Command cmd;
138
137
auto options = OptionsFromPass (pass);
@@ -231,6 +230,7 @@ std::optional<Entity> GaussianBlurFilterContents::RenderFilter(
231
230
return std::nullopt;
232
231
}
233
232
233
+ // TODO(gaaclarke): Scale the blur radius based on the entity transform.
234
234
Scalar blur_radius = CalculateBlurRadius (sigma_);
235
235
Scalar desired_scale = 1.0 / CalculateScale (blur_radius);
236
236
Vector2 downsample =
0 commit comments