chore: import upstream snapshot with attribution
@@ -0,0 +1,11 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
*.lock
|
||||
.idea
|
||||
/*.log
|
||||
/*.txt
|
||||
*.rgs
|
||||
/data
|
||||
history.bin
|
||||
/settings.ron
|
||||
/AutomatedTests
|
||||
@@ -0,0 +1,36 @@
|
||||
[package]
|
||||
name = "fyroxed_base"
|
||||
license = "MIT"
|
||||
version = "2.0.0-rc.1"
|
||||
authors = ["Dmitry Stepanov <d1maxa@yandex.ru>"]
|
||||
edition = "2021"
|
||||
rust-version = "1.94"
|
||||
description = "A scene editor for Fyrox game engine"
|
||||
homepage = "https://github.com/FyroxEngine/Fyrox"
|
||||
keywords = ["fyrox", "editor", "rust"]
|
||||
repository = "https://github.com/FyroxEngine/Fyrox"
|
||||
readme = "README.md"
|
||||
include = ["/src/**/*", "/Cargo.toml", "/LICENSE", "/README.md", "/resources/**/*"]
|
||||
|
||||
[dependencies]
|
||||
fyrox = { version = "2.0.0-rc.1", path = "../fyrox", default-features = false }
|
||||
fyrox-build-tools = { version = "2.0.0-rc.1", path = "../fyrox-build-tools" }
|
||||
ron = "0.11"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
toml = { version = "0.9", default-features = false, features = ["parse"] }
|
||||
toml_edit = "0.23"
|
||||
strum = "0.27"
|
||||
strum_macros = "0.27"
|
||||
open = "5"
|
||||
opener = { version = "0.8", default-features = false, features = ["reveal"] }
|
||||
rust-fuzzy-search = "0.1.1"
|
||||
cargo_metadata = "0.22"
|
||||
serde_json = { version = "1", features = ["raw_value", "default", "std", "unbounded_depth"] }
|
||||
image = { version = "0.25.1", default-features = false, features = ["gif", "jpeg", "png", "tga", "tiff", "bmp"] }
|
||||
imageproc = "0.25.0"
|
||||
notify = "8"
|
||||
bitflags = "2.9.1"
|
||||
|
||||
[features]
|
||||
default = ["fyrox/default"]
|
||||
dylib_engine = ["fyrox/dylib"]
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Dmitry Stepanov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,6 @@
|
||||
# FyroxEd
|
||||
|
||||
Full-featured editor for [Fyrox engine](https://github.com/FyroxEngine/Fyrox). This is the basic library for the editor,
|
||||
it cannot be run as executable. See `editor-standalone` for this.
|
||||
|
||||
The main purpose of making the editor library is to use it with static plugins, see `scripting` example for more info.
|
||||
|
After Width: | Height: | Size: 536 B |
|
After Width: | Height: | Size: 563 B |
|
After Width: | Height: | Size: 778 B |
|
After Width: | Height: | Size: 936 B |
|
After Width: | Height: | Size: 803 B |
|
After Width: | Height: | Size: 974 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 969 B |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 869 B |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 519 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 648 B |
|
After Width: | Height: | Size: 376 B |
|
After Width: | Height: | Size: 563 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 659 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 878 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 796 B |
|
After Width: | Height: | Size: 647 B |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 982 B |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 655 B |
|
After Width: | Height: | Size: 681 B |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 858 B |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 865 B |
|
After Width: | Height: | Size: 805 B |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 415 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 830 B |
|
After Width: | Height: | Size: 1023 B |
|
After Width: | Height: | Size: 920 B |
|
After Width: | Height: | Size: 618 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 931 B |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 504 B |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 735 B |
|
After Width: | Height: | Size: 1011 B |
|
After Width: | Height: | Size: 967 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 434 B |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 467 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1015 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 694 B |
|
After Width: | Height: | Size: 884 B |
|
After Width: | Height: | Size: 678 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 445 B |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 998 B |
@@ -0,0 +1,85 @@
|
||||
(
|
||||
name: "GizmoShader",
|
||||
|
||||
resources: [
|
||||
(
|
||||
name: "properties",
|
||||
kind: PropertyGroup([
|
||||
(
|
||||
name: "diffuseColor",
|
||||
kind: Color(r: 255, g: 255, b: 255, a: 255),
|
||||
),
|
||||
]),
|
||||
binding: 0
|
||||
),
|
||||
(
|
||||
name: "fyrox_instanceData",
|
||||
kind: PropertyGroup([
|
||||
// Autogenerated
|
||||
]),
|
||||
binding: 1
|
||||
),
|
||||
],
|
||||
|
||||
disabled_passes: ["GBuffer", "DirectionalShadow", "PointShadow", "SpotShadow"],
|
||||
|
||||
passes: [
|
||||
(
|
||||
name: "Forward",
|
||||
draw_parameters: DrawParameters(
|
||||
cull_face: None,
|
||||
color_write: ColorMask(
|
||||
red: true,
|
||||
green: true,
|
||||
blue: true,
|
||||
alpha: true,
|
||||
),
|
||||
depth_write: true,
|
||||
stencil_test: None,
|
||||
depth_test: Some(Less),
|
||||
blend: Some(BlendParameters(
|
||||
func: BlendFunc(
|
||||
sfactor: SrcAlpha,
|
||||
dfactor: OneMinusSrcAlpha,
|
||||
alpha_sfactor: SrcAlpha,
|
||||
alpha_dfactor: OneMinusSrcAlpha,
|
||||
),
|
||||
equation: BlendEquation(
|
||||
rgb: Add,
|
||||
alpha: Add
|
||||
)
|
||||
)),
|
||||
stencil_op: StencilOp(
|
||||
fail: Keep,
|
||||
zfail: Keep,
|
||||
zpass: Keep,
|
||||
write_mask: 0xFFFF_FFFF,
|
||||
),
|
||||
scissor_box: None
|
||||
),
|
||||
vertex_shader:
|
||||
r#"
|
||||
layout(location = 0) in vec3 vertexPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = fyrox_instanceData.worldViewProjection * vec4(vertexPosition, 1.0);
|
||||
}
|
||||
"#,
|
||||
|
||||
fragment_shader:
|
||||
r#"
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = properties.diffuseColor;
|
||||
|
||||
// Pull depth towards near clipping plane so the gizmo will be drawn on top
|
||||
// of everything, but its parts will be correctly handled by depth test.
|
||||
gl_FragDepth = gl_FragCoord.z * 0.001;
|
||||
}
|
||||
"#,
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,205 @@
|
||||
(
|
||||
name: "GridShader",
|
||||
|
||||
resources: [
|
||||
(
|
||||
name: "properties",
|
||||
kind: PropertyGroup([
|
||||
(
|
||||
name: "diffuseColor",
|
||||
kind: Color(r: 40, g: 40, b: 40, a: 255),
|
||||
),
|
||||
(
|
||||
name: "xAxisColor",
|
||||
kind: Color(r: 255, g: 0, b: 0, a: 255),
|
||||
),
|
||||
(
|
||||
name: "yAxisColor",
|
||||
kind: Color(r: 0, g: 255, b: 0, a: 255),
|
||||
),
|
||||
(
|
||||
name: "zAxisColor",
|
||||
kind: Color(r: 0, g: 0, b: 255, a: 255),
|
||||
),
|
||||
(
|
||||
name: "orientation",
|
||||
kind: Int(value: 0),
|
||||
),
|
||||
(
|
||||
name: "isPerspective",
|
||||
kind: Bool(value: false)
|
||||
),
|
||||
(
|
||||
name: "scale",
|
||||
kind: Vector2(value: (1.0, 1.0))
|
||||
)
|
||||
]),
|
||||
binding: 0
|
||||
),
|
||||
(
|
||||
name: "fyrox_cameraData",
|
||||
kind: PropertyGroup([
|
||||
// Autogenerated
|
||||
]),
|
||||
binding: 1
|
||||
),
|
||||
],
|
||||
|
||||
disabled_passes: ["GBuffer", "DirectionalShadow", "PointShadow", "SpotShadow"],
|
||||
|
||||
passes: [
|
||||
(
|
||||
name: "Forward",
|
||||
draw_parameters: DrawParameters(
|
||||
cull_face: None,
|
||||
color_write: ColorMask(
|
||||
red: true,
|
||||
green: true,
|
||||
blue: true,
|
||||
alpha: true,
|
||||
),
|
||||
depth_write: true,
|
||||
stencil_test: None,
|
||||
depth_test: Some(Less),
|
||||
blend: Some(BlendParameters(
|
||||
func: BlendFunc(
|
||||
sfactor: SrcAlpha,
|
||||
dfactor: OneMinusSrcAlpha,
|
||||
alpha_sfactor: SrcAlpha,
|
||||
alpha_dfactor: OneMinusSrcAlpha,
|
||||
),
|
||||
equation: BlendEquation(
|
||||
rgb: Add,
|
||||
alpha: Add
|
||||
)
|
||||
)),
|
||||
stencil_op: StencilOp(
|
||||
fail: Keep,
|
||||
zfail: Keep,
|
||||
zpass: Keep,
|
||||
write_mask: 0xFFFF_FFFF,
|
||||
),
|
||||
scissor_box: None
|
||||
),
|
||||
vertex_shader:
|
||||
r#"
|
||||
layout(location = 0) in vec3 vertexPosition;
|
||||
|
||||
out vec3 nearPoint;
|
||||
out vec3 farPoint;
|
||||
|
||||
vec3 Unproject(float x, float y, float z, mat4 matrix)
|
||||
{
|
||||
vec4 position = matrix * vec4(x, y, z, 1.0);
|
||||
return position.xyz / position.w;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 invViewProj = inverse(fyrox_cameraData.viewProjectionMatrix);
|
||||
nearPoint = Unproject(vertexPosition.x, vertexPosition.y, 0.0, invViewProj);
|
||||
farPoint = Unproject(vertexPosition.x, vertexPosition.y, 1.0, invViewProj);
|
||||
gl_Position = vec4(vertexPosition, 1.0);
|
||||
}
|
||||
"#,
|
||||
|
||||
fragment_shader:
|
||||
r#"
|
||||
// Original code: https://asliceofrendering.com/scene%20helper/2020/01/05/InfiniteGrid/
|
||||
// Fixed and adapted for Fyrox.
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec3 nearPoint;
|
||||
in vec3 farPoint;
|
||||
|
||||
vec4 grid(vec3 fragPos3D) {
|
||||
vec2 projection;
|
||||
vec3 planeNormal;
|
||||
vec4 xColor;
|
||||
vec4 yColor;
|
||||
if (properties.orientation == 0) {
|
||||
projection = fragPos3D.xz;
|
||||
planeNormal = vec3(0.0, 1.0, 0.0);
|
||||
xColor = properties.xAxisColor;
|
||||
yColor = properties.zAxisColor;
|
||||
} else if (properties.orientation == 1) {
|
||||
projection = fragPos3D.xy;
|
||||
planeNormal = vec3(0.0, 0.0, 1.0);
|
||||
xColor = properties.yAxisColor;
|
||||
yColor = properties.xAxisColor;
|
||||
} else if (properties.orientation == 2) {
|
||||
projection = fragPos3D.zy;
|
||||
planeNormal = vec3(1.0, 0.0, 0.0);
|
||||
xColor = properties.zAxisColor;
|
||||
yColor = properties.yAxisColor;
|
||||
}
|
||||
|
||||
vec2 coord = projection * properties.scale;
|
||||
vec2 derivative = fwidth(coord);
|
||||
vec2 grid = abs(fract(coord - 0.5) - 0.5) / derivative;
|
||||
float line = min(grid.x, grid.y);
|
||||
float minX = 0.5 * min(derivative.x, 1.0);
|
||||
float minY = 0.5 * min(derivative.y, 1.0);
|
||||
|
||||
vec4 color = properties.diffuseColor;
|
||||
float alpha = 1.0 - min(line, 1.0);
|
||||
// Sharpen lines a bit.
|
||||
color.a = alpha >= 0.5 ? 1.0 : 0.0;
|
||||
|
||||
if (projection.x > -minX && projection.x < minX) {
|
||||
color.xyz = xColor.xyz;
|
||||
} else if (projection.y > -minY && projection.y < minY) {
|
||||
color.xyz = yColor.xyz;
|
||||
} else {
|
||||
vec3 viewDir = fragPos3D - fyrox_cameraData.position;
|
||||
// This helps to negate moire pattern at large distances.
|
||||
float cosAngle = abs(dot(planeNormal, normalize(viewDir)));
|
||||
color.a *= cosAngle;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
float computeDepth(vec3 pos) {
|
||||
vec4 clip_space_pos = fyrox_cameraData.viewProjectionMatrix * vec4(pos.xyz, 1.0);
|
||||
return (clip_space_pos.z / clip_space_pos.w);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
float nearCoord;
|
||||
float farCoord;
|
||||
if (properties.orientation == 0) {
|
||||
nearCoord = nearPoint.y;
|
||||
farCoord = farPoint.y;
|
||||
} else if (properties.orientation == 1) {
|
||||
nearCoord = nearPoint.z;
|
||||
farCoord = farPoint.z;
|
||||
} else if (properties.orientation == 2) {
|
||||
nearCoord = nearPoint.x;
|
||||
farCoord = farPoint.x;
|
||||
}
|
||||
|
||||
float denominator = farCoord - nearCoord;
|
||||
float t = denominator != 0.0 ? -nearCoord / denominator : 0.0;
|
||||
|
||||
vec3 fragPos3D = nearPoint + t * (farPoint - nearPoint);
|
||||
|
||||
float depth = computeDepth(fragPos3D);
|
||||
gl_FragDepth = ((gl_DepthRange.diff * depth) + gl_DepthRange.near + gl_DepthRange.far) / 2.0;
|
||||
|
||||
FragColor = grid(fragPos3D);
|
||||
if (properties.isPerspective) {
|
||||
FragColor.a *= float(t > 0.0);
|
||||
}
|
||||
|
||||
// Alpha test to prevent blending issues.
|
||||
if (FragColor.a < 0.01) {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
"#,
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,100 @@
|
||||
(
|
||||
name: "Highlight",
|
||||
resources: [
|
||||
(
|
||||
name: "frameTexture",
|
||||
kind: Texture(kind: Sampler2D, fallback: White),
|
||||
binding: 0
|
||||
),
|
||||
(
|
||||
name: "properties",
|
||||
kind: PropertyGroup([
|
||||
(name: "worldViewProjection", kind: Matrix4()),
|
||||
(name: "color", kind: Vector4()),
|
||||
]),
|
||||
binding: 0
|
||||
),
|
||||
],
|
||||
passes: [
|
||||
(
|
||||
name: "Primary",
|
||||
|
||||
draw_parameters: DrawParameters(
|
||||
cull_face: None,
|
||||
color_write: ColorMask(
|
||||
red: true,
|
||||
green: true,
|
||||
blue: true,
|
||||
alpha: true,
|
||||
),
|
||||
depth_write: false,
|
||||
stencil_test: None,
|
||||
depth_test: None,
|
||||
blend: Some(BlendParameters(
|
||||
func: BlendFunc(
|
||||
sfactor: SrcAlpha,
|
||||
dfactor: OneMinusSrcAlpha,
|
||||
alpha_sfactor: SrcAlpha,
|
||||
alpha_dfactor: OneMinusSrcAlpha,
|
||||
),
|
||||
equation: BlendEquation(
|
||||
rgb: Add,
|
||||
alpha: Add
|
||||
)
|
||||
)),
|
||||
stencil_op: StencilOp(
|
||||
fail: Keep,
|
||||
zfail: Keep,
|
||||
zpass: Keep,
|
||||
write_mask: 0xFFFF_FFFF,
|
||||
),
|
||||
scissor_box: None
|
||||
),
|
||||
|
||||
vertex_shader:
|
||||
r#"
|
||||
layout(location = 0) in vec3 vertexPosition;
|
||||
layout(location = 1) in vec2 vertexTexCoord;
|
||||
|
||||
out vec2 texCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
texCoord = vertexTexCoord;
|
||||
gl_Position = properties.worldViewProjection * vec4(vertexPosition, 1.0);
|
||||
}
|
||||
"#,
|
||||
|
||||
fragment_shader:
|
||||
r#"
|
||||
layout (location = 0) out vec4 outColor;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
ivec2 size = textureSize(frameTexture, 0);
|
||||
|
||||
float w = 1.0 / float(size.x);
|
||||
float h = 1.0 / float(size.y);
|
||||
|
||||
float n[9];
|
||||
n[0] = texture(frameTexture, texCoord + vec2(-w, -h)).a;
|
||||
n[1] = texture(frameTexture, texCoord + vec2(0.0, -h)).a;
|
||||
n[2] = texture(frameTexture, texCoord + vec2(w, -h)).a;
|
||||
n[3] = texture(frameTexture, texCoord + vec2( -w, 0.0)).a;
|
||||
n[4] = texture(frameTexture, texCoord).a;
|
||||
n[5] = texture(frameTexture, texCoord + vec2(w, 0.0)).a;
|
||||
n[6] = texture(frameTexture, texCoord + vec2(-w, h)).a;
|
||||
n[7] = texture(frameTexture, texCoord + vec2(0.0, h)).a;
|
||||
n[8] = texture(frameTexture, texCoord + vec2(w, h)).a;
|
||||
|
||||
float sobel_edge_h = n[2] + (2.0 * n[5]) + n[8] - (n[0] + (2.0 * n[3]) + n[6]);
|
||||
float sobel_edge_v = n[0] + (2.0 * n[1]) + n[2] - (n[6] + (2.0 * n[7]) + n[8]);
|
||||
float sobel = sqrt((sobel_edge_h * sobel_edge_h) + (sobel_edge_v * sobel_edge_v));
|
||||
|
||||
outColor = vec4(properties.color.rgb, properties.color.a * sobel);
|
||||
}
|
||||
"#,
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,87 @@
|
||||
(
|
||||
name: "Overlay",
|
||||
resources: [
|
||||
(
|
||||
name: "diffuseTexture",
|
||||
kind: Texture(kind: Sampler2D, fallback: White),
|
||||
binding: 0
|
||||
),
|
||||
(
|
||||
name: "properties",
|
||||
kind: PropertyGroup([
|
||||
(name: "viewProjectionMatrix", kind: Matrix4()),
|
||||
(name: "worldMatrix", kind: Matrix4()),
|
||||
(name: "cameraSideVector", kind: Vector3()),
|
||||
(name: "cameraUpVector", kind: Vector3()),
|
||||
(name: "size", kind: Float()),
|
||||
]),
|
||||
binding: 0
|
||||
),
|
||||
],
|
||||
passes: [
|
||||
(
|
||||
name: "Primary",
|
||||
|
||||
draw_parameters: DrawParameters(
|
||||
cull_face: None,
|
||||
color_write: ColorMask(
|
||||
red: true,
|
||||
green: true,
|
||||
blue: true,
|
||||
alpha: true,
|
||||
),
|
||||
depth_write: false,
|
||||
stencil_test: None,
|
||||
depth_test: None,
|
||||
blend: Some(BlendParameters(
|
||||
func: BlendFunc(
|
||||
sfactor: SrcAlpha,
|
||||
dfactor: OneMinusSrcAlpha,
|
||||
alpha_sfactor: SrcAlpha,
|
||||
alpha_dfactor: OneMinusSrcAlpha,
|
||||
),
|
||||
equation: BlendEquation(
|
||||
rgb: Add,
|
||||
alpha: Add
|
||||
)
|
||||
)),
|
||||
stencil_op: StencilOp(
|
||||
fail: Keep,
|
||||
zfail: Keep,
|
||||
zpass: Keep,
|
||||
write_mask: 0xFFFF_FFFF,
|
||||
),
|
||||
scissor_box: None
|
||||
),
|
||||
|
||||
vertex_shader:
|
||||
r#"
|
||||
layout (location = 0) in vec3 vertexPosition;
|
||||
layout (location = 1) in vec2 vertexTexCoord;
|
||||
|
||||
out vec2 texCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
texCoord = vertexTexCoord;
|
||||
vec2 vertexOffset = vertexTexCoord * 2.0 - 1.0;
|
||||
vec4 worldPosition = properties.worldMatrix * vec4(vertexPosition, 1.0);
|
||||
vec3 offset = (vertexOffset.x * properties.cameraSideVector + vertexOffset.y * properties.cameraUpVector) * properties.size;
|
||||
gl_Position = properties.viewProjectionMatrix * (worldPosition + vec4(offset.x, offset.y, offset.z, 0.0));
|
||||
}
|
||||
"#,
|
||||
|
||||
fragment_shader:
|
||||
r#"
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(diffuseTexture, texCoord);
|
||||
}
|
||||
"#,
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,104 @@
|
||||
(
|
||||
name: "SpriteGizmoShader",
|
||||
|
||||
resources: [
|
||||
(
|
||||
name: "diffuseTexture",
|
||||
kind: Texture(kind: Sampler2D, fallback: White),
|
||||
binding: 0
|
||||
),
|
||||
(
|
||||
name: "fyrox_instanceData",
|
||||
kind: PropertyGroup([
|
||||
// Autogenerated
|
||||
]),
|
||||
binding: 0
|
||||
),
|
||||
(
|
||||
name: "fyrox_cameraData",
|
||||
kind: PropertyGroup([
|
||||
// Autogenerated
|
||||
]),
|
||||
binding: 1
|
||||
),
|
||||
],
|
||||
|
||||
disabled_passes: ["GBuffer", "DirectionalShadow", "PointShadow", "SpotShadow"],
|
||||
|
||||
passes: [
|
||||
(
|
||||
name: "Forward",
|
||||
draw_parameters: DrawParameters(
|
||||
cull_face: None,
|
||||
color_write: ColorMask(
|
||||
red: true,
|
||||
green: true,
|
||||
blue: true,
|
||||
alpha: true,
|
||||
),
|
||||
depth_write: true,
|
||||
stencil_test: None,
|
||||
depth_test: Some(Less),
|
||||
blend: Some(BlendParameters(
|
||||
func: BlendFunc(
|
||||
sfactor: SrcAlpha,
|
||||
dfactor: OneMinusSrcAlpha,
|
||||
alpha_sfactor: SrcAlpha,
|
||||
alpha_dfactor: OneMinusSrcAlpha,
|
||||
),
|
||||
equation: BlendEquation(
|
||||
rgb: Add,
|
||||
alpha: Add
|
||||
)
|
||||
)),
|
||||
stencil_op: StencilOp(
|
||||
fail: Keep,
|
||||
zfail: Keep,
|
||||
zpass: Keep,
|
||||
write_mask: 0xFFFF_FFFF,
|
||||
),
|
||||
scissor_box: None
|
||||
),
|
||||
vertex_shader:
|
||||
r#"
|
||||
layout(location = 0) in vec3 vertexPosition;
|
||||
layout(location = 1) in vec2 vertexTexCoord;
|
||||
layout(location = 2) in vec2 vertexParams;
|
||||
layout(location = 3) in vec4 vertexColor;
|
||||
|
||||
out vec2 texCoord;
|
||||
out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
float size = vertexParams.x;
|
||||
float rotation = vertexParams.y;
|
||||
|
||||
texCoord = vertexTexCoord;
|
||||
color = vertexColor;
|
||||
vec2 vertexOffset = S_RotateVec2(vertexTexCoord * 2.0 - 1.0, rotation);
|
||||
vec4 worldPosition = fyrox_instanceData.worldMatrix * vec4(vertexPosition, 1.0);
|
||||
vec3 offset = (vertexOffset.x * fyrox_cameraData.sideVector + vertexOffset.y * fyrox_cameraData.upVector) * size;
|
||||
gl_Position = fyrox_cameraData.viewProjectionMatrix * (worldPosition + vec4(offset.x, offset.y, offset.z, 0.0));
|
||||
}
|
||||
"#,
|
||||
|
||||
fragment_shader:
|
||||
r#"
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 texCoord;
|
||||
in vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = color * S_SRGBToLinear(texture(diffuseTexture, texCoord));
|
||||
|
||||
// Pull depth towards near clipping plane so the gizmo will be drawn on top
|
||||
// of everything, but its parts will be correctly handled by depth test.
|
||||
gl_FragDepth = gl_FragCoord.z * 0.001;
|
||||
}
|
||||
"#,
|
||||
),
|
||||
],
|
||||
)
|
||||