Nouveau shader pour les barres de progression qui donne un aspect "tube"
This commit is contained in:
parent
d587940b45
commit
ec45df9c5e
@ -0,0 +1,36 @@
|
||||
#version 410
|
||||
|
||||
in vec4 color;
|
||||
in vec2 fragCoord;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform float time;
|
||||
uniform float fill;
|
||||
uniform bool leftToRight;
|
||||
uniform float height;
|
||||
|
||||
void main()
|
||||
{ //Rectangle plus large que haut
|
||||
vec4 colorTemp = color;
|
||||
float ouverture = 0.8f;
|
||||
float lum = -pow(fragCoord.y + height/2f, 2f) * 5f /height + ouverture;
|
||||
colorTemp.xyz *= lum;
|
||||
if (leftToRight){
|
||||
if (fill > fragCoord.x){
|
||||
FragColor = colorTemp;
|
||||
}
|
||||
else {
|
||||
FragColor = vec4(0f);
|
||||
}
|
||||
} else {
|
||||
if (fill < fragCoord.x){
|
||||
FragColor = colorTemp;
|
||||
}
|
||||
else {
|
||||
FragColor = vec4(0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -9,13 +9,15 @@ public class HorizontalProgressBar extends ObjectGl {
|
||||
private float max;
|
||||
private float current;
|
||||
private int leftToRight;
|
||||
private boolean useHeight;
|
||||
|
||||
public HorizontalProgressBar(float z, float w, float h, float size, float current, float max, boolean leftToRight) {
|
||||
super(z, w, h, size, null, new Vector3f(0f, 1f, 0f));
|
||||
this.max = max;
|
||||
this.current = current;
|
||||
this.leftToRight = leftToRight ? 1 : 0;
|
||||
this.setShader("shaders/StylishShaders/BasicNoTexVert.glsl", "shaders/StylishShaders/HorizontalProgressBar.glsl");
|
||||
this.useHeight = false;
|
||||
this.setShader("shaders/StylishShaders/BasicNoTexVert.glsl", "shaders/StylishShaders/HorizontalProgressBarFrag.glsl");
|
||||
}
|
||||
|
||||
public void setCurrent(float newCurrent) {
|
||||
@ -26,6 +28,10 @@ public class HorizontalProgressBar extends ObjectGl {
|
||||
this.max = newMax;
|
||||
}
|
||||
|
||||
public void setUseHeight(boolean b){
|
||||
this.useHeight = b;
|
||||
}
|
||||
|
||||
protected void uniformInjection() {
|
||||
if (this.useTime) this.shader.setUniform1f("time", (float) glfwGetTime());
|
||||
|
||||
@ -35,6 +41,10 @@ public class HorizontalProgressBar extends ObjectGl {
|
||||
this.shader.setUniform1f("fill", Math.abs(((this.current / this.max) * this.getWidth()) - this.getWidth()));
|
||||
}
|
||||
|
||||
if (this.useHeight) {
|
||||
this.shader.setUniform1f("height", this.height);
|
||||
}
|
||||
|
||||
this.shader.setUniform1i("leftToRight", this.leftToRight);
|
||||
|
||||
this.shader.setUniformMat4f("projection", projection);
|
||||
|
@ -190,7 +190,8 @@ public class match {
|
||||
engine.add_uiElement(coordP2);
|
||||
// Barre de vie
|
||||
healthBarP1Obj = new HorizontalProgressBar(80f, 8.5f, 0.4f, 100f, p1.getCurrentHP(), p1.getMaxHP(), false);
|
||||
healthBarP1Obj.setColorVerticalGradient(new Vector3f(39f/255f, 201f/255f, 30f/255f), new Vector3f(19f/255f, 89f/255f, 15f/255f));
|
||||
healthBarP1Obj.setShader("shaders/StylishShaders/BasicNoTexVert.glsl", "shaders/StylishShaders/HorizontalProgressBarGradientSquareFrag.glsl");
|
||||
healthBarP1Obj.setUseHeight(true);
|
||||
healthBarP1 = new UIElement(healthBarP1Obj, 0.0138f, 0.980f, engine);
|
||||
healthBarP2Obj = new HorizontalProgressBar(80f, 8.5f, 0.4f, 100f, p2.getCurrentHP(), p2.getMaxHP(), true);
|
||||
healthBarP2Obj.setColorVerticalGradient(new Vector3f(39f/255f, 201f/255f, 30f/255f), new Vector3f(19f/255f, 89f/255f, 15f/255f));
|
||||
|
Loading…
x
Reference in New Issue
Block a user