feat: add flag for keepData for gltf instancing, add highlightScene, add stencilHighlight method
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
#ifndef UNLIT_MATERIAL_PROVIDER_HPP
|
||||
#define UNLIT_MATERIAL_PROVIDER_HPP
|
||||
|
||||
#include <filament/gltfio/MaterialProvider.h>
|
||||
#include <filament/Material.h>
|
||||
#include <filament/MaterialInstance.h>
|
||||
#include <filament/Texture.h>
|
||||
#include <filament/TextureSampler.h>
|
||||
#include <math/mat3.h>
|
||||
#include <math/vec3.h>
|
||||
#include <math/vec4.h>
|
||||
|
||||
namespace thermion_filament {
|
||||
|
||||
class UnlitMaterialProvider : public filament::gltfio::MaterialProvider {
|
||||
private:
|
||||
filament::Material* mUnlitMaterial;
|
||||
const filament::Material* mMaterials[1];
|
||||
filament::Engine* mEngine;
|
||||
|
||||
public:
|
||||
UnlitMaterialProvider(filament::Engine* engine, const void* const data, const size_t size) : mEngine(engine) {
|
||||
mUnlitMaterial = filament::Material::Builder()
|
||||
.package(data, size)
|
||||
.build(*engine);
|
||||
mMaterials[0] = mUnlitMaterial;
|
||||
}
|
||||
|
||||
~UnlitMaterialProvider() {
|
||||
mEngine->destroy(mUnlitMaterial);
|
||||
}
|
||||
|
||||
filament::MaterialInstance* createMaterialInstance(filament::gltfio::MaterialKey* config,
|
||||
filament::gltfio::UvMap* uvmap,
|
||||
const char* label = "unlit",
|
||||
const char* extras = nullptr) override {
|
||||
auto instance = mUnlitMaterial->createInstance();
|
||||
|
||||
// Set default parameters
|
||||
instance->setParameter("color", filament::math::float3{1.0f, 1.0f, 1.0f});
|
||||
instance->setParameter("scale", 1.0f);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
filament::Material* getMaterial(filament::gltfio::MaterialKey* config,
|
||||
filament::gltfio::UvMap* uvmap,
|
||||
const char* label = "unlit") override {
|
||||
return mUnlitMaterial;
|
||||
}
|
||||
|
||||
const filament::Material* const* getMaterials() const noexcept override {
|
||||
return mMaterials;
|
||||
}
|
||||
|
||||
size_t getMaterialsCount() const noexcept override {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void destroyMaterials() override {
|
||||
// Materials are destroyed in the destructor
|
||||
}
|
||||
|
||||
bool needsDummyData(filament::VertexAttribute attrib) const noexcept override {
|
||||
// For unlit material, we don't need dummy data for any attribute
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace thermion_filament
|
||||
|
||||
#endif // UNLIT_MATERIAL_PROVIDER_HPP
|
||||
12
thermion_dart/native/include/material/unlit.S
Normal file
12
thermion_dart/native/include/material/unlit.S
Normal file
@@ -0,0 +1,12 @@
|
||||
.global UNLIT_UNLIT_OFFSET;
|
||||
.global UNLIT_UNLIT_SIZE;
|
||||
|
||||
.global UNLIT_PACKAGE
|
||||
.section .rodata
|
||||
UNLIT_PACKAGE:
|
||||
.incbin "unlit.bin"
|
||||
UNLIT_UNLIT_OFFSET:
|
||||
.int 0
|
||||
UNLIT_UNLIT_SIZE:
|
||||
.int 26426
|
||||
|
||||
12
thermion_dart/native/include/material/unlit.apple.S
Normal file
12
thermion_dart/native/include/material/unlit.apple.S
Normal file
@@ -0,0 +1,12 @@
|
||||
.global _UNLIT_UNLIT_OFFSET;
|
||||
.global _UNLIT_UNLIT_SIZE;
|
||||
|
||||
.global _UNLIT_PACKAGE
|
||||
.section __TEXT,__const
|
||||
_UNLIT_PACKAGE:
|
||||
.incbin "unlit.bin"
|
||||
_UNLIT_UNLIT_OFFSET:
|
||||
.int 0
|
||||
_UNLIT_UNLIT_SIZE:
|
||||
.int 26426
|
||||
|
||||
BIN
thermion_dart/native/include/material/unlit.bin
Normal file
BIN
thermion_dart/native/include/material/unlit.bin
Normal file
Binary file not shown.
1332
thermion_dart/native/include/material/unlit.c
Normal file
1332
thermion_dart/native/include/material/unlit.c
Normal file
File diff suppressed because it is too large
Load Diff
13
thermion_dart/native/include/material/unlit.h
Normal file
13
thermion_dart/native/include/material/unlit.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef UNLIT_H_
|
||||
#define UNLIT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C" {
|
||||
extern const uint8_t UNLIT_PACKAGE[];
|
||||
extern int UNLIT_UNLIT_OFFSET;
|
||||
extern int UNLIT_UNLIT_SIZE;
|
||||
}
|
||||
#define UNLIT_UNLIT_DATA (UNLIT_PACKAGE + UNLIT_UNLIT_OFFSET)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user