diff --git a/Examples/Complete/ABCompare/Core/ABCompare.cs b/Examples/Complete/ABCompare/Core/ABCompare.cs new file mode 100644 index 000000000..25c6cf92c --- /dev/null +++ b/Examples/Complete/ABCompare/Core/ABCompare.cs @@ -0,0 +1,755 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Fusee.Base.Common; +using Fusee.Base.Core; +using Fusee.Engine.Common; +using Fusee.Engine.Core; +using Fusee.Math.Core; +using Fusee.Serialization; +using Fusee.Xene; +using static Fusee.Engine.Core.Input; +using static Fusee.Engine.Core.Time; +using Fusee.Engine.GUI; +using System.Threading.Tasks; + + +namespace Fusee.Examples.ABCompare.Core +{ + [FuseeApplication(Name = "FUSEE ABCompare Example", Description = "A example for comparing two Models.")] + public class ABCompare : RenderCanvas + { + public string ModelFile = "FUSEERocket.fus"; + public string ModelFile2 = "RocketFus.fus"; + + // angle variables + private static float _angleHorz = M.PiOver3, _angleVert = -M.PiOver6 * 0.5f, _angleVelHorz, _angleVelVert, _angleRoll, _angleRollInit, _zoomVel, _zoom, _viewtranslate; + private static float2 _offset; + private static float2 _offsetInit; + private const float RotationSpeed = 7; + private const float Damping = 0.8f; + private SceneContainer _scene1; + private SceneContainer _scene2; + private SceneRendererForward _sceneRenderer1; + private SceneRendererForward _sceneRenderer2; + private float4x4 _sceneCenter; + private float4x4 _sceneScale; + private bool _twoTouchRepeated; + + private bool _keys; + private const float ZNear = 1f; + private const float ZFar = 3000; + private float _aspectRatio; + private float _fovy = M.PiOver4; + + private SceneRendererForward _guiRenderer; + private SceneContainer _gui; + private SceneInteractionHandler _sih; + private readonly CanvasRenderMode _canvasRenderMode = CanvasRenderMode.SCREEN; + + private float _initCanvasWidth; + private float _initCanvasHeight; + private float _canvasWidth = 16; + private float _canvasHeight = 9; + + private float _maxPinchSpeed; + + private GamePadDevice _gamePad; + + + private bool _abbtn1; + private bool _abbtn2; + private bool _viewports = false; + private bool _multipass = false; + private WritableTexture _renderTex1; + private WritableTexture _renderTex2; + private float2 _point1; + private float2 _point2; + private float2 btnscale; + private float _radius; + private float2 _middlepoint; + private ShaderEffect _blurPassEffect; + private SceneContainer _quadScene; + private SceneRendererForward _sceneRendererBlur; + private readonly int _texRes = (int)TexRes.HIGH_RES; + private TextureNodeContainer ab1; + private TextureNodeContainer ab2; + private TextNodeContainer textviewportlegacy; + + // Init is called on startup. + public override async Task Init() + { + + //=> Erstellung der Texturen für das Multipass Rendering + + _renderTex1 = WritableTexture.CreateAlbedoTex(_texRes, _texRes); + _renderTex2 = WritableTexture.CreateAlbedoTex(_texRes, _texRes); + + //=> Punkte zur Geradenberechnung dürfen nicht aufeinander liegen!! + //=> Initialisierung der Punkte der Geradengleichung + _point1 = new float2(0.5f, 0.5f); + _point2 = new float2(0.5f, 0.6f); + + //=> Initialisierung der Variablen für den Kreisausschnitt + //_radius = 0.1f; + //_middlepoint = new float2(0.5f, 0.5f); + + //=> Initialisierung der zu verwendenden Shader + _blurPassEffect = new ShaderEffect(new[] + { + new EffectPassDeclaration + { + VS = AssetStorage.Get("screenFilledQuad.vert"), + PS = AssetStorage.Get("multitex.frag"), + StateSet = new RenderStateSet + { + AlphaBlendEnable = false, + ZEnable = true, + }, + } + }, + new[] + { + //=> Initialiserung und Zuweisung der Uniform Variablen + new EffectParameterDeclaration { Name = "InputTex1", Value = _renderTex1}, + new EffectParameterDeclaration { Name = "InputTex2", Value = _renderTex2}, + new EffectParameterDeclaration { Name = "Point1", Value = _point1}, + new EffectParameterDeclaration { Name = "Point2", Value = _point2}, + new EffectParameterDeclaration { Name = "Middlepoint", Value = _middlepoint}, + new EffectParameterDeclaration { Name = "Radius", Value = _radius} + + }); + + //=> Szene, der die Shader übergeben werden + _quadScene = new SceneContainer() + { + Children = new List() + { + new SceneNodeContainer() + { + Components = new List() + { + new ProjectionComponent(ProjectionMethod.PERSPECTIVE, 0.1f, 1, M.DegreesToRadians(45f)), + + new ShaderEffectComponent() + { + Effect = _blurPassEffect + }, + new Plane() + } + } + } + }; + + _initCanvasWidth = Width / 100f; + _initCanvasHeight = Height / 100f; + + _canvasHeight = _initCanvasHeight; + _canvasWidth = _initCanvasWidth; + + _aspectRatio = Width / (float)Height; + + // Initial "Zoom" value (it's rather the distance in view direction, not the camera's focal distance/opening angle) + _zoom = 400; + + _angleRoll = 0; + _angleRollInit = 0; + _twoTouchRepeated = false; + _offset = float2.Zero; + _offsetInit = float2.Zero; + + // Set the clear color for the back buffer to white (100% intensity in all color channels R, G, B, A). + RC.ClearColor = new float4(1, 1, 1, 1); + + // Load the standard model + + _scene1 = AssetStorage.Get(ModelFile); + + + _scene2 = AssetStorage.Get(ModelFile2); + + //==> Muss für eigene Projektion entfernt werden! + _scene1.Children.RemoveAt(0); + _scene2.Children.RemoveAt(0); + + + _gui = CreateGui(); + // Create the interaction handler + _sih = new SceneInteractionHandler(_gui); + + + // Register the input devices that are not already given. + _gamePad = GetDevice(0); + + + + AABBCalculator aabbc = new AABBCalculator(_scene1); + var bbox = aabbc.GetBox(); + if (bbox != null) + { + // If the model origin is more than one third away from its bounding box, + // recenter it to the bounding box. Do this check individually per dimension. + // This way, small deviations will keep the model's original center, while big deviations + // will make the model rotate around its geometric center. + float3 bbCenter = bbox.Value.Center; + float3 bbSize = bbox.Value.Size; + float3 center = float3.Zero; + if (System.Math.Abs(bbCenter.x) > bbSize.x * 0.3) + center.x = bbCenter.x; + if (System.Math.Abs(bbCenter.y) > bbSize.y * 0.3) + center.y = bbCenter.y; + if (System.Math.Abs(bbCenter.z) > bbSize.z * 0.3) + center.z = bbCenter.z; + _sceneCenter = float4x4.CreateTranslation(-center); + + // Adjust the model size + float maxScale = System.Math.Max(bbSize.x, System.Math.Max(bbSize.y, bbSize.z)); + if (maxScale != 0) + _sceneScale = float4x4.CreateScale(200.0f / maxScale); + else + _sceneScale = float4x4.Identity; + } + + // Wrap a SceneRenderer around the model. + _sceneRendererBlur = new SceneRendererForward(_quadScene); + + _sceneRenderer1 = new SceneRendererForward(_scene1); + + _sceneRenderer2 = new SceneRendererForward(_scene2); + + _guiRenderer = new SceneRendererForward(_gui); + + return true; + } + + + // RenderAFrame is called once a frame + public override void RenderAFrame() + { + + //if (_gamePad != null) + // Diagnostics.Log(_gamePad.LSX); + + // Clear the backbuffer + RC.Clear(ClearFlags.Color | ClearFlags.Depth); + + + // Mouse and keyboard movement + if (Keyboard.LeftRightAxis != 0 || Keyboard.UpDownAxis != 0) + { + _keys = true; + + } + if (Keyboard.ADAxis != 0) + { + _keys = true; + } + + var curDamp = (float)System.Math.Exp(-Damping * DeltaTime); + // Zoom & Roll + if (Touch.TwoPoint) + { + if (!_twoTouchRepeated) + { + _twoTouchRepeated = true; + _angleRollInit = Touch.TwoPointAngle - _angleRoll; + _offsetInit = Touch.TwoPointMidPoint - _offset; + _maxPinchSpeed = 0; + } + _zoomVel = Touch.TwoPointDistanceVel * -0.01f; + _angleRoll = Touch.TwoPointAngle - _angleRollInit; + _offset = Touch.TwoPointMidPoint - _offsetInit; + float pinchSpeed = Touch.TwoPointDistanceVel; + if (pinchSpeed > _maxPinchSpeed) _maxPinchSpeed = pinchSpeed; // _maxPinchSpeed is used for debugging only. + } + else + { + _twoTouchRepeated = false; + _zoomVel = Mouse.WheelVel * -0.5f; + _angleRoll *= curDamp * 0.8f; + _offset *= curDamp * 0.8f; + } + + + // UpDown / LeftRight rotation + if (Mouse.LeftButton) + { + + //==> Rückgabe der Mausposition und Umwandlung in normalisierte Koordinaten + float mousex = (Mouse.Position.x / Width); + float mousey = 1.0f - (Mouse.Position.y / Height);//==> Anpassug an gegenläufiges UV-Koordinatensystem + + + //==> Positionierung der Punkte der Geradengleichung und der verbundenen TextureNodeContainer + if (_abbtn1) + { + + _point1 = new float2(mousex,mousey); + + //=> Position wird bei resize nicht richtig zurückgegeben! + _gui.Children.FindNodes(node => node.Name == "ab1").First().GetComponent().Offsets = UIElementPosition.CalcOffsets(AnchorPos.MIDDLE, new float2(_initCanvasWidth * _point1.x - (btnscale.x/2), _initCanvasHeight *_point1.y - (btnscale.y/2)), _initCanvasHeight, _initCanvasWidth, btnscale); + } + + else if(_abbtn2) + { + + _point2 = new float2(mousex, mousey); + + //=> Position wird bei resize nicht richtig zurückgegeben! + _gui.Children.FindNodes(node => node.Name == "ab2").First().GetComponent().Offsets = UIElementPosition.CalcOffsets(AnchorPos.MIDDLE, new float2(_initCanvasWidth * _point2.x - (btnscale.x / 2), _initCanvasHeight * _point2.y - (btnscale.y / 2)), _initCanvasHeight, _initCanvasWidth, btnscale); + } + + else + { + _keys = false; + _angleVelHorz = -RotationSpeed * Mouse.XVel * DeltaTime * 0.0005f; + _angleVelVert = -RotationSpeed * Mouse.YVel * DeltaTime * 0.0005f; + } + + } + else + { + + _abbtn1 = false; + _abbtn2 = false; + + if (_keys) + { + _angleVelHorz = -RotationSpeed * Keyboard.LeftRightAxis * DeltaTime; + _angleVelVert = -RotationSpeed * Keyboard.UpDownAxis * DeltaTime; + _viewtranslate = Keyboard.ADAxis;//=> Änderung des Kamerafrustums der multiple Viewport Szene + + //_radius = Keyboard.ADAxis;//=> Änderung des Radius für den Kreisaussschnitt + } + else + { + _angleVelHorz *= curDamp; + _angleVelVert *= curDamp; + } + } + + + //=> Aktualisierung der Uniform Variablen zur Laufzeit!!! + + _blurPassEffect.SetEffectParam("Radius", _radius); + _blurPassEffect.SetEffectParam("Point1", _point1); + _blurPassEffect.SetEffectParam("Point2", _point2); + + _zoom += _zoomVel; + // Limit zoom + if (_zoom < 80) + _zoom = 80; + if (_zoom > 2000) + _zoom = 2000; + + _angleHorz += _angleVelHorz; + // Wrap-around to keep _angleHorz between -PI and + PI + _angleHorz = M.MinAngle(_angleHorz); + + _angleVert += _angleVelVert; + // Limit pitch to the range between [-PI/2, + PI/2] + _angleVert = M.Clamp(_angleVert, -M.PiOver2, M.PiOver2); + + // Wrap-around to keep _angleRoll between -PI and + PI + _angleRoll = M.MinAngle(_angleRoll); + + // Create the camera matrix and set it as the current View transformation + var mtxRot = /*float4x4.CreateRotationZ(_angleRoll) **/ float4x4.CreateRotationX(_angleVert) * float4x4.CreateRotationY(_angleHorz); + var mtxCam = float4x4.LookAt(0, 20, -_zoom, 0, 0, 0, 0, 1, 0); + RC.View = mtxCam * mtxRot * _sceneScale * _sceneCenter; + var mtxOffset = float4x4.CreateTranslation(2f * _offset.x / Width, -2f * _offset.y / Height, 0); + RC.Projection *= mtxOffset; + + // Constantly check for interactive objects. + _sih.CheckForInteractiveObjects(Input.Mouse.Position, Width, Height); + + if (Touch.GetTouchActive(TouchPoints.Touchpoint_0) && !Touch.TwoPoint) + { + _sih.CheckForInteractiveObjects(Touch.GetPosition(TouchPoints.Touchpoint_0), Width, Height); + } + // Tick any animations and Render the scene loaded in Init() + _sceneRenderer1.Animate(); + + _sceneRenderer2.Animate(); + + + // Create two Viewports + //==> Rendervorgang für Multipass Example + if (_multipass) + { + + RC.Projection = float4x4.CreatePerspectiveFieldOfView(45.0f * M.Pi / 180.0f, _aspectRatio, ZNear, ZFar); + RC.Viewport(0, 0, _texRes, _texRes, false); + _sceneRenderer1.Render(RC, _renderTex1); //Pass 1: render the first model to "_renderTex1", using the standard material. + + RC.Viewport(0, 0, _texRes, _texRes, false); + _sceneRenderer2.Render(RC, _renderTex2); //Pass 2: render the second model to "_renderTex2", using the standard material. + + RC.Viewport(0, 0, Width, Height); + _sceneRendererBlur.Render(RC); //Pass 3: render a screen filled quad, using the "_blurPassEffect" material we defined above. + + _sih.View = RC.View; + + _guiRenderer.Render(RC); + } + //==> Rendervorgang für mehrere Viewports + else if (_viewports) + { + + + bool nearclip = false; + + RC.Projection = CreatePerspectiveFieldOfViewOwn(45.0f * M.Pi / 180.0f, _aspectRatio, ZNear, ZFar, nearclip);//=> Erstellen des Sichtfeldes + RC.Viewport(0, 0, Width / 2, Height); //=>definieren des Viewport für die erste Szene + _sceneRenderer1.Render(RC); + nearclip = true; + RC.Projection = CreatePerspectiveFieldOfViewOwn(45.0f * M.Pi / 180.0f, _aspectRatio, ZNear, ZFar, nearclip); + RC.Viewport(Width / 2, 0, Width / 2, Height);//=>definieren des Viewport für die zweite Szene + _sceneRenderer2.Render(RC); + + } + else + { + //=> Standard Rendervorgang + + RC.Projection = float4x4.CreatePerspectiveFieldOfView(45.0f * M.Pi / 180.0f, _aspectRatio, ZNear, ZFar); + RC.Viewport(0, 0, Width, Height); + _sceneRenderer1.Render(RC); + } + + RC.Viewport(0, 0, Width, Height); + + _sih.View = RC.View; + + _guiRenderer.Render(RC); + + // Swap buffers: Show the contents of the backbuffer (containing the currently rendered frame) on the front buffer. + Present(); + } + + + // Field of View Methode für Viewport-Ansatz + + public static float4x4 CreatePerspectiveFieldOfViewOwn(float fovy, float aspect, float zNear, float zFar, bool nearclip) + { + float4x4 result; + + if (fovy <= 0 || fovy > System.Math.PI) + throw new ArgumentOutOfRangeException("fovy"); + if (aspect <= 0) + throw new ArgumentOutOfRangeException("aspect"); + if (zNear <= 0) + throw new ArgumentOutOfRangeException("zNear"); + if (zFar <= 0) + throw new ArgumentOutOfRangeException("zFar"); + if (zNear >= zFar) + throw new ArgumentOutOfRangeException("zNear"); + + float yMax = zNear * (float)System.Math.Tan(0.5f * fovy); + float yMin = -yMax; + float xMin; + float xMax; + //=> Berechnung des Frustums für die rechte und die linke Seite + if (nearclip) + { + //=> Erstellung rechte Seite. Sichtfeld der Kamera startet im Szenenursprung. + xMin = 0 + (yMin * aspect) * _viewtranslate/2; + xMax = yMax * aspect - (yMax * aspect) * _viewtranslate/2; + } + else + { + //=> Erstellung linke Seite. Sichtfeld der Kamera endet im Szenenursprung. + xMin = yMin * aspect + (yMin * aspect) * _viewtranslate/2; + xMax = 0 - (yMax * aspect) * _viewtranslate/2; + } + result = Math.Core.float4x4.CreatePerspectiveOffCenter(xMin, xMax, yMin, yMax, zNear, zFar); + + return result; + } + + + /////////////////////////////// + private InputDevice Creator(IInputDeviceImp device) + { + throw new NotImplementedException(); + } + + // Is called when the window was resized + public override void Resize(ResizeEventArgs e) + { + + } + + private SceneContainer CreateGui() + { + var vsTex = AssetStorage.Get("texture.vert"); + var psTex = AssetStorage.Get("texture.frag"); + + var btnFuseeLogo = new GUIButton + { + Name = "Canvas_Button" + }; + + btnFuseeLogo.OnMouseEnter += BtnLogoEnter; + btnFuseeLogo.OnMouseExit += BtnLogoExit; + btnFuseeLogo.OnMouseDown += BtnLogoDown; + + + var btnAB1 = new GUIButton + { + Name = "AB_Compare1" + }; + + btnAB1.OnMouseDown += BtnAB1Down; + + var btnAB2 = new GUIButton + { + Name = "AB_Compare2" + }; + + btnAB2.OnMouseDown += BtnAB2Down; + + var btnmultiview = new GUIButton + { + Name = "Multiple Viewports" + }; + + btnmultiview.OnMouseDown += BtnMultiviewDown; + + var btnmultipass = new GUIButton + { + Name = "Multipass" + }; + + btnmultipass.OnMouseDown += BtnMultipassDown; + + var btnstandard = new GUIButton + { + Name = "Standard" + }; + + btnstandard.OnMouseDown += BtnStandardDown; + + var guiFuseeLogo = new Texture(AssetStorage.Get("FuseeText.png")); + var fuseeLogo = new TextureNodeContainer( + "fuseeLogo", + vsTex, + psTex, + //Set the diffuse 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. + UIElementPosition.GetAnchors(AnchorPos.TOP_TOP_LEFT), + //Define Offset and therefor the size of the element. + UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_LEFT, new float2(0, _initCanvasHeight - 0.5f), _initCanvasHeight, _initCanvasWidth, new float2(1.75f, 0.5f)) + ); + fuseeLogo.AddComponent(btnFuseeLogo); + + + btnscale = new float2(0.3f, 0.3f); + + var guiButtonPoint = new Texture(AssetStorage.Get("buttonpoint.png")); + + ab1 = new TextureNodeContainer( + "ab1", + vsTex, + psTex, + //Set the diffuse texture you want to use. + guiButtonPoint, + //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent. + UIElementPosition.GetAnchors(AnchorPos.MIDDLE), + //Define Offset and therefor the size of the element. + UIElementPosition.CalcOffsets(AnchorPos.MIDDLE, new float2(_initCanvasWidth * _point1.x - (btnscale.x/2), _initCanvasHeight * _point1.y - (btnscale.y/2)), _initCanvasHeight, _initCanvasWidth, btnscale) + ); + ab1.AddComponent(btnAB1); + ab1.GetComponent().Active = _multipass; //=>Mesh aktiv oder inaktiv setzen + + ab2 = new TextureNodeContainer( + "ab2", + vsTex, + psTex, + //Set the diffuse texture you want to use. + guiButtonPoint, + //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent. + UIElementPosition.GetAnchors(AnchorPos.MIDDLE), + //Define Offset and therefor the size of the element. + UIElementPosition.CalcOffsets(AnchorPos.MIDDLE, new float2(_initCanvasWidth * _point2.x - (btnscale.x / 2), _initCanvasHeight * _point2.y - (btnscale.y / 2)), _initCanvasHeight, _initCanvasWidth, btnscale) + ); + ab2.AddComponent(btnAB2); + ab2.GetComponent().Active = _multipass; //=>Mesh aktiv oder inaktiv setzen + + // Initialize the information text line. + var textToDisplay = "FUSEE 3D Scene"; + if (_scene1.Header.CreatedBy != null || _scene1.Header.CreationDate != null) + { + textToDisplay += " created"; + if (_scene1.Header.CreatedBy != null) + textToDisplay += " by " + _scene1.Header.CreatedBy; + + if (_scene1.Header.CreationDate != null) + textToDisplay += " on " + _scene1.Header.CreationDate; + } + + var fontLato = AssetStorage.Get("Lato-Black.ttf"); + var guiLatoBlack = new FontMap(fontLato, 18); + + var text = new TextNodeContainer( + textToDisplay, + "SceneDescriptionText", + vsTex, + psTex, + UIElementPosition.GetAnchors(AnchorPos.STRETCH_HORIZONTAL), + UIElementPosition.CalcOffsets(AnchorPos.STRETCH_HORIZONTAL, new float2(_initCanvasWidth / 2 - 4, 0), _initCanvasHeight, _initCanvasWidth, new float2(8, 1)), + guiLatoBlack, + ColorUint.Tofloat4(ColorUint.Greenery), 200f); + + //==> TextNodeContainer für die GUI Übersicht + var textmultipass = new TextNodeContainer( + "Multipass Example", + "MultipassExample", + vsTex, + psTex, + UIElementPosition.GetAnchors(AnchorPos.TOP_TOP_LEFT), + UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_LEFT, new float2(_initCanvasWidth * 0.01f, _initCanvasHeight * 0.7f), _initCanvasHeight, _initCanvasWidth, new float2(2, 1)), + guiLatoBlack, + ColorUint.Tofloat4(ColorUint.Greenery), 200f); + + textmultipass.Children[0].AddComponent(btnmultipass); + + + + var textmultiview = new TextNodeContainer( + "Viewport Example", + "ViewportExample", + vsTex, + psTex, + UIElementPosition.GetAnchors(AnchorPos.TOP_TOP_LEFT), + UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_LEFT, new float2(_initCanvasWidth * 0.01f, _initCanvasHeight * 0.5f), _initCanvasHeight, _initCanvasWidth, new float2(2, 1)), + guiLatoBlack, + ColorUint.Tofloat4(ColorUint.Greenery), 200f); + + textmultiview.Children[0].AddComponent(btnmultiview); + + + var textstandard = new TextNodeContainer( + "Standard Example", + "StandardExample", + vsTex, + psTex, + UIElementPosition.GetAnchors(AnchorPos.TOP_TOP_LEFT), + UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_LEFT, new float2(_initCanvasWidth * 0.01f, _initCanvasHeight * 0.3f), _initCanvasHeight, _initCanvasWidth, new float2(2, 1)), + guiLatoBlack, + ColorUint.Tofloat4(ColorUint.Greenery), 200f); + + textstandard.Children[0].AddComponent(btnstandard); + + textviewportlegacy = new TextNodeContainer( + "Press A or D for Interaction", + "ViewportText", + vsTex, + psTex, + UIElementPosition.GetAnchors(AnchorPos.STRETCH_HORIZONTAL), + UIElementPosition.CalcOffsets(AnchorPos.STRETCH_HORIZONTAL, new float2(_initCanvasWidth / 2 - 4, _initCanvasHeight* 0.05f), _initCanvasHeight, _initCanvasWidth, new float2(8, 1)), + guiLatoBlack, + ColorUint.Tofloat4(ColorUint.Greenery), 200f); + + //=> Problem bei Zugriff über GetComponentsInChildren + textviewportlegacy.Children[0].GetComponent().Active = _viewports; //=> Mesh aktiv oder inaktiv setzen + + + var canvas = new CanvasNodeContainer( + "Canvas", + _canvasRenderMode, + new MinMaxRect + { + Min = new float2(-_canvasWidth / 2, -_canvasHeight / 2f), + Max = new float2(_canvasWidth / 2, _canvasHeight / 2f) + }); + canvas.Children.Add(fuseeLogo); + canvas.Children.Add(text); + canvas.Children.Add(textmultipass); + canvas.Children.Add(textmultiview); + canvas.Children.Add(textstandard); + canvas.Children.Add(textviewportlegacy); + + canvas.Children.Add(ab1); + canvas.Children.Add(ab2); + + //Create canvas projection component and add resize delegate + var canvasProjComp = new ProjectionComponent(ProjectionMethod.ORTHOGRAPHIC, ZNear, ZFar, _fovy); + canvas.Components.Insert(0, canvasProjComp); + // AddResizeDelegate(delegate { canvasProjComp.Resize(Width, Height); }); + + return new SceneContainer + { + Children = new List + { + //Add canvas. + canvas + } + }; + } + + public void BtnLogoEnter(CodeComponent sender) + { + _gui.Children.FindNodes(node => node.Name == "fuseeLogo").First().GetComponent().Effect.SetEffectParam("DiffuseColor", new float4(0.8f, 0.8f, 0.8f, 1f)); + + } + + public void BtnLogoExit(CodeComponent sender) + { + _gui.Children.FindNodes(node => node.Name == "fuseeLogo").First().GetComponent().Effect.SetEffectParam("DiffuseColor", float4.One); + } + + public void BtnLogoDown(CodeComponent sender) + { + OpenLink("http://fusee3d.org"); + + } + + //=> Aktivierung zum Rendern des Viewport-Ansatzes + public void BtnMultiviewDown(CodeComponent sender) + { + _viewports = !_viewports; // toggeln des Buttons + _multipass = false; + ab1.GetComponent().Active = _multipass; + ab2.GetComponent().Active = _multipass; + textviewportlegacy.Children[0].GetComponent().Active = _viewports; + } + + //=> Aktivierung zum Rendern des Shader-Ansatzes + public void BtnMultipassDown(CodeComponent sender) + { + _multipass = !_multipass; + _viewports = false; + + ab1.GetComponent().Active = _multipass; + ab2.GetComponent().Active = _multipass; + textviewportlegacy.Children[0].GetComponent().Active = _viewports; + } + + //=> Aktivierung zum Rendern der Standard Szene + public void BtnStandardDown(CodeComponent sender) + { + _multipass = false; + _viewports = false; + + ab1.GetComponent().Active = _multipass; + ab2.GetComponent().Active = _multipass; + textviewportlegacy.Children[0].GetComponent().Active = _viewports; + } + + //=> Aktivierung der Buttons zur Verschiebung der Trennlinie + public void BtnAB1Down(CodeComponent sender) + { + _abbtn1 = true; + + } + + public void BtnAB2Down(CodeComponent sender) + { + + _abbtn2 = true; + } + + } +} \ No newline at end of file diff --git a/Examples/Complete/ABCompare/Core/Assets/FUSEERocket.fus b/Examples/Complete/ABCompare/Core/Assets/FUSEERocket.fus new file mode 100644 index 000000000..5a278d8ac Binary files /dev/null and b/Examples/Complete/ABCompare/Core/Assets/FUSEERocket.fus differ diff --git a/Examples/Complete/ABCompare/Core/Assets/FuseeText.png b/Examples/Complete/ABCompare/Core/Assets/FuseeText.png new file mode 100644 index 000000000..af5ffb051 Binary files /dev/null and b/Examples/Complete/ABCompare/Core/Assets/FuseeText.png differ diff --git a/Examples/Complete/ABCompare/Core/Assets/Lato-Black.ttf b/Examples/Complete/ABCompare/Core/Assets/Lato-Black.ttf new file mode 100644 index 000000000..6848db0d1 Binary files /dev/null and b/Examples/Complete/ABCompare/Core/Assets/Lato-Black.ttf differ diff --git a/Examples/Complete/ABCompare/Core/Assets/RocketFus.blend b/Examples/Complete/ABCompare/Core/Assets/RocketFus.blend new file mode 100644 index 000000000..9e7e3daea Binary files /dev/null and b/Examples/Complete/ABCompare/Core/Assets/RocketFus.blend differ diff --git a/Examples/Complete/ABCompare/Core/Assets/RocketFus.blend1 b/Examples/Complete/ABCompare/Core/Assets/RocketFus.blend1 new file mode 100644 index 000000000..061dd6379 Binary files /dev/null and b/Examples/Complete/ABCompare/Core/Assets/RocketFus.blend1 differ diff --git a/Examples/Complete/ABCompare/Core/Assets/RocketFus.fus b/Examples/Complete/ABCompare/Core/Assets/RocketFus.fus new file mode 100644 index 000000000..f65f996a7 Binary files /dev/null and b/Examples/Complete/ABCompare/Core/Assets/RocketFus.fus differ diff --git a/Examples/Complete/ABCompare/Core/Assets/buttonpoint.png b/Examples/Complete/ABCompare/Core/Assets/buttonpoint.png new file mode 100644 index 000000000..2f48df4d2 Binary files /dev/null and b/Examples/Complete/ABCompare/Core/Assets/buttonpoint.png differ diff --git a/Examples/Complete/ABCompare/Core/Assets/multitex.frag b/Examples/Complete/ABCompare/Core/Assets/multitex.frag new file mode 100644 index 000000000..dd732bd19 --- /dev/null +++ b/Examples/Complete/ABCompare/Core/Assets/multitex.frag @@ -0,0 +1,132 @@ +#version 300 es +precision highp float; + +in vec2 vUV; + +uniform sampler2D InputTex1; +uniform sampler2D InputTex2; + + +uniform vec2 Point1; +uniform vec2 Point2; + +uniform vec2 Middlepoint; +uniform float Radius; + + +layout (location = 0) out vec4 oBlurred; + +vec3 result; +vec3 tex1; +vec3 tex2; + + +void linearEquation() +{ + + //=>Berechnung der Trennlinie + + float Se = (vUV.y - Point1.y)*(Point2.x - Point1.x) - (Point2.y - Point1.y)*(vUV.x - Point1.x); + + //=> Werte auf 0 oder 1 setzen + + Se = step(0.0,Se); + + //=> für eine Interpolation zwischen den Texturen + + //Se = smoothstep(-0.01,0.01,Se); + + result = mix(tex2, tex1, Se); + +} + +void circle() +{ + //=> Berechnung ob Wert innerhalb oder außerhalb des Kreises ist + + float difference = distance(Middlepoint, vUV) - Radius; + + difference = step(0.0,difference); + + result = mix(tex2,tex1,difference); + + +} + + + +//=> Versuche und Fehlschläge! + +void inother() +{ + //=> rendert die eine in die andere Textur! + + //result = texture(InputTex2, vUV).rgb + texture(InputTex1, vUV).rgb; +} + +void overlapping() +{ + //=> rendert beide Texturen über einander! + + //result = texture(InputTex2, vUV).rgb * texture(InputTex1, vUV).rgb; +} + +void onecolorpoint() +{ + //=>Farbwert einzelner Punkt in Textur + + //vec2 texcoord = vec2(0.5, 0.5); // get a value from the middle of the texture + //result = texture(InputTex2, texcoord).rgb * texture(InputTex1, texcoord).rgb; +} + +void simple() +{ + //=> eine Textur wird gerendert! + + //result = texture(InputTex2, vUV).rgb; + +} + +void simplecomparex() +{ + //=> ab Hälfte der X-Achse wird andere Textur gerendert! + + //result = texture(InputTex2,vUV).rgb; + //if(vUV.x >0.5){ + + //result = texture(InputTex1, vUV).rgb; + + //} + +} + + +void simplecomparey() +{ + //=> ab Hälfte der Y-Achse wird andere Textur gerendert! + + //if(vUV.y< 0.5){ + + //result = texture(InputTex2, vUV ).rgb; + + //} + +} + + +void main() +{ + result = vec3(0.0, 0.0, 0.0); + + tex1 = texture(InputTex1, vUV).rgb; + tex2 = texture(InputTex2, vUV).rgb; + + linearEquation(); + //circle(); + oBlurred = vec4(result, 1.0); +} + + + + + diff --git a/Examples/Complete/ABCompare/Core/Assets/screenFilledQuad.vert b/Examples/Complete/ABCompare/Core/Assets/screenFilledQuad.vert new file mode 100644 index 000000000..a4213e1b5 --- /dev/null +++ b/Examples/Complete/ABCompare/Core/Assets/screenFilledQuad.vert @@ -0,0 +1,20 @@ +#version 300 es + +in vec2 fuUV; +in vec3 fuVertex; +out vec2 vUV; + + + +//Failures! +//vUV = fuVertex.xy + 0.5; +//vUV = vec2(fuVertex.x + fuVertex.y + 0.5, fuVertex.y + 0.4 ); +//vUV = vec2(fuVertex.x , fuVertex.y+ 0.5); + +void main() +{ + + vUV = fuUV; + + gl_Position = vec4(fuVertex * 2.0,1.0); //=> Vertex Position in clip space +} \ No newline at end of file diff --git a/Examples/Complete/ABCompare/Core/Assets/simpleBlur.frag b/Examples/Complete/ABCompare/Core/Assets/simpleBlur.frag new file mode 100644 index 000000000..fe64d2c68 --- /dev/null +++ b/Examples/Complete/ABCompare/Core/Assets/simpleBlur.frag @@ -0,0 +1,30 @@ +#version 300 es +precision highp float; +#define KERNEL_SIZE_HALF 8 + +in vec2 vUV; +uniform sampler2D InputTex1; + +layout (location = 0) out vec4 oBlurred; + +void main() +{ + vec2 texelSize = 1.0 / vec2(textureSize(InputTex, 0)); + vec3 result = vec3(0.0, 0.0, 0.0); + + for (int x = -KERNEL_SIZE_HALF; x < KERNEL_SIZE_HALF; ++x) + { + for (int y = -KERNEL_SIZE_HALF; y < KERNEL_SIZE_HALF; ++y) + { + vec2 offset = vec2(float(x), float(y)) * texelSize; + result += texture(InputTex1, vUV + offset).rgb; + + } + } + + float kernelSize = float(KERNEL_SIZE_HALF) * 4.0; + result = result / (kernelSize * kernelSize); + + + oBlurred = vec4(result, 1.0); +} \ No newline at end of file diff --git a/Examples/Complete/ABCompare/Core/Assets/simpleDis.frag b/Examples/Complete/ABCompare/Core/Assets/simpleDis.frag new file mode 100644 index 000000000..be8a2ca95 --- /dev/null +++ b/Examples/Complete/ABCompare/Core/Assets/simpleDis.frag @@ -0,0 +1,18 @@ +#version 300 es +precision highp float; + +in vec2 vUV; +uniform sampler2D InputTex1; + +layout (location = 0) out vec4 oBlurred; + +void main() +{ + vec3 result = vec3(0.0, 0.0, 0.0); + + //=> Erstellung einer simplen Verzerrung + + result = texture(InputTex1, vUV + 0.005*vec2( sin(1024.0*vUV.r),cos(768.0*vUV.g))).rgb; + + oBlurred = vec4(result, 1.0); +} \ No newline at end of file diff --git a/Examples/Complete/ABCompare/Core/Assets/test.fus b/Examples/Complete/ABCompare/Core/Assets/test.fus new file mode 100644 index 000000000..1f7586a0f Binary files /dev/null and b/Examples/Complete/ABCompare/Core/Assets/test.fus differ diff --git a/Examples/Complete/ABCompare/Core/Fusee.Examples.ABCompare.Core.csproj b/Examples/Complete/ABCompare/Core/Fusee.Examples.ABCompare.Core.csproj new file mode 100644 index 000000000..c0ac97633 --- /dev/null +++ b/Examples/Complete/ABCompare/Core/Fusee.Examples.ABCompare.Core.csproj @@ -0,0 +1,28 @@ + + + Fusee.Examples.ABCompare.Core + Fusee.Examples.ABCompare.Core + netstandard2.0 + + + + $(BaseOutputPath)\Examples\ABCompare\Core\ + + + + + + + + + + + + + + + + + + + diff --git a/Examples/Complete/ABCompare/Desktop/Fusee.Examples.ABCompare.Desktop.csproj b/Examples/Complete/ABCompare/Desktop/Fusee.Examples.ABCompare.Desktop.csproj new file mode 100644 index 000000000..11bbc453e --- /dev/null +++ b/Examples/Complete/ABCompare/Desktop/Fusee.Examples.ABCompare.Desktop.csproj @@ -0,0 +1,21 @@ + + + Fusee.Examples.ABCompare.Desktop + Fusee.Examples.ABCompare.Desktop + netcoreapp3.0 + Exe + PLATFORM_DESKTOP + FuseeLogo.ico + + + + $(BaseOutputPath)\Examples\ABCompare\Desktop\ + Fusee.Examples.ABCompare.Desktop.ABCompare + + + + + + + + \ No newline at end of file diff --git a/Examples/Complete/ABCompare/Desktop/FuseeLogo.ico b/Examples/Complete/ABCompare/Desktop/FuseeLogo.ico new file mode 100644 index 000000000..dbdc5bc33 Binary files /dev/null and b/Examples/Complete/ABCompare/Desktop/FuseeLogo.ico differ diff --git a/Examples/Complete/ABCompare/Desktop/Main.cs b/Examples/Complete/ABCompare/Desktop/Main.cs new file mode 100644 index 000000000..dfd2ef970 --- /dev/null +++ b/Examples/Complete/ABCompare/Desktop/Main.cs @@ -0,0 +1,69 @@ +using System.IO; +using System.Runtime.InteropServices; +using Fusee.Base.Common; +using Fusee.Base.Core; +using Fusee.Base.Imp.Desktop; +using Fusee.Engine.Core; +using Fusee.Serialization; +using FileMode = Fusee.Base.Common.FileMode; +using Path = Fusee.Base.Common.Path; +using System.Reflection; +using System; + +namespace Fusee.Examples.ABCompare.Desktop +{ + public class ABCompare + { + 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 = delegate (string id, object storage) + { + if (!Path.GetExtension(id).ToLower().Contains("ttf")) return null; + return new Font{ _fontImp = new FontImp((Stream)storage) }; + }, + Checker = id => Path.GetExtension(id).ToLower().Contains("ttf") + }); + fap.RegisterTypeHandler( + new AssetHandler + { + ReturnedType = typeof(SceneContainer), + Decoder = delegate (string id, object storage) + { + if (!Path.GetExtension(id).ToLower().Contains("fus")) return null; + return Serializer.DeserializeSceneContainer((Stream)storage); + }, + Checker = id => Path.GetExtension(id).ToLower().Contains("fus") + }); + + AssetStorage.RegisterProvider(fap); + + //==> Only relevant when using RenderDoc! + //Console.ReadKey(); + + var app = new Core.ABCompare(); + + // 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(); + } + } +} diff --git a/Fusee.sln b/Fusee.sln index 1b3b4fa37..153432922 100644 --- a/Fusee.sln +++ b/Fusee.sln @@ -372,6 +372,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fusee.Examples.SimpleDeferr EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fusee.Tools.CmdLine", "src\Tools\fuseeCmdLine\Fusee.Tools.CmdLine.csproj", "{1C5149B2-DC38-49C8-998C-49FC1D9CCCE5}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ABCompare", "ABCompare", "{B963EA33-ADD7-4BCE-8AFD-06A6BAA82BCB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fusee.Examples.ABCompare.Core", "Examples\Complete\ABCompare\Core\Fusee.Examples.ABCompare.Core.csproj", "{A7D7179E-F24C-4A65-B327-BA3324267609}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fusee.Examples.ABCompare.Desktop", "Examples\Complete\ABCompare\Desktop\Fusee.Examples.ABCompare.Desktop.csproj", "{B8A9A3D6-DC58-47C6-9173-EAE64B580012}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FusViewer", "src\Tools\FusViewer\FusViewer.csproj", "{69912481-B885-42EF-9F3A-E1691D2D8FCE}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Render", "Render", "{58433A65-35DC-4C22-A795-2443C72F7428}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fusee.Test.Render.Desktop", "src\Tests\Render\Desktop\Fusee.Test.Render.Desktop.csproj", "{B053ED47-3A82-475D-B75D-336C026F953E}" @@ -3382,6 +3390,157 @@ Global {1C5149B2-DC38-49C8-998C-49FC1D9CCCE5}.Release-WebAsm|x64.Build.0 = Release|Any CPU {1C5149B2-DC38-49C8-998C-49FC1D9CCCE5}.Release-WebAsm|x86.ActiveCfg = Release|Any CPU {1C5149B2-DC38-49C8-998C-49FC1D9CCCE5}.Release-WebAsm|x86.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug|x64.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug|x64.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug|x86.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug|x86.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Android|Any CPU.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Android|Any CPU.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Android|x64.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Android|x64.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Android|x86.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Android|x86.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Desktop|Any CPU.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Desktop|Any CPU.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Desktop|x64.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Desktop|x64.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Desktop|x86.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-Desktop|x86.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-WebAsm|Any CPU.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-WebAsm|Any CPU.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-WebAsm|x64.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-WebAsm|x64.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-WebAsm|x86.ActiveCfg = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Debug-WebAsm|x86.Build.0 = Debug|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release|Any CPU.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release|x64.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release|x64.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release|x86.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release|x86.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Android|Any CPU.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Android|Any CPU.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Android|x64.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Android|x64.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Android|x86.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Android|x86.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Desktop|Any CPU.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Desktop|Any CPU.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Desktop|x64.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Desktop|x64.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Desktop|x86.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-Desktop|x86.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-NuGet|Any CPU.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-NuGet|x64.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-NuGet|x64.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-NuGet|x86.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-NuGet|x86.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-WebAsm|Any CPU.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-WebAsm|Any CPU.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-WebAsm|x64.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-WebAsm|x64.Build.0 = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-WebAsm|x86.ActiveCfg = Release|Any CPU + {A7D7179E-F24C-4A65-B327-BA3324267609}.Release-WebAsm|x86.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug|x64.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug|x64.Build.0 = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug|x86.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug|x86.Build.0 = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-Android|Any CPU.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-Android|x64.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-Android|x64.Build.0 = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-Android|x86.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-Android|x86.Build.0 = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-Desktop|Any CPU.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-Desktop|Any CPU.Build.0 = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-Desktop|x64.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-Desktop|x64.Build.0 = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-Desktop|x86.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-Desktop|x86.Build.0 = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-WebAsm|Any CPU.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-WebAsm|x64.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-WebAsm|x64.Build.0 = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-WebAsm|x86.ActiveCfg = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Debug-WebAsm|x86.Build.0 = Debug|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release|Any CPU.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release|x64.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release|x64.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release|x86.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release|x86.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-Android|Any CPU.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-Android|x64.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-Android|x64.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-Android|x86.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-Android|x86.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-Desktop|Any CPU.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-Desktop|Any CPU.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-Desktop|x64.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-Desktop|x64.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-Desktop|x86.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-Desktop|x86.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-NuGet|Any CPU.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-NuGet|x64.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-NuGet|x64.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-NuGet|x86.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-NuGet|x86.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-WebAsm|Any CPU.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-WebAsm|x64.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-WebAsm|x64.Build.0 = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-WebAsm|x86.ActiveCfg = Release|Any CPU + {B8A9A3D6-DC58-47C6-9173-EAE64B580012}.Release-WebAsm|x86.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug|x64.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug|x64.Build.0 = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug|x86.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug|x86.Build.0 = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-Android|Any CPU.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-Android|x64.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-Android|x64.Build.0 = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-Android|x86.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-Android|x86.Build.0 = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-Desktop|Any CPU.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-Desktop|Any CPU.Build.0 = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-Desktop|x64.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-Desktop|x64.Build.0 = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-Desktop|x86.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-Desktop|x86.Build.0 = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-WebAsm|Any CPU.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-WebAsm|x64.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-WebAsm|x64.Build.0 = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-WebAsm|x86.ActiveCfg = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Debug-WebAsm|x86.Build.0 = Debug|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release|Any CPU.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release|x64.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release|x64.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release|x86.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release|x86.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-Android|Any CPU.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-Android|x64.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-Android|x64.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-Android|x86.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-Android|x86.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-Desktop|Any CPU.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-Desktop|Any CPU.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-Desktop|x64.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-Desktop|x64.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-Desktop|x86.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-Desktop|x86.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-NuGet|Any CPU.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-NuGet|x64.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-NuGet|x64.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-NuGet|x86.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-NuGet|x86.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-WebAsm|Any CPU.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-WebAsm|x64.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-WebAsm|x64.Build.0 = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-WebAsm|x86.ActiveCfg = Release|Any CPU + {69912481-B885-42EF-9F3A-E1691D2D8FCE}.Release-WebAsm|x86.Build.0 = Release|Any CPU {B053ED47-3A82-475D-B75D-336C026F953E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B053ED47-3A82-475D-B75D-336C026F953E}.Debug|Any CPU.Build.0 = Debug|Any CPU {B053ED47-3A82-475D-B75D-336C026F953E}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -3554,6 +3713,10 @@ Global {01898E61-1A52-4CEC-B62D-9C97C0AE67BF} = {024BFD50-DF2A-44DB-B9D6-BCEA67963E75} {C29B4190-69CD-49EE-9884-52C84F0451BA} = {024BFD50-DF2A-44DB-B9D6-BCEA67963E75} {1C5149B2-DC38-49C8-998C-49FC1D9CCCE5} = {0C344D5F-BE70-4828-B95A-1D313B894BC3} + {B963EA33-ADD7-4BCE-8AFD-06A6BAA82BCB} = {E68628DA-312F-4171-A5ED-08072B5CCA3C} + {A7D7179E-F24C-4A65-B327-BA3324267609} = {B963EA33-ADD7-4BCE-8AFD-06A6BAA82BCB} + {B8A9A3D6-DC58-47C6-9173-EAE64B580012} = {B963EA33-ADD7-4BCE-8AFD-06A6BAA82BCB} + {69912481-B885-42EF-9F3A-E1691D2D8FCE} = {0C344D5F-BE70-4828-B95A-1D313B894BC3} {58433A65-35DC-4C22-A795-2443C72F7428} = {E1BC200B-7234-4037-9421-E65FD4D915B0} {B053ED47-3A82-475D-B75D-336C026F953E} = {58433A65-35DC-4C22-A795-2443C72F7428} {4C4A2368-21EE-42EF-A710-95B7EE1D1437} = {0C344D5F-BE70-4828-B95A-1D313B894BC3} diff --git a/src/Engine/Player/Core/Assets/screenFilledQuad_1.vert b/src/Engine/Player/Core/Assets/screenFilledQuad_1.vert new file mode 100644 index 000000000..4fc1d96a5 --- /dev/null +++ b/src/Engine/Player/Core/Assets/screenFilledQuad_1.vert @@ -0,0 +1,10 @@ +#version 300 es + +in vec3 fuVertex; +out vec2 vUV; + +void main() +{ + vUV = fuVertex.xy * 2.0 * 0.5 + 0.5; + gl_Position = vec4(fuVertex.xy * 2.0, 0.0 ,1.0); +} \ No newline at end of file diff --git a/src/Engine/Player/Core/Assets/simpleBlur_1.frag b/src/Engine/Player/Core/Assets/simpleBlur_1.frag new file mode 100644 index 000000000..006fb2ee1 --- /dev/null +++ b/src/Engine/Player/Core/Assets/simpleBlur_1.frag @@ -0,0 +1,31 @@ +#version 300 es +precision highp float; +#define KERNEL_SIZE_HALF 8 + +in vec2 vUV; +uniform sampler2D InputTex; + + + +layout (location = 0) out vec4 oBlurred; + +void main() +{ + vec2 texelSize = 1.0 / vec2(textureSize(InputTex, 0)); + vec3 result = vec3(0.0, 0.0, 0.0); + + for (int x = -KERNEL_SIZE_HALF; x < KERNEL_SIZE_HALF; ++x) + { + for (int y = -KERNEL_SIZE_HALF; y < KERNEL_SIZE_HALF; ++y) + { + vec2 offset = vec2(float(x), float(y)) * texelSize; + result += texture(InputTex, vUV + offset).rgb; + } + } + + float kernelSize = float(KERNEL_SIZE_HALF) * 2.0; + result = result / (kernelSize * kernelSize); + + oBlurred = vec4(result, 1.0); + //oBlurred = vec4(texture( InputTex, vUV + 0.005*vec2( sin(1024.0*vUV.x),cos(768.0*vUV.y)) ).xyz, 1.0); +} \ No newline at end of file diff --git a/src/Engine/Player/Core/Assets/test.fus b/src/Engine/Player/Core/Assets/test.fus new file mode 100644 index 000000000..1f7586a0f Binary files /dev/null and b/src/Engine/Player/Core/Assets/test.fus differ diff --git a/src/Engine/Player/Core/Player.cs b/src/Engine/Player/Core/Player.cs index eae699ccb..d39190988 100644 --- a/src/Engine/Player/Core/Player.cs +++ b/src/Engine/Player/Core/Player.cs @@ -38,15 +38,12 @@ public class Player : RenderCanvas private const float ZNear = 1f; private const float ZFar = 3000; - private float _aspectRatio; private float _fovy = M.PiOver4; private SceneRendererForward _guiRenderer; private SceneContainer _gui; private SceneInteractionHandler _sih; private readonly CanvasRenderMode _canvasRenderMode = CanvasRenderMode.SCREEN; - private float _initWindowWidth; - private float _initWindowHeight; private float _initCanvasWidth; private float _initCanvasHeight; private float _canvasWidth = 16; @@ -59,16 +56,11 @@ public class Player : RenderCanvas // Init is called on startup. public override async Task Init() { - _initWindowWidth = Width; - _initWindowHeight = Height; - _initCanvasWidth = Width / 100f; _initCanvasHeight = Height / 100f; _canvasHeight = _initCanvasHeight; - _canvasWidth = _initCanvasWidth; - - _aspectRatio = Width / (float)Height; + _canvasWidth = _initCanvasWidth; // Initial "Zoom" value (it's rather the distance in view direction, not the camera's focal distance/opening angle) _zoom = 400; @@ -136,6 +128,7 @@ public override void RenderAFrame() // Clear the backbuffer RC.Clear(ClearFlags.Color | ClearFlags.Depth); + RC.Viewport(0, 0, Width, Height); // Mouse and keyboard movement if (Keyboard.LeftRightAxis != 0 || Keyboard.UpDownAxis != 0) @@ -219,24 +212,30 @@ public override void RenderAFrame() // Create the camera matrix and set it as the current View transformation var mtxRot = /*float4x4.CreateRotationZ(_angleRoll) **/ float4x4.CreateRotationX(_angleVert) * float4x4.CreateRotationY(_angleHorz); - var mtxCam = float4x4.LookAt(0, 20, -_zoom, 0, 0, 0, 0, 1, 0); - RC.View = mtxCam * mtxRot * _sceneScale * _sceneCenter; - var mtxOffset = float4x4.CreateTranslation(2f * _offset.x / Width, -2f * _offset.y / Height, 0); - RC.Projection *= mtxOffset; + var mtxCam = float4x4.LookAt(0, 20, -_zoom, 0, 0, 0, 0, 1, 0); + var mtxOffset = float4x4.CreateTranslation(2f * _offset.x / Width, -2f * _offset.y / Height, 0); + + var view = mtxCam * mtxRot * _sceneScale * _sceneCenter; ; + var perspective = float4x4.CreatePerspectiveFieldOfView(_fovy, (float)Width / Height, ZNear, ZFar) * mtxOffset; + var orthographic = float4x4.CreateOrthographic(Width, Height, ZNear, ZFar); + RC.View = view; + RC.Projection = orthographic; // Constantly check for interactive objects. - _sih.CheckForInteractiveObjects(Input.Mouse.Position, Width, Height); + _sih.CheckForInteractiveObjects(RC, Mouse.Position, Width, Height); if (Touch.GetTouchActive(TouchPoints.Touchpoint_0) && !Touch.TwoPoint) { - _sih.CheckForInteractiveObjects(Touch.GetPosition(TouchPoints.Touchpoint_0), Width, Height); + _sih.CheckForInteractiveObjects(RC, Touch.GetPosition(TouchPoints.Touchpoint_0), Width, Height); } // Tick any animations and Render the scene loaded in Init() + RC.View = view; + RC.Projection = perspective; _sceneRenderer.Animate(); - _sceneRenderer.Render(RC); - - _sih.View = RC.View; + _sceneRenderer.Render(RC); + RC.View = view; + RC.Projection = orthographic; _guiRenderer.Render(RC); // Swap buffers: Show the contents of the backbuffer (containing the currently rendered frame) on the front buffer. @@ -317,11 +316,7 @@ private async Task CreateGui() Max = new float2(_canvasWidth / 2, _canvasHeight / 2f) }); canvas.Children.Add(fuseeLogo); - canvas.Children.Add(text); - - //Create canvas projection component and add resize delegate - var canvasProjComp = new ProjectionComponent(ProjectionMethod.ORTHOGRAPHIC, ZNear, ZFar, _fovy); - canvas.Components.Insert(0, canvasProjComp); + canvas.Children.Add(text); return new SceneContainer { diff --git a/src/Tools/BlenderScripts/addons/io_export_fus.zip b/src/Tools/BlenderScripts/addons/io_export_fus.zip new file mode 100644 index 000000000..7df1f1ac4 Binary files /dev/null and b/src/Tools/BlenderScripts/addons/io_export_fus.zip differ