Unit assembler shader fix

This commit is contained in:
Anuken
2025-02-09 22:12:59 -05:00
parent 8ee02562c3
commit 90dc291b66
4 changed files with 12 additions and 8 deletions
+4 -3
View File
@@ -7,6 +7,7 @@ uniform vec2 u_uv;
uniform vec2 u_uv2;
uniform float u_progress;
uniform float u_time;
uniform float u_alpha;
varying vec4 v_color;
varying vec2 v_texCoords;
@@ -45,11 +46,11 @@ void main(){
float dst = (abs(center.x - coords.x) + abs(center.y - coords.y))/2.0;
if((mod(u_time / 1.5 + value, 20.0) < 15.0 && cont(t, v))){
gl_FragColor = blend(color, v_color);
gl_FragColor = blend(color, v_color) * vec4(vec3(1.0), u_alpha);
}else if(dst > (1.0-u_progress) * (center.x)){
gl_FragColor = color;
gl_FragColor = color * vec4(vec3(1.0), u_alpha);
}else if((dst + 2.0 > (1.0-u_progress) * (center.x)) && color.a > 0.1){
gl_FragColor = blend(color, v_color);
gl_FragColor = blend(color, v_color) * vec4(vec3(1.0), u_alpha);
}else{
gl_FragColor = vec4(0.0);
}
-1
View File
@@ -400,7 +400,6 @@ public class Control implements ApplicationListener, Loadable{
control.saves.resetSave();
}
//for planet launches, mostly
if(sector.preset != null){
sector.preset.quietUnlock();
}
+3
View File
@@ -232,6 +232,8 @@ public class Shaders{
public static class BlockBuildShader extends LoadShader{
public float progress;
//Alpha changes the opacity of *everything*, while the provided batch color only changes the outline
public float alpha = 1f;
public TextureRegion region = new TextureRegion();
public float time;
@@ -243,6 +245,7 @@ public class Shaders{
public void apply(){
setUniformf("u_progress", progress);
setUniformf("u_time", time);
setUniformf("u_alpha", alpha);
if(region.texture == null){
setUniformf("u_uv", 0f, 0f);
@@ -200,7 +200,7 @@ public class UnitAssembler extends PayloadBlock{
}).left();
t.table(req -> {
req.table().grow(); //it refuses to go to the right unless I do this. please help.
req.add().grow(); //it refuses to go to the right unless I do this. please help.
req.table(solid -> {
int length = 0;
@@ -222,13 +222,13 @@ public class UnitAssembler extends PayloadBlock{
length++;
}
}).right();
LiquidStack[] stacks = plan.liquidReq;
if(stacks != null){
for(int i = 0; i < plan.liquidReq.length; i++){
req.row();
req.table().grow(); //another one.
req.add().grow(); //another one.
req.add(StatValues.displayLiquid(stacks[i].liquid, stacks[i].amount * 60f, true)).right();
}
@@ -561,18 +561,19 @@ public class UnitAssembler extends PayloadBlock{
var plan = plan();
//draw the unit construction as outline
//TODO flashes when no gallium
Draw.draw(Layer.blockBuilding, () -> {
Draw.color(Pal.accent, warmup);
Shaders.blockbuild.region = plan.unit.fullIcon;
Shaders.blockbuild.time = Time.time;
Shaders.blockbuild.alpha = warmup;
//margin due to units not taking up whole region
Shaders.blockbuild.progress = Mathf.clamp(progress + 0.05f);
Draw.rect(plan.unit.fullIcon, sx, sy, rotdeg() - 90f);
Draw.flush();
Draw.color();
Shaders.blockbuild.alpha = 1f;
});
Draw.reset();