mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-20 04:37:31 +07:00
Shield shader simplification
This commit is contained in:
@ -6,9 +6,10 @@ precision highp int;
|
||||
#define MAX_HITS 64
|
||||
#define HIT_RADIUS 12.0
|
||||
#define ALPHA 0.18
|
||||
#define thickness 1.0
|
||||
#define step 2.0
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
uniform vec4 u_color;
|
||||
uniform vec2 u_texsize;
|
||||
uniform float u_time;
|
||||
uniform float u_scaling;
|
||||
@ -25,29 +26,19 @@ float round(float f){
|
||||
void main() {
|
||||
|
||||
vec2 T = v_texCoord.xy;
|
||||
|
||||
vec2 coords = (T * u_texsize) + u_offset;
|
||||
|
||||
T += vec2(sin(coords.y / 3.0 + u_time / 20.0) / 240.0, sin(coords.x / 3.0 + u_time / 20.0) / 240.0) * u_scaling;
|
||||
|
||||
float si = sin(u_time / 20.0) / 8.0;
|
||||
|
||||
vec4 color = texture2D(u_texture, T);
|
||||
|
||||
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
|
||||
|
||||
bool any = false;
|
||||
if(texture2D(u_texture, T).a < 0.1 &&
|
||||
(texture2D(u_texture, T + vec2(0, step) * v).a > 0.1 || texture2D(u_texture, T + vec2(0, -step) * v).a > 0.1 ||
|
||||
texture2D(u_texture, T + vec2(step, 0) * v).a > 0.1 || texture2D(u_texture, T + vec2(-step, 0) * v).a > 0.1)){
|
||||
|
||||
float thickness = 1.0;
|
||||
float step = 2.0;
|
||||
|
||||
if(texture2D(u_texture, T).a < 0.1 &&
|
||||
(texture2D(u_texture, T + vec2(0, step) * v).a > 0.1 || texture2D(u_texture, T + vec2(0, -step) * v).a > 0.1 ||
|
||||
texture2D(u_texture, T + vec2(step, 0) * v).a > 0.1 || texture2D(u_texture, T + vec2(-step, 0) * v).a > 0.1))
|
||||
any = true;
|
||||
|
||||
if(any){
|
||||
gl_FragColor = mix(u_color, vec4(1.0), si);
|
||||
gl_FragColor = mix(v_color, vec4(1.0), si);
|
||||
}else{
|
||||
|
||||
if(color.a > 0.1){
|
||||
|
@ -248,11 +248,12 @@ public class Renderer extends RendererModule{
|
||||
overlays.drawBottom();
|
||||
drawAndInterpolate(playerGroup, p -> true, Player::drawBuildRequests);
|
||||
|
||||
Shaders.shield.color.set(Palette.accent);
|
||||
Graphics.beginShaders(Shaders.shield);
|
||||
EntityDraw.draw(shieldGroup);
|
||||
EntityDraw.drawWith(shieldGroup, shield -> true, shield -> ((ShieldEntity)shield).drawOver());
|
||||
Draw.color(Palette.accent);
|
||||
Graphics.endShaders();
|
||||
Draw.color();
|
||||
|
||||
overlays.drawTop();
|
||||
|
||||
|
@ -3,7 +3,6 @@ package io.anuke.mindustry.graphics;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.FloatArray;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
@ -168,9 +167,7 @@ public class Shaders{
|
||||
}
|
||||
|
||||
public static class Shield extends Shader{
|
||||
public static final int MAX_HITS = 3 * 64;
|
||||
public Color color = new Color();
|
||||
public FloatArray hits = new FloatArray();
|
||||
//public Color color = new Color();
|
||||
|
||||
public Shield(){
|
||||
super("shield", "default");
|
||||
@ -179,12 +176,9 @@ public class Shaders{
|
||||
@Override
|
||||
public void apply(){
|
||||
float scaling = Core.cameraScale / 4f / Core.camera.zoom;
|
||||
if(hits.size > 0){
|
||||
shader.setUniform3fv("u_hits[0]", hits.items, 0, Math.min(hits.size, MAX_HITS));
|
||||
shader.setUniformi("u_hitamount", Math.min(hits.size, MAX_HITS) / 3);
|
||||
}
|
||||
|
||||
shader.setUniformf("u_dp", Unit.dp.scl(1f));
|
||||
shader.setUniformf("u_color", color);
|
||||
//shader.setUniformf("u_color", color);
|
||||
shader.setUniformf("u_time", Timers.time() / Unit.dp.scl(1f));
|
||||
shader.setUniformf("u_scaling", scaling);
|
||||
shader.setUniformf("u_offset",
|
||||
|
Reference in New Issue
Block a user