Jump to content

Item texture splicing


redria7

Recommended Posts

I am currently working on a new item that will be related to a vanilla item. I want to make around 50 of my new item for about 50 vanilla blocks, then I want to have 3 levels of each of my item, making around 150 total new items that I am adding.

 

With this, I want to have a frame and a background relating to my item, then fill in the rest of the texture with the vanilla item texture that it is related to. So for the one relating to cobblestone, it would have my frame, and inside the frame the texture would be filled with that portion of the cobblestone texture.

 

One way to make these textures work is to make 150 textures, one for each of my items.

The way I would like to do it is to make 3 frame textures: one for each level I plan to have, then cut out the appropriate filling from the related vanilla block and layer it over top of my textures. So with the cobblestone example, I would have my frame texture, then this process I want would take the center portion of the cobblestone texture and visually paste it on top of my own texture.

This would greatly cut down on the amount of icons I would need to make and store to have this item display the way I want.

 

Has anyone done something like this or know how I might try to approach it?

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Link to comment
Share on other sites

I've been doing something similar, but the way I did it was to yoink the relevant block texture, render it, then render a second quad with my overlay on it, a very tiny fraction of a pixel above* the first quad.  Just enough offset so there's no z-fighting, but too small to see.  1F/256 is good.

 

I have, however, been having a devil of a time getting block brightness to be calculated correctly.  Think I thought of a solution, and that's a faux block that gets rendered using the normal renderer after rendering the base material block in the same manner.

 

*relative to the block face

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.

Link to comment
Share on other sites

Believe me, I can render blocks in the world. I have a blast playing with that and I have some models that I specifically designed to make a viewer uncomfortable and I have a hard time looking at them myself even without finalized textures - which is exactly what I wanted.

 

My problem is item rendering, in the hand and in the inventory. I just want a 2d panel like most items have where the texture is mixed. So I probably need to know how to set up a custom rendering for an item (I know how to do one for a block, which includes holding it hand, but I don't know how for an item) or I need to find a different way of layering the texture.

I don't know if it would be a bigger hit on overall performance to just have an extra 150 textures, or to go through the extra processing to draw in custom rendering of a couple textures

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Link to comment
Share on other sites

My problem is item rendering, in the hand and in the inventory. I just want a 2d panel like most items have where the texture is mixed.

 

Ahhh.

Yeah, I was having that problem too, and rather than doing quads like in the world I created a fake block and told the renderer to render that instead (which is what I'm thinking about doing to get things in-world too, in order to fix the lighting issue).

 

Might be a tad trickier on your end though, I only had two textures to deal with: while my block will camouflage itself when placed, I just used a fixed texture for the inventory render.  Picked a block, pulled the original texture, applied the overlay, saved as an icon, registered it with the fake block.

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.

Link to comment
Share on other sites

HA!

public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	int wid = world.getBlockId(x, y, z);
	renderer.renderBlockByRenderType(Block.blocksList[wid], x, y, z);
	renderer.renderBlockUsingTexture(Block.blocksList[wid], x, y, z, block.getIcon(0, 0));
	return false;
}

 

And there's no z-fighting.  I have no idea why.  But it totally works.

 

The only downside is that the "overlay" texture can't be partially transparent.  It'll get rendered as binary transparency (each pixel is either fully solid or fully transparent).  No idea why.

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.

Link to comment
Share on other sites

The only downside is that the "overlay" texture can't be partially transparent.  It'll get rendered as binary transparency (each pixel is either fully solid or fully transparent).  No idea why.

 

glEnable(GL_BLEND)

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

renderOverlay(...)

glDisable(GL_BLEND)

 

This should work (warning: pseudocode)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

glEnable(GL_BLEND)

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

renderOverlay(...)

glDisable(GL_BLEND)

 

This should work (warning: pseudocode)

 

Didn't help.

(And yes, I converted it to proper code).

 

Keep in mind this is how I'm doing it:

 

renderer.renderBlockUsingTexture(Block.stone, x, y, z, camo);
switch(metadata) {
		case 0:
			renderer.renderFaceYNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, self);
[...etc...]
}

 

Where camo is the block icon of the block adjacent to my block (checks for nulls, self, etc. with a fallback default) and self is my block's own icon (the overlay texture).

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.

Link to comment
Share on other sites

hm, can I see your code with my answer included?

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

renderer.renderBlockUsingTexture(Block.stone, x, y, z, camo);
[code]GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
switch(metadata) {
		case 0:
			renderer.renderFaceYNeg(Block.blocksList[wid], (double)x, (double)y, (double)z, self);
[...etc...]
}
GL11.glDisable(GL11.GL_BLEND);

 

In any case, I figured out what my problem was:

 

return false

 

Go go auto-constructed code supplying a return type where what that returned boolean does is undocumented (roughly speaking if the return is false, the game stops rendering stuff because it thinks its done).

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.

Link to comment
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.
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.



×
×
  • Create New...

Important Information

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