fogleman / Minecraft

Simple Minecraft-inspired program using Python and Pyglet
MIT License
5.22k stars 1.23k forks source link

How can I display translucent block from texture in this program like glass or leaves? #103

Closed ghost closed 5 years ago

ghost commented 5 years ago

Maybe something to do with texture picture format?

ghost commented 5 years ago

I'm using texture.png and it's not working...

uuk0 commented 5 years ago

You must configuration opengl for using alpha values

ghost commented 5 years ago

Thank you, but can you show me the code to do it?

ghost commented 5 years ago

Oh I mean the blocks are not showing all the pixels, and it turns out to be black in that part.

uuk0 commented 5 years ago

I think this should work glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

(for example past this code in the setup() function)

ghost commented 5 years ago

I'll try that

ghost commented 5 years ago

It worked!

ghost commented 5 years ago

Thank you!

ghost commented 5 years ago

webwxgetmsgimgWeird.

ghost commented 5 years ago

I think I should add something called depth test I guess

ghost commented 5 years ago

Oh I just didn't disable the hide block surface of these block

ghost commented 5 years ago

I'll fix that

uuk0 commented 5 years ago

There may be also another bug that translucent blocks 2 Or More Blocks apart will disable rendering the block behind another

ghost commented 5 years ago

Yeah, I notice that.

uuk0 commented 5 years ago

There may be also another bug that translucent blocks 2 Or More Blocks apart will disable rendering the block behind another

ghost commented 5 years ago

Some blocks displayed after the translucent block will not show behind it

ghost commented 5 years ago

But that also mean if I display the translucent block after the full blocks, there'll still problems between translucent blocks.

uuk0 commented 5 years ago

One part (normal behind transparent) can be fixed by using separated batches one for alpha textures and one for non-alpha, for the other I have no clue how to fix it

ghost commented 5 years ago

ok