|
12 | 12 | #include "impeller/geometry/vector.h" |
13 | 13 | #include "impeller/renderer/device_buffer_descriptor.h" |
14 | 14 | #include "impeller/renderer/formats.h" |
| 15 | +#include "impeller/renderer/sampler_descriptor.h" |
| 16 | +#include "impeller/renderer/sampler_library.h" |
15 | 17 | #include "impeller/renderer/vertex_buffer.h" |
16 | 18 | #include "impeller/renderer/vertex_buffer_builder.h" |
17 | 19 | #include "impeller/scene/importer/scene_flatbuffers.h" |
@@ -117,6 +119,8 @@ std::shared_ptr<Geometry> Geometry::MakeFromFlatbuffer( |
117 | 119 | return MakeVertexBuffer(std::move(vertex_buffer), is_skinned); |
118 | 120 | } |
119 | 121 |
|
| 122 | +void Geometry::SetJointsTexture(const std::shared_ptr<Texture>& texture) {} |
| 123 | + |
120 | 124 | //------------------------------------------------------------------------------ |
121 | 125 | /// CuboidGeometry |
122 | 126 | /// |
@@ -239,10 +243,31 @@ void SkinnedVertexBufferGeometry::BindToCommand( |
239 | 243 | command.BindVertices( |
240 | 244 | GetVertexBuffer(*scene_context.GetContext()->GetResourceAllocator())); |
241 | 245 |
|
| 246 | + SamplerDescriptor sampler_desc; |
| 247 | + sampler_desc.min_filter = MinMagFilter::kNearest; |
| 248 | + sampler_desc.mag_filter = MinMagFilter::kNearest; |
| 249 | + sampler_desc.mip_filter = MipFilter::kNone; |
| 250 | + sampler_desc.width_address_mode = SamplerAddressMode::kRepeat; |
| 251 | + sampler_desc.label = "NN Repeat"; |
| 252 | + |
| 253 | + SkinnedVertexShader::BindJointsTexture( |
| 254 | + command, |
| 255 | + joints_texture_ ? joints_texture_ : scene_context.GetPlaceholderTexture(), |
| 256 | + scene_context.GetContext()->GetSamplerLibrary()->GetSampler( |
| 257 | + sampler_desc)); |
| 258 | + |
242 | 259 | SkinnedVertexShader::VertInfo info; |
243 | 260 | info.mvp = transform; |
| 261 | + info.enable_skinning = joints_texture_ ? 1 : 0; |
| 262 | + info.joint_texture_size = |
| 263 | + joints_texture_ ? joints_texture_->GetSize().width : 1; |
244 | 264 | SkinnedVertexShader::BindVertInfo(command, buffer.EmplaceUniform(info)); |
245 | 265 | } |
246 | 266 |
|
| 267 | +// |Geometry| |
| 268 | +void SkinnedVertexBufferGeometry::SetJointsTexture( |
| 269 | + const std::shared_ptr<Texture>& texture) { |
| 270 | + joints_texture_ = texture; |
| 271 | +} |
247 | 272 | } // namespace scene |
248 | 273 | } // namespace impeller |
0 commit comments