Jump to content

Recommended Posts

Posted

Heyho Guys!

I need a few tips on rendering. I have several things I want to do and I want to know whether there is an easy solution to them, possibly a single method that I can call. Optionally also a self written method...

[*]Rendering a texture in a solidified way (like an Item)

[*]Rendering an IBakedModel

[*]Like 1, but with the enchantment effect on the texture. Also: overlaying a drawn face with the enchantment glint

[*]Rendering an .obj file

[*]Rendering an Item or Block like they are shown in a GUI (2D) but solidified (like 1). Not sure if this is even possible

 

I hope, some of you have got an idea how to do some of the things above!

 

-BM

Posted
  On 4/28/2015 at 6:16 PM, Bedrock_Miner said:

Heyho Guys!

I need a few tips on rendering. I have several things I want to do and I want to know whether there is an easy solution to them, possibly a single method that I can call. Optionally also a self written method...

[*]Rendering a texture in a solidified way (like an Item)

[*]Rendering an IBakedModel

[*]Like 1, but with the enchantment effect on the texture. Also: overlaying a drawn face with the enchantment glint

[*]Rendering an .obj file

[*]Rendering an Item or Block like they are shown in a GUI (2D) but solidified (like 1). Not sure if this is even possible

 

I hope, some of you have got an idea how to do some of the things above!

 

-BM

Hi

 

Those are all possible, 1 - 3 are quite easy with a bit of digging into the rendering code.  4 is possible if you port the 1.7.10 object model code (for use in a tessellator), I recall a post about this a few months ago - or use Blender or similar to convert your obj to B3D (which is now supported in Forge).

 

5 is also possible:

first part is to render your 3D model to a texture, second part is to convert the texture to an item with  "thickness".  This class does the first part (renders your 3D model to a flat texture) and the item generation will do the second bit.

https://github.com/TheGreyGhost/SpeedyTools/blob/master/src/main/java/speedytools/clientside/selections/SelectionBlockTextures.java

You would need to render from an oblique angle instead of looking directly at each face, but that's a simple rotation and scale.

 

Let me know if you have trouble tracking down 1 -3 , I am AFK for 10 hours but can look at it this evening.

 

-TGG

Posted

Hi

 

1: look in ItemModelGenerator.makeItemModel()

2: check out BlockModelRenderer

3: This link shows an example of custom layers for your item model

https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/mbe11_item_variants/Notes.txt

and this one talks a bit more about layers and about the enchantment "glint"

http://greyminecraftcoder.blogspot.com.au/2014/12/item-rendering-18.html

See also RenderItem.renderEffect()

 

-TGG

Posted

Oh, thanks that you researched that for me!

 

I don't have time to look at it right now, but I will do this the next days.

 

I just wanted to add another thing I might want to do, namely taking several textures, and baking them together dynamically. (Like the tools in Tinker's Construct). So I have a texture for, say a shovel, and another one for a bigger shovel handle and I want to overlay them to be used as one texture. Even better if this works with Alpha as well, so that you can see the texture of a texture even if its overlayed by a halfway transparent one.

Posted

With ICustomModelLoader and your own IBakedModel you can do this quite easily.

https://github.com/MinecraftForge/MinecraftForge/blob/master/src/test/java/net/minecraftforge/debug/ModelBakeEventDebug.java

or

https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/mbe05_block_smartblockmodel2/Notes.txt

 

You've got enough rendering challenges there to last you for quite a while I think :P

 

-TGG

 

 

Posted

I'll note that you might be able to get vanilla to render an item by creating an EntityItem and telling the rederer to render it.  (No need to spawn it in the world).

 

It'll have more overhead than some other solutions, but it's a straightforward way to get the existing systems to do what you want as long as you can supply the necessary object.  It's how I did it for a display case like block in 1.7.10 and I'd wager that it'd still work in 1.8, due to the ease of creating an EntityItem and the fact that such entities need to be independently rendered (like all entities).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

OK, so I experimented and here are my results:

 

1. The method TGG mentioned is basically a Generator for an IBakedModel, not a renderer for a simple texture solidified, so I decided to write my own method that renders the texture on the fly:

 

  Reveal hidden contents

With this method the rendering is pretty easy and the results are awesome.

  Reveal hidden contents


 

2. I dug a bit in the source code and found an easy method to render an IBakedModel. Unfortunately, is does not work for builtin/entity renderers, but I didn't expect that anyway.

 

  Reveal hidden contents

BTW, does anyone know why IBakedModel is deprecated?


 

3. I looked at RenderItem.renderEffect(), but I don't understand what it does. Mostly because the OpenGL constants are there as numbers, not as the constant names. Maybe someone could help me understanding how this works, this would help me a lot.


 

4. I found an example on Forge's B3D loader, but it didn't work well for me.

https://github.com/MinecraftForge/MinecraftForge/blob/master/src/test/java/net/minecraftforge/debug/ModelLoaderRegistryDebug.java

I created a B3D model which has an Animation (scaling up/down along the y axis). I applied this model to a block using the method in the example. My model was rendered wrong, namely 0.5 Blocks moved away along every axis and without texture. Also, I discovered that the animation does not work. Any ideas what I could have done wrong?

 

  Reveal hidden contents


 

5. Well, it's a fancy class in this GitHub repo, but I really don't understand how I use it and how this can help me with my problem.


 

I've not thought about 6 a lot, want to solve the others first.

Posted

Hi

 

1.  keen.

2.IBakedModel is deprecated because one of the forge team (Rainwarrior I think) wants you to use IFlexibleBakedModel instead.

/*

* Version of IBakedModel with less restriction on camera transformations and with explicit format of the baked array.

*/

Just ignore it unless you are trying to do fancy stuff with your models and you know what you're doing.

3. In order to figure out the OpenGL constants, you can do this-

a) Convert the number to hexadecimal

eg

        GlStateManager.depthFunc(514);

becomes

        GlStateManager.depthFunc(0x202);

b) Search the GL11 class for 0x202

--> GL_EQUAL = 0x202,

or

        GlStateManager.matrixMode(5890);

-->  GlStateManager.matrixMode(0x1702);

--> GlStateManager.matrixMode(GL_TEXTURE);

 

This methods renders the model again, but binding the "glint" texture, using an unusual blend mode and translating/rotating the texture in a time-dependent way to give it the moving glint appearance.

4. Sorry, had no experience with B3D, can't help there...

5. How I think you could solve your problem:

a) Render your 3D item or block as normal, but to a texture instead of to the screen.  You now have a flat 2D texture of your item/block that looks the same as when displayed in your inventory. 

b) You can then convert it into an "item with thickness" exactly the same as you did in 1)

The methods in that class in the repo show you how to do step a).  You will need to rotate the block to be oblique view instead of direct-on to a face like that class does.

 

-TGG

 

Posted

After a large bit of refactoring, I got the glint effect to work partially. After a bit more research on the glMatrixMode method, I finally understood what the method does and I changed it a bit so that it works in my favor.

I have now a pretty useful enchantment renderer. It has some restrictions, but it works fine.

 

  Reveal hidden contents

 

 

Still nothing new about the b3d thing, I think the guys from Forge are the only ones who know how it works.

Also, I understood how the SelectionBlockTextures thing works, at least the basics of it. I still don't quite know how to use it in order to render the "gui" state of the block onto a texture and use it afterwards. Best thing would be if I could just create an instance of a class with the block as an argument, it registers automatically as IResourceManagerReloadListener and provides methods to bind the generated texture to OpenGL.

Posted

I worked a bit with the SelectionBlockTextures thingy and was able to use it.  ;D

Then I decided to make it a bit more generic by providing a Renderer wrapped in a Runnable instead of a block. That's were I obviously messed up, because now I always get a completely black image.

I'll post my code here, hopefully anyone can tell me what I did wrong (maybe I miss some transformations before the rendering?)

 

  Reveal hidden contents

 

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.