From c3ef81ff5ff040fae353bed13018bc3027888a0c Mon Sep 17 00:00:00 2001 From: elucent Date: Wed, 7 Dec 2016 07:56:17 -0500 Subject: [PATCH] Laser Rendering Improvements (#462) * Improved laser rendering. * Removed unused import. --- .../mod/proxy/ClientProxy.java | 2 +- .../actuallyadditions/mod/util/AssetUtil.java | 58 +++++++++++------- .../textures/items/item_canola_seed.png | Bin 258 -> 265 bytes .../item_misc_crystallized_canola_seed.png | Bin 256 -> 244 bytes .../items/item_misc_empowered_canola_seed.png | Bin 260 -> 264 bytes 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java index ec1d6aba8..8c8188297 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java @@ -44,7 +44,7 @@ public class ClientProxy implements IProxy{ private static final List COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING = new ArrayList(); private static final Map MODEL_LOCATIONS_FOR_REGISTERING = new HashMap(); - + @Override public void preInit(FMLPreInitializationEvent event){ ModUtil.LOGGER.info("PreInitializing ClientProxy..."); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java index 30c040989..fe31d50b3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java @@ -21,9 +21,12 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.client.renderer.GlStateManager.DestFactor; +import net.minecraft.client.renderer.GlStateManager.SourceFactor; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; @@ -35,6 +38,9 @@ import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.opengl.GL11; public final class AssetUtil{ + + public static int maxLightX = 0xF000F0; + public static int maxLightY = 0xF000F0; public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("gui_inventory"); @@ -233,7 +239,10 @@ public final class AssetUtil{ GlStateManager.disableLighting(); GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE); + int func = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC); + float ref = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF); + GlStateManager.alphaFunc(GL11.GL_ALWAYS, 0); GlStateManager.translate(firstX-TileEntityRendererDispatcher.staticPlayerX, firstY-TileEntityRendererDispatcher.staticPlayerY, firstZ-TileEntityRendererDispatcher.staticPlayerZ); GlStateManager.rotate((float)(180*yaw/Math.PI), 0, 1, 0); GlStateManager.rotate((float)(180*pitch/Math.PI), 0, 0, 1); @@ -286,31 +295,36 @@ public final class AssetUtil{ } else{*/ GlStateManager.disableTexture2D(); - render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); - render.pos(length, beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(0, beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(0, -beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(length, -beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); - - render.pos(length, -beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(0, -beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(0, beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(length, beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); - - render.pos(length, beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(0, beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(0, beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(length, beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); - - render.pos(length, -beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(0, -beamWidth, beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(0, -beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); - render.pos(length, -beamWidth, -beamWidth).color(r, g, b, alpha).endVertex(); + render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); + for (double i = 0; i < 4; i ++){ + double width = beamWidth * (i/4.0); + render.pos(length, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(0, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(0, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(length, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + + render.pos(length, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(0, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(0, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(length, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + + render.pos(length, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(0, width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(0, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(length, width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + + render.pos(length, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(0, -width, width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(0, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + render.pos(length, -width, -width).tex(0, 0).lightmap(maxLightX, maxLightY).color(r, g, b, alpha).endVertex(); + } tessy.draw(); - + GlStateManager.enableTexture2D(); //} + GlStateManager.alphaFunc(func, ref); + GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.popMatrix(); diff --git a/src/main/resources/assets/actuallyadditions/textures/items/item_canola_seed.png b/src/main/resources/assets/actuallyadditions/textures/items/item_canola_seed.png index f5773f3145e9d2db78ddd3cfa991788290bc4ad2..faa523a583a57ba4ba2046ffa32819bbcd1aa9f0 100644 GIT binary patch delta 237 zcmVz!>3E<0r@e@1%7O7~iEX@8400000NkvXXu0mjfx;|!t delta 230 zcmeBVYGRt8QqPj^=5?%K7Z zl2P%yy{GEI_(di`nM~`w>*Q2;HJ2(ru`JR#v-51cQ-G_>p?${=DLmG8a9q-;pdXz0 zZpE3O90EVO=R3>`e<@mE;{8crfuYWU>4sGcTt&CcvMu3Wvvt)0t{t3fc84^IGK9sm e^oagwJH)DF_gvF4#5x`57zR&QKbLh*2~7Z)HdF%u diff --git a/src/main/resources/assets/actuallyadditions/textures/items/item_misc_crystallized_canola_seed.png b/src/main/resources/assets/actuallyadditions/textures/items/item_misc_crystallized_canola_seed.png index 1e3408d11efea824fac3328c7238fc57e938f86b..74351c314f7944ff60d1d5539c82ef80dc91fc0f 100644 GIT binary patch delta 216 zcmV;}04M)|0`vipB!9a}L_t(Ijn$Gt3W87&hCfX~Xd!_ugm)t^;od8B7%$N|xZWrL^9CX(EuK-<3; zY(qHR;CL0mMPxBHi|5B(jUpX;pT+?GkUW?%+4f)};WVx%Hc^9NG04(%f%U6l9}1^= zCqD7-R4h`gPNgr;eY5WpQ2!hT|5}cn_ zQl40p%21G)nOCBhms+A=qGzCIXt0)x3#gi**3-o?#KM2=#DlyI1{|(88@k1X&5Ib; z-HSbVH`}4UdD)CvPM@kCeiqU&{4DV8jj`y{2)z@rQ#&MXySO^4g*P;vU_N*%WQuiG zu_Y7Bze(yFo`=@4%IHqAVaed({*c-wpApEqHjV#oQ^s1Y4yMee7kZ%rtPWSq8--Z+ c30g5;;(qbxj>58dpi3A$UHx3vIVCg!0M*h`CIA2c diff --git a/src/main/resources/assets/actuallyadditions/textures/items/item_misc_empowered_canola_seed.png b/src/main/resources/assets/actuallyadditions/textures/items/item_misc_empowered_canola_seed.png index 437ddd95564db44450f6020fbda6761b7a862bcc..3d80da3ca9c18e62e30c0a382f60793859b85cf8 100644 GIT binary patch delta 236 zcmVeQM*!CCZ*MZW;~hjI5!!s4zuEs zfZ#zTYDlph{gs11o0rDj*^Tb(W_H}SQM)qo{#*mtDY;L!5oIZOa+6WJQbXN6SxlzQ zs8G2=Lx7zMoeFD{0z86U#3%k26>C?j;G>`C)@+vqg8$rPgx~~Ef43E|DA0^2)9OG! mY3@|G=R| zDNig)Whh9@%q!8$OD$0_(KFC9G+4{U1ys$@=;`7ZV&T7bq9Ip<0gr2U>HBwTd42N^ zoaN@&`QKBE^PkYtiC)4Lv7bIGWO`_pDxMdder8VMV=b0Y7nL`K=Xi|vF^RZHacoOG zbw+lor92~3{YT*wpSAWf^`&{rF`4XQ{bA(Be?_AyYIAE^