mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
ground work before gui
This commit is contained in:
parent
27eb3a567c
commit
29a9bd7917
8 changed files with 724 additions and 601 deletions
|
|
@ -156,10 +156,10 @@ singleton ShaderData( CubemapSaveShader )
|
|||
//-----------------------------------------------------------------------------
|
||||
singleton ShaderData( RoundedRectangleGUI )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/fixedFunction/colorV.hlsl";
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/fixedFunction/addColorTextureV.hlsl";
|
||||
DXPixelShaderFile = $Core::CommonShaderPath @ "/fixedFunction/roundedRectangleP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/fixedFunction/gl/colorV.glsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/fixedFunction/gl/addColorTextureV.glsl";
|
||||
OGLPixelShaderFile = $Core::CommonShaderPath @ "/fixedFunction/gl/roundedRectangleP.glsl";
|
||||
|
||||
pixVersion = 3.0;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
in vec4 color;
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
|
|
@ -29,6 +30,7 @@ uniform vec2 oneOverViewport;
|
|||
uniform float radius;
|
||||
uniform float borderSize;
|
||||
uniform vec4 borderCol;
|
||||
uniform float gradientFill;
|
||||
|
||||
float RoundedRectSDF(vec2 p, vec2 size, float radius)
|
||||
{
|
||||
|
|
@ -57,13 +59,16 @@ void main()
|
|||
|
||||
float cornerRadius = radius;
|
||||
|
||||
// if ((p.y < 0.0 && p.x < 0.0) || // top left corner
|
||||
// (p.y < 0.0 && p.x > 0.0) || // top right corner
|
||||
// (p.y > 0.0 && p.x > 0.0) || // bottom right corner.
|
||||
// (p.y > 0.0 && p.x < 0.0)) // bottom left corner
|
||||
// {
|
||||
// cornerRadius = radius;
|
||||
// }
|
||||
vec4 baseColor = color;
|
||||
|
||||
if(gradientFill > 0.5f)
|
||||
{
|
||||
float blendX = (1.0 - texCoord.x);
|
||||
float blendY = texCoord.y;
|
||||
|
||||
vec4 interpolatedColor = mix(mix(baseColor,vec4(1.0f, 1.0f, 1.0f, 1.0f), blendX),vec4(0.0f, 0.0f, 0.0f, 1.0f), blendY);
|
||||
baseColor = interpolatedColor;
|
||||
}
|
||||
|
||||
if(cornerRadius > 0.0 || halfBorder > 0.0)
|
||||
{
|
||||
|
|
@ -73,14 +78,8 @@ void main()
|
|||
{
|
||||
if(sdf < 0.0)
|
||||
{
|
||||
// if ((p.y >= -halfSize.y - radius + halfBorder && p.y <= -halfSize.y + radius - halfBorder) || // top border
|
||||
// (p.y >= halfSize.y - radius + halfBorder && p.y <= halfSize.y + radius - halfBorder) || // bottom border
|
||||
// (p.x >= -halfSize.x - radius + halfBorder && p.x <= -halfSize.x + radius - halfBorder) || // left border
|
||||
// (p.x >= halfSize.x - radius + halfBorder && p.x <= halfSize.x + radius - halfBorder) ) { // right border
|
||||
|
||||
// }
|
||||
toColor = color;
|
||||
sdf = abs(sdf) / borderSize;
|
||||
sdf = abs(sdf) - borderSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,14 +26,17 @@ struct Conn
|
|||
{
|
||||
float4 HPOS : TORQUE_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
uniform float2 sizeUni;
|
||||
uniform float2 rectCenter;
|
||||
uniform float2 oneOverViewport;
|
||||
uniform float radius;
|
||||
uniform float borderSize;
|
||||
uniform float4 borderCol;
|
||||
uniform float gradientFill;
|
||||
|
||||
float RoundedRectSDF(float2 p, float2 size, float radius)
|
||||
{
|
||||
|
|
@ -62,13 +65,16 @@ float4 main(Conn IN) : TORQUE_TARGET0
|
|||
|
||||
float cornerRadius = radius;
|
||||
|
||||
// if ((p.y < 0.0 && p.x < 0.0) || // top left corner
|
||||
// (p.y < 0.0 && p.x > 0.0) || // top right corner
|
||||
// (p.y > 0.0 && p.x > 0.0) || // bottom right corner.
|
||||
// (p.y > 0.0 && p.x < 0.0)) // bottom left corner
|
||||
// {
|
||||
// cornerRadius = radius;
|
||||
// }
|
||||
float4 baseColor = IN.color;
|
||||
|
||||
if(gradientFill > 0.5f)
|
||||
{
|
||||
float blendX = (1.0 - IN.texCoord.x);
|
||||
float blendY = IN.texCoord.y;
|
||||
|
||||
float4 interpolatedColor = lerp(lerp(baseColor,float4(1.0f, 1.0f, 1.0f, 1.0f), blendX),float4(0.0f, 0.0f, 0.0f, 1.0f), blendY);
|
||||
baseColor = interpolatedColor;
|
||||
}
|
||||
|
||||
if(cornerRadius > 0.0 || halfBorder > 0.0)
|
||||
{
|
||||
|
|
@ -78,19 +84,13 @@ float4 main(Conn IN) : TORQUE_TARGET0
|
|||
{
|
||||
if(sdf < 0.0)
|
||||
{
|
||||
// if ((p.y >= -halfSize.y - radius + halfBorder && p.y <= -halfSize.y + radius - halfBorder) || // top border
|
||||
// (p.y >= halfSize.y - radius + halfBorder && p.y <= halfSize.y + radius - halfBorder) || // bottom border
|
||||
// (p.x >= -halfSize.x - radius + halfBorder && p.x <= -halfSize.x + radius - halfBorder) || // left border
|
||||
// (p.x >= halfSize.x - radius + halfBorder && p.x <= halfSize.x + radius - halfBorder) ) { // right border
|
||||
|
||||
// }
|
||||
toColor = IN.color;
|
||||
sdf = abs(sdf) / borderSize;
|
||||
toColor = baseColor;
|
||||
sdf = abs(sdf) - borderSize;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
fromColor = IN.color;
|
||||
fromColor = baseColor;
|
||||
}
|
||||
|
||||
float alpha = smoothstep(-1.0, 1.0, sdf);
|
||||
|
|
@ -98,6 +98,6 @@ float4 main(Conn IN) : TORQUE_TARGET0
|
|||
}
|
||||
else
|
||||
{
|
||||
return IN.color;
|
||||
return baseColor;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue