diff --git a/paket.dependencies b/paket.dependencies index e6332aa0..7bd4f29f 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -25,9 +25,6 @@ nuget FShade.Core ~> 5.6.0-prerelease0001 nuget FShade ~> 5.6.0-prerelease0001 nuget FShade.Debug ~> 5.6.0-prerelease0001 -// Some tests and examples require an image loader -nuget Aardvark.PixImage.ImageSharp ~> 2.0.1-prerelease0001 - nuget Unofficial.OpenVR ~> 1.1.0 nuget Unofficial.Typography ~> 0.1.0 nuget CommonMark.NET ~> 0.15.1 @@ -46,6 +43,10 @@ nuget Silk.NET.Direct3D9 = 2.15.0 nuget SharpZipLib ~> 1.4.1 +// Examples +nuget Aardvark.PixImage.ImageSharp ~> 2.0.1-prerelease0001 +nuget Aardvark.Data.GLTF ~> 1.0.0-prerelease0001 + group Test framework: net8.0 source https://api.nuget.org/v3/index.json diff --git a/paket.lock b/paket.lock index 531a45f8..fc9754b1 100644 --- a/paket.lock +++ b/paket.lock @@ -45,6 +45,11 @@ NUGET FSharp.Core (>= 3.1.2.5) - restriction: || (== net471) (&& (== net8.0) (>= net45)) (&& (== net8.0-windows10.0.17763.0) (>= net45)) (&& (== netstandard2.0) (>= net45)) FSharp.Core (>= 4.2.3) - restriction: || (&& (== net471) (< net45)) (== net8.0) (== net8.0-windows10.0.17763.0) (== netstandard2.0) Aardvark.Build (1.0.24) + Aardvark.Data.GLTF (1.0.0-prerelease0001) + Aardvark.Base.Tensors (>= 5.3.0-prerelease0005 < 5.4.0-prerelease) + Aardvark.Rendering.Common (>= 5.5.0-prerelease0002) + FSharp.Core (>= 8.0) + glTF2Loader (>= 1.1.4-alpha < 1.2.0-alpha) Aardvark.Geometry (5.3.0-prerelease0005) Aardvark.Base (5.3.0-prerelease0005) Aardvark.Base.FSharp (5.3.0-prerelease0005) @@ -58,6 +63,10 @@ NUGET Aardvark.Base.Tensors (>= 5.3.0-prerelease0004 < 5.4.0-prerelease) FSharp.Core (>= 8.0) SixLabors.ImageSharp (>= 2.1.8 < 2.2) + Aardvark.Rendering.Common (5.5.0-prerelease0002) + Aardvark.Base (>= 5.3.0-prerelease0005) + FSharp.Core (>= 8.0) + System.Reflection.Emit.Lightweight (>= 4.7) AssimpNet (5.0.0-beta1) NETStandard.Library (>= 1.6.1) - restriction: || (&& (== net471) (< net35)) (== net8.0) (== net8.0-windows10.0.17763.0) (== netstandard2.0) CommonMark.NET (0.15.1) @@ -144,6 +153,9 @@ NUGET FSharp.Core (>= 4.7) GLSLangSharp (0.4.15) FSharp.Core (>= 5.0) + glTF2Loader (1.1.4-alpha) + NETStandard.Library (>= 1.6.1) + Newtonsoft.Json (>= 10.0.3) Microsoft.Bcl.AsyncInterfaces (8.0) - restriction: || (== net471) (&& (== net8.0) (>= net462)) (&& (== net8.0) (< net6.0)) (&& (== net8.0-windows10.0.17763.0) (>= net462)) (&& (== net8.0-windows10.0.17763.0) (< net6.0)) (== netstandard2.0) System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (== net471) (&& (== net8.0) (>= net462)) (&& (== net8.0) (< netstandard2.1)) (&& (== net8.0-windows10.0.17763.0) (>= net462)) (&& (== net8.0-windows10.0.17763.0) (< netstandard2.1)) (== netstandard2.0) Microsoft.Bcl.HashCode (1.1.1) - restriction: || (== net471) (&& (== net8.0) (< netstandard2.1)) (&& (== net8.0-windows10.0.17763.0) (< netstandard2.1)) (== netstandard2.0) @@ -162,7 +174,7 @@ NUGET Microsoft.NETFramework.ReferenceAssemblies (1.0) Microsoft.NETFramework.ReferenceAssemblies.net471 (>= 1.0) - restriction: || (== net471) (&& (== net8.0) (>= net471)) (&& (== net8.0-windows10.0.17763.0) (>= net471)) (&& (== netstandard2.0) (>= net471)) Microsoft.NETFramework.ReferenceAssemblies.net471 (1.0.2) - restriction: || (== net471) (&& (== net8.0) (>= net471)) (&& (== net8.0-windows10.0.17763.0) (>= net471)) (&& (== netstandard2.0) (>= net471)) - NETStandard.Library (2.0.3) - restriction: || (&& (== net471) (< net35)) (== net8.0) (== net8.0-windows10.0.17763.0) (== netstandard2.0) + NETStandard.Library (2.0.3) Microsoft.NETCore.Platforms (>= 1.1) Newtonsoft.Json (13.0.1) Offler (2.1.1-prerelease0001) @@ -260,7 +272,7 @@ NUGET System.Threading (>= 4.3) - restriction: || (&& (== net471) (< net45)) (== net8.0) (== net8.0-windows10.0.17763.0) (== netstandard2.0) System.Memory (4.5.5) System.Buffers (>= 4.5.1) - restriction: || (== net471) (&& (== net8.0) (>= monotouch)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= xamarinios)) (&& (== net8.0) (>= xamarinmac)) (&& (== net8.0) (>= xamarintvos)) (&& (== net8.0) (>= xamarinwatchos)) (&& (== net8.0-windows10.0.17763.0) (>= monotouch)) (&& (== net8.0-windows10.0.17763.0) (>= net461)) (&& (== net8.0-windows10.0.17763.0) (< netcoreapp2.0)) (&& (== net8.0-windows10.0.17763.0) (< netstandard1.1)) (&& (== net8.0-windows10.0.17763.0) (< netstandard2.0)) (&& (== net8.0-windows10.0.17763.0) (>= xamarinios)) (&& (== net8.0-windows10.0.17763.0) (>= xamarinmac)) (&& (== net8.0-windows10.0.17763.0) (>= xamarintvos)) (&& (== net8.0-windows10.0.17763.0) (>= xamarinwatchos)) (== netstandard2.0) - System.Numerics.Vectors (>= 4.4) - restriction: || (&& (== net471) (== net8.0)) (&& (== net471) (== net8.0-windows10.0.17763.0)) (&& (== net471) (< net45)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0-windows10.0.17763.0) (< netcoreapp2.0)) (== netstandard2.0) + System.Numerics.Vectors (>= 4.4) - restriction: || (&& (== net471) (< net45)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0-windows10.0.17763.0) (< netcoreapp2.0)) (== netstandard2.0) System.Numerics.Vectors (>= 4.5) - restriction: || (== net471) (&& (== net8.0) (>= net461)) (&& (== net8.0-windows10.0.17763.0) (>= net461)) (&& (== netstandard2.0) (>= net461)) System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (== net471) (&& (== net8.0) (>= monotouch)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< netcoreapp2.0)) (&& (== net8.0) (< netcoreapp2.1)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= uap10.1)) (&& (== net8.0) (>= xamarinios)) (&& (== net8.0) (>= xamarinmac)) (&& (== net8.0) (>= xamarintvos)) (&& (== net8.0) (>= xamarinwatchos)) (&& (== net8.0-windows10.0.17763.0) (>= monotouch)) (&& (== net8.0-windows10.0.17763.0) (>= net461)) (&& (== net8.0-windows10.0.17763.0) (< netcoreapp2.0)) (&& (== net8.0-windows10.0.17763.0) (< netcoreapp2.1)) (&& (== net8.0-windows10.0.17763.0) (< netstandard1.1)) (&& (== net8.0-windows10.0.17763.0) (< netstandard2.0)) (&& (== net8.0-windows10.0.17763.0) (>= uap10.1)) (&& (== net8.0-windows10.0.17763.0) (>= xamarinios)) (&& (== net8.0-windows10.0.17763.0) (>= xamarinmac)) (&& (== net8.0-windows10.0.17763.0) (>= xamarintvos)) (&& (== net8.0-windows10.0.17763.0) (>= xamarinwatchos)) (== netstandard2.0) System.Numerics.Vectors (4.5) @@ -277,10 +289,10 @@ NUGET System.Reflection.Primitives (>= 4.3) - restriction: || (&& (== net471) (< net45)) (== net8.0) (== net8.0-windows10.0.17763.0) (== netstandard2.0) System.Runtime (>= 4.3) - restriction: || (&& (== net471) (< net45)) (== net8.0) (== net8.0-windows10.0.17763.0) (== netstandard2.0) System.Reflection.Emit (4.7) - restriction: || (&& (== net471) (< net45)) (== net8.0) (== net8.0-windows10.0.17763.0) (== netstandard2.0) - System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net471) (== net8.0)) (&& (== net471) (== net8.0-windows10.0.17763.0)) (&& (== net471) (< net45)) (&& (== net471) (< netstandard1.1)) (&& (== net471) (< netstandard2.0) (>= wpa81)) (&& (== net471) (>= uap10.1)) (&& (== net8.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= uap10.1)) (&& (== net8.0-windows10.0.17763.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0-windows10.0.17763.0) (< netstandard1.1)) (&& (== net8.0-windows10.0.17763.0) (< netstandard2.0)) (&& (== net8.0-windows10.0.17763.0) (>= uap10.1)) (== netstandard2.0) + System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net471) (< net45)) (&& (== net471) (< netstandard1.1)) (&& (== net471) (< netstandard2.0) (>= wpa81)) (&& (== net471) (>= uap10.1)) (&& (== net8.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0) (< netstandard1.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (>= uap10.1)) (&& (== net8.0-windows10.0.17763.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0-windows10.0.17763.0) (< netstandard1.1)) (&& (== net8.0-windows10.0.17763.0) (< netstandard2.0)) (&& (== net8.0-windows10.0.17763.0) (>= uap10.1)) (== netstandard2.0) System.Reflection.Emit.ILGeneration (4.7) - restriction: || (&& (== net471) (< net45)) (&& (== net471) (< netstandard2.0) (>= wpa81)) (&& (== net471) (< portable-net45+wp8)) (&& (== net471) (>= uap10.1)) (== net8.0) (== net8.0-windows10.0.17763.0) (== netstandard2.0) System.Reflection.Emit.Lightweight (4.7) - System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net471) (== net8.0)) (&& (== net471) (== net8.0-windows10.0.17763.0)) (&& (== net471) (< net45)) (&& (== net471) (< netstandard2.0) (>= wpa81)) (&& (== net471) (< portable-net45+wp8)) (&& (== net471) (>= uap10.1)) (&& (== net8.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (< portable-net45+wp8)) (&& (== net8.0) (>= uap10.1)) (&& (== net8.0-windows10.0.17763.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0-windows10.0.17763.0) (< netstandard2.0)) (&& (== net8.0-windows10.0.17763.0) (< portable-net45+wp8)) (&& (== net8.0-windows10.0.17763.0) (>= uap10.1)) (== netstandard2.0) + System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net471) (< net45)) (&& (== net471) (< netstandard2.0) (>= wpa81)) (&& (== net471) (< portable-net45+wp8)) (&& (== net471) (>= uap10.1)) (&& (== net8.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0) (< netstandard2.0)) (&& (== net8.0) (< portable-net45+wp8)) (&& (== net8.0) (>= uap10.1)) (&& (== net8.0-windows10.0.17763.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net8.0-windows10.0.17763.0) (< netstandard2.0)) (&& (== net8.0-windows10.0.17763.0) (< portable-net45+wp8)) (&& (== net8.0-windows10.0.17763.0) (>= uap10.1)) (== netstandard2.0) System.Reflection.Extensions (4.3) - restriction: || (&& (== net471) (< net45)) (== net8.0) (== net8.0-windows10.0.17763.0) (== netstandard2.0) Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (&& (== net471) (< net45)) (== net8.0) (== net8.0-windows10.0.17763.0) (== netstandard2.0) Microsoft.NETCore.Targets (>= 1.1) - restriction: || (&& (== net471) (< net45)) (== net8.0) (== net8.0-windows10.0.17763.0) (== netstandard2.0) diff --git a/src/Aardvark.Rendering.NonWindows.slnf b/src/Aardvark.Rendering.NonWindows.slnf index 3d37ec83..cfa55eee 100644 --- a/src/Aardvark.Rendering.NonWindows.slnf +++ b/src/Aardvark.Rendering.NonWindows.slnf @@ -9,8 +9,8 @@ "Aardvark.Rendering.Vulkan.Wrapper\\Aardvark.Rendering.Vulkan.Wrapper.fsproj", "Aardvark.Rendering.Vulkan\\Aardvark.Rendering.Vulkan.fsproj", "Aardvark.Rendering\\Aardvark.Rendering.fsproj", - "Aardvark.SceneGraph.Browser\\Aardvark.SceneGraph.Browser.fsproj", "Aardvark.SceneGraph.Assimp\\Aardvark.SceneGraph.Assimp.fsproj", + "Aardvark.SceneGraph.Browser\\Aardvark.SceneGraph.Browser.fsproj", "Aardvark.SceneGraph.Opc\\Aardvark.SceneGraph.Opc.fsproj", "Aardvark.SceneGraph\\Aardvark.SceneGraph.fsproj", "Application\\Aardvark.Application.OpenVR.GL\\Aardvark.Application.OpenVR.GL.fsproj", @@ -59,6 +59,8 @@ "Examples (netcore)\\34 - StorageBuffers\\34 - StorageBuffers.fsproj", "Examples (netcore)\\35 - Picking\\35 - Picking.fsproj", "Examples (netcore)\\36 - Raytracing\\36 - Raytracing.fsproj", + "Examples (netcore)\\37 - ReversedDepth\\37 - ReversedDepth.fsproj", + "Examples (netcore)\\38 - GLTF\\38 - GLTF.fsproj", "Scratch (netcore)\\01 - Triangle\\01 - Triangle.fsproj", "Scratch (netcore)\\02 - OpcDemo\\02 - OpcDemo.fsproj", "Scratch (netcore)\\03 - Sorted\\03 - Sorted.fsproj", diff --git a/src/Aardvark.Rendering.sln b/src/Aardvark.Rendering.sln index 45a0e088..d3fe18a6 100644 --- a/src/Aardvark.Rendering.sln +++ b/src/Aardvark.Rendering.sln @@ -226,6 +226,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "23 - NativeMemoryLeak", "Sc EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Aardvark.Rendering.Common", "Aardvark.Rendering.Common\Aardvark.Rendering.Common.fsproj", "{FBFF12BC-5292-4154-B985-31130061F3D6}" EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "38 - GLTF", "Examples (netcore)\38 - GLTF\38 - GLTF.fsproj", "{470275FD-9F08-4814-A6DF-73E9C812C1D6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -624,6 +626,10 @@ Global {FBFF12BC-5292-4154-B985-31130061F3D6}.Debug|Any CPU.Build.0 = Debug|Any CPU {FBFF12BC-5292-4154-B985-31130061F3D6}.Release|Any CPU.ActiveCfg = Release|Any CPU {FBFF12BC-5292-4154-B985-31130061F3D6}.Release|Any CPU.Build.0 = Release|Any CPU + {470275FD-9F08-4814-A6DF-73E9C812C1D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {470275FD-9F08-4814-A6DF-73E9C812C1D6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {470275FD-9F08-4814-A6DF-73E9C812C1D6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {470275FD-9F08-4814-A6DF-73E9C812C1D6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -717,6 +723,7 @@ Global {159213C5-ECA5-48B6-BDCF-D75BAE733E80} = {5E3312C4-1B3C-4D41-964C-C3A3E01DA966} {6DFA9CC5-3C57-44FC-A989-F1DC5097C2DB} = {29CA9CA1-CC31-4B5D-8DB0-2FEA748C09D8} {DD9808AD-AEB3-4E90-A70C-E398CADE55FF} = {29CA9CA1-CC31-4B5D-8DB0-2FEA748C09D8} + {470275FD-9F08-4814-A6DF-73E9C812C1D6} = {5E3312C4-1B3C-4D41-964C-C3A3E01DA966} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C41172B9-09C3-4327-8CE2-CB47CBAA29AC} diff --git a/src/Examples (netcore)/38 - GLTF/38 - GLTF.fsproj b/src/Examples (netcore)/38 - GLTF/38 - GLTF.fsproj new file mode 100644 index 00000000..1542143c --- /dev/null +++ b/src/Examples (netcore)/38 - GLTF/38 - GLTF.fsproj @@ -0,0 +1,49 @@ + + + + Exe + net8.0 + true + + + ..\..\..\bin\Debug + DEBUG;TRACE + + + ..\..\..\bin\Release + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Aardvark.SceneGraph.GLTF/CubeMap.fs b/src/Examples (netcore)/38 - GLTF/CubeMap.fs similarity index 94% rename from src/Aardvark.SceneGraph.GLTF/CubeMap.fs rename to src/Examples (netcore)/38 - GLTF/CubeMap.fs index 15942b10..5d21edfe 100644 --- a/src/Aardvark.SceneGraph.GLTF/CubeMap.fs +++ b/src/Examples (netcore)/38 - GLTF/CubeMap.fs @@ -1,13 +1,12 @@ -namespace Aardvark.GLTF +namespace Example.GLTF open Aardvark.Base open Aardvark.Rendering open FSharp.Data.Adaptive open Aardvark.SceneGraph - module internal EnvironmentMap = - + [] module Shader = open FShade @@ -20,7 +19,7 @@ module internal EnvironmentMap = addressV WrapMode.Wrap addressW WrapMode.Wrap } - + let rand = sampler2d { texture uniform?Random @@ -28,15 +27,15 @@ module internal EnvironmentMap = addressU WrapMode.Wrap addressV WrapMode.Wrap } - + type UniformScope with member x.SourceLevel : int = uniform?SourceLevel member x.LevelCount : int = uniform?LevelCount member x.IsDiffuse : bool = uniform?IsDiffuse - + [] let suint32 (_v : uint32) : uint32 = onlyInShaderCode "asda" - + let radicalInverse (bits : uint32) = let bits = (bits <<< 16) ||| (bits >>> 16) let bits = ((bits &&& suint32 0x55555555u) <<< 1) ||| ((bits &&& suint32 0xAAAAAAAAu) >>> 1) @@ -44,7 +43,7 @@ module internal EnvironmentMap = let bits = ((bits &&& suint32 0x0F0F0F0Fu) <<< 4) ||| ((bits &&& suint32 0xF0F0F0F0u) >>> 4) let bits = ((bits &&& suint32 0x00FF00FFu) <<< 8) ||| ((bits &&& suint32 0xFF00FF00u) >>> 8) float bits * 2.3283064365386963e-10 - // float RadicalInverse_VdC(uint bits) + // float RadicalInverse_VdC(uint bits) // { // bits = (bits << 16u) | (bits >> 16u); // bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); @@ -53,25 +52,25 @@ module internal EnvironmentMap = // bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); // return float(bits) * 2.3283064365386963e-10; // / 0x100000000 // } - + let hammersley (i : int) (n : int) = V2d(float i / float n, radicalInverse (uint32 i)) - + let linearToSrgb (v : V4d) = let e = 1.0 / 2.2 V4d(v.X ** e, v.Y ** e, v.Z ** e, v.W) - + let srgbToLinear (v : V4d) = let e = 2.2 V4d(v.X ** e, v.Y ** e, v.Z ** e, v.W) - + let sampleEnv (worldDir : V3d) (roughness : float) = let z = worldDir let x = if abs z.Z > 0.999 then Vec.cross z V3d.OIO |> Vec.normalize else Vec.cross z V3d.OOI |> Vec.normalize let y = Vec.cross z x - + let mutable sum = V4d.Zero let v = worldDir let n = worldDir @@ -96,29 +95,29 @@ module internal EnvironmentMap = let fy = sin phi * sinTheta let fz = cosTheta Vec.normalize (x * fx + y * fy + z * fz) - + let l = Vec.normalize (2.0 * Vec.dot v h * h - v) let nl = Vec.dot n l |> max 0.0 - + if nl > 0.0 then let c = skybox.SampleLevel(h, 0.0) |> srgbToLinear |> Vec.xyz sum <- sum + V4d(c * nl, nl) - - + + sum.XYZ / sum.W - - + + let sampleFace (v : Effects.Vertex) = fragment { let p00 = v.pos.XY / v.pos.W let s00 = uniform.ViewTrafoInv.TransformDir (V3d(p00, -1.0)) |> Vec.normalize - + let roughness = float (uniform.SourceLevel + 1) / float (uniform.LevelCount - 1) let res = sampleEnv s00 roughness return linearToSrgb (V4d(res, 1.0)) } - - + + let pano = sampler2d { texture uniform?Panorama @@ -126,25 +125,25 @@ module internal EnvironmentMap = addressU WrapMode.Wrap addressV WrapMode.Wrap } - + let samplePano (v : Effects.Vertex) = fragment { // let dx = V2d(1.0 / (float uniform.ViewportSize.X), 0.0) // let dy = V2d(0.0, 1.0 / (float uniform.ViewportSize.Y)) - + let p00 = v.pos.XY / v.pos.W // let p01 = p00 + dy // let p10 = p00 + dx // let p11 = p00 + dx + dy - + let s00 = uniform.ViewTrafoInv.TransformDir (V3d(p00, -1.0)) |> Vec.normalize - + let x = (atan2 s00.Y s00.X) / Constant.PiTimesTwo + 0.5 let y = asin s00.Z / Constant.Pi + 0.5 - + return pano.SampleLevel(V2d(x,y), 0.0) } - + let private faces = [| 0, CameraView.lookAt V3d.Zero V3d.IOO V3d.ONO @@ -154,7 +153,7 @@ module internal EnvironmentMap = 4, CameraView.lookAt V3d.Zero V3d.OOI V3d.ONO 5, CameraView.lookAt V3d.Zero V3d.OON V3d.ONO |] - + let private random = let img = PixImage(Col.Format.RGBA, V2i(128, 128)) let rand = RandomSystem() @@ -162,25 +161,25 @@ module internal EnvironmentMap = rand.UniformV4f().ToC4f() ) |> ignore PixTexture2d(PixImageMipMap [| img :> PixImage |], TextureParams.empty) :> ITexture - + let levelCount = 8 - + let prepare (runtime : IRuntime) (src : ITexture) = let src = runtime.PrepareTexture src let diffuse = runtime.CreateTextureCube(src.Size.X, src.Format, src.MipMapLevels) - + let signature = runtime.CreateFramebufferSignature [ DefaultSemantic.Colors, src.Format ] - + let view = cval (CameraView.lookAt V3d.Zero V3d.IOO V3d.OOI) let viewportSize = cval V2i.II let sourceLevel = cval 0 let isDiffuse = cval false - - - + + + let task = Sg.fullScreenQuad |> Sg.shader { @@ -195,7 +194,7 @@ module internal EnvironmentMap = |> Sg.uniform "SourceLevel" sourceLevel |> Sg.depthTest' DepthTest.None |> Sg.compile runtime signature - + let mutable dstSize = max V2i.II (src.Size.XY / 2) let mutable dstLevel = 1 while dstLevel < src.MipMapLevels do @@ -204,49 +203,49 @@ module internal EnvironmentMap = viewportSize.Value <- dstSize sourceLevel.Value <- srcLevel ) - + for index, cam in faces do use fbo = runtime.CreateFramebuffer(signature, [DefaultSemantic.Colors, src.[TextureAspect.Color, dstLevel, index] :> IFramebufferOutput]) transact (fun () -> view.Value <- cam) task.Run(fbo) - - + + dstSize <- max V2i.II (dstSize / 2) dstLevel <- dstLevel + 1 - + // diffuse transact (fun () -> viewportSize.Value <- src.Size.XY sourceLevel.Value <- 0 isDiffuse.Value <- true ) - + for index, cam in faces do use fbo = runtime.CreateFramebuffer(signature, [DefaultSemantic.Colors, diffuse.[TextureAspect.Color, 0, index] :> IFramebufferOutput]) transact (fun () -> view.Value <- cam) task.Run(fbo) runtime.GenerateMipMaps(diffuse) - + // for level in 0 .. src.MipMapLevels - 1 do // for face in 0 .. 5 do // runtime.Download(src, level, face).Save (sprintf "/Users/schorsch/Desktop/textures/f%d_%d.jpg" face level) - // + // src, diffuse let ofPanorama (runtime : IRuntime) (img : ITexture) = let img = runtime.PrepareTexture img - + let cubeSize = Fun.NextPowerOfTwo img.Size.Y let result = runtime.CreateTextureCube(cubeSize, img.Format, int (floor (log2 (float cubeSize)) + 1.0)) - + let signature = runtime.CreateFramebufferSignature [ DefaultSemantic.Colors, img.Format ] - + let view = cval (CameraView.lookAt V3d.Zero V3d.IOO V3d.OOI) - - + + let task = Sg.fullScreenQuad |> Sg.shader { @@ -256,10 +255,10 @@ module internal EnvironmentMap = |> Sg.texture' "Panorama" img |> Sg.depthTest' DepthTest.None |> Sg.compile runtime signature - + for index, cam in faces do use fbo = runtime.CreateFramebuffer(signature, [DefaultSemantic.Colors, result.[TextureAspect.Color, 0, index] :> IFramebufferOutput]) transact (fun () -> view.Value <- cam) task.Run(fbo) - + prepare runtime result diff --git a/src/Aardvark.GLTF.Tests/Program.fs b/src/Examples (netcore)/38 - GLTF/Program.fs similarity index 87% rename from src/Aardvark.GLTF.Tests/Program.fs rename to src/Examples (netcore)/38 - GLTF/Program.fs index 58f3f3e0..1802ca3a 100644 --- a/src/Aardvark.GLTF.Tests/Program.fs +++ b/src/Examples (netcore)/38 - GLTF/Program.fs @@ -1,49 +1,51 @@ open Aardvark.Base open Aardvark.Rendering open Aardvark.SceneGraph -open Aardvark.GLTF +open Aardvark.Data.GLTF open Aardvark.Application open FSharp.Data.Adaptive +open Example.GLTF + [] let main args = - + let initialModels = args |> Array.choose GLTF.tryLoad - + Aardvark.Init() - + let app = new Aardvark.Application.Slim.OpenGlApplication(DebugLevel.None) let win = app.CreateGameWindow(4) - + let view = CameraView.lookAt (V3d(4,5,6)) V3d.Zero V3d.OOI |> DefaultCameraController.control win.Mouse win.Keyboard win.Time |> AVal.map CameraView.viewTrafo - + let proj = win.Sizes |> AVal.map (fun s -> Frustum.perspective 60.0 0.1 100.0 (float s.X / float s.Y)) |> AVal.map Frustum.projTrafo - + let enableTask = RenderTask.custom (fun _ -> OpenTK.Graphics.OpenGL4.GL.Enable(OpenTK.Graphics.OpenGL4.EnableCap.TextureCubeMapSeamless) ) let testScene = - let mutable materials = HashMap.empty - let mutable geometries = HashMap.empty + let mutable materials = Map.empty + let mutable geometries = Map.empty let mutable nodes = [] - + let geometry = let prim = IndexedGeometryPrimitives.solidPhiThetaSphere (Sphere3d(V3d.Zero, 0.3)) 36 C4b.White let pos = prim.IndexedAttributes.[DefaultSemantic.Positions] :?> V3f[] - + let idx = prim.IndexArray :?> int[] // for i in 0 .. 3 .. idx.Length - 2 do // Fun.Swap(&idx.[i], &idx.[i+2]) - + { Name = Some "Sphere" BoundingBox = Box3d.FromCenterAndSize(V3d.Zero, V3d.III * 0.6) @@ -55,59 +57,59 @@ let main args = TexCoords = [] Colors = None } - + let gid = MeshId.New() - geometries <- HashMap.add gid geometry geometries - - + geometries <- Map.add gid geometry geometries + + let steps = 8 for ri in 0 .. steps - 1 do let mutable roughness = float ri / float (steps - 1) for mi in 0 .. steps - 1 do let mutable metalness = float mi / float (steps - 1) let offset = Trafo3d.Translation(float ri, float mi, 0.0) - + let mid = MaterialId.New() - - let material = + + let material = { Name = Some (sprintf "%.3f_%.3f" roughness metalness) - + DoubleSided = true Opaque = true - + BaseColorTexture = None BaseColor = C4f.Beige - + Roughness = roughness RoughnessTexture = None RoughnessTextureComponent = 0 - + Metallicness = metalness MetallicnessTexture = None MetallicnessTextureComponent = 0 - + EmissiveColor = C4f.Black EmissiveTexture = None - + NormalTexture = None NormalTextureScale = 1.0 } - - materials <- HashMap.add mid material materials + + materials <- Map.add mid material materials nodes <- { Name = None; Trafo = Some offset; Meshes = [ { Mesh = gid; Material = Some mid } ]; Children = [] } :: nodes - + { Materials = materials Meshes = geometries - ImageData = HashMap.empty + ImageData = Map.empty RootNode = { Name = None; Trafo = None; Meshes = []; Children = nodes } } - + // let initialModels = [| GLTF.loadZip "/Users/schorsch/Development/glTF-Sample-Models/2.0/Avocado/glTF/Archive.zip" |] - // + // let models = clist (if initialModels.Length > 0 then Array.toList initialModels else [ testScene ]) - + win.DropFiles.Add (fun paths -> let ms = paths |> Array.choose GLTF.tryLoad if ms.Length > 0 then @@ -115,7 +117,7 @@ let main args = models.UpdateTo models |> ignore ) ) - + let sw = System.Diagnostics.Stopwatch.StartNew() let rot = win.Time |> AVal.map (fun _ -> Trafo3d.RotationZ(0.4 * sw.Elapsed.TotalSeconds)) @@ -125,7 +127,7 @@ let main args = Trafo3d.Translation(-bb.Center) * Trafo3d.Scale(5.0 / bb.Size.NormMax) ) - + let renderTask = Sg.ofList [ @@ -135,7 +137,7 @@ let main args = |> Sg.dynamic |> Sg.trafo centerTrafo1 |> Sg.trafo' (Trafo3d.RotationX Constant.PiHalf) - + ] //|> Sg.uniform' "LightLocation" (V3d(10,20,30)) |> Sg.shader { @@ -148,5 +150,5 @@ let main args = |> Sg.compile win.Runtime win.FramebufferSignature win.RenderTask <- RenderTask.ofList [enableTask; renderTask] win.Run() - + 0 \ No newline at end of file diff --git a/src/Aardvark.SceneGraph.GLTF/SceneGraph.fs b/src/Examples (netcore)/38 - GLTF/SceneGraph.fs similarity index 89% rename from src/Aardvark.SceneGraph.GLTF/SceneGraph.fs rename to src/Examples (netcore)/38 - GLTF/SceneGraph.fs index 0dd70aac..ba2ad685 100644 --- a/src/Aardvark.SceneGraph.GLTF/SceneGraph.fs +++ b/src/Examples (netcore)/38 - GLTF/SceneGraph.fs @@ -1,9 +1,10 @@ -namespace Aardvark.GLTF +namespace Example.GLTF open Aardvark.Base open Aardvark.Rendering -open FSharp.Data.Adaptive open Aardvark.SceneGraph +open Aardvark.Data.GLTF +open FSharp.Data.Adaptive open System.IO module Skybox = @@ -18,7 +19,7 @@ module Skybox = load let get (name : string) = - + AVal.custom (fun _ -> let env = // let names = typeof.Assembly.GetManifestResourceNames() @@ -34,11 +35,11 @@ module Skybox = // res.[l] <- PixImageSharp.ToPixImage ii // res let trafo t (img : PixImage) = - img.Transformed t + img.TransformedPixImage t //|> getMipMaps - - PixImageCube [| + + PixCube [| PixImageMipMap( getImage (name.Replace("$", "rt")) |> trafo ImageTrafo.Rot90 @@ -47,7 +48,7 @@ module Skybox = getImage (name.Replace("$", "lf")) |> trafo ImageTrafo.Rot270 ) - + PixImageMipMap( getImage (name.Replace("$", "bk")) ) @@ -55,7 +56,7 @@ module Skybox = getImage (name.Replace("$", "ft")) |> trafo ImageTrafo.Rot180 ) - + PixImageMipMap( getImage (name.Replace("$", "up")) |> trafo ImageTrafo.Rot90 @@ -80,7 +81,7 @@ module Semantic = [] module Shader = open FShade - + type ViewPositionAttribute() = inherit SemanticAttribute("ViewPosition") type RoughnessCoordinateAttribute() = inherit SemanticAttribute("RoughnessCoordinate") type MetallicnessCoordinateAttribute() = inherit SemanticAttribute("MetallicnessCoordinate") @@ -90,7 +91,7 @@ module Shader = type ViewTangentAttribute() = inherit SemanticAttribute("ViewTangent") type ViewBiTangentAttribute() = inherit SemanticAttribute("ViewBiTangent") type ViewLightDirectionAttribute() = inherit SemanticAttribute("ViewLightDirection") - + let skyboxSpecular = samplerCube { texture uniform?SkyboxSpecular @@ -99,7 +100,7 @@ module Shader = addressV WrapMode.Wrap addressW WrapMode.Wrap } - + let skyboxDiffuse = samplerCube { texture uniform?SkyboxDiffuse @@ -108,7 +109,7 @@ module Shader = addressV WrapMode.Wrap addressW WrapMode.Wrap } - + let diffuseColorTex = sampler2d { texture uniform?DiffuseColorTexture @@ -116,7 +117,7 @@ module Shader = addressV WrapMode.Wrap filter Filter.MinMagMipLinear } - + let roughnessTexture = sampler2d { texture uniform?RoughnessTexture @@ -124,7 +125,7 @@ module Shader = addressV WrapMode.Wrap filter Filter.MinMagMipLinear } - + let metallicnessTexture = sampler2d { texture uniform?MetallicnessTexture @@ -132,7 +133,7 @@ module Shader = addressV WrapMode.Wrap filter Filter.MinMagMipLinear } - + let emissiveTexture = sampler2d { texture uniform?EmissiveTexture @@ -140,7 +141,7 @@ module Shader = addressV WrapMode.Wrap filter Filter.MinMagMipLinear } - + let normalTexture = sampler2d { texture uniform?(string DefaultSemantic.NormalMapTexture) @@ -148,28 +149,28 @@ module Shader = addressV WrapMode.Wrap filter Filter.MinMagMipLinear } - + type UniformScope with member x.DiffuseColor : V4d = uniform?Material?DiffuseColor member x.Roughness : float = uniform?Material?Roughness member x.Metallicness : float = uniform?Material?Metallicness member x.EmissiveColor : V4d = uniform?Material?EmissiveColor member x.NormalTextureScale : float = uniform?Material?NormalTextureScale - + member x.HasDiffuseColorTexture : bool = uniform?Material?HasDiffuseColorTexture member x.HasRoughnessTexture : bool = uniform?Material?HasRoughnessTexture member x.HasMetallicnessTexture : bool = uniform?Material?HasMetallicnessTexture member x.HasEmissiveTexture : bool = uniform?Material?HasEmissiveTexture member x.HasNormalTexture : bool = uniform?Material?("Has" + string DefaultSemantic.NormalMapTexture) - + member x.RoughnessTextureComponent : int = uniform?Material?RoughnessTextureComponent member x.MetallicnessTextureComponent : int = uniform?Material?MetallicnessTextureComponent - + member x.HasNormals : bool = uniform?Mesh?HasNormals member x.HasTangents : bool = uniform?Mesh?HasTangents member x.HasColors : bool = uniform?Mesh?HasColors member x.LevelCount : int = uniform?LevelCount - + type Vertex = { [] pos : V4d @@ -185,16 +186,16 @@ module Shader = [] viewBiTangent : V3d [] viewLightDir : V3d } - + let trafo (v : Vertex) = vertex { - + let vp = uniform.ModelViewTrafo * v.pos let vld = (uniform.ViewTrafo * V4d(uniform.LightLocation, 1.0) - vp).XYZ |> Vec.normalize let vn = uniform.ModelViewTrafoInv.Transposed.TransformDir v.normal |> Vec.normalize let vt = uniform.ModelViewTrafoInv.Transposed.TransformDir v.tangent.XYZ |> Vec.normalize let vb = v.tangent.W * Vec.cross vn vt - + return { v with pos = uniform.ProjTrafo * vp @@ -205,7 +206,7 @@ module Shader = viewLightDir = vld } } - + let samples24 = [| V2d( -0.4612850228120782, -0.8824263018037591 ) @@ -232,55 +233,55 @@ module Shader = V2d( 0.38289808661249414, 0.15269522898022844 ) V2d( -0.4951171173546325, -0.2654758742352245 ) |] - + let linearToSrgb (v : V4d) = let e = 1.0 / 2.2 V4d(v.X ** e, v.Y ** e, v.Z ** e, v.W) - + [] let srgbToLinear (v : V4d) = let e = 2.2 V4d(v.X ** e, v.Y ** e, v.Z ** e, v.W) - + let trowbridgeReitzNDF (roughness : float) (nDotH : float) = let a = roughness * roughness let a2 = a * a let nDotH2 = nDotH * nDotH let denom = nDotH2 * (a2 - 1.0) + 1.0 a2 / (Constant.Pi * denom * denom) - + let fresnel (f0 : V3d) (nv : float) (roughness : float) = let a = V3d.III * (1.0 - roughness) f0 + (max f0 a - f0) * nv ** 5.0 - + let schlickBeckmannGAF (d : float) (roughness : float) = let a = roughness * roughness let k = a * 0.797884560803 d / (d * (1.0 - k) + k) - + let sampleEnvDiffuse (viewDir : V3d) = let worldDir = uniform.ViewTrafoInv.TransformDir viewDir |> Vec.normalize skyboxDiffuse.Sample(worldDir) |> srgbToLinear |> Vec.xyz - + let sampleEnv (viewDir : V3d) (roughness : float) = let worldDir = uniform.ViewTrafoInv.TransformDir viewDir |> Vec.normalize skyboxSpecular.SampleLevel(worldDir, roughness * float (uniform.LevelCount - 1)) |> srgbToLinear |> Vec.xyz - + [] [] let getR0 (reflectivity : float, metalness : float, baseColor : V3d) = V3d.III * reflectivity * (1.0 - metalness) + baseColor * metalness - + let shade (v : Vertex) = fragment { let eps = 0.00001 - + let baseColor = if uniform.HasDiffuseColorTexture then let tex = diffuseColorTex.Sample(v.texCoord) |> srgbToLinear tex * uniform.DiffuseColor else uniform.DiffuseColor - + let roughness = if uniform.HasRoughnessTexture then let tv = roughnessTexture.Sample(v.roughCoord).[uniform.RoughnessTextureComponent] @@ -288,7 +289,7 @@ module Shader = uv * tv |> saturate else uniform.Roughness + eps |> clamp 0.0 0.99 - + let metalness = if uniform.HasMetallicnessTexture then let tv = metallicnessTexture.Sample(v.metalCoord).[uniform.MetallicnessTextureComponent] @@ -296,81 +297,81 @@ module Shader = uv * tv |> saturate else uniform.Metallicness + eps |> saturate - + let occlusion = 1.0 - + if baseColor.W < 0.01 then discard() - + let vn = v.normal |> Vec.normalize let vld = v.viewLightDir |> Vec.normalize let vcd = -v.viewPos.XYZ |> Vec.normalize - + let half = let v = vld + vcd let l = Vec.Length v if l > eps then v / l else V3d.Zero - + let vn = if uniform.HasNormalTexture then let vt = Vec.normalize v.viewTangent let vb = Vec.normalize v.viewBiTangent - + let v = normalTexture.Sample(v.normCoord).XYZ let nn = (v * 2.0 - 1.0) * V3d(V2d.II * uniform.NormalTextureScale * 0.5, 1.0) - + let newNormal = vn * nn.Z + vt * nn.X + vb * nn.Y |> Vec.normalize if newNormal.Z < 0.0 then vn else newNormal else vn - - + + let refl = -Vec.reflect vn vcd let nl = Vec.dot vn vld |> max 0.0 let nh = Vec.dot vn half |> max 0.0 //let hv = Vec.dot half vcd |> max 0.0 let nv = Vec.dot vn vcd |> max 0.0 - - - + + + let f0 = getR0(0.04, metalness, V3d.III) * baseColor.XYZ let d = trowbridgeReitzNDF nh roughness - + let f = fresnel f0 nv roughness let g = schlickBeckmannGAF nv roughness * schlickBeckmannGAF nl roughness - + let lambert = nl * 3.0 let dr = V3d.III * occlusion - + let diffuseIrradiance = sampleEnvDiffuse vn * occlusion let specularIrradiance = sampleEnv refl roughness * occlusion - + let diffuseDirectTerm = (baseColor.XYZ / Constant.Pi) * (V3d.III - f) * (1.0 - metalness) - + let specularDirectTerm = (f * g * d) / (4.0 * nl * nv + eps) - - let brdfDirectOutput = (diffuseDirectTerm + specularDirectTerm) * lambert * dr - let ambientDiffuse = diffuseIrradiance * (baseColor.XYZ / Constant.Pi) * (1.0 - f) * (1.0 - metalness) - - let ambientSpecular = specularIrradiance * f - + + let brdfDirectOutput = (diffuseDirectTerm + specularDirectTerm) * lambert * dr + let ambientDiffuse = diffuseIrradiance * (baseColor.XYZ / Constant.Pi) * (1.0 - f) * (1.0 - metalness) + + let ambientSpecular = specularIrradiance * f + let color = brdfDirectOutput + ambientDiffuse + ambientSpecular - + return V4d(saturate color, 1.0) |> linearToSrgb } - + let environment (v : Effects.Vertex) = fragment { let ndc = v.pos.XY / v.pos.W - + let p04 = uniform.ProjTrafoInv * V4d(ndc, -1.0, 1.0) let p14 = uniform.ProjTrafoInv * V4d(ndc, -0.8, 1.0) - + let dir = p14.XYZ / p14.W - p04.XYZ / p04.W - + let res = V4d(sampleEnv dir 0.2, 1.0) return linearToSrgb res //return skybox.Sample(dir) @@ -378,39 +379,39 @@ module Shader = [] module SceneSg = - + let private white = let img = PixImage(Col.Format.RGBA, V2i.II) img.GetMatrix().Set(C4b.White) |> ignore PixTexture2d(PixImageMipMap [| img :> PixImage |], TextureParams.empty) :> ITexture |> AVal.constant - - + + let private meshSg (m : Mesh) = let fvc = match m.Index with | Some i -> i.Length | None -> m.Positions.Length - - let mutable sg = + + let mutable sg = Sg.render m.Mode (DrawCallInfo(FaceVertexCount = fvc, InstanceCount = 1)) |> Sg.vertexAttribute' DefaultSemantic.Positions m.Positions - + match m.Index with | Some idx -> sg <- sg |> Sg.indexArray idx | None -> () - + match m.Normals with | Some ns -> sg <- sg |> Sg.vertexAttribute' DefaultSemantic.Normals ns | None -> () - + match m.Tangents with | Some ns -> sg <- sg |> Sg.vertexAttribute' Semantic.Tangent ns | None -> () - + match m.Colors with | Some cs -> sg <- sg |> Sg.vertexAttribute' DefaultSemantic.Colors cs | None -> () - + for data, sems in m.TexCoords do let view = BufferView.ofArray data for sem in sems do @@ -421,21 +422,21 @@ module SceneSg = | TextureSemantic.Emissive -> Semantic.EmissiveCoordinate | TextureSemantic.Metallicness -> Semantic.MetallicnessCoordinate | TextureSemantic.Normal -> Semantic.NormalCoordinate - + sg <- sg |> Sg.vertexBuffer semantic view - + let uniforms = UniformProvider.ofList [ "HasNormals", AVal.constant (Option.isSome m.Normals) :> IAdaptiveValue "HasTangents", AVal.constant (Option.isSome m.Tangents) "HasColors", AVal.constant (Option.isSome m.Colors) ] - - + + Sg.UniformApplicator(uniforms, sg) :> ISg - + let toSimpleSg (runtime : IRuntime) (scenes : seq) = - + let defaultMaterial = UniformProvider.ofList [ "DiffuseColor", AVal.constant C4f.White :> IAdaptiveValue @@ -443,13 +444,13 @@ module SceneSg = "Metallicness", AVal.constant 0.0 "EmissiveColor", AVal.constant C4f.Black "NormalTextureScale", AVal.constant 1.0 - + "HasDiffuseColorTexture", AVal.constant false "HasRoughnessTexture", AVal.constant false "HasMetallicnessTexture", AVal.constant false "HasEmissiveTexture", AVal.constant false "Has" + string DefaultSemantic.NormalMapTexture, AVal.constant false - + "DiffuseColorTexture", white "RoughnessTexture", white "RoughnessTextureComponent", AVal.constant 0 @@ -458,73 +459,73 @@ module SceneSg = string DefaultSemantic.NormalMapTexture, white "EmissiveTexture", white ] - + let sceneSgs = scenes |> Seq.toList |> List.map (fun scene -> let textures = - scene.ImageData |> HashMap.map (fun _ data -> + scene.ImageData |> Map.map (fun _ data -> let texture = StreamTexture(fun () -> new MemoryStream(data.Data)) texture :> ITexture |> AVal.constant ) - + let meshes = - scene.Meshes |> HashMap.map (fun _ m -> meshSg m) - - - + scene.Meshes |> Map.map (fun _ m -> meshSg m) + + + let rec traverse (node : Node) = - - + + let cs = match node.Children with | [] -> None | _ -> node.Children |> Seq.map traverse |> Sg.ofSeq |> Some - + let ms = node.Meshes |> List.choose (fun mi -> - match HashMap.tryFind mi.Mesh meshes with + match Map.tryFind mi.Mesh meshes with | Some mesh -> - match mi.Material |> Option.bind (fun mid -> HashMap.tryFind mid scene.Materials) with + match mi.Material |> Option.bind (fun mid -> Map.tryFind mid scene.Materials) with | Some mat -> - let uniforms = + let uniforms = let baseColorTexture = - match mat.BaseColorTexture |> Option.bind (fun id -> HashMap.tryFind id textures) with + match mat.BaseColorTexture |> Option.bind (fun id -> Map.tryFind id textures) with | Some t -> t | None -> white - + let roughnessTexture = - match mat.RoughnessTexture |> Option.bind (fun id -> HashMap.tryFind id textures) with + match mat.RoughnessTexture |> Option.bind (fun id -> Map.tryFind id textures) with | Some t -> t | None -> white - + let metallicnessTexture = - match mat.MetallicnessTexture |> Option.bind (fun id -> HashMap.tryFind id textures) with + match mat.MetallicnessTexture |> Option.bind (fun id -> Map.tryFind id textures) with | Some t -> t | None -> white - + let normalTexture = - match mat.NormalTexture |> Option.bind (fun id -> HashMap.tryFind id textures) with + match mat.NormalTexture |> Option.bind (fun id -> Map.tryFind id textures) with | Some t -> t | None -> white - + let emissiveTexture = - match mat.EmissiveTexture |> Option.bind (fun id -> HashMap.tryFind id textures) with + match mat.EmissiveTexture |> Option.bind (fun id -> Map.tryFind id textures) with | Some t -> t | None -> white - + UniformProvider.ofList [ "DiffuseColor", AVal.constant mat.BaseColor :> IAdaptiveValue "Roughness", AVal.constant mat.Roughness "Metallicness", AVal.constant mat.Metallicness "EmissiveColor", AVal.constant mat.EmissiveColor "NormalTextureScale", AVal.constant mat.NormalTextureScale - - "HasDiffuseColorTexture", AVal.constant (Option.isSome mat.BaseColorTexture) - "HasRoughnessTexture", AVal.constant (Option.isSome mat.RoughnessTexture) - "HasMetallicnessTexture", AVal.constant (Option.isSome mat.MetallicnessTexture) - "HasEmissiveTexture", AVal.constant (Option.isSome mat.EmissiveTexture) - "Has" + string DefaultSemantic.NormalMapTexture, AVal.constant (Option.isSome mat.NormalTexture) - + + "HasDiffuseColorTexture", AVal.constant (Option.isSome mat.BaseColorTexture) + "HasRoughnessTexture", AVal.constant (Option.isSome mat.RoughnessTexture) + "HasMetallicnessTexture", AVal.constant (Option.isSome mat.MetallicnessTexture) + "HasEmissiveTexture", AVal.constant (Option.isSome mat.EmissiveTexture) + "Has" + string DefaultSemantic.NormalMapTexture, AVal.constant (Option.isSome mat.NormalTexture) + "DiffuseColorTexture", baseColorTexture "RoughnessTexture", roughnessTexture "MetallicnessTexture", metallicnessTexture @@ -539,7 +540,7 @@ module SceneSg = | None -> None ) |> Sg.ofList |> Some - + let sg = match cs with | Some cs -> @@ -550,24 +551,24 @@ module SceneSg = match ms with | Some ms -> ms | None -> Sg.empty - + match node.Trafo with | Some t -> Sg.trafo' t sg | None -> sg - + traverse scene.RootNode ) - + let specular, diffuse = // FileTexture("/Users/schorsch/Desktop/studio_country_hall_4k.png", TextureParams.empty) // |> EnvironmentMap.ofPanorama runtime Skybox.get "chapel_$.png" |> AVal.force |> EnvironmentMap.prepare runtime - + let specular = specular :> ITexture |> AVal.constant let diffuse = diffuse :> ITexture |> AVal.constant - + Sg.ofList [ Sg.UniformApplicator(defaultMaterial, Sg.ofList sceneSgs) |> Sg.vertexBufferValue' DefaultSemantic.Normals V3f.OOI @@ -579,17 +580,14 @@ module SceneSg = |> Sg.vertexBufferValue' Semantic.NormalCoordinate V2f.Zero |> Sg.texture "SkyboxSpecular" specular |> Sg.texture "SkyboxDiffuse" diffuse - + Sg.farPlaneQuad |> Sg.texture "SkyboxSpecular" specular |> Sg.texture "SkyboxDiffuse" diffuse |> Sg.shader { do! Shader.environment } - - - ] - |> Sg.uniform' "LevelCount" EnvironmentMap.levelCount - - + + ] + |> Sg.uniform' "LevelCount" EnvironmentMap.levelCount \ No newline at end of file diff --git a/src/Examples (netcore)/38 - GLTF/data/chapel_bk.png b/src/Examples (netcore)/38 - GLTF/data/chapel_bk.png new file mode 100644 index 00000000..0849d7db Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/chapel_bk.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/chapel_dn.png b/src/Examples (netcore)/38 - GLTF/data/chapel_dn.png new file mode 100644 index 00000000..c86946c4 Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/chapel_dn.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/chapel_ft.png b/src/Examples (netcore)/38 - GLTF/data/chapel_ft.png new file mode 100644 index 00000000..01ba6243 Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/chapel_ft.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/chapel_lf.png b/src/Examples (netcore)/38 - GLTF/data/chapel_lf.png new file mode 100644 index 00000000..c973bcaf Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/chapel_lf.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/chapel_rt.png b/src/Examples (netcore)/38 - GLTF/data/chapel_rt.png new file mode 100644 index 00000000..d63bfcc5 Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/chapel_rt.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/chapel_up.png b/src/Examples (netcore)/38 - GLTF/data/chapel_up.png new file mode 100644 index 00000000..8a704ccd Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/chapel_up.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/miramar_bk.png b/src/Examples (netcore)/38 - GLTF/data/miramar_bk.png new file mode 100644 index 00000000..0d040122 Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/miramar_bk.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/miramar_dn.png b/src/Examples (netcore)/38 - GLTF/data/miramar_dn.png new file mode 100644 index 00000000..02395b86 Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/miramar_dn.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/miramar_ft.png b/src/Examples (netcore)/38 - GLTF/data/miramar_ft.png new file mode 100644 index 00000000..dac44b3c Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/miramar_ft.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/miramar_lf.png b/src/Examples (netcore)/38 - GLTF/data/miramar_lf.png new file mode 100644 index 00000000..7938342b Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/miramar_lf.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/miramar_rt.png b/src/Examples (netcore)/38 - GLTF/data/miramar_rt.png new file mode 100644 index 00000000..09bc256f Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/miramar_rt.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/miramar_up.png b/src/Examples (netcore)/38 - GLTF/data/miramar_up.png new file mode 100644 index 00000000..3bac7c47 Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/miramar_up.png differ diff --git a/src/Examples (netcore)/38 - GLTF/data/random.png b/src/Examples (netcore)/38 - GLTF/data/random.png new file mode 100644 index 00000000..83643b7e Binary files /dev/null and b/src/Examples (netcore)/38 - GLTF/data/random.png differ diff --git a/src/Examples (netcore)/38 - GLTF/paket.references b/src/Examples (netcore)/38 - GLTF/paket.references new file mode 100644 index 00000000..c7d65ae5 --- /dev/null +++ b/src/Examples (netcore)/38 - GLTF/paket.references @@ -0,0 +1,4 @@ +Aardvark.Build +FSharp.Core +Aardvark.Data.GLTF +Aardvark.PixImage.ImageSharp \ No newline at end of file