Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED] [1.12.2] Rendering Glitches
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 2
SerpentDagger

[SOLVED] [1.12.2] Rendering Glitches

By SerpentDagger, October 26 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

SerpentDagger    15

SerpentDagger

SerpentDagger    15

  • Creeper Killer
  • SerpentDagger
  • Members
  • 15
  • 124 posts
Posted October 26 (edited)

I've been working on a 3D graphing calculator, and have run into a couple undesirable rendering effects.

 

The first is that where the graph should be visible behind itself, only from one side is that the case, as shown below.

This seems like there's some GlStateManager setting involved, but I don't know what that would be. Currently, my settings are those of the FastTESR, so I can't change GlStateManager settings without also switching to a normal TESR. Or I could set up my own batching system with the proper settings. If there's a way around this problem without doing either of those things, though, that would be great.

2019-10-26_14_23_21.thumb.png.979c92da99debe7da15540e2fe7d36b1.png2019-10-26_14_23_33.thumb.png.4dd7587a7bfe4f6a7ad806428fbc494c.png


The second is that the graph will not be rendered if its block is not within the frustum, or at least sometimes it won't. At first, it would never render if the player couldn't see the block, but having returned the infinite bounding box from TileEntity#getRenderBoundingBox(), it's improved a little. Now it seems that if I look a large enough angle away, the block stops being rendered, as opposed to looking even slightly away. This is shown below, with a stone block for reference.

2019-10-26_14_27_22.thumb.png.81db44615ee2bf118b2ff566b826f15d.png2019-10-26_14_27_25.thumb.png.87f0744c5f3141b9174cb6554252d64e.png

 

If someone could help with either of these issues, that would be fantastic.

 

FastTESR:

Spoiler

package graphingcalculator3d.client;

import graphingcalculator3d.common.gameplay.tile.TileGCCartesian;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.client.model.animation.FastTESR;

public class MeshRender extends FastTESR<TileGCCartesian>
{
	Vec3d[][] vArray;
	boolean[][] disconnects;
	
	@Override
	public void renderTileEntityFast(TileGCCartesian te, double x, double y, double z, float partialTicks,
			int destroyStage, float partial, BufferBuilder buffer)
	{
		if (te.isErrored())
			return;
		if (!te.renderReady)
			return;
		vArray = te.getVertexArray();
		if (vArray == null)
			return;
		disconnects = te.disconnects;
		if (disconnects == null)
			return;
		int[] rgba = new int[]
		{ 100, 100, 100, 100 };
		int lightmap = 220;
		
		for (int j = 0; j + 1 < vArray.length; j++)
		{
			for (int k = 0; k + 1 < vArray[j].length; k++)
			{
				if (disconnects[j][k])
					continue;
				buffer.pos(x + 0.5 + vArray[j][k].x, y + 0.5 + vArray[j][k].y, z + 0.5 + vArray[j][k].z)
						.color(rgba[0], rgba[1], rgba[2], rgba[3]).tex(0, 0.05).lightmap(lightmap, lightmap).endVertex();
				buffer.pos(x + 0.5 + vArray[j + 1][k].x, y + 0.5 + vArray[j + 1][k].y, z + 0.5 + vArray[j + 1][k].z)
						.color(rgba[0], rgba[1], rgba[2], rgba[3]).tex(0, 0.05).lightmap(lightmap, lightmap).endVertex();
				buffer.pos(x + 0.5 + vArray[j + 1][k + 1].x, y + 0.5 + vArray[j + 1][k + 1].y, z + 0.5 + vArray[j + 1][k + 1].z)
						.color(rgba[0], rgba[1], rgba[2], rgba[3]).tex(0, 0.05).lightmap(lightmap, lightmap).endVertex();
				buffer.pos(x + 0.5 + vArray[j][k + 1].x, y + 0.5 + vArray[j][k + 1].y, z + 0.5 + vArray[j][k + 1].z)
						.color(rgba[0], rgba[1], rgba[2], rgba[3]).tex(0, 0.05).lightmap(lightmap, lightmap).endVertex();
			}
		}
	}
}

 

Bounding Box code:

Spoiler

	@SideOnly(Side.CLIENT)
	@Override
	public AxisAlignedBB getRenderBoundingBox()
	{
		return INFINITE_EXTENT_AABB;
	}

 

 

Edited November 14 by SerpentDagger
  • Quote

Share this post


Link to post
Share on other sites

SerpentDagger    15

SerpentDagger

SerpentDagger    15

  • Creeper Killer
  • SerpentDagger
  • Members
  • 15
  • 124 posts
Posted October 27

As some additional information, the "translucent" graph also eclipses blocks like stained glass and ice, as well as portions of the graph that have higher opacity.

2019-10-26_19_59_31.thumb.png.7eba65f8393763e2de219f1b78138320.png

2019-10-26_20_03_56.thumb.png.3e33548863cb170fe5a232dbb4999a88.png2019-10-26_20_04_06.thumb.png.9e2395882f785841a422c80a07b6b06f.png

  • Quote

Share this post


Link to post
Share on other sites

SerpentDagger    15

SerpentDagger

SerpentDagger    15

  • Creeper Killer
  • SerpentDagger
  • Members
  • 15
  • 124 posts
Posted October 30

Neither of these glitches is too awful, but with the rest of the mod shaping up to be pretty neat, I'd really like for them to be resolved.

 

Perhaps no one knows the root of the transparency issue, but I don't think this happens with ice and glass, so there must be some way of doing it. Might anyone be able to point me towards the code that renders blocks like this? I've looked around myself, of course, but the rendering devolves into a gigantic sprawling maze of work, and it's difficult to pinpoint anything in particular.

 

As for the only-renders-when-you're-looking-at-it thing, I may be wrong in thinking it, but that seems like something that should be really easy to fix if I just know what to do about it. If no one knows the solution to that, is there an open source mod that has the same system? Surely I'm not the only one with the situation of rendering something bigger than a block with a FastTESR.

  • Quote

Share this post


Link to post
Share on other sites

Toma™    7

Toma™

Toma™    7

  • Stone Miner
  • Toma™
  • Members
  • 7
  • 74 posts
Posted November 1

There's TileEntitySpecialRenderer#isGlobalRenderer method. Minecraft uses that for rendering beacons, maybe it could help you with your issue with the rendering outside frustrum

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

SerpentDagger    15

SerpentDagger

SerpentDagger    15

  • Creeper Killer
  • SerpentDagger
  • Members
  • 15
  • 124 posts
Posted November 1

Fabulous! That was it, the frustum check is now properly ignored. Thanks a bunch. Having played around with it for a while now, that was definitely the major issue of the two, so having it fixed is a huge improvement.

  • Quote

Share this post


Link to post
Share on other sites

SerpentDagger    15

SerpentDagger

SerpentDagger    15

  • Creeper Killer
  • SerpentDagger
  • Members
  • 15
  • 124 posts
Posted November 14

After scouring the rendering code, I found that the problem was because the vertices weren't sorted in relation to the player's view, and that I could return true from TileEntity#shouldRenderInPass() during pass #1 instead of pass #0 to opt-in to the vertex sorting. The transparency now works perfectly.

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • saxon564
      [1.14.4] [UNSOLVED] Server Thread Freezes After Entity Explodes

      By saxon564 · Posted 7 minutes ago

      Does anyone else have any thoughts as to what might be causing this issue?
    • diesieben07
      [1.12.2] How can I close GUI in Forge?

      By diesieben07 · Posted 18 minutes ago

      You cannot call Minecraft methods from a separate thread. You need to wait a tick using ClientTickEvent.
    • bismuth210
      [1.12.2] Killing fireworks in unloaded chunks

      By bismuth210 · Posted 33 minutes ago

      I'm creating a custom gamemode using forge in which players get teleported around regularly. I've run into a problem when I do the following:   I spawn a firework rocket near a player I teleport the player to a different location I wait a couple of seconds (or minutes) I teleport the player back to the same location as in step 1. Doing this will show the firework spawned in step 1 in step 4, despite significant time having passed in 3. This video shows what I mean:   I suspect the reason for why this happens is because once I teleport the player somewhere else, the chunk with the firework is no longer loaded and doesn't get updated.   Is there a simple way for me to simply "get rid" of all active fireworks shortly before teleporting players so that this doesn't occur? Or do I really have to forcibly keep all chunks loaded? To be more clear: I don't want to disable fireworks all together, but I don't want remnants of old fireworks showing up when I teleport players. "Killing" all firework rockets when I teleport a player would work fine, but I don't know if/how I can do that.   I've tried using /kill @e[type=!player] But that doesn't work for firework rockets apparently.
    • RunKeish
      Forge 14.4 crashes on statup

      By RunKeish · Posted 33 minutes ago

      It finally worked! Thankyou so much. The installation was dodgy for me so I had to download JDK8 using:       ~$ sudo apt install openjdk-8-jdk openjdk-8-jre   Followed by:     ~$ update-java-alternatives --config java   Then select the java-8-openjdk-amd64/jre/bin/java from the list (to make java 8 the default, can switch and whatever but it works!!!)   Thanks a tonne!
    • Filip4223
      [1.12.2] How can I close GUI in Forge?

      By Filip4223 · Posted 44 minutes ago

      OK, it works.Tthanks.     I wonder is there better way for doing it instead of creating new thread?    System.out.println("Turning off"); Thread thread = new Thread(new CloseGui()); thread.start(); //CloseGui class public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("closing"); Minecraft.getMinecraft().player.closeScreen(); }  
  • Topics

    • saxon564
      12
      [1.14.4] [UNSOLVED] Server Thread Freezes After Entity Explodes

      By saxon564
      Started Friday at 05:11 AM

    • Filip4223
      5
      [1.12.2] How can I close GUI in Forge?

      By Filip4223
      Started 1 hour ago

    • bismuth210
      0
      [1.12.2] Killing fireworks in unloaded chunks

      By bismuth210
      Started 33 minutes ago

    • RunKeish
      4
      Forge 14.4 crashes on statup

      By RunKeish
      Started 2 hours ago

    • Differentiation
      12
      [SOLVED] [1.12.2] Modifying player capabilities for offline players?

      By Differentiation
      Started 9 hours ago

  • Who's Online (See full list)

    • diesieben07
    • bismuth210
    • imacatlolol
    • Kangoro
    • AkosM
    • saxon564
    • plugsmustard
    • RunKeish
    • Filip4223
    • alox
    • DavidM
    • geduardcatalindev
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED] [1.12.2] Rendering Glitches
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community