26 Sep 2021
General: + Added Summaries Renderer ------- SM.Base: + SM.Base.Controls.Mouse now has a feature to disable tracking. + Replaced Bloom Effect with the similar system how blender use it. + You can now disable ANY post processing effects. + Interpolation for CVectors. + MathUtils + RenderPipelines now have a central list for post processing effects. ~ Log-System is now ignored if a debugger is attached. ~ Post Processing Shader does now send the texel size as the "renderedTextureTexelSize"-uniform. ~ Improved Text Rendering SM.OGL: + ColorAttachments now contain a reference to the framebuffer its connected. + ColorAttachments can now have a own size. + Framebuffer.Append(string key, Vector2 size, int pos) +Framebuffers now have a method to completely reset itself. + Framebuffers now have a Blit-method called "CopyTo". ~ Framebuffer.GetCurrentlyActive() will now return an actual SM.OGL.Framebuffer-object. ~ Renderbuffers now are a class and contain the ID by itself. ~ Renamed Uniform-function to its class-name: f.E. SetBool, SetFloat instead of SetUniform1 Optionals: Controls: + Framecache for the GameController.GetState()
This commit is contained in:
parent
dffa581596
commit
9b52d401e7
61 changed files with 1529 additions and 818 deletions
|
|
@ -9,7 +9,7 @@
|
|||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SM.Intergrations</RootNamespace>
|
||||
<AssemblyName>SM.Intergrations</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
|
|
|
|||
|
|
@ -23,30 +23,30 @@ namespace SM.Intergrations.ShaderTool
|
|||
|
||||
STPCompositeNode composeNode = drawNode.OGLEffect;
|
||||
|
||||
ShaderFileFiles.Vertex = new[] { new ShaderFile(composeNode.Vertex.ShaderCode) };
|
||||
ShaderFileFiles.Fragment = new [] {new ShaderFile(composeNode.Fragment.ShaderCode)};
|
||||
ShaderFiles.Vertex = new[] { new ShaderFile(composeNode.Vertex.ShaderCode) };
|
||||
ShaderFiles.Fragment = new [] {new ShaderFile(composeNode.Fragment.ShaderCode)};
|
||||
if (composeNode.Geometry != null)
|
||||
ShaderFileFiles.Geometry = new[] {new ShaderFile(composeNode.Geometry.ShaderCode)};
|
||||
ShaderFiles.Geometry = new[] {new ShaderFile(composeNode.Geometry.ShaderCode)};
|
||||
|
||||
foreach (KeyValuePair<string, STPVariable> pair in drawNode.Variables)
|
||||
{
|
||||
switch (pair.Value.Type)
|
||||
{
|
||||
case STPBasisType.Bool:
|
||||
_uniforms += context => Uniforms[pair.Key].SetUniform1(context.Material.ShaderArguments.Get(pair.Key, false));
|
||||
_uniforms += context => Uniforms[pair.Key].SetBool(context.Material.ShaderArguments.Get(pair.Key, false));
|
||||
break;
|
||||
case STPBasisType.Float:
|
||||
_uniforms += context => Uniforms[pair.Key].SetUniform1(context.Material.ShaderArguments.Get(pair.Key, 0.0f));
|
||||
_uniforms += context => Uniforms[pair.Key].SetFloat(context.Material.ShaderArguments.Get(pair.Key, 0.0f));
|
||||
break;
|
||||
case STPBasisType.Vector2:
|
||||
_uniforms += context => Uniforms[pair.Key].SetUniform2(context.Material.ShaderArguments.Get(pair.Key, Vector2.Zero));
|
||||
_uniforms += context => Uniforms[pair.Key].SetVector2(context.Material.ShaderArguments.Get(pair.Key, Vector2.Zero));
|
||||
break;
|
||||
case STPBasisType.Vector3:
|
||||
_uniforms += context => Uniforms[pair.Key].SetUniform3(context.Material.ShaderArguments.Get(pair.Key, Vector3.Zero));
|
||||
_uniforms += context => Uniforms[pair.Key].SetVector3(context.Material.ShaderArguments.Get(pair.Key, Vector3.Zero));
|
||||
break;
|
||||
case STPBasisType.Vector4:
|
||||
_uniforms += context =>
|
||||
Uniforms[pair.Key].SetUniform4(context.Material.ShaderArguments.Get(pair.Key, Vector4.Zero));
|
||||
Uniforms[pair.Key].SetVector4(context.Material.ShaderArguments.Get(pair.Key, Vector4.Zero));
|
||||
break;
|
||||
case STPBasisType.Matrix:
|
||||
_uniforms += context => Uniforms[pair.Key].SetMatrix4(context.Material.ShaderArguments.Get(pair.Key, Matrix4.Identity));
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace SM.Intergrations.ShaderTool
|
|||
}
|
||||
}
|
||||
|
||||
public override void Draw(ColorAttachment source, DrawContext context)
|
||||
protected override void Drawing(ColorAttachment source, DrawContext context)
|
||||
{
|
||||
Arguments["_Scene"] = (TextureBase)source;
|
||||
Arguments["_MVP"] = Mvp;
|
||||
|
|
|
|||
|
|
@ -23,30 +23,30 @@ namespace SM.Intergrations.ShaderTool
|
|||
|
||||
STPCompositeNode composeNode = postProcessNode.OGLEffect;
|
||||
|
||||
ShaderFileFiles.Vertex = new[] { new ShaderFile(composeNode.Vertex.ShaderCode) };
|
||||
ShaderFileFiles.Fragment = new[] { new ShaderFile(composeNode.Fragment.ShaderCode) };
|
||||
ShaderFiles.Vertex = new[] { new ShaderFile(composeNode.Vertex.ShaderCode) };
|
||||
ShaderFiles.Fragment = new[] { new ShaderFile(composeNode.Fragment.ShaderCode) };
|
||||
if (composeNode.Geometry != null)
|
||||
ShaderFileFiles.Geometry = new[] { new ShaderFile(composeNode.Geometry.ShaderCode) };
|
||||
ShaderFiles.Geometry = new[] { new ShaderFile(composeNode.Geometry.ShaderCode) };
|
||||
|
||||
foreach (KeyValuePair<string, STPVariable> pair in postProcessNode.Variables)
|
||||
{
|
||||
switch (pair.Value.Type)
|
||||
{
|
||||
case STPBasisType.Bool:
|
||||
_uniforms += context => Uniforms[pair.Key].SetUniform1(context.Get(pair.Key, false));
|
||||
_uniforms += context => Uniforms[pair.Key].SetBool(context.Get(pair.Key, false));
|
||||
break;
|
||||
case STPBasisType.Float:
|
||||
_uniforms += context => Uniforms[pair.Key].SetUniform1(context.Get(pair.Key, 0.0f));
|
||||
_uniforms += context => Uniforms[pair.Key].SetFloat(context.Get(pair.Key, 0.0f));
|
||||
break;
|
||||
case STPBasisType.Vector2:
|
||||
_uniforms += context => Uniforms[pair.Key].SetUniform2(context.Get(pair.Key, Vector2.Zero));
|
||||
_uniforms += context => Uniforms[pair.Key].SetVector2(context.Get(pair.Key, Vector2.Zero));
|
||||
break;
|
||||
case STPBasisType.Vector3:
|
||||
_uniforms += context => Uniforms[pair.Key].SetUniform3(context.Get(pair.Key, Vector3.Zero));
|
||||
_uniforms += context => Uniforms[pair.Key].SetVector3(context.Get(pair.Key, Vector3.Zero));
|
||||
break;
|
||||
case STPBasisType.Vector4:
|
||||
_uniforms += context =>
|
||||
Uniforms[pair.Key].SetUniform4(context.Get(pair.Key, Vector4.Zero));
|
||||
Uniforms[pair.Key].SetVector4(context.Get(pair.Key, Vector4.Zero));
|
||||
break;
|
||||
case STPBasisType.Matrix:
|
||||
_uniforms += context => Uniforms[pair.Key].SetMatrix4(context.Get(pair.Key, Matrix4.Identity));
|
||||
|
|
|
|||
|
|
@ -1,38 +1,55 @@
|
|||
using SharpDX.XInput;
|
||||
using SM.Base;
|
||||
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
public struct GameController
|
||||
public class GameController
|
||||
{
|
||||
public static float GlobalDeadband = 2500;
|
||||
public static float GlobalDeadband = .1F;
|
||||
|
||||
private Controller _controller;
|
||||
private ulong _lastFrame;
|
||||
|
||||
internal GamepadButtonFlags _lastPressedButtons;
|
||||
|
||||
public float Deadband { get; set; }
|
||||
public bool IsConnected => _controller.IsConnected;
|
||||
|
||||
public UserIndex Index { get; private set; }
|
||||
public GameControllerState LastState { get; private set; }
|
||||
|
||||
public UserIndex Index { get; private set; }
|
||||
|
||||
public GameController(int id) : this((UserIndex)id)
|
||||
{}
|
||||
|
||||
public GameController(UserIndex index = UserIndex.Any)
|
||||
{
|
||||
_lastPressedButtons = GamepadButtonFlags.None;
|
||||
_controller = new Controller(index);
|
||||
Index = index;
|
||||
Deadband = GlobalDeadband;
|
||||
}
|
||||
|
||||
public GameControllerState GetState()
|
||||
public GameControllerState GetState(bool force = false)
|
||||
{
|
||||
if (!IsConnected)
|
||||
if (!force && _lastFrame == SMRenderer.CurrentFrame)
|
||||
{
|
||||
return new GameControllerState(true);
|
||||
return LastState;
|
||||
}
|
||||
|
||||
Gamepad state = _controller.GetState().Gamepad;
|
||||
GameControllerState st = new GameControllerState(true);
|
||||
if (IsConnected)
|
||||
{
|
||||
Gamepad state = _controller.GetState().Gamepad;
|
||||
st = new GameControllerState(state, this);
|
||||
_lastPressedButtons = state.Buttons;
|
||||
}
|
||||
|
||||
return new GameControllerState(state, ref this);
|
||||
LastState = st;
|
||||
|
||||
_lastFrame = SMRenderer.CurrentFrame;
|
||||
|
||||
return st;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,22 +22,11 @@ namespace SM.Utils.Controls
|
|||
DPad = GameControllerStateDPad.Default;
|
||||
Buttons = GameControllerStateButtons.Default;
|
||||
}
|
||||
internal GameControllerState(Gamepad state, ref GameController controller)
|
||||
internal GameControllerState(Gamepad state, GameController controller)
|
||||
{
|
||||
FromConnected = true;
|
||||
|
||||
Thumbs = new GameControllerStateThumbs
|
||||
{
|
||||
Left = new Vector2(
|
||||
Math.Abs((float)state.LeftThumbX) < controller.Deadband ? 0 : (float)state.LeftThumbX / short.MaxValue,
|
||||
Math.Abs((float)state.LeftThumbY) < controller.Deadband ? 0 : (float)state.LeftThumbY / short.MaxValue),
|
||||
Right = new Vector2(
|
||||
Math.Abs((float)state.RightThumbX) < controller.Deadband ? 0 : (float)state.RightThumbX / short.MaxValue,
|
||||
Math.Abs((float)state.RightThumbY) < controller.Deadband ? 0 : (float)state.RightThumbY / short.MaxValue),
|
||||
|
||||
PressedLeft = state.Buttons.HasFlag(GamepadButtonFlags.LeftThumb),
|
||||
PressedRight = state.Buttons.HasFlag(GamepadButtonFlags.RightThumb)
|
||||
};
|
||||
Thumbs = new GameControllerStateThumbs(controller, state);
|
||||
|
||||
Triggers = new GameControllerStateTriggers()
|
||||
{
|
||||
|
|
@ -46,7 +35,7 @@ namespace SM.Utils.Controls
|
|||
};
|
||||
|
||||
DPad = new GameControllerStateDPad(state.Buttons);
|
||||
Buttons = new GameControllerStateButtons(state.Buttons);
|
||||
Buttons = new GameControllerStateButtons(state.Buttons, controller);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
|||
|
|
@ -4,9 +4,14 @@ namespace SM.Utils.Controls
|
|||
{
|
||||
public struct GameControllerStateButtons
|
||||
{
|
||||
public static GameControllerStateButtons Default = new GameControllerStateButtons(GamepadButtonFlags.None);
|
||||
public static GameControllerStateButtons Default = new GameControllerStateButtons()
|
||||
{
|
||||
_buttonFlags = GamepadButtonFlags.None,
|
||||
_lastButtonFlags = GamepadButtonFlags.None
|
||||
};
|
||||
|
||||
private GamepadButtonFlags _buttonFlags;
|
||||
private GamepadButtonFlags _lastButtonFlags;
|
||||
|
||||
public bool X;
|
||||
public bool Y;
|
||||
|
|
@ -22,13 +27,14 @@ namespace SM.Utils.Controls
|
|||
public bool Start;
|
||||
public bool Back;
|
||||
|
||||
public bool this[GamepadButtonFlags flags] => _buttonFlags.HasFlag(flags);
|
||||
public bool this[GamepadButtonFlags flags, bool once = false] => _buttonFlags.HasFlag(flags) && !(once && _lastButtonFlags.HasFlag(flags));
|
||||
|
||||
public bool AnyInteraction { get; }
|
||||
|
||||
internal GameControllerStateButtons(GamepadButtonFlags flags)
|
||||
internal GameControllerStateButtons(GamepadButtonFlags flags, GameController controller)
|
||||
{
|
||||
_buttonFlags = flags;
|
||||
_lastButtonFlags = controller._lastPressedButtons;
|
||||
|
||||
X = flags.HasFlag(GamepadButtonFlags.X);
|
||||
Y = flags.HasFlag(GamepadButtonFlags.Y);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using OpenTK;
|
||||
using System;
|
||||
using OpenTK;
|
||||
using SharpDX.XInput;
|
||||
|
||||
namespace SM.Utils.Controls
|
||||
{
|
||||
|
|
@ -15,6 +17,18 @@ namespace SM.Utils.Controls
|
|||
|
||||
public bool AnyInteraction => Left != Vector2.Zero || Right != Vector2.Zero || PressedLeft || PressedRight;
|
||||
|
||||
public GameControllerStateThumbs(GameController controller, Gamepad state)
|
||||
{
|
||||
Vector2 left = new Vector2(state.LeftThumbX, state.LeftThumbY) / short.MaxValue;
|
||||
Vector2 right = new Vector2(state.RightThumbX, state.RightThumbY) / short.MaxValue;
|
||||
|
||||
Left = new Vector2(Math.Abs(left.X) < controller.Deadband ? 0 : left.X, Math.Abs(left.Y) < controller.Deadband ? 0 : left.Y);
|
||||
Right = new Vector2(Math.Abs(right.X) < controller.Deadband ? 0 : right.X, Math.Abs(right.Y) < controller.Deadband ? 0 : right.Y);
|
||||
|
||||
PressedLeft = state.Buttons.HasFlag(GamepadButtonFlags.LeftThumb);
|
||||
PressedRight = state.Buttons.HasFlag(GamepadButtonFlags.RightThumb);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Left: ({Left.X}; {Left.Y}){(PressedLeft ? " Pressed" : "")}; Right: ({Right.X}; {Right.Y}){(PressedRight ? " Pressed" : "")}";
|
||||
|
|
|
|||
|
|
@ -12,16 +12,25 @@ namespace SM.Utils.Controls
|
|||
public struct GameKeybindActor
|
||||
{
|
||||
private GameKeybindActorType _type;
|
||||
private GameController? _controller;
|
||||
private GameController _controller;
|
||||
|
||||
private GameKeybindHost _keybindHost;
|
||||
|
||||
public GameKeybindActorType Type => _type;
|
||||
public GameController? Controller => _controller;
|
||||
public GameController Controller => _controller;
|
||||
|
||||
public object[] Parameter;
|
||||
|
||||
private GameKeybindActor(GameKeybindActorType type, GameController? controller)
|
||||
private GameKeybindActor(GameKeybindActorType type, GameController controller)
|
||||
{
|
||||
_type = type;
|
||||
_controller = controller;
|
||||
|
||||
_keybindHost = null;
|
||||
|
||||
Parameter = new object[0];
|
||||
}
|
||||
private GameKeybindActor(GameKeybindActorType type, ref GameController controller)
|
||||
{
|
||||
_type = type;
|
||||
_controller = controller;
|
||||
|
|
@ -58,7 +67,7 @@ namespace SM.Utils.Controls
|
|||
|
||||
KeyboardState = Keyboard.GetState(),
|
||||
MouseState = Mouse.GetState(),
|
||||
ControllerState = Controller?.GetState(),
|
||||
ControllerState = Controller?.GetState() ?? new GameControllerState(true),
|
||||
};
|
||||
|
||||
return keybind[Type].Invoke(context);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace SM.Utils.Controls
|
|||
{
|
||||
public KeyboardState KeyboardState;
|
||||
public MouseState MouseState;
|
||||
public GameControllerState? ControllerState;
|
||||
public GameControllerState ControllerState;
|
||||
|
||||
public GameKeybindActor Actor;
|
||||
public GameKeybindHost Host;
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@
|
|||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SM.Utils</RootNamespace>
|
||||
<AssemblyName>SM.Utils</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
@ -61,5 +62,11 @@
|
|||
<None Include="OpenTK.dll.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\renderer\SM.Base\SM.Base.csproj">
|
||||
<Project>{8e733844-4204-43e7-b3dc-3913cddabb0d}</Project>
|
||||
<Name>SM.Base</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue