Skip to content

Commit

Permalink
Merge branch 'Siv3D:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sfpgmr authored Jan 20, 2024
2 parents 1a13cf9 + 91be5ed commit 78fa05e
Show file tree
Hide file tree
Showing 46 changed files with 1,464 additions and 167 deletions.
60 changes: 60 additions & 0 deletions Linux/App/resources/engine/shader/essl/quad_warp.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# version 300 es

// Copyright (c) 2008-2023 Ryo Suzuki.
// Copyright (c) 2016-2023 OpenSiv3D Project.
// Licensed under the MIT License.

precision mediump float;

//
// Textures
//
uniform sampler2D Texture0;

//
// PSInput
//
in vec4 Color;
in vec2 UV;

//
// PSOutput
//
layout(location = 0) out vec4 FragColor;

//
// Constant Buffer
//
layout(std140) uniform PSConstants2D
{
vec4 g_colorAdd;
vec4 g_sdfParam;
vec4 g_sdfOutlineColor;
vec4 g_sdfShadowColor;
};

layout(std140) uniform PSQuadWarp
{
mat3x3 g_invHomography;
vec4 g_uvTransform;
};

vec2 Transform(vec2 pos, mat3x3 mat)
{
float s = (mat[0][2] * pos.x + mat[1][2] * pos.y + mat[2][2]);
float x = (mat[0][0] * pos.x + mat[1][0] * pos.y + mat[2][0]) / s;
float y = (mat[0][1] * pos.x + mat[1][1] * pos.y + mat[2][1]) / s;
return vec2(x, y);
}

//
// Functions
//
void main()
{
vec2 uv = (Transform(UV, g_invHomography) * g_uvTransform.xy + g_uvTransform.zw);

vec4 texColor = texture(Texture0, uv);

FragColor = ((texColor * Color) + g_colorAdd);
}
62 changes: 62 additions & 0 deletions Linux/App/resources/engine/shader/essl/quad_warp.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#version 300 es

// Copyright (c) 2008-2023 Ryo Suzuki.
// Copyright (c) 2016-2023 OpenSiv3D Project.
// Licensed under the MIT License.

//
// VSInput
//
layout(location = 0) in vec2 VertexPosition;
layout(location = 1) in vec2 VertexUV;
layout(location = 2) in vec4 VertexColor;

//
// VSOutput
//
out vec4 Color;
out vec2 UV;

//
// Siv3D Functions
//
vec4 s3d_Transform2D(const vec2 pos, const vec4 t[2])
{
return vec4(t[0].zw + (pos.x * t[0].xy) + (pos.y * t[1].xy), t[1].zw);
}

//
// Constant Buffer
//
layout(std140) uniform VSConstants2D
{
vec4 g_transform[2];
vec4 g_colorMul;
};

layout(std140) uniform VSQuadWarp
{
mat3x3 g_homography;
};

vec2 Transform(vec2 pos, mat3x3 mat)
{
float s = (mat[0][2] * pos.x + mat[1][2] * pos.y + mat[2][2]);
float x = (mat[0][0] * pos.x + mat[1][0] * pos.y + mat[2][0]) / s;
float y = (mat[0][1] * pos.x + mat[1][1] * pos.y + mat[2][1]) / s;
return vec2(x, y);
}

//
// Functions
//
void main()
{
vec2 position = Transform(VertexPosition, g_homography);

gl_Position = s3d_Transform2D(position, g_transform);

Color = (VertexColor * g_colorMul);

UV = position;
}
59 changes: 59 additions & 0 deletions Linux/App/resources/engine/shader/glsl/quad_warp.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2008-2023 Ryo Suzuki.
// Copyright (c) 2016-2023 OpenSiv3D Project.
// Licensed under the MIT License.

# version 410

//
// Textures
//
uniform sampler2D Texture0;

//
// PSInput
//
layout(location = 0) in vec4 Color;
layout(location = 1) in vec2 UV;

//
// PSOutput
//
layout(location = 0) out vec4 FragColor;

//
// Constant Buffer
//
layout(std140) uniform PSConstants2D
{
vec4 g_colorAdd;
vec4 g_sdfParam;
vec4 g_sdfOutlineColor;
vec4 g_sdfShadowColor;
vec4 g_internal;
};

layout(std140) uniform PSQuadWarp
{
mat3x3 g_invHomography;
vec4 g_uvTransform;
};

vec2 Transform(vec2 pos, mat3x3 mat)
{
float s = (mat[0][2] * pos.x + mat[1][2] * pos.y + mat[2][2]);
float x = (mat[0][0] * pos.x + mat[1][0] * pos.y + mat[2][0]) / s;
float y = (mat[0][1] * pos.x + mat[1][1] * pos.y + mat[2][1]) / s;
return vec2(x, y);
}

//
// Functions
//
void main()
{
vec2 uv = (Transform(UV, g_invHomography) * g_uvTransform.xy + g_uvTransform.zw);

vec4 texColor = texture(Texture0, uv);

FragColor = ((texColor * Color) + g_colorAdd);
}
66 changes: 66 additions & 0 deletions Linux/App/resources/engine/shader/glsl/quad_warp.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright (c) 2008-2023 Ryo Suzuki.
// Copyright (c) 2016-2023 OpenSiv3D Project.
// Licensed under the MIT License.

# version 410

//
// VSInput
//
layout(location = 0) in vec2 VertexPosition;
layout(location = 1) in vec2 VertexUV;
layout(location = 2) in vec4 VertexColor;

//
// VSOutput
//
layout(location = 0) out vec4 Color;
layout(location = 1) out vec2 UV;
out gl_PerVertex
{
vec4 gl_Position;
};

//
// Siv3D Functions
//
vec4 s3d_Transform2D(const vec2 pos, const vec4 t[2])
{
return vec4(t[0].zw + (pos.x * t[0].xy) + (pos.y * t[1].xy), t[1].zw);
}

//
// Constant Buffer
//
layout(std140) uniform VSConstants2D
{
vec4 g_transform[2];
vec4 g_colorMul;
};

layout(std140) uniform VSQuadWarp
{
mat3x3 g_homography;
};

vec2 Transform(vec2 pos, mat3x3 mat)
{
float s = (mat[0][2] * pos.x + mat[1][2] * pos.y + mat[2][2]);
float x = (mat[0][0] * pos.x + mat[1][0] * pos.y + mat[2][0]) / s;
float y = (mat[0][1] * pos.x + mat[1][1] * pos.y + mat[2][1]) / s;
return vec2(x, y);
}

//
// Functions
//
void main()
{
vec2 position = Transform(VertexPosition, g_homography);

gl_Position = s3d_Transform2D(position, g_transform);

Color = (VertexColor * g_colorMul);

UV = position;
}
Loading

0 comments on commit 78fa05e

Please sign in to comment.