Jump to content

Disable lighting for renderer/tesselator


Stalker

Recommended Posts

Hi,

 

I'm relatively new to MC modding, so I probably made some stupid mistakes there.

 

So here's my question:

 

I have a gun, that renders a muzzle flash (just a view aligned quad) when firing, which all works fine. The muzzle flash is affected by sky/world lighting, but I want it to be at full brightness at all times, just like the GUI or particles.

 

Right now my code is executed from the gun item's renderer (which probably isn't the best way to do it)

 

How can I tell the tesselator to ignore lighting? I have tried to disable gl_LIGHTING, or setting the tesselator's brightness but it didn't work.

 

Also, would it be better to do this in the GUI? If so, would it be possible to render this quad behind the gun model?

 

 

 

 


public void doRender(float progress, float offsetX, float offsetY, float offsetZ, float scale) {
	System.out.println("RenderMuzzleFlash");
	int currentFrame = (int)((float)numSprites*progress);
	if (currentFrame < numSprites) {
		int col = currentFrame % cols;
		int row = (currentFrame / cols);

		float u = 1.f/cols;
		float v = 1.f/rows;

		float U1 = col*u;
		float V1 = row*v;
		float U2 = (col+1)*u;
		float V2 = (row+1)*v;



		Minecraft.getMinecraft().getTextureManager().bindTexture(fxTexture);
		GL11.glPushMatrix();
		GL11.glTranslatef(0.f, 0.f, 0.f);
		GL11.glRotatef(0, 0, 0, 0);
		GL11.glScalef(scale, scale, scale);
		//GL11.glDisable(GL11.GL_DIFFUSE);
		//GL11.glDisable(GL11.GL_LIGHTING);
		Tessellator tessellator = Tessellator.instance;
		tessellator.startDrawingQuads();
            tessellator.addVertexWithUV(offsetX, offsetY, offsetZ+scale, (double)U1, (double)V1);
            tessellator.addVertexWithUV(offsetX+scale, offsetY, offsetZ+scale, (double)U2, (double)V1);
            tessellator.addVertexWithUV(offsetX+scale, offsetY, offsetZ, (double)U2, (double)V2);
            tessellator.addVertexWithUV(offsetX, offsetY, offsetZ, (double)U1, (double)V2);
                         
            //tessellator.setBrightness(15);
            //GL11.glColor3f(1, 1, 1);
            tessellator.setColorOpaque(255, 255, 255);
            
            tessellator.draw();
            //GL11.glEnable(GL11.GL_DIFFUSE);
            //GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glPopMatrix();
	}
}

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.