Mana Pool shader.

This commit is contained in:
Vasco Lavos committed 2014-04-10 16:33:26 +01:00
1 parent f06d08564d
commit ded0167eff
5 files changed
+20 -2

No files matched your search

@@ -36,6 +36,7 @@ public final class ShaderHelper {
public static int pylonGlow = 0;
public static int enchanterRune = 0;
public static int manaPool = 0;
public static void initShaders() {
if(!useShaders())
@@ -43,6 +44,7 @@ public final class ShaderHelper {
pylonGlow = createProgram(null, LibResources.SHADER_PYLON_GLOW_FRAG);
enchanterRune = createProgram(null, LibResources.SHADER_ENCHANTER_RUNE_FRAG);
manaPool = createProgram(null, LibResources.SHADER_MANA_POOL_FRAG);
}
public static void useShader(int shader) {
@@ -61,7 +63,6 @@ public final class ShaderHelper {
useShader(0);
}
public static boolean useShaders() {
return ConfigHandler.useShaders && OpenGlHelper.shadersSupported;
}
@@ -59,6 +59,7 @@ public final class LibResources {
public static final String SHADER_PYLON_GLOW_FRAG = PREFIX_SHADER + "pylon_glow.frag";
public static final String SHADER_ENCHANTER_RUNE_FRAG = PREFIX_SHADER + "enchanter_rune.frag";
public static final String SHADER_MANA_POOL_FRAG = PREFIX_SHADER + "mana_pool.frag";
public static final String[] LANGS = new String[] {
"en_US", "de_DE"
@@ -24,6 +24,7 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.model.ModelPool;
import vazkii.botania.common.block.tile.TilePool;
@@ -79,7 +80,10 @@ public class RenderTilePool extends TileEntitySpecialRenderer {
tessellator.addVertexWithUV(par1 + par4, par2 + par5, zLevel, par3Icon.getMaxU(), par3Icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + 0, zLevel, par3Icon.getMaxU(), par3Icon.getMinV());
tessellator.addVertexWithUV(par1 + 0, par2 + 0, zLevel, par3Icon.getMinU(), par3Icon.getMinV());
ShaderHelper.useShader(ShaderHelper.manaPool);
tessellator.draw();
ShaderHelper.releaseShader();
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
@@ -131,7 +131,7 @@ public class TilePool extends TileMod implements IManaPool {
if(worldObj.isRemote) {
double particleChance = 1F - (double) getCurrentMana() / (double) MAX_MANA * 0.1;
Color color = new Color(0x00C6FF);
if(Math.random() > particleChance)
if(Math.random() > particleChance);
Botania.proxy.wispFX(worldObj, xCoord + 0.3 + Math.random() * 0.5, yCoord + 0.6 + Math.random() * 0.25, zCoord + Math.random(), color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random() / 3F, (float) -Math.random() / 25F);
}
@@ -0,0 +1,12 @@
uniform sampler2D bgl_RenderedTexture;
uniform int time; // Passed in, see ShaderHelper.java
void main() {
vec2 texcoord = vec2(gl_TexCoord[0]);
vec4 color = texture2D(bgl_RenderedTexture, texcoord);
float c = sin(time / 80.0 + sin(texcoord.x / 5 + (texcoord.y - cos(time / 300.0) * 0.25) / ((1 - sin(time / 200.0) / 10.0) * 5)) * sin(time / 600.0) * 1000) * 0.5 + 0.5;
float g = c * 0.2 + 0.1;
float b = 1 - c * 0.2 - 0.2;
gl_FragColor = vec4(0, g, b, color.a);
}