Jump to content

Transparent Skin Rendering


Romejanic

Recommended Posts

Hello Everyone!

 

I am developing a mod and I making a mob that is semi-transparent. I used photoshop to make the skins semi-transparent. In the game, if the mob is in the nether, it is sometimes transparent. And is not transparent at all in the over world. Should I put some code in my rendering class? I was looking at GL11.glColor4f() and making the red, green and blue 1 with the alpha 0.5 but I think I put that code in the wrong method. Here is my render code:

 

package assets.bm.romejanic.client.render;

import assets.bm.romejanic.common.entity.EntityGhost;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelSkeleton;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.ForgeHooksClient;

import org.lwjgl.opengl.GL11;

@SideOnly(Side.CLIENT)
public class RenderGhost extends RenderBiped
{
private static final ResourceLocation[] textures = new ResourceLocation[] {

	new ResourceLocation(EntityGhost.getGhostTexture(0)),
	new ResourceLocation(EntityGhost.getGhostTexture(1))

};

public RenderGhost(ModelBiped model)
{
	super(model, 0.5F);
}

protected void func_82422_c()
{
	GL11.glTranslatef(0.09375F, 0.1875F, 0.0F);
}

protected ResourceLocation func_110860_a(EntityGhost ghost)
{
	return ghost.isAngry ? textures[1] : textures[0];
}

protected ResourceLocation func_110856_a(EntityLiving par1EntityLiving)
{
	return this.func_110860_a((EntityGhost)par1EntityLiving);
}

/**
 * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
 */
protected ResourceLocation getEntityTexture(Entity par1Entity)
{
	return this.func_110860_a((EntityGhost)par1Entity);
}

}

 

An I tried to put the GL11.glColor4f(1.0, 1.0, 1.0, 0.5); in the func_82422_c() method, but am I wrong?

 

Thanks!

Romejanic

Romejanic

 

Creator of Witch Hats, Explosive Chickens and Battlefield!

Link to comment
Share on other sites

Hi

 

I am just guessing because I have never tried this, but it might give you a couple of clues to try:

- I suspect that alpha blending might sometimes be turned off for rendering entities. 

 

You might need to write a custom renderer for your entity and turn the alpha blending back on

 

            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

            GL11.glEnable(GL11.GL_BLEND);

 

- see EntityRenderer.renderWorld() about halfway through.

 

-TGG

 

 

 

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.

Announcements



×
×
  • Create New...

Important Information

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