[英]How to flex a 3D texture with OpenGL ES?
I have tried to draw some 3D squares (with OpenGL on iPhone) and make them rotate around, now they look like a sphere. 我尝试绘制一些3D正方形(在iPhone上使用OpenGL)并使其旋转,现在它们看起来像一个球体。
http://i618.photobucket.com/albums/tt265/LoyalMoral/Post/ScreenShot2013-05-15at23249PM.png http://i618.photobucket.com/albums/tt265/LoyalMoral/Post/ScreenShot2013-05-15at23249PM.png
But the square is flat (the first one on image below), and I want to flex it: 但是正方形是平坦的(下图中的第一个),我想弯曲它:
http://i618.photobucket.com/albums/tt265/LoyalMoral/Post/Untitled-1.jpg http://i618.photobucket.com/albums/tt265/LoyalMoral/Post/Untitled-1.jpg
someone told me that I have to use glsl, but I don't know shading language. 有人告诉我,我必须使用glsl,但是我不懂着色语言。
this is my vertex and fragment (follow Ray Wenderlich's tutorial): 这是我的顶点和片段(遵循Ray Wenderlich的教程):
// Vertex.glsl
attribute vec4 Position;
attribute vec4 SourceColor;
varying vec4 DestinationColor;
uniform mat4 Projection;
uniform mat4 Modelview;
attribute vec2 TexCoordIn;
varying vec2 TexCoordOut;
void main(void) {
DestinationColor = SourceColor;
gl_Position = Projection * Modelview * Position;
TexCoordOut = TexCoordIn;
}
// Fragment.glsl
varying lowp vec4 DestinationColor;
varying lowp vec2 TexCoordOut;
uniform sampler2D Texture;
void main(void) {
gl_FragColor = DestinationColor * texture2D(Texture, TexCoordOut);
}
could somebody help me? 有人可以帮我吗? :)
:)
Instead of using a quad (pair of triangles) for a square use a grid for it. 代替对正方形使用四边形(成对的三角形),请使用网格。 Thus you will be able to place vertices of the grid manually resulting in the shape you want.
因此,您将能够手动放置网格的顶点,从而得到所需的形状。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.