什么样的着色器的2D游戏(即超级马里奥) [英] What kind of shader for 2D games (ie. Super Mario)

查看:149
本文介绍了什么样的着色器的2D游戏(即超级马里奥)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图找出如何使用的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);
      }

这篇关于什么样的着色器的2D游戏(即超级马里奥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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