Jump to content

[Solved] [1.12.2] Optimized Client-Side structure rendering


Recommended Posts

Posted (edited)

Good day,

 

I've recently hit a wall playing around with the rendering hooks: 
Suppose you have a fairly large (~500) collection of BlockStates and want to render them as a preview in the client world only - calling

BlockRendererDispatcher.renderBlock(IBlockState, BlockPos, IBlockAccess, BufferBuilder)

this many times during a

RenderWorldLastEvent

works in a way, but doesn't seem like the way to go, especially concerning optimization. 
I've had a look at some alternatives, those used by the mod Schematica for instance. However before I look into extending from RenderGlobal with my limited understanding of the engine itself,

I was interested in whether I've missed any obvious / recommended ways to go about this, as I am sure this has been done many times before. ?


Any suggestions are welcome, thanks for your time.~

Edited by simicats
Posted

You can cache the BufferBuilder results by doing the same thing that RenderChunk does. I’ll write you some example code in a bit because it’s relatively complicated and I have lots of experience but the basic idea is:

1) Render your data to your own BufferBuilder

2) Render your BufferBuilder from the event

3) Update the BufferBuilder when your data changes 

  • Like 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

Hello Cadiboo and thanks for your response, I'm glad to have found an expert on the matter. =]

Caching a BufferBuilder sounds very reasonable, if you feel like leaving some code / reference: I'd be most interested in the general life cycle of said Buffer, from the size on creation to the render call in the event. 

Posted (edited)

Ideally you would do the block rebuilding off-thread or even multithreaded. I haven't done that in this example though.

https://gist.github.com/Cadiboo/753607e41ca4e2ca9e0ce3b928bab5ef

If you do multi-thread/off-thread your rebuilding, you will need to have proper thread safe code.

Edited by Cadiboo
  • Like 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.