opengl z-排序透明度 [英] opengl z-sorting transparency

查看:25
本文介绍了opengl z-排序透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 opengl es 2.0 中的简单正方形上渲染 png,但是当我尝试在正方形后面绘制一些东西时,我已经在顶部正方形中绘制了透明区域,渲染的颜色与背景相同.

im rendering png's on simple squares in opengl es 2.0, but when i try and draw something behind an square i have already drawn the transparent area in my top square are rendered the same color as the background.

我在每次渲染调用开始时调用它们.

I am calling these at the start of every render call.

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glEnable (GL_BLEND); 
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

推荐答案

你的标题本质上就是你问题的答案!

Your title is essentially the answer to your question!

一般来说,透明是通过首先渲染场景中的所有不透明对象(让 z-buffer 确定什么是可见的),然后从后到前渲染所有透明对象来实现的.

Generally transparency is done by first rendering all opaque objects in the scene (letting the z-buffer figure out what's visible), then rendering all transparent objects from back to front.

这篇关于opengl z-排序透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆