-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
812301b
commit 85aa1d4
Showing
5 changed files
with
107 additions
and
59 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
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
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
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
37 changes: 37 additions & 0 deletions
37
paint/src/main/scala/roguepaint/shaders/BackgroundGrid.scala
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,37 @@ | ||
package roguepaint.shaders | ||
|
||
import indigo.* | ||
|
||
object BackgroundGrid: | ||
|
||
val shader: Shader = | ||
UltravioletShader.entityFragment( | ||
ShaderId("background grid"), | ||
EntityShader.fragment[FragmentEnv](fragment, FragmentEnv.reference) | ||
) | ||
|
||
val shaderData: ShaderData = | ||
ShaderData( | ||
shader.id, | ||
Batch.empty, | ||
None, | ||
None, | ||
None, | ||
None | ||
) | ||
|
||
import ultraviolet.syntax.* | ||
|
||
inline def fragment: Shader[FragmentEnv, Unit] = | ||
Shader[FragmentEnv] { env => | ||
|
||
def fragment(color: vec4): vec4 = | ||
val gridSize = 10.0f | ||
val count = vec2(1280.0f, 720.0f) / gridSize | ||
val size = 1.0f / count | ||
val outline = step(0.8f, mod(env.UV, size) * count) | ||
val lines = max(outline.x, outline.y) | ||
val lineColour = vec3(1.0f, 1.0f, 1.0f) * max(1.0f - env.UV.y, 0.25f) * 0.15f | ||
|
||
vec4(lineColour * lines, lines) | ||
} |