-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed implicit resource binding + replaced editor shaders with native
- Loading branch information
Showing
15 changed files
with
288 additions
and
464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
"#, | ||
) | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
"#, | ||
) | ||
] | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.