move outline material to embedded binary
This commit is contained in:
@@ -66,6 +66,8 @@ void main(List<String> args) async {
|
|||||||
"unlit_fixed_size.c"),
|
"unlit_fixed_size.c"),
|
||||||
path.join(pkgRootFilePath, "native", "include", "material", "image.c"),
|
path.join(pkgRootFilePath, "native", "include", "material", "image.c"),
|
||||||
path.join(pkgRootFilePath, "native", "include", "material", "grid.c"),
|
path.join(pkgRootFilePath, "native", "include", "material", "grid.c"),
|
||||||
|
path.join(pkgRootFilePath, "native", "include", "material", "linear_depth.c"),
|
||||||
|
path.join(pkgRootFilePath, "native", "include", "material", "outline.c"),
|
||||||
path.join(pkgRootFilePath, "native", "include", "resources",
|
path.join(pkgRootFilePath, "native", "include", "resources",
|
||||||
"translation_gizmo_glb.c"),
|
"translation_gizmo_glb.c"),
|
||||||
path.join(pkgRootFilePath, "native", "include", "resources",
|
path.join(pkgRootFilePath, "native", "include", "resources",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
import 'package:thermion_dart/src/filament/src/implementation/ffi_material.dart';
|
||||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_texture.dart';
|
import 'package:thermion_dart/src/filament/src/implementation/ffi_texture.dart';
|
||||||
import 'package:thermion_dart/src/filament/src/interface/scene.dart';
|
import 'package:thermion_dart/src/filament/src/interface/scene.dart';
|
||||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_filament_app.dart';
|
import 'package:thermion_dart/src/filament/src/implementation/ffi_filament_app.dart';
|
||||||
@@ -278,13 +279,8 @@ class FFIView extends View<Pointer<TView>> {
|
|||||||
int primitiveIndex = 0}) async {
|
int primitiveIndex = 0}) async {
|
||||||
entity ??= asset.entity;
|
entity ??= asset.entity;
|
||||||
|
|
||||||
|
|
||||||
if (overlayScene == null) {
|
if (overlayScene == null) {
|
||||||
// overlayView = await FilamentApp.instance!.createView();
|
|
||||||
overlayScene = await FilamentApp.instance!.createScene();
|
overlayScene = await FilamentApp.instance!.createScene();
|
||||||
// await overlayView!.setScene(overlayScene!);
|
|
||||||
// await overlayView!.setRenderTarget(await this.getRenderTarget());
|
|
||||||
|
|
||||||
final vp = await getViewport();
|
final vp = await getViewport();
|
||||||
overlayRenderTarget =
|
overlayRenderTarget =
|
||||||
await FilamentApp.instance!.createRenderTarget(vp.width, vp.height);
|
await FilamentApp.instance!.createRenderTarget(vp.width, vp.height);
|
||||||
@@ -294,28 +290,12 @@ class FFIView extends View<Pointer<TView>> {
|
|||||||
getNativeHandle(),
|
getNativeHandle(),
|
||||||
overlayScene!.getNativeHandle(),
|
overlayScene!.getNativeHandle(),
|
||||||
overlayRenderTarget!.getNativeHandle());
|
overlayRenderTarget!.getNativeHandle());
|
||||||
// await setBlendMode(BlendMode.transparent);
|
|
||||||
// await overlayView!.setBlendMode(BlendMode.transparent);
|
|
||||||
// await overlayView!.setCamera(await getCamera());
|
|
||||||
// await overlayView!.setViewport(vp.width, vp.height);
|
|
||||||
// await setStencilBufferEnabled(true);
|
|
||||||
// await overlayView!.setStencilBufferEnabled(true);
|
|
||||||
RenderTicker_setOverlayManager(app.renderTicker, overlayManager!);
|
RenderTicker_setOverlayManager(app.renderTicker, overlayManager!);
|
||||||
highlightMaterial ??= await FilamentApp.instance!.createMaterial(
|
final highlightMaterialPtr = await withPointerCallback<TMaterial>(
|
||||||
File("/Users/nickfisher/Documents/thermion/materials/outline.filamat")
|
(cb) => Material_createOutlineMaterialRenderThread(app.engine, cb));
|
||||||
.readAsBytesSync());
|
highlightMaterial = FFIMaterial(highlightMaterialPtr, app);
|
||||||
}
|
}
|
||||||
|
|
||||||
// await sourceMaterialInstance.setStencilWriteEnabled(true);
|
|
||||||
// await sourceMaterialInstance
|
|
||||||
// .setStencilOpDepthStencilPass(StencilOperation.REPLACE);
|
|
||||||
// await sourceMaterialInstance
|
|
||||||
// .setStencilReferenceValue(View.STENCIL_HIGHLIGHT_REFERENCE_VALUE);
|
|
||||||
// await sourceMaterialInstance.setDepthCullingEnabled(false);
|
|
||||||
// await sourceMaterialInstance.setDepthFunc(SamplerCompareFunction.A);
|
|
||||||
// await sourceMaterialInstance
|
|
||||||
// .setStencilCompareFunction(SamplerCompareFunction.A);
|
|
||||||
|
|
||||||
var highlightMaterialInstance = await highlightMaterial!.createInstance();
|
var highlightMaterialInstance = await highlightMaterial!.createInstance();
|
||||||
|
|
||||||
await highlightMaterialInstance.setDepthCullingEnabled(true);
|
await highlightMaterialInstance.setDepthCullingEnabled(true);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ set(MATERIAL_SOURCES
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/material/image.c"
|
"${CMAKE_CURRENT_SOURCE_DIR}/include/material/image.c"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/material/grid.c"
|
"${CMAKE_CURRENT_SOURCE_DIR}/include/material/grid.c"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/material/linear_depth.c"
|
"${CMAKE_CURRENT_SOURCE_DIR}/include/material/linear_depth.c"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/include/material/outline.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
set_source_files_properties(${MATERIAL_SOURCES} PROPERTIES LANGUAGE CXX)
|
set_source_files_properties(${MATERIAL_SOURCES} PROPERTIES LANGUAGE CXX)
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ extern "C"
|
|||||||
EMSCRIPTEN_KEEPALIVE TMaterial *Material_createImageMaterial(TEngine *tEngine);
|
EMSCRIPTEN_KEEPALIVE TMaterial *Material_createImageMaterial(TEngine *tEngine);
|
||||||
EMSCRIPTEN_KEEPALIVE TMaterial *Material_createGridMaterial(TEngine *tEngine);
|
EMSCRIPTEN_KEEPALIVE TMaterial *Material_createGridMaterial(TEngine *tEngine);
|
||||||
EMSCRIPTEN_KEEPALIVE TMaterial *Material_createGizmoMaterial(TEngine *tEngine);
|
EMSCRIPTEN_KEEPALIVE TMaterial *Material_createGizmoMaterial(TEngine *tEngine);
|
||||||
|
EMSCRIPTEN_KEEPALIVE TMaterial *Material_createOutlineMaterial(TEngine *tEngine);
|
||||||
EMSCRIPTEN_KEEPALIVE bool Material_hasParameter(TMaterial *tMaterial, const char *propertyName);
|
EMSCRIPTEN_KEEPALIVE bool Material_hasParameter(TMaterial *tMaterial, const char *propertyName);
|
||||||
EMSCRIPTEN_KEEPALIVE bool MaterialInstance_isStencilWriteEnabled(TMaterialInstance *materialInstance);
|
EMSCRIPTEN_KEEPALIVE bool MaterialInstance_isStencilWriteEnabled(TMaterialInstance *materialInstance);
|
||||||
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setStencilWrite(TMaterialInstance *materialInstance, bool enabled);
|
EMSCRIPTEN_KEEPALIVE void MaterialInstance_setStencilWrite(TMaterialInstance *materialInstance, bool enabled);
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ namespace thermion
|
|||||||
void Material_createInstanceRenderThread(TMaterial *tMaterial, void (*onComplete)(TMaterialInstance *));
|
void Material_createInstanceRenderThread(TMaterial *tMaterial, void (*onComplete)(TMaterialInstance *));
|
||||||
void Material_createImageMaterialRenderThread(TEngine *tEngine, void (*onComplete)(TMaterial *));
|
void Material_createImageMaterialRenderThread(TEngine *tEngine, void (*onComplete)(TMaterial *));
|
||||||
void Material_createGizmoMaterialRenderThread(TEngine *tEngine, void (*onComplete)(TMaterial *));
|
void Material_createGizmoMaterialRenderThread(TEngine *tEngine, void (*onComplete)(TMaterial *));
|
||||||
|
void Material_createOutlineMaterialRenderThread(TEngine *tEngine, void (*onComplete)(TMaterial *));
|
||||||
|
|
||||||
void ColorGrading_createRenderThread(TEngine *tEngine, TToneMapping toneMapping, void (*callback)(TColorGrading *));
|
void ColorGrading_createRenderThread(TEngine *tEngine, TToneMapping toneMapping, void (*callback)(TColorGrading *));
|
||||||
void View_pickRenderThread(TView *tView, uint32_t requestId, uint32_t x, uint32_t y, PickCallback callback);
|
void View_pickRenderThread(TView *tView, uint32_t requestId, uint32_t x, uint32_t y, PickCallback callback);
|
||||||
|
|||||||
12
thermion_dart/native/include/material/outline.S
Normal file
12
thermion_dart/native/include/material/outline.S
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
.global OUTLINE_OUTLINE_OFFSET;
|
||||||
|
.global OUTLINE_OUTLINE_SIZE;
|
||||||
|
|
||||||
|
.global OUTLINE_PACKAGE
|
||||||
|
.section .rodata
|
||||||
|
OUTLINE_PACKAGE:
|
||||||
|
.incbin "outline.bin"
|
||||||
|
OUTLINE_OUTLINE_OFFSET:
|
||||||
|
.int 0
|
||||||
|
OUTLINE_OUTLINE_SIZE:
|
||||||
|
.int 112782
|
||||||
|
|
||||||
12
thermion_dart/native/include/material/outline.apple.S
Normal file
12
thermion_dart/native/include/material/outline.apple.S
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
.global _OUTLINE_OUTLINE_OFFSET;
|
||||||
|
.global _OUTLINE_OUTLINE_SIZE;
|
||||||
|
|
||||||
|
.global _OUTLINE_PACKAGE
|
||||||
|
.section __TEXT,__const
|
||||||
|
_OUTLINE_PACKAGE:
|
||||||
|
.incbin "outline.bin"
|
||||||
|
_OUTLINE_OUTLINE_OFFSET:
|
||||||
|
.int 0
|
||||||
|
_OUTLINE_OUTLINE_SIZE:
|
||||||
|
.int 112782
|
||||||
|
|
||||||
BIN
thermion_dart/native/include/material/outline.bin
Normal file
BIN
thermion_dart/native/include/material/outline.bin
Normal file
Binary file not shown.
5650
thermion_dart/native/include/material/outline.c
Normal file
5650
thermion_dart/native/include/material/outline.c
Normal file
File diff suppressed because it is too large
Load Diff
13
thermion_dart/native/include/material/outline.h
Normal file
13
thermion_dart/native/include/material/outline.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef OUTLINE_H_
|
||||||
|
#define OUTLINE_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
extern const uint8_t OUTLINE_PACKAGE[];
|
||||||
|
extern int OUTLINE_OUTLINE_OFFSET;
|
||||||
|
extern int OUTLINE_OUTLINE_SIZE;
|
||||||
|
}
|
||||||
|
#define OUTLINE_OUTLINE_DATA (OUTLINE_PACKAGE + OUTLINE_OUTLINE_OFFSET)
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "material/image.h"
|
#include "material/image.h"
|
||||||
#include "material/grid.h"
|
#include "material/grid.h"
|
||||||
#include "material/unlit_fixed_size.h"
|
#include "material/unlit_fixed_size.h"
|
||||||
|
#include "material/outline.h"
|
||||||
|
|
||||||
#include "c_api/TMaterialInstance.h"
|
#include "c_api/TMaterialInstance.h"
|
||||||
|
|
||||||
@@ -74,6 +75,14 @@ namespace thermion
|
|||||||
return reinterpret_cast<TMaterial *>(material);
|
return reinterpret_cast<TMaterial *>(material);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EMSCRIPTEN_KEEPALIVE TMaterial *Material_createOutlineMaterial(TEngine *tEngine) {
|
||||||
|
auto *engine = reinterpret_cast<filament::Engine *>(tEngine);
|
||||||
|
auto *material = filament::Material::Builder()
|
||||||
|
.package(OUTLINE_OUTLINE_DATA, OUTLINE_OUTLINE_SIZE)
|
||||||
|
.build(*engine);
|
||||||
|
return reinterpret_cast<TMaterial *>(material);
|
||||||
|
}
|
||||||
|
|
||||||
EMSCRIPTEN_KEEPALIVE bool Material_hasParameter(TMaterial *tMaterial, const char *propertyName) {
|
EMSCRIPTEN_KEEPALIVE bool Material_hasParameter(TMaterial *tMaterial, const char *propertyName) {
|
||||||
auto *material = reinterpret_cast<filament::Material *>(tMaterial);
|
auto *material = reinterpret_cast<filament::Material *>(tMaterial);
|
||||||
return material->hasParameter(propertyName);
|
return material->hasParameter(propertyName);
|
||||||
|
|||||||
@@ -513,6 +513,17 @@ extern "C"
|
|||||||
auto fut = _renderThread->add_task(lambda);
|
auto fut = _renderThread->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EMSCRIPTEN_KEEPALIVE void Material_createOutlineMaterialRenderThread(TEngine *tEngine, void (*onComplete)(TMaterial *))
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda(
|
||||||
|
[=]() mutable
|
||||||
|
{
|
||||||
|
auto *instance = Material_createOutlineMaterial(tEngine);
|
||||||
|
PROXY(onComplete(instance));
|
||||||
|
});
|
||||||
|
auto fut = _renderThread->add_task(lambda);
|
||||||
|
}
|
||||||
|
|
||||||
EMSCRIPTEN_KEEPALIVE void Material_createInstanceRenderThread(TMaterial *tMaterial, void (*onComplete)(TMaterialInstance *))
|
EMSCRIPTEN_KEEPALIVE void Material_createInstanceRenderThread(TMaterial *tMaterial, void (*onComplete)(TMaterialInstance *))
|
||||||
{
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
|
|||||||
Reference in New Issue
Block a user