forked from hannibal002/SkyHanni
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #347 from Thunderblade73/pr/DavidArthurCole/PetDis…
…playV2
- Loading branch information
Showing
6 changed files
with
135 additions
and
70 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/main/java/at/hannibal2/skyhanni/shader/CircleShader.kt
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,29 @@ | ||
package at.hannibal2.skyhanni.shader | ||
|
||
import at.hannibal2.skyhanni.utils.shader.Shader | ||
import at.hannibal2.skyhanni.utils.shader.Uniform | ||
import net.minecraft.client.Minecraft | ||
|
||
object CircleShader : Shader("circle", "circle") { | ||
|
||
val INSTANCE get() = this | ||
|
||
var scaleFactor: Float = 0f | ||
var radius: Float = 0f | ||
var smoothness: Float = 0f | ||
var centerPos: FloatArray = floatArrayOf(0f, 0f) | ||
set(value) { | ||
field = floatArrayOf(value[0], Minecraft.getMinecraft().displayHeight - value[1]) | ||
} | ||
var angle1: Float = 0f | ||
var angle2: Float = 0f | ||
|
||
override fun registerUniforms() { | ||
registerUniform(Uniform.UniformType.FLOAT, "scaleFactor") { scaleFactor } | ||
registerUniform(Uniform.UniformType.FLOAT, "radius") { radius } | ||
registerUniform(Uniform.UniformType.FLOAT, "smoothness") { smoothness } | ||
registerUniform(Uniform.UniformType.FLOAT, "angle1") { angle1 } | ||
registerUniform(Uniform.UniformType.FLOAT, "angle2") { angle2 } | ||
registerUniform(Uniform.UniformType.VEC2, "centerPos") { centerPos } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#version 120 | ||
|
||
const float pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062f; | ||
|
||
uniform float scaleFactor; | ||
uniform float radius; | ||
uniform float smoothness; | ||
uniform vec2 centerPos; | ||
uniform float angle1; | ||
uniform float angle2; | ||
|
||
varying vec4 color; | ||
|
||
void main() { | ||
float xScale = gl_ModelViewMatrix[0][0]; | ||
float yScale = gl_ModelViewMatrix[1][1]; | ||
float xTranslation = gl_ModelViewMatrix[3][0]; | ||
float yTranslation = gl_ModelViewMatrix[3][1]; | ||
|
||
vec2 cords = vec2(gl_FragCoord.x, gl_FragCoord.y); | ||
|
||
vec2 newCenterPos = vec2((centerPos.x + (radius * (xScale - 1.0))) + (xTranslation * scaleFactor), (centerPos.y - (radius * (yScale - 1.0))) - (yTranslation * scaleFactor)); | ||
|
||
float newRadius = radius * min(xScale,yScale); | ||
|
||
vec2 adjusted = cords - newCenterPos; | ||
|
||
float smoothed = 1.0 - smoothstep(pow(newRadius - smoothness,2.0), pow(newRadius,2.0), pow(adjusted.x, 2.0) + pow(adjusted.y, 2.0)); | ||
|
||
float current = atan(adjusted.y,adjusted.x); | ||
|
||
float sanity = step(angle1,angle2); | ||
|
||
float lim1 = step(current,angle1); | ||
float lim2 = step(angle2,current); | ||
|
||
float lim3 = step(angle1,current); | ||
float lim4 = step(current,angle2); | ||
|
||
float lim = max(lim1,lim2)*sanity+(1.0-sanity)*(1.0-max(lim3,lim4)); | ||
|
||
gl_FragColor = color * vec4(1.0, 1.0, 1.0, smoothed*lim); | ||
} |
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,8 @@ | ||
#version 120 | ||
|
||
varying vec4 color; | ||
|
||
void main() { | ||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; | ||
color = gl_Color; | ||
} |