-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from FRC3476/shader-trajectories
Shader trajectories
- Loading branch information
Showing
7 changed files
with
172 additions
and
48 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,13 @@ | ||
#ifdef GL_ES | ||
#define LOWP lowp | ||
precision mediump float; | ||
#else | ||
#define LOWP | ||
#endif | ||
|
||
varying LOWP vec4 v_color; | ||
|
||
void main() | ||
{ | ||
gl_FragColor = v_color; | ||
} |
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,23 @@ | ||
// All components are in the range [0…1], including hue. | ||
vec3 hsv2rgb(vec3 c) | ||
{ | ||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); | ||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); | ||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); | ||
} | ||
|
||
attribute vec2 a_position; | ||
attribute float a_speedPercent; | ||
|
||
uniform mat4 u_projTrans; | ||
uniform vec2 u_colorhv; | ||
|
||
varying vec4 v_color; | ||
|
||
void main() | ||
{ | ||
vec3 _hsvColor = vec3(u_colorhv.x, a_speedPercent * 0.9 + 0.1, u_colorhv.y); | ||
v_color = vec4(hsv2rgb(_hsvColor), 0); | ||
vec4 pos = vec4(a_position.xy, 0, 1); | ||
gl_Position = u_projTrans * pos; | ||
} |
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
24 changes: 24 additions & 0 deletions
24
core/src/main/com/dacubeking/autobuilder/gui/util/shaders/ShaderLoader.java
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,24 @@ | ||
package com.dacubeking.autobuilder.gui.util.shaders; | ||
|
||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.assets.loaders.ShaderProgramLoader; | ||
import com.badlogic.gdx.graphics.glutils.ShaderProgram; | ||
import com.dacubeking.autobuilder.gui.AutoBuilder; | ||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public final class ShaderLoader { | ||
|
||
private ShaderLoader() { | ||
} | ||
|
||
private static final @NotNull ShaderProgramLoader.ShaderProgramParameter defaultShaderParameter = | ||
new ShaderProgramLoader.ShaderProgramParameter(); | ||
|
||
@Contract("_ -> new") | ||
public static @NotNull ShaderProgram loadShader(@NotNull String name) { | ||
var assetManager = AutoBuilder.getInstance().getAssetManager(); | ||
return new ShaderProgram(Gdx.files.internal("shaders/" + name + ".vert"), | ||
Gdx.files.internal("shaders/" + name + ".frag")); | ||
} | ||
} |