我一直在试图找出如何使用的OpenGL ES 2.0的2D。到目前为止,我觉得我对大多数事情的句柄。但是,我还没有想出的一件事是做什么的着色器?
I've been trying to figure out how to use OpenGL ES 2.0 for 2D. So far I think I have a handle on most things. But the one thing that I haven't figured out is what to do for the shaders?
据我所知,你设置摄像机/视图和着色器的灯光,但我不希望阴影或任何种类的灯光标志。基本上,我只是想在屏幕上移动精灵,并有精灵看起来完全一样,他们没有当我画他们在Photoshop。
I understand that you set up the camera/view and the lights in the shader, but I don't want shadows or any kind of sign of lighting. Basically I just want to move sprites around the screen and have the sprites look exactly like they did when I drew them in photoshop.
任何人都有一个着色器,将做到这一点的例子吗?或者,也许是谈论这个的文章?
Anyone have an example of a shader that would do this? Or maybe an article that talks about this?
我已经发现有很多的OpenGL的3D开销试图让一个纯粹的2D程序时,但显然这是在Android上唯一可行的选择。
I already find that there's a lot of 3d overhead in OpenGL when trying to make a purely 2D program, but apparently it's the only viable option on Android.
我做了一个2D视频游戏,这些都是我所使用的着色器。两个很简单的着色器。这是你要求的?
I made a 2D videogame and these are the shaders I used. Two very simple shaders. Is this what you asking for?
**VERTEX_SHADER_2D =**
attribute vec4 position;
attribute vec2 textureCoordIn;
varying vec2 vTextureCoordOut;
uniform mediump mat4 modelViewMatrix;
void main()
{
gl_Position = modelViewMatrix * position;
vTextureCoordOut = textureCoordIn;
}
**FRAGMENT_SHADER_2D =**
varying mediump vec2 vTextureCoordOut;
uniform sampler2D sampler;
void main()
{
gl_FragColor = texture2D(sampler, vTextureCoordOut);
}
上一篇:如何做到这一点的坐标系统运行更有效率?这一点、更有、坐标、效率
下一篇:针对 swagger 文件验证 json 有效负载 - json-schema-validator负载、有效、文件、swagger