mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Fixed circle rendering and added 2D circle collider
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
Y = 0,
|
||||
Z = 1,
|
||||
W = 1
|
||||
}
|
||||
},
|
||||
IsCircle = false
|
||||
},
|
||||
TransformComponent = {
|
||||
Position = {
|
||||
@@ -79,7 +80,8 @@
|
||||
Y = 0,
|
||||
Z = 1,
|
||||
W = 1
|
||||
}
|
||||
},
|
||||
IsCircle = false
|
||||
},
|
||||
TransformComponent = {
|
||||
Position = {
|
||||
@@ -160,9 +162,68 @@
|
||||
OrthographicHeight = 10,
|
||||
OrthographicNearPlane = 0,
|
||||
OrthographicFarPlane = 10,
|
||||
AspectRatio = 2.864979,
|
||||
AspectRatio = 2.01173,
|
||||
FixedAspectRatio = false
|
||||
}
|
||||
},
|
||||
{
|
||||
Id = 15710354273720487680,
|
||||
NameComponent = {
|
||||
Name = "Circle"
|
||||
},
|
||||
SpriterRendererComponent = {
|
||||
Color = {
|
||||
R = 1,
|
||||
G = 0,
|
||||
B = 0,
|
||||
A = 1
|
||||
},
|
||||
UvTransform = {
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Z = 1,
|
||||
W = 1
|
||||
},
|
||||
IsCircle = true
|
||||
},
|
||||
TransformComponent = {
|
||||
Position = {
|
||||
X = -0.121203,
|
||||
Y = 0.66016,
|
||||
Z = 0
|
||||
},
|
||||
Rotation = {
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Z = 0,
|
||||
W = 1
|
||||
},
|
||||
Scale = {
|
||||
X = 1,
|
||||
Y = 1,
|
||||
Z = 1
|
||||
},
|
||||
EditorEulerRotation = {
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Z = 0
|
||||
}
|
||||
},
|
||||
Rigidbody2D = {
|
||||
BodyType = .Dynamic,
|
||||
FixedRotation = false
|
||||
},
|
||||
CircleCollider2D = {
|
||||
Offset = {
|
||||
X = 0,
|
||||
Y = 0
|
||||
},
|
||||
Radius = 0.5,
|
||||
Density = 1,
|
||||
Friction = 0.5,
|
||||
Restitution = 0,
|
||||
RestitutionThreshold = 0.5
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
#define EDITOR
|
||||
|
||||
Texture2D Texture : register(t0);
|
||||
SamplerState Sampler : register(s0);
|
||||
|
||||
@@ -14,6 +16,9 @@ struct VS_Input
|
||||
float4 Color : COLOR;
|
||||
float4 UVTransform : TEXCOORD1;
|
||||
float InnerRadius : TEXCOORD2;
|
||||
#ifdef EDITOR
|
||||
uint EntityId : ENTITYID;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct PS_Input
|
||||
@@ -22,6 +27,9 @@ struct PS_Input
|
||||
float2 RawPos : TEXCOORD0;
|
||||
float2 Texcoord : TEXCOORD1;
|
||||
float4 Color : COLOR;
|
||||
#ifdef EDITOR
|
||||
nointerpolation uint EntityId : ENTITYID;
|
||||
#endif
|
||||
float InnerRadius : TEXCOORD2;
|
||||
};
|
||||
|
||||
@@ -35,11 +43,25 @@ PS_Input VS(VS_Input input)
|
||||
output.Color = input.Color;
|
||||
output.InnerRadius = input.InnerRadius;
|
||||
|
||||
#ifdef EDITOR
|
||||
output.EntityId = input.EntityId;
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 PS(PS_Input input) : SV_Target0
|
||||
struct PS_Output
|
||||
{
|
||||
float4 Color : SV_Target0;
|
||||
#ifdef EDITOR
|
||||
uint EntityId : SV_TARGET1;
|
||||
#endif
|
||||
};
|
||||
|
||||
PS_Output PS(PS_Input input)
|
||||
{
|
||||
PS_Output output;
|
||||
|
||||
float2 uv = input.RawPos * 2;
|
||||
|
||||
float distance = 1.0f - length(uv);
|
||||
@@ -53,10 +75,14 @@ float4 PS(PS_Input input) : SV_Target0
|
||||
// Discard invisible pixels
|
||||
clip(amount - 0.5f);
|
||||
|
||||
float4 color = Texture.Sample(Sampler, input.Texcoord) * input.Color;
|
||||
color.a *= amount;
|
||||
output.Color = Texture.Sample(Sampler, input.Texcoord) * input.Color;
|
||||
output.Color.a *= amount;
|
||||
|
||||
return color;
|
||||
#ifdef EDITOR
|
||||
output.EntityId = input.EntityId;
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#pragma Effect[VS=VS; PS=PS]
|
||||
Reference in New Issue
Block a user