Jump to content

[1.10.2] Add shading to a cube from VertexBuffer quads


Recommended Posts

Posted

This is how I render my cube:

 

         worldRendererIn.setTranslation(f5, f6, f7);

         for (int vertex = 0; vertex < 24; vertex++)
        {
            worldRendererIn.pos(rotatedCubeVectors[vertex][0], rotatedCubeVectors[vertex][1], rotatedCubeVectors[vertex][2])
                    .tex(params[vertex][0], params[vertex][1])
                    .color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j, k)
                    .endVertex();
        }

        worldRendererIn.setTranslation(0, 0, 0);

 

I basically draw the vanilla digging particle with my own rotation 6 times (so it's a cube). As you know, the vanilla digging particles have no shading or smooth lighting, it's just true color.

 

so how can I add this shading to a VertexBuffer quad?

 

Somebody told me that I can use VertexBuffer.normal(), but no matter what numbers I pass it, it makes the particles dance around (like if it was doing VertexBuffer.setTranslation()). There's also some kind of black ray flashing in the game...

 

EDIT:

 

Here you have an example of what I'm trying to achieve(the particle texture is darkening on the sides of the cube):

Posted

Hi

 

normal only works if the item lighting (opengl light sources) are on, and even then it can be hard to get right.

 

I think the easiest way is just to change the color for different faces, i.e. for example

.color(this.particleRed * faceGrey, this.particleGreen * faceGrey, this.particleBlue * faceGrey, this.particleAlpha).lightmap(j, k)

where faceGrey = (say) 0.8 for north and south, 0.6 for east and west, 1.0 for up, 0.5 for down

 

Some more info here

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

 

-TGG

 

 

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.