Posted June 23, 20169 yr Hello everybody! I'm trying to duplicate the standard cloud. Is the following code (90% vanila): private Minecraft mc = Minecraft.getMinecraft(); private TextureManager renderEngine; private WorldClient theWorld; private static final ResourceLocation locationCloudsPng = new ResourceLocation("mod:textures/environment/cloud.png"); @SideOnly(Side.CLIENT) @SubscribeEvent public void renderCloudEvent(RenderWorldLastEvent e) { layerCloudRender(e.partialTicks); } private void layerCloudRender(float partialTicks) { this.renderEngine = mc.getTextureManager(); this.theWorld = mc.theWorld; float p_72718_1_ = partialTicks; IRenderHandler renderer = null; if ((renderer = theWorld.provider.getCloudRenderer()) != null) { renderer.render(p_72718_1_, theWorld, mc); return; } if (this.mc.theWorld.provider.isSurfaceWorld()) { GL11.glDisable(GL11.GL_CULL_FACE); float f1 = (float)(this.mc.renderViewEntity.lastTickPosY + (this.mc.renderViewEntity.posY - this.mc.renderViewEntity.lastTickPosY) * (double)p_72718_1_); byte b0 = 32; int i = 256 / b0; Tessellator tessellator = Tessellator.instance; this.renderEngine.bindTexture(locationCloudsPng); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); Vec3 vec3 = this.theWorld.getCloudColour(p_72718_1_); float f2 = (float)vec3.xCoord; float f3 = (float)vec3.yCoord; float f4 = (float)vec3.zCoord; float f5; if (this.mc.gameSettings.anaglyph) { f5 = (f2 * 30.0F + f3 * 59.0F + f4 * 11.0F) / 100.0F; float f6 = (f2 * 30.0F + f3 * 70.0F) / 100.0F; float f7 = (f2 * 30.0F + f4 * 70.0F) / 100.0F; f2 = f5; f3 = f6; f4 = f7; } f5 = 4.8828125E-4F; double d2 = (double)((float)50 + p_72718_1_); double d0 = this.mc.renderViewEntity.prevPosX + (this.mc.renderViewEntity.posX - this.mc.renderViewEntity.prevPosX) * (double)p_72718_1_ + d2 * 0.029999999329447746D; double d1 = this.mc.renderViewEntity.prevPosZ + (this.mc.renderViewEntity.posZ - this.mc.renderViewEntity.prevPosZ) * (double)p_72718_1_; int j = MathHelper.floor_double(d0 / 2048.0D); int k = MathHelper.floor_double(d1 / 2048.0D); d0 -= (double)(j * 2048); d1 -= (double)(k * 2048); float f8 = this.theWorld.provider.getCloudHeight() - f1 - 16.33F; float f9 = (float)(d0 * (double)f5); float f10 = (float)(d1 * (double)f5); tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(f2, f3, f4, 0.8F); for (int l = -b0 * i; l < b0 * i; l += b0) { for (int i1 = -b0 * i; i1 < b0 * i; i1 += b0) { tessellator.addVertexWithUV((double)(l + 0), (double)f8, (double)(i1 + b0), (double)((float)(l + 0) * f5 + f9), (double)((float)(i1 + b0) * f5 + f10)); tessellator.addVertexWithUV((double)(l + b0), (double)f8, (double)(i1 + b0), (double)((float)(l + b0) * f5 + f9), (double)((float)(i1 + b0) * f5 + f10)); tessellator.addVertexWithUV((double)(l + b0), (double)f8, (double)(i1 + 0), (double)((float)(l + b0) * f5 + f9), (double)((float)(i1 + 0) * f5 + f10)); tessellator.addVertexWithUV((double)(l + 0), (double)f8, (double)(i1 + 0), (double)((float)(l + 0) * f5 + f9), (double)((float)(i1 + 0) * f5 + f10)); } } tessellator.draw(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_CULL_FACE); } } However, my cloud do not disappear in the distance. Moreover, translucent blocks in the foreground are not visible. The picture shows the both problems: How can I fix it? Sorry, I don't speak English very well...
June 25, 20169 yr You can't render it on RenderWorldLastEvent, because it is one of the farthest objects in the world, next to the sky. So you should render it on IRenderHandler and register it using WorldProvider#setCloudRenderer. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
June 25, 20169 yr Author Yes, I tried it. But the glass blocks are still not visible. But I've been thinking. Water and colored glass using renderPass = 1 and they can see through each other. How can I render a transparent plane (my clouds) using a renderPass = 1? Sorry, I don't speak English very well...
June 26, 20169 yr No, you can't use them. They are sorted correctly on rendering, thus have no problem. What is the exact problem do you have with WorldProvider#setCloudRenderer? That should not hide any transparent blocks Show what you have tried with it in code. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
June 26, 20169 yr Author My problem is that the horizon line is at a height of 160. Duplicated clouds are located under your feet, at a height of about 140. At this height clouds transparency settings are changed and the clouds become transparent. You can check it yourself. Under such conditions, a translucent blocks are not visible. This happens if the use WorldProvider#setCloudRenderer or RenderWorldLastEvent. However, if you use DrawBlockHighlightEvent, for example, transparent blocks before clouds become visible, but they disappear behind the clouds. My code: @SideOnly(Side.CLIENT) @SubscribeEvent public void renderEvent(DrawBlockHighlightEvent e) { World world = this.mc.thePlayer.worldObj; if (world.isRemote && world.provider.dimensionId == CommonProxy.dimensionId) { cloudRender(e.partialTicks, (WorldClient)world, this.mc); } } public static void cloudRender(float partialTicks, WorldClient world, Minecraft mc) { float playerHeight = (float)(mc.renderViewEntity.lastTickPosY + (mc.renderViewEntity.posY - mc.renderViewEntity.lastTickPosY) * (double)partialTicks); byte i = 4; int r = mc.gameSettings.renderDistanceChunks * 16; int e = r / i; int d = r * 2; Tessellator tessellator = Tessellator.instance; Last Edit: Yesterday at 04:35:53 pm mc.getTextureManager().bindTexture(locationCloudPng); GL11.glEnable(GL11.GL_BLEND); GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F); GL11.glEnable(GL11.GL_FOG); OpenGlHelper.glBlendFunc(770, 771, 1, 0); Vec3 vec3 = world.getCloudColour(partialTicks); float f2 = (float)vec3.xCoord; float f3 = (float)vec3.yCoord; float f4 = (float)vec3.zCoord; float colorOffset = 0.64F; float height = 140; tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(f2 + colorOffset, f3 + colorOffset, f4 + colorOffset, 0.05F); for (int x = -e * i; x < e * i; x += e) { for (int y = -e * i; y < e * i; y += e) { tessellator.addVertexWithUV(x, height, y, (float)(r+y)/d, (float)(r-x)/d); tessellator.addVertexWithUV(x, height, y+e, (float)(r+y+e)/d, (float)(r-x)/d); tessellator.addVertexWithUV(x+e, height, y+e, (float)(r+y+e)/d, (float)(r-x-e)/d); tessellator.addVertexWithUV(x+e, height, y, (float)(r+y)/d, (float)(r-x-e)/d); } } tessellator.draw(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_FOG); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glDisable(GL11.GL_BLEND); } Sorry, I don't speak English very well...
June 27, 20169 yr Well, you didnt post the code you used with setCloudRenderer. Also, you should try to understand vanilla cloud code before just copying it. GL state can be different on each methods. What is your goal with this? If you are just simulating vanilla clouds. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
June 27, 20169 yr Author You're right, my goal is not clouds. Sorry if I express myself is not clear. I need to render a translucent plane under the player's feet. The plane should be visible regardless of the clouds ON/OFF settings. That's why I do not use the WorldProvider#setCloudRenderer. Could you tell me about the GL states? Maybe it will help me to implement its plans. Sorry, I don't speak English very well...
June 29, 20169 yr First, the cloud disappears when it is far enough from the player. (This phenomenon is caused by z-clipping) So the closer its vertical position to the player, the further its visible edge goes. The GL state related with this concept is Depth Test and Depth Mask. Google is your friend: [lmgtfy]Depth Test and Depth Mask[/lmgtfy] They might be disabled on RenderWorldLastEvent, test for it. Also, note that cloud is rendered twice, before world rendering and after world rendering. You can simulate latter by RenderWorldLastEvent, but there is no event fired before world rendering. So World#setCloudRenderer migh be the only possibility. Look at EntityRenderer#renderWorldPass for more information. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.