updates
This commit is contained in:
@@ -123,25 +123,26 @@ class _MyAppState extends State<MyApp> {
|
||||
_filamentController.setCamera(_cube!, "Camera_Orientation");
|
||||
break;
|
||||
case 15:
|
||||
final animation = AnimationBuilder()
|
||||
.setFramerate(30)
|
||||
.setDuration(4)
|
||||
.setNumMorphWeights(8)
|
||||
.interpolateMorphWeights(0, 4, 0, 1)
|
||||
.interpolateBoneTransform(
|
||||
"Bone.001",
|
||||
"Cube.001",
|
||||
2,
|
||||
4,
|
||||
v.Vector3.zero(),
|
||||
v.Vector3.zero(),
|
||||
// Vec3(x: 1, y: 1, z: 1),
|
||||
v.Quaternion(0, 0, 0, 1),
|
||||
v.Quaternion(1, 1, 1, 1))
|
||||
// Quaternion(x: 1, y: 1, z: 1, w: 1))
|
||||
.build();
|
||||
throw Exception("FIXME");
|
||||
// final animation = AnimationBuilder()
|
||||
// .setFramerate(30)
|
||||
// .setDuration(4)
|
||||
// .setNumMorphWeights(8)
|
||||
// .interpolateMorphWeights(0, 4, 0, 1)
|
||||
// .interpolateBoneTransform(
|
||||
// "Bone.001",
|
||||
// "Cube.001",
|
||||
// 2,
|
||||
// 4,
|
||||
// v.Vector3.zero(),
|
||||
// v.Vector3.zero(),
|
||||
// // Vec3(x: 1, y: 1, z: 1),
|
||||
// v.Quaternion(0, 0, 0, 1),
|
||||
// v.Quaternion(1, 1, 1, 1))
|
||||
// // Quaternion(x: 1, y: 1, z: 1, w: 1))
|
||||
// .build();
|
||||
|
||||
_filamentController.setAnimation(_cube!, animation);
|
||||
// _filamentController.setAnimation(_cube!, animation);
|
||||
break;
|
||||
case 16:
|
||||
_targetNames =
|
||||
@@ -307,7 +308,7 @@ class _MyAppState extends State<MyApp> {
|
||||
alignment: Alignment.center,
|
||||
child: SizedBox(
|
||||
child: FilamentGestureDetector(
|
||||
showControls: true,
|
||||
showControlOverlay: true,
|
||||
controller: _filamentController,
|
||||
child: FilamentWidget(
|
||||
controller: _filamentController,
|
||||
|
||||
@@ -5,49 +5,56 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.9.0"
|
||||
version: "2.10.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.1.1"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: characters
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.16.0"
|
||||
version: "1.17.0"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cupertino_icons
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: "486b7bc707424572cdf7bd7e812a0c146de3fd47ecadf070254cc60383f21dd8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
flutter:
|
||||
@@ -59,7 +66,8 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
flutter_test:
|
||||
@@ -67,46 +75,60 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: js
|
||||
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.5"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.12"
|
||||
version: "0.12.13"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.5"
|
||||
version: "0.2.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.8.2"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: "5aadc2af7cd403ad0b95ef654c3e628517f4cae9682b4229a66caf9df71844d2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
polyvox_filament:
|
||||
@@ -125,51 +147,58 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
version: "1.9.1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
version: "1.11.0"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.1.1"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
version: "1.2.0"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.4.12"
|
||||
version: "0.4.16"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.dartlang.org"
|
||||
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
version: "2.1.4"
|
||||
sdks:
|
||||
dart: ">=2.17.1 <3.0.0"
|
||||
dart: ">=2.18.0 <3.0.0"
|
||||
flutter: ">=1.20.0"
|
||||
|
||||
@@ -10,14 +10,16 @@ enum GestureType { RotateCamera, PanCamera, PanBackground }
|
||||
class FilamentGestureDetector extends StatefulWidget {
|
||||
final Widget? child;
|
||||
final FilamentController controller;
|
||||
final bool showControls;
|
||||
final bool showControlOverlay;
|
||||
final bool enableControls;
|
||||
|
||||
const FilamentGestureDetector({
|
||||
Key? key,
|
||||
required this.controller,
|
||||
this.child,
|
||||
this.showControls = false,
|
||||
}) : super(key: key);
|
||||
const FilamentGestureDetector(
|
||||
{Key? key,
|
||||
required this.controller,
|
||||
this.child,
|
||||
this.showControlOverlay = false,
|
||||
this.enableControls = true})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _FilamentGestureDetectorState();
|
||||
@@ -68,9 +70,9 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(Widget oldWidget) {
|
||||
if (widget.showControls !=
|
||||
(oldWidget as FilamentGestureDetector).showControls) {
|
||||
void didUpdateWidget(FilamentGestureDetector oldWidget) {
|
||||
if (widget.showControlOverlay != oldWidget.showControlOverlay ||
|
||||
widget.enableControls != oldWidget.enableControls) {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -81,64 +83,93 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print(widget.enableControls);
|
||||
return Stack(children: [
|
||||
Positioned.fill(
|
||||
// pinch zoom on mobile
|
||||
// couldn't find any equivalent for pointerCount in Listener so we use two widgets:
|
||||
// - outer is a GestureDetector only for pinch zoom
|
||||
// - inner is a Listener for all other gestures
|
||||
// - inner is a Listener for all other gestures (including scroll zoom on desktop)
|
||||
child: GestureDetector(
|
||||
onScaleStart: (d) async {
|
||||
if (d.pointerCount == 2) {
|
||||
await widget.controller.zoomEnd();
|
||||
await widget.controller.zoomBegin();
|
||||
}
|
||||
},
|
||||
onScaleEnd: (d) async {
|
||||
if (d.pointerCount == 2) {
|
||||
_lastScale = 0;
|
||||
await widget.controller.zoomEnd();
|
||||
}
|
||||
},
|
||||
onScaleUpdate: (d) async {
|
||||
if (d.pointerCount == 2) {
|
||||
if (_lastScale != 0) {
|
||||
await widget.controller
|
||||
.zoomUpdate(100 * (_lastScale - d.scale));
|
||||
}
|
||||
}
|
||||
_lastScale = d.scale;
|
||||
},
|
||||
onScaleStart: !widget.enableControls
|
||||
? null
|
||||
: (d) async {
|
||||
if (d.pointerCount == 2) {
|
||||
await widget.controller.zoomEnd();
|
||||
await widget.controller.zoomBegin();
|
||||
}
|
||||
},
|
||||
onScaleEnd: !widget.enableControls
|
||||
? null
|
||||
: (d) async {
|
||||
if (d.pointerCount == 2) {
|
||||
_lastScale = 0;
|
||||
await widget.controller.zoomEnd();
|
||||
}
|
||||
},
|
||||
onScaleUpdate: !widget.enableControls
|
||||
? null
|
||||
: (d) async {
|
||||
if (d.pointerCount == 2) {
|
||||
if (_lastScale != 0) {
|
||||
await widget.controller
|
||||
.zoomUpdate(100 * (_lastScale - d.scale));
|
||||
}
|
||||
}
|
||||
_lastScale = d.scale;
|
||||
},
|
||||
child: Listener(
|
||||
onPointerSignal: (pointerSignal) async {
|
||||
// scroll-wheel zoom on desktop
|
||||
if (pointerSignal is PointerScrollEvent) {
|
||||
_scrollTimer?.cancel();
|
||||
await widget.controller.zoomBegin();
|
||||
await widget.controller.zoomUpdate(
|
||||
pointerSignal.scrollDelta.dy > 0 ? 10 : -10);
|
||||
_scrollTimer = Timer(Duration(milliseconds: 100), () {
|
||||
widget.controller.zoomEnd();
|
||||
_scrollTimer = null;
|
||||
});
|
||||
} else {
|
||||
print(pointerSignal);
|
||||
}
|
||||
},
|
||||
onPointerPanZoomStart: (pzs) {},
|
||||
onPointerDown: (d) async {
|
||||
await _functionStart(
|
||||
d.localPosition.dx, d.localPosition.dy);
|
||||
},
|
||||
onPointerMove: (d) async {
|
||||
await _functionUpdate(
|
||||
d.localPosition.dx, d.localPosition.dy);
|
||||
},
|
||||
onPointerUp: (d) async {
|
||||
await _functionEnd();
|
||||
},
|
||||
onPointerSignal: !widget.enableControls
|
||||
? null
|
||||
: (pointerSignal) async {
|
||||
// scroll-wheel zoom on desktop
|
||||
if (pointerSignal is PointerScrollEvent) {
|
||||
_scrollTimer?.cancel();
|
||||
await widget.controller.zoomBegin();
|
||||
await widget.controller.zoomUpdate(
|
||||
pointerSignal.scrollDelta.dy > 0 ? 10 : -10);
|
||||
_scrollTimer =
|
||||
Timer(Duration(milliseconds: 100), () {
|
||||
widget.controller.zoomEnd();
|
||||
_scrollTimer = null;
|
||||
});
|
||||
}
|
||||
},
|
||||
onPointerPanZoomStart:
|
||||
!widget.enableControls ? null : (pzs) {},
|
||||
onPointerDown: !widget.enableControls
|
||||
? null
|
||||
: (d) async {
|
||||
if (d.buttons == kTertiaryButton) {
|
||||
await widget.controller.rotateStart(
|
||||
d.localPosition.dx, d.localPosition.dy);
|
||||
} else {
|
||||
await _functionStart(
|
||||
d.localPosition.dx, d.localPosition.dy);
|
||||
}
|
||||
},
|
||||
onPointerMove: !widget.enableControls
|
||||
? null
|
||||
: (d) async {
|
||||
if (d.buttons == kTertiaryButton) {
|
||||
await widget.controller.rotateUpdate(
|
||||
d.localPosition.dx, d.localPosition.dy);
|
||||
} else {
|
||||
await _functionUpdate(
|
||||
d.localPosition.dx, d.localPosition.dy);
|
||||
}
|
||||
},
|
||||
onPointerUp: !widget.enableControls
|
||||
? null
|
||||
: (d) async {
|
||||
if (d.buttons == kTertiaryButton) {
|
||||
await widget.controller.rotateEnd();
|
||||
} else {
|
||||
await _functionEnd();
|
||||
}
|
||||
},
|
||||
child: widget.child))),
|
||||
widget.showControls
|
||||
widget.showControlOverlay
|
||||
? Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: GestureDetector(
|
||||
|
||||
@@ -57,6 +57,8 @@ class FilamentWidget extends StatefulWidget {
|
||||
class _FilamentWidgetState extends State<FilamentWidget> {
|
||||
StreamSubscription? _listener;
|
||||
|
||||
bool _resizing = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_listener = widget.controller.onInitializationRequested.listen((_) {
|
||||
@@ -85,7 +87,7 @@ class _FilamentWidgetState extends State<FilamentWidget> {
|
||||
Widget build(BuildContext context) {
|
||||
return StreamBuilder(
|
||||
stream: widget.controller.textureId,
|
||||
builder: (ctx, AsyncSnapshot<int> textureId) {
|
||||
builder: (ctx, AsyncSnapshot<int?> textureId) {
|
||||
if (textureId.data == null) {
|
||||
return Container();
|
||||
}
|
||||
@@ -101,14 +103,23 @@ class _FilamentWidgetState extends State<FilamentWidget> {
|
||||
width: constraints.maxWidth,
|
||||
child: ResizeObserver(
|
||||
onResized: (Size oldSize, Size newSize) async {
|
||||
setState(() {
|
||||
_resizing = true;
|
||||
});
|
||||
|
||||
await widget.controller.resize(
|
||||
newSize.width.toInt(), newSize.height.toInt());
|
||||
setState(() {
|
||||
_resizing = false;
|
||||
});
|
||||
},
|
||||
child: Platform.isLinux
|
||||
? Transform(
|
||||
alignment: Alignment.center,
|
||||
transform: Matrix4.rotationX(pi),
|
||||
child: texture)
|
||||
? _resizing
|
||||
? Container()
|
||||
: Transform(
|
||||
alignment: Alignment.center,
|
||||
transform: Matrix4.rotationX(pi),
|
||||
child: texture)
|
||||
: texture))));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ link_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
||||
|
||||
add_library(FILAMENT_SHADERS SHARED
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../ios/include/material/image_material.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../ios/include/material/unlitopaque.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../ios/include/material/unlit_opaque.c"
|
||||
)
|
||||
|
||||
# Define the plugin library target. Its name must not be changed (see comment
|
||||
|
||||
178
materials/unlit_fade.mat
Normal file
178
materials/unlit_fade.mat
Normal file
@@ -0,0 +1,178 @@
|
||||
material {
|
||||
name : unlit_fade,
|
||||
requires : [ uv0, uv1, color ],
|
||||
shadingModel : ${SHADINGMODEL},
|
||||
blending : ${BLENDING},
|
||||
doubleSided : ${DOUBLESIDED},
|
||||
transparency : ${TRANSPARENCY},
|
||||
flipUV : false,
|
||||
specularAmbientOcclusion : simple,
|
||||
specularAntiAliasing : true,
|
||||
clearCoatIorChange : false,
|
||||
reflections : screenspace,
|
||||
parameters : [
|
||||
|
||||
{ type : float3, name : specularFactor },
|
||||
{ type : float, name : glossinessFactor },
|
||||
|
||||
// Base Color
|
||||
{ type : int, name : baseColorIndex },
|
||||
{ type : float4, name : baseColorFactor },
|
||||
{ type : sampler2d, name : baseColorMap },
|
||||
{ type : mat3, name : baseColorUvMatrix, precision: high },
|
||||
|
||||
// Metallic-Roughness Map
|
||||
{ type : int, name : metallicRoughnessIndex },
|
||||
{ type : float, name : metallicFactor },
|
||||
{ type : float, name : roughnessFactor },
|
||||
{ type : sampler2d, name : metallicRoughnessMap },
|
||||
{ type : mat3, name : metallicRoughnessUvMatrix, precision: high },
|
||||
|
||||
// Normal Map
|
||||
{ type : int, name : normalIndex },
|
||||
{ type : float, name : normalScale },
|
||||
{ type : sampler2d, name : normalMap },
|
||||
{ type : mat3, name : normalUvMatrix, precision: high },
|
||||
|
||||
// Ambient Occlusion
|
||||
{ type : int, name : aoIndex },
|
||||
{ type : float, name : aoStrength },
|
||||
{ type : sampler2d, name : occlusionMap },
|
||||
{ type : mat3, name : occlusionUvMatrix, precision: high },
|
||||
|
||||
// Emissive Map
|
||||
{ type : int, name : emissiveIndex },
|
||||
{ type : float3, name : emissiveFactor },
|
||||
{ type : float, name : emissiveStrength },
|
||||
{ type : sampler2d, name : emissiveMap },
|
||||
{ type : mat3, name : emissiveUvMatrix, precision: high },
|
||||
|
||||
// Clear coat
|
||||
{ type : float, name : clearCoatFactor },
|
||||
{ type : float, name : clearCoatRoughnessFactor },
|
||||
{ type : int, name : clearCoatIndex },
|
||||
{ type : sampler2d, name : clearCoatMap },
|
||||
{ type : mat3, name : clearCoatUvMatrix, precision: high },
|
||||
{ type : int, name : clearCoatRoughnessIndex },
|
||||
{ type : sampler2d, name : clearCoatRoughnessMap },
|
||||
{ type : mat3, name : clearCoatRoughnessUvMatrix, precision: high },
|
||||
{ type : int, name : clearCoatNormalIndex },
|
||||
{ type : sampler2d, name : clearCoatNormalMap },
|
||||
{ type : mat3, name : clearCoatNormalUvMatrix, precision: high },
|
||||
{ type : float, name : clearCoatNormalScale },
|
||||
|
||||
// Reflectance
|
||||
{ type : float, name : reflectance }
|
||||
|
||||
${CUSTOM_PARAMS}
|
||||
],
|
||||
}
|
||||
|
||||
vertex {
|
||||
void materialVertex(inout MaterialVertexInputs material) {
|
||||
${CUSTOM_VERTEX}
|
||||
}
|
||||
}
|
||||
|
||||
fragment {
|
||||
void material(inout MaterialInputs material) {
|
||||
highp float2 uvs[2];
|
||||
uvs[0] = getUV0();
|
||||
uvs[1] = getUV1();
|
||||
|
||||
#if !defined(SHADING_MODEL_UNLIT)
|
||||
if (materialParams.normalIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.normalIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.normalUvMatrix).xy;
|
||||
material.normal = texture(materialParams_normalMap, uv).xyz * 2.0 - 1.0;
|
||||
material.normal.xy *= materialParams.normalScale;
|
||||
}
|
||||
#if defined(SHADING_MODEL_LIT)
|
||||
if (materialParams.clearCoatNormalIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.clearCoatNormalIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.clearCoatNormalUvMatrix).xy;
|
||||
material.clearCoatNormal = texture(materialParams_clearCoatNormalMap, uv).xyz * 2.0 - 1.0;
|
||||
material.clearCoatNormal.xy *= materialParams.clearCoatNormalScale;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
prepareMaterial(material);
|
||||
material.baseColor = materialParams.baseColorFactor;
|
||||
|
||||
if (materialParams.baseColorIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.baseColorIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.baseColorUvMatrix).xy;
|
||||
material.baseColor *= texture(materialParams_baseColorMap, uv);
|
||||
}
|
||||
|
||||
#if defined(BLEND_MODE_TRANSPARENT)
|
||||
material.baseColor.rgb *= material.baseColor.a;
|
||||
#endif
|
||||
|
||||
material.baseColor *= getColor();
|
||||
|
||||
#if !defined(SHADING_MODEL_UNLIT)
|
||||
|
||||
#if defined(SHADING_MODEL_LIT)
|
||||
material.roughness = materialParams.roughnessFactor;
|
||||
material.metallic = materialParams.metallicFactor;
|
||||
|
||||
// KHR_materials_clearcoat forbids clear coat from
|
||||
// being applied in the specular/glossiness model
|
||||
material.clearCoat = materialParams.clearCoatFactor;
|
||||
material.clearCoatRoughness = materialParams.clearCoatRoughnessFactor;
|
||||
|
||||
if (materialParams.clearCoatIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.clearCoatIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.clearCoatUvMatrix).xy;
|
||||
material.clearCoat *= texture(materialParams_clearCoatMap, uv).r;
|
||||
}
|
||||
if (materialParams.clearCoatRoughnessIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.clearCoatRoughnessIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.clearCoatRoughnessUvMatrix).xy;
|
||||
material.clearCoatRoughness *= texture(materialParams_clearCoatRoughnessMap, uv).g;
|
||||
}
|
||||
#endif
|
||||
|
||||
material.emissive = vec4(materialParams.emissiveStrength *
|
||||
materialParams.emissiveFactor.rgb, 0.0);
|
||||
|
||||
#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)
|
||||
material.glossiness = materialParams.glossinessFactor;
|
||||
material.specularColor = materialParams.specularFactor;
|
||||
#else
|
||||
material.reflectance = materialParams.reflectance;
|
||||
#endif
|
||||
|
||||
if (materialParams.metallicRoughnessIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.metallicRoughnessIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.metallicRoughnessUvMatrix).xy;
|
||||
|
||||
#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)
|
||||
vec4 sg = texture(materialParams_metallicRoughnessMap, uv);
|
||||
material.specularColor *= sg.rgb;
|
||||
material.glossiness *= sg.a;
|
||||
#else
|
||||
vec4 mr = texture(materialParams_metallicRoughnessMap, uv);
|
||||
material.roughness *= mr.g;
|
||||
material.metallic *= mr.b;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (materialParams.aoIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.aoIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.occlusionUvMatrix).xy;
|
||||
float occlusion = texture(materialParams_occlusionMap, uv).r;
|
||||
material.ambientOcclusion = 1.0 + materialParams.aoStrength * (occlusion - 1.0);
|
||||
}
|
||||
if (materialParams.emissiveIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.emissiveIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.emissiveUvMatrix).xy;
|
||||
material.emissive.rgb *= texture(materialParams_emissiveMap, uv).rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
${CUSTOM_FRAGMENT}
|
||||
}
|
||||
}
|
||||
15
materials/unlit_opaque.mat
Normal file
15
materials/unlit_opaque.mat
Normal file
@@ -0,0 +1,15 @@
|
||||
material {
|
||||
name : BakedColor,
|
||||
requires : [
|
||||
color
|
||||
],
|
||||
shadingModel : unlit,
|
||||
culling : none
|
||||
}
|
||||
|
||||
fragment {
|
||||
void material(inout MaterialInputs material) {
|
||||
prepareMaterial(material);
|
||||
material.baseColor = getColor();
|
||||
}
|
||||
}
|
||||
53
pubspec.lock
53
pubspec.lock
@@ -7,7 +7,7 @@ packages:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.8.2"
|
||||
version: "2.9.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -21,35 +21,28 @@ packages:
|
||||
name: characters
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
version: "1.2.1"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.15.0"
|
||||
version: "1.16.0"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.3.1"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@@ -80,28 +73,35 @@ packages:
|
||||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.11"
|
||||
version: "0.12.12"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.5"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
version: "1.8.2"
|
||||
plugin_platform_interface:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
version: "2.1.3"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@@ -113,7 +113,7 @@ packages:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
version: "1.9.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -134,35 +134,28 @@ packages:
|
||||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.2.1"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.3"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "0.4.12"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.1.2"
|
||||
sdks:
|
||||
dart: ">=2.12.0 <3.0.0"
|
||||
dart: ">=2.17.1 <3.0.0"
|
||||
flutter: ">=1.20.0"
|
||||
|
||||
Reference in New Issue
Block a user