diff --git a/Examples/Complete/RenderToTexture/Core/Assets/FuseeText.png b/Examples/Complete/RenderToTexture/Core/Assets/FuseeText.png new file mode 100644 index 000000000..af5ffb051 Binary files /dev/null and b/Examples/Complete/RenderToTexture/Core/Assets/FuseeText.png differ diff --git a/Examples/Complete/RenderToTexture/Core/Assets/Lato-Black.ttf b/Examples/Complete/RenderToTexture/Core/Assets/Lato-Black.ttf new file mode 100644 index 000000000..6848db0d1 Binary files /dev/null and b/Examples/Complete/RenderToTexture/Core/Assets/Lato-Black.ttf differ diff --git a/Examples/Complete/RenderToTexture/Core/Fusee.Examples.RenderToTexture.Core.csproj b/Examples/Complete/RenderToTexture/Core/Fusee.Examples.RenderToTexture.Core.csproj new file mode 100644 index 000000000..bacfac2ae --- /dev/null +++ b/Examples/Complete/RenderToTexture/Core/Fusee.Examples.RenderToTexture.Core.csproj @@ -0,0 +1,26 @@ + + + netstandard2.1 + $(BaseOutputPath)\Examples\Simple\Core\ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/Complete/RenderToTexture/Core/RenderToTexture.cs b/Examples/Complete/RenderToTexture/Core/RenderToTexture.cs new file mode 100644 index 000000000..0ea459bc1 --- /dev/null +++ b/Examples/Complete/RenderToTexture/Core/RenderToTexture.cs @@ -0,0 +1,292 @@ +using Fusee.Base.Common; +using Fusee.Base.Core; +using Fusee.Engine.Common; +using Fusee.Engine.Core; +using Fusee.Engine.Core.Effects; +using Fusee.Engine.Core.Scene; +using Fusee.Engine.Core.ShaderShards; +using Fusee.Engine.GUI; +using Fusee.Math.Core; +using Fusee.Xene; +using System.Collections.Generic; +using System.Linq; +using static Fusee.Engine.Core.Input; +using static Fusee.Engine.Core.Time; + +namespace Fusee.Examples.RenderToTexture.Core +{ + [FuseeApplication(Name = "FUSEE Texture Rendering Example", Description = "An example on how to render a camera to a texture.")] + public class RenderToTexture : RenderCanvas + { + private SceneContainer _scene; + private SceneRendererForward _sceneRenderer; + + private SceneRendererForward _guiRenderer; + private SceneContainer _gui; + private SceneInteractionHandler _sih; + private readonly CanvasRenderMode _canvasRenderMode = CanvasRenderMode.Screen; + + private readonly Engine.Core.Scene.Camera _renderCam = new Engine.Core.Scene.Camera(ProjectionMethod.Perspective, 5, 100, M.PiOver4); + private readonly Engine.Core.Scene.Camera _mainCam = new Engine.Core.Scene.Camera(ProjectionMethod.Perspective, 1, 1000, M.PiOver4); + private Transform _renderCamTransform; + private Transform _mainCamTransform; + + private WritableTexture _renderTexture = new WritableTexture(RenderTargetTextureTypes.Albedo, new ImagePixelFormat(ColorFormat.RGB), 500, 500); + + // Init is called on startup. + public override void Init() + { + _mainCam.Viewport = new float4(0, 0, 100, 100); + _mainCam.BackgroundColor = new float4(1f, 1f, 1f, 1); + _mainCam.Layer = 10; + + _renderCam.Viewport = new float4(0, 0, 10, 10); + _renderCam.BackgroundColor = new float4(0f, 0f, 0f, 1); + _renderCam.Layer = 20; + _renderCam.RenderTexture = _renderTexture; + + _mainCamTransform = new Transform() + { + Rotation = new float3(0, 0, 0), + Translation = new float3(0, 20, 20), + Scale = new float3(1, 1, 1), + }; + var rotation = float4x4.LookAt(_mainCamTransform.Translation, new float3(0, -5, 0), float3.UnitY); + _mainCamTransform.Rotate(rotation.RotationComponent()); + + + SceneNode mainCam = new SceneNode() + { + Name = "MainCam", + Components = new List() + { + _mainCamTransform, + _mainCam, + } + }; + + _renderCamTransform = new Transform() + { + Rotation = float3.Zero, + Translation = new float3(0, 5, -20), + Scale = new float3(1, 1, 1), + }; + + SceneNode renderCam = new SceneNode() + { + Name = "RenderCam", + Components = new List() + { + _renderCamTransform, + _renderCam, + MakeEffect.FromDiffuseSpecular(new float4(1,0,0,1), float4.Zero), + new Engine.Core.Primitives.Cube(), + + }, + Children = new ChildList() + { + new SceneNode() + { + Components = new List() + { + new Transform() + { + Scale = new float3(0.5f, 0.5f, 1f), + Translation = new float3(0,0, 1f) + }, + new Engine.Core.Primitives.Cube() + } + } + } + }; + + SceneNode plane = new SceneNode() + { + Name = "Plane", + Components = new List() + { + new Transform + { + Rotation = new float3(0, M.Pi, 0), + Translation = new float3(0, 5, 20), + Scale = float3.One + }, + MakeEffect.FromDiffuseRenderTexture((float4)ColorUint.Red, _renderTexture, new float2(1, 1), .5f), + new Engine.Core.Primitives.Plane() + } + }; + + _gui = CreateGui(); + _scene = CreateScene(); + + _scene.Children.Add(mainCam); + _scene.Children.Add(renderCam); + _scene.Children.Add(plane); + + // Create the interaction handler + _sih = new SceneInteractionHandler(_gui); + + // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A). + RC.ClearColor = new float4(1, 1, 1, 1); + + // Wrap a SceneRenderer around the model. + _sceneRenderer = new SceneRendererForward(_scene); + _guiRenderer = new SceneRendererForward(_gui); + } + + // RenderAFrame is called once a frame + public override void RenderAFrame() + { + // Clear the backbuffer + RC.Clear(ClearFlags.Color | ClearFlags.Depth); + + RC.Viewport(0, 0, Width, Height); + + // Mouse and keyboard movement + + _mainCamTransform.RotateAround(new float3(0, -50, 0), new float3(0, DeltaTime * 0.2f, 0)); + + // Render the scene loaded in Init() + _sceneRenderer.Render(RC); + //_guiRenderer.Render(RC); + + // Swap buffers: Show the contents of the backbuffer (containing the currently rendered frame) on the front buffer. + Present(); + } + + private SceneContainer CreateGui() + { + var vsTex = AssetStorage.Get("texture.vert"); + var psTex = AssetStorage.Get("texture.frag"); + var psText = AssetStorage.Get("text.frag"); + + var canvasWidth = Width / 100f; + var canvasHeight = Height / 100f; + + var btnFuseeLogo = new GUIButton + { + Name = "Canvas_Button" + }; + btnFuseeLogo.OnMouseEnter += BtnLogoEnter; + btnFuseeLogo.OnMouseExit += BtnLogoExit; + btnFuseeLogo.OnMouseDown += BtnLogoDown; + + var guiFuseeLogo = new Texture(AssetStorage.Get("FuseeText.png")); + var fuseeLogo = new TextureNode( + "fuseeLogo", + vsTex, + psTex, + //Set the albedo texture you want to use. + guiFuseeLogo, + //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent. + //In this setup the element will stretch horizontally but stay the same vertically if the parent element is scaled. + UIElementPosition.GetAnchors(AnchorPos.TopTopLeft), + //Define Offset and therefor the size of the element. + UIElementPosition.CalcOffsets(AnchorPos.TopTopLeft, new float2(0, canvasHeight - 0.5f), canvasHeight, canvasWidth, new float2(1.75f, 0.5f)), + float2.One + ); + fuseeLogo.AddComponent(btnFuseeLogo); + + var fontLato = AssetStorage.Get("Lato-Black.ttf"); + var guiLatoBlack = new FontMap(fontLato, 24); + + var text = new TextNode( + "FUSEE Simple Example", + "ButtonText", + vsTex, + psText, + UIElementPosition.GetAnchors(AnchorPos.StretchHorizontal), + UIElementPosition.CalcOffsets(AnchorPos.StretchHorizontal, new float2(canvasWidth / 2 - 4, 0), canvasHeight, canvasWidth, new float2(8, 1)), + guiLatoBlack, + (float4)ColorUint.Greenery, + HorizontalTextAlignment.Center, + VerticalTextAlignment.Center); + + var canvas = new CanvasNode( + "Canvas", + _canvasRenderMode, + new MinMaxRect + { + Min = new float2(-canvasWidth / 2, -canvasHeight / 2f), + Max = new float2(canvasWidth / 2, canvasHeight / 2f) + }) + { + Children = new ChildList() + { + //Simple Texture Node, contains the fusee logo. + fuseeLogo, + text + } + }; + + return new SceneContainer + { + Children = new List + { + //Add canvas. + canvas + } + }; + } + + private SceneContainer CreateScene() + { + var scene = new SceneContainer + { + Header = new SceneHeader + { + CreationDate = "November 2021", + CreatedBy = "Jonas Haller", + Generator = "Handcoded with pride :)", + }, + Children = new List { }, + }; + + var rand = new System.Random(); + + for (int i = 0; i < 20; i++) + { + int x = rand.Next(-10, 10); + int y = rand.Next(-10, 10); + int z = rand.Next(-10, 10); + + var cube = new SceneNode + { + Name = "Cube" + i, + Components = new List + { + new Transform { + Translation=new float3(x, y, z), + Scale = float3.One + }, + MakeEffect.FromDiffuseSpecular((float4)ColorUint.Gray, float4.Zero, 4.0f, 1f), + new Engine.Core.Primitives.Cube() + } + }; + + scene.Children.Add(cube); + } + + return scene; + } + + public void BtnLogoEnter(CodeComponent sender) + { + var effect = _gui.Children.FindNodes(node => node.Name == "fuseeLogo").First().GetComponent(); + effect.SetFxParam(UniformNameDeclarations.Albedo, (float4)ColorUint.Black); + effect.SetFxParam(UniformNameDeclarations.AlbedoMix, 0.8f); + } + + public void BtnLogoExit(CodeComponent sender) + { + var effect = _gui.Children.FindNodes(node => node.Name == "fuseeLogo").First().GetComponent(); + effect.SetFxParam(UniformNameDeclarations.Albedo, float4.One); + effect.SetFxParam(UniformNameDeclarations.AlbedoMix, 1f); + } + + public void BtnLogoDown(CodeComponent sender) + { + OpenLink("http://fusee3d.org"); + } + } +} \ No newline at end of file diff --git a/Examples/Complete/RenderToTexture/Desktop/Fusee.Examples.RenderToTexture.Desktop.csproj b/Examples/Complete/RenderToTexture/Desktop/Fusee.Examples.RenderToTexture.Desktop.csproj new file mode 100644 index 000000000..42c7a0884 --- /dev/null +++ b/Examples/Complete/RenderToTexture/Desktop/Fusee.Examples.RenderToTexture.Desktop.csproj @@ -0,0 +1,14 @@ + + + netcoreapp3.1 + Exe + $(BaseOutputPath)\Examples\Simple\Desktop\ + + + + + + + + + \ No newline at end of file diff --git a/Examples/Complete/RenderToTexture/Desktop/FuseeLogo.ico b/Examples/Complete/RenderToTexture/Desktop/FuseeLogo.ico new file mode 100644 index 000000000..dbdc5bc33 Binary files /dev/null and b/Examples/Complete/RenderToTexture/Desktop/FuseeLogo.ico differ diff --git a/Examples/Complete/RenderToTexture/Desktop/Main.cs b/Examples/Complete/RenderToTexture/Desktop/Main.cs new file mode 100644 index 000000000..f09728938 --- /dev/null +++ b/Examples/Complete/RenderToTexture/Desktop/Main.cs @@ -0,0 +1,63 @@ +using Fusee.Base.Common; +using Fusee.Base.Core; +using Fusee.Base.Imp.Desktop; +using Fusee.Engine.Core; +using Fusee.Engine.Core.Scene; +using Fusee.Serialization; +using System.IO; +using System.Reflection; + +namespace Fusee.Examples.RenderToTexture.Desktop +{ + public class RenderToTexture + { + public static void Main() + { + // Inject Fusee.Engine.Base InjectMe dependencies + IO.IOImp = new Fusee.Base.Imp.Desktop.IOImp(); + + var fap = new Fusee.Base.Imp.Desktop.FileAssetProvider("Assets"); + fap.RegisterTypeHandler( + new AssetHandler + { + ReturnedType = typeof(Font), + Decoder = (string id, object storage) => + { + if (!Path.GetExtension(id).Contains("ttf", System.StringComparison.OrdinalIgnoreCase)) return null; + return new Font { _fontImp = new FontImp((Stream)storage) }; + }, + Checker = id => Path.GetExtension(id).Contains("ttf", System.StringComparison.OrdinalIgnoreCase) + }); + fap.RegisterTypeHandler( + new AssetHandler + { + ReturnedType = typeof(SceneContainer), + Decoder = (string id, object storage) => + { + if (!Path.GetExtension(id).Contains("fus", System.StringComparison.OrdinalIgnoreCase)) return null; + return FusSceneConverter.ConvertFrom(ProtoBuf.Serializer.Deserialize((Stream)storage), id); + }, + Checker = id => Path.GetExtension(id).Contains("fus", System.StringComparison.OrdinalIgnoreCase) + }); + + AssetStorage.RegisterProvider(fap); + + var app = new Core.RenderToTexture(); + + // Inject Fusee.Engine InjectMe dependencies (hard coded) + System.Drawing.Icon appIcon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); + app.CanvasImplementor = new Fusee.Engine.Imp.Graphics.Desktop.RenderCanvasImp(appIcon); + app.ContextImplementor = new Fusee.Engine.Imp.Graphics.Desktop.RenderContextImp(app.CanvasImplementor); + Input.AddDriverImp(new Fusee.Engine.Imp.Graphics.Desktop.RenderCanvasInputDriverImp(app.CanvasImplementor)); + Input.AddDriverImp(new Fusee.Engine.Imp.Graphics.Desktop.WindowsTouchInputDriverImp(app.CanvasImplementor)); + // app.InputImplementor = new Fusee.Engine.Imp.Graphics.Desktop.InputImp(app.CanvasImplementor); + // app.AudioImplementor = new Fusee.Engine.Imp.Sound.Desktop.AudioImp(); + // app.NetworkImplementor = new Fusee.Engine.Imp.Network.Desktop.NetworkImp(); + // app.InputDriverImplementor = new Fusee.Engine.Imp.Input.Desktop.InputDriverImp(); + // app.VideoManagerImplementor = ImpFactory.CreateIVideoManagerImp(); + + // Start the app + app.Run(); + } + } +} \ No newline at end of file diff --git a/Fusee.sln b/Fusee.sln index 5caf88174..98604fffc 100644 --- a/Fusee.sln +++ b/Fusee.sln @@ -247,7 +247,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scene", "Scene", "{A9EE99FE EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Components", "Components", "{87F19962-A219-45D7-AB71-C0E3618CCF41}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fusee.Test.Scene.Components", "src\Tests\Scene\Components\Fusee.Test.Scene.Components\Fusee.Test.Scene.Components.csproj", "{45F790CB-C1C5-4CC3-AAB2-788696BC65E4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fusee.Test.Scene.Components", "src\Tests\Scene\Components\Fusee.Test.Scene.Components\Fusee.Test.Scene.Components.csproj", "{45F790CB-C1C5-4CC3-AAB2-788696BC65E4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GameWindow", "GameWindow", "{ED2FBF72-1E63-4DDE-8646-9008F2BF3CAC}" EndProject @@ -259,6 +259,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fusee.Examples.Starkiller.C EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fusee.Examples.Starkiller.Desktop", "Examples\Complete\Starkiller\Desktop\Fusee.Examples.Starkiller.Desktop.csproj", "{6629EF3B-DA6B-4217-8A21-2B3A0863FBF9}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fusee.Examples.RenderToTexture.Core", "Examples\Complete\RenderToTexture\Core\Fusee.Examples.RenderToTexture.Core.csproj", "{53781070-8492-444A-A3A6-5D5210C1CD68}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RenderToTexture", "RenderToTexture", "{EA29105D-BE52-48C1-B468-864FED1C03C3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fusee.Examples.RenderToTexture.Android", "Examples\Complete\RenderToTexture\Android\Fusee.Examples.RenderToTexture.Android.csproj", "{810E3CE0-2CE6-4BF9-B512-837FC7C3771F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fusee.Examples.RenderToTexture.Desktop", "Examples\Complete\RenderToTexture\Desktop\Fusee.Examples.RenderToTexture.Desktop.csproj", "{E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Engine\Imp\Graphics\Shared\Fusee.Engine.Imp.Graphics.Shared.projitems*{253263c9-9c67-44a5-94d3-51c586bbdaec}*SharedItemsImports = 13 @@ -4713,6 +4721,195 @@ Global {6629EF3B-DA6B-4217-8A21-2B3A0863FBF9}.Release-WebAsm|x64.Build.0 = Release|Any CPU {6629EF3B-DA6B-4217-8A21-2B3A0863FBF9}.Release-WebAsm|x86.ActiveCfg = Release|Any CPU {6629EF3B-DA6B-4217-8A21-2B3A0863FBF9}.Release-WebAsm|x86.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug|Any CPU.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug|x64.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug|x64.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug|x86.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug|x86.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Android|Any CPU.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Android|Any CPU.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Android|x64.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Android|x64.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Android|x86.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Android|x86.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Desktop|Any CPU.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Desktop|Any CPU.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Desktop|x64.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Desktop|x64.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Desktop|x86.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-Desktop|x86.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-WebAsm|Any CPU.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-WebAsm|Any CPU.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-WebAsm|x64.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-WebAsm|x64.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-WebAsm|x86.ActiveCfg = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Debug-WebAsm|x86.Build.0 = Debug|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release|Any CPU.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release|Any CPU.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release|x64.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release|x64.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release|x86.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release|x86.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Android|Any CPU.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Android|Any CPU.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Android|x64.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Android|x64.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Android|x86.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Android|x86.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Desktop|Any CPU.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Desktop|Any CPU.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Desktop|x64.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Desktop|x64.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Desktop|x86.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-Desktop|x86.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-NuGet|Any CPU.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-NuGet|Any CPU.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-NuGet|x64.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-NuGet|x64.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-NuGet|x86.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-NuGet|x86.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-WebAsm|Any CPU.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-WebAsm|Any CPU.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-WebAsm|x64.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-WebAsm|x64.Build.0 = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-WebAsm|x86.ActiveCfg = Release|Any CPU + {53781070-8492-444A-A3A6-5D5210C1CD68}.Release-WebAsm|x86.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug|x64.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug|x64.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug|x64.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug|x86.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug|x86.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug|x86.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Android|Any CPU.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Android|Any CPU.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Android|Any CPU.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Android|x64.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Android|x64.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Android|x64.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Android|x86.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Android|x86.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Android|x86.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Desktop|Any CPU.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Desktop|Any CPU.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Desktop|Any CPU.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Desktop|x64.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Desktop|x64.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Desktop|x64.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Desktop|x86.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Desktop|x86.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-Desktop|x86.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-WebAsm|Any CPU.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-WebAsm|Any CPU.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-WebAsm|Any CPU.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-WebAsm|x64.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-WebAsm|x64.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-WebAsm|x64.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-WebAsm|x86.ActiveCfg = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-WebAsm|x86.Build.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Debug-WebAsm|x86.Deploy.0 = Debug|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release|Any CPU.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release|Any CPU.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release|x64.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release|x64.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release|x64.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release|x86.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release|x86.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release|x86.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Android|Any CPU.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Android|Any CPU.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Android|Any CPU.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Android|x64.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Android|x64.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Android|x64.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Android|x86.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Android|x86.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Android|x86.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Desktop|Any CPU.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Desktop|Any CPU.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Desktop|Any CPU.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Desktop|x64.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Desktop|x64.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Desktop|x64.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Desktop|x86.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Desktop|x86.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-Desktop|x86.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-NuGet|Any CPU.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-NuGet|Any CPU.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-NuGet|Any CPU.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-NuGet|x64.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-NuGet|x64.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-NuGet|x64.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-NuGet|x86.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-NuGet|x86.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-NuGet|x86.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-WebAsm|Any CPU.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-WebAsm|Any CPU.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-WebAsm|Any CPU.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-WebAsm|x64.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-WebAsm|x64.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-WebAsm|x64.Deploy.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-WebAsm|x86.ActiveCfg = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-WebAsm|x86.Build.0 = Release|Any CPU + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F}.Release-WebAsm|x86.Deploy.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug|x64.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug|x64.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug|x86.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug|x86.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Android|Any CPU.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Android|Any CPU.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Android|x64.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Android|x64.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Android|x86.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Android|x86.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Desktop|Any CPU.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Desktop|Any CPU.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Desktop|x64.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Desktop|x64.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Desktop|x86.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-Desktop|x86.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-WebAsm|Any CPU.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-WebAsm|Any CPU.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-WebAsm|x64.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-WebAsm|x64.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-WebAsm|x86.ActiveCfg = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Debug-WebAsm|x86.Build.0 = Debug|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release|Any CPU.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release|x64.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release|x64.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release|x86.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release|x86.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Android|Any CPU.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Android|Any CPU.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Android|x64.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Android|x64.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Android|x86.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Android|x86.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Desktop|Any CPU.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Desktop|Any CPU.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Desktop|x64.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Desktop|x64.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Desktop|x86.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-Desktop|x86.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-NuGet|Any CPU.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-NuGet|Any CPU.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-NuGet|x64.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-NuGet|x64.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-NuGet|x86.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-NuGet|x86.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-WebAsm|Any CPU.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-WebAsm|Any CPU.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-WebAsm|x64.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-WebAsm|x64.Build.0 = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-WebAsm|x86.ActiveCfg = Release|Any CPU + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7}.Release-WebAsm|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4830,6 +5027,10 @@ Global {C8A57860-4A53-46BA-969D-02EB861B3309} = {E68628DA-312F-4171-A5ED-08072B5CCA3C} {E3CA0E6F-729D-4C5E-B3B0-E328F48C33CD} = {C8A57860-4A53-46BA-969D-02EB861B3309} {6629EF3B-DA6B-4217-8A21-2B3A0863FBF9} = {C8A57860-4A53-46BA-969D-02EB861B3309} + {53781070-8492-444A-A3A6-5D5210C1CD68} = {EA29105D-BE52-48C1-B468-864FED1C03C3} + {EA29105D-BE52-48C1-B468-864FED1C03C3} = {E68628DA-312F-4171-A5ED-08072B5CCA3C} + {810E3CE0-2CE6-4BF9-B512-837FC7C3771F} = {EA29105D-BE52-48C1-B468-864FED1C03C3} + {E114ECBB-4231-4DA9-BC63-AE6A46C0DFD7} = {EA29105D-BE52-48C1-B468-864FED1C03C3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {CC1775C2-579F-4897-8770-592966D00E3D} diff --git a/src/Engine/Core/Effects/SurfaceEffectInput.cs b/src/Engine/Core/Effects/SurfaceEffectInput.cs index 931e22be8..012e5ab5a 100644 --- a/src/Engine/Core/Effects/SurfaceEffectInput.cs +++ b/src/Engine/Core/Effects/SurfaceEffectInput.cs @@ -1,4 +1,5 @@ using Fusee.Math.Core; +using Fusee.Engine.Common; using System; namespace Fusee.Engine.Core.Effects @@ -279,7 +280,7 @@ public float AlbedoMix /// /// The albedo texture. /// - public Texture AlbedoTex + public ITextureBase AlbedoTex { get => _albedoTex; set @@ -291,12 +292,12 @@ public Texture AlbedoTex } } } - private Texture _albedoTex; + private ITextureBase _albedoTex; /// /// The normal texture. /// - public Texture NormalTex + public ITextureBase NormalTex { get => _normalTex; set @@ -308,7 +309,7 @@ public Texture NormalTex } } } - private Texture _normalTex; + private ITextureBase _normalTex; /// /// The normal texture. @@ -371,7 +372,7 @@ public float AlbedoMix /// /// The albedo texture. /// - public Texture AlbedoTex + public ITextureBase AlbedoTex { get => _albedoTex; set @@ -383,7 +384,7 @@ public Texture AlbedoTex } } } - private Texture _albedoTex; + private ITextureBase _albedoTex; /// /// The normal texture. @@ -412,7 +413,7 @@ public class TextureInputColor : TextureInputColorUnlit /// /// The normal texture. /// - public Texture NormalTex + public ITextureBase NormalTex { get => _normalTex; set @@ -424,7 +425,7 @@ public Texture NormalTex } } } - private Texture _normalTex; + private ITextureBase _normalTex; /// /// The normal texture. @@ -470,7 +471,7 @@ public float AlbedoMix /// /// The albedo texture. /// - public Texture AlbedoTex + public ITextureBase AlbedoTex { get => _albedoTex; set @@ -482,12 +483,12 @@ public Texture AlbedoTex } } } - private Texture _albedoTex; + private ITextureBase _albedoTex; /// /// The normal texture. /// - public Texture NormalTex + public ITextureBase NormalTex { get => _normalTex; set @@ -499,7 +500,7 @@ public Texture NormalTex } } } - private Texture _normalTex; + private ITextureBase _normalTex; /// /// The normal texture. diff --git a/src/Engine/Core/FusSceneConverter.cs b/src/Engine/Core/FusSceneConverter.cs index 7a211be3c..547c7fffe 100644 --- a/src/Engine/Core/FusSceneConverter.cs +++ b/src/Engine/Core/FusSceneConverter.cs @@ -1018,17 +1018,21 @@ public void ConvEffect(DefaultSurfaceEffect effect) Color = surfaceInput.Albedo }; - if (surfaceInput.AlbedoTex != null) + if (surfaceInput.AlbedoTex != null && surfaceInput.AlbedoTex is Texture) { + Texture albedoTex = surfaceInput.AlbedoTex as Texture; + mat.Albedo.Mix = surfaceInput.AlbedoMix; - mat.Albedo.Texture = surfaceInput.AlbedoTex?.PathAndName; + mat.Albedo.Texture = albedoTex?.PathAndName; } - if (surfaceInput.NormalTex != null) + if (surfaceInput.NormalTex != null && surfaceInput.NormalTex is Texture) { + Texture normalTex = surfaceInput.NormalTex as Texture; + mat.NormalMap = new NormapMapChannel() { - Texture = surfaceInput.NormalTex.PathAndName, + Texture = normalTex.PathAndName, Intensity = surfaceInput.NormalMappingStrength }; } @@ -1080,17 +1084,21 @@ public void ConvEffect(DefaultSurfaceEffect effect) Color = surfaceInput.Albedo }; - if (surfaceInput.AlbedoTex != null) + if (surfaceInput.AlbedoTex != null && surfaceInput.AlbedoTex is Texture) { + Texture albedoTex = surfaceInput.AlbedoTex as Texture; + mat.Albedo.Mix = surfaceInput.AlbedoMix; - mat.Albedo.Texture = surfaceInput.AlbedoTex?.PathAndName; + mat.Albedo.Texture = albedoTex?.PathAndName; } - if (surfaceInput.NormalTex != null) + if (surfaceInput.NormalTex != null && surfaceInput.NormalTex is Texture) { + Texture normalTex = surfaceInput.NormalTex as Texture; + mat.NormalMap = new NormapMapChannel() { - Texture = surfaceInput.NormalTex.PathAndName, + Texture = normalTex.PathAndName, Intensity = surfaceInput.NormalMappingStrength }; } diff --git a/src/Engine/Core/MakeEffect.cs b/src/Engine/Core/MakeEffect.cs index 9d9c2b5e3..1b11e4638 100644 --- a/src/Engine/Core/MakeEffect.cs +++ b/src/Engine/Core/MakeEffect.cs @@ -442,6 +442,21 @@ public static DefaultSurfaceEffect FromDiffuseAlbedoTexture(float4 albedoColor, return new DefaultSurfaceEffect(lighingSetup, input, FragShards.SurfOutBody_Textures(lighingSetup), VertShards.SufOutBody_PosNorm); } + public static DefaultSurfaceEffect FromDiffuseRenderTexture(float4 albedoColor, WritableTexture albedoTex, float2 texTiles, float albedoMix, float roughness = 0f) + { + var input = new TextureInputColor() + { + Albedo = albedoColor, + AlbedoTex = albedoTex, + AlbedoMix = albedoMix, + TexTiles = texTiles, + Roughness = roughness + }; + + var lighingSetup = LightingSetupFlags.DiffuseOnly | LightingSetupFlags.AlbedoTex; + return new DefaultSurfaceEffect(lighingSetup, input, FragShards.SurfOutBody_Textures(lighingSetup), VertShards.SufOutBody_PosNorm); + } + /// /// Builds a simple shader effect with diffuse component. ///