LibGdx GLES2.0立方体纹理像素拉伸 [英] LibGdx GLES2.0 cube texel stretching
问题描述
我已经几年编程在Windows / SDL OpenGL和我能够做相当多的先进的东西吧。
I've been programming OpenGL on Windows/SDL for a few years and am able to do quite a lot of advanced things with it.
我已经切换到Android和libgdx在过去的几天里试图把一个简单的演示起来,只是一个旋转的立方体。
I've switched over to Android and libgdx and over the past few days have tried to put a simple demo together, just a spinning cube.
使用libgdx的 ObjLoader
和网
类,我装在搅拌机出口(与法线和UV COORDS立方体网),并尝试应用纹理,并将其绘制一个立方体,但似乎只使用一个纹理像素从纹理以覆盖整个模型
Using libgdx's ObjLoader
and Mesh
classes, I loaded a cube mesh exported from blender(with normals and uv coords), and tried to apply a texture, and it draws a cube, but seems to only uses one texel from the texture to cover the whole model.
我仔细检查过的纹理坐标,甚至手$ C $光盘的具体坐标,以测试飞机,同样的事情正在发生。
I've double checked the texture coordinates and even hand coded a plane with specific coordinates to test, and the same thing is happening.
这是顶点着色器:
attribute vec4 a_position;
attribute vec3 a_normal;
attribute vec2 a_texCoord;
uniform mat4 mvp;
varying vec3 outNormal;
varying vec2 outTexcd;
void main(){
outNormal = a_normal;
outTexcd = a_texCoord;
gl_Position = mvp * a_position;
}
和片段着色器:
precision highp float;
varying vec3 outNormal;
varying vec2 outTexcd;
uniform sampler2D tex;
void main(){
vec3 norms = outNormal;
gl_FragColor = texture2D(tex,outTexcd);
}
但我不认为这是问题所在。或者,也许是这样,我不知道。
But I don't think that's where the problem lies. Or maybe it does, I'm not sure.
本来不想堵塞这个问题太多这样的主要来源是在这里(引擎收录):主要来源
Didn't want to clog up this question too much so the main source is here(pastebin): Main Source
如果这是一个不好的问题,请让我知道,这是我的第一个。
If this is a bad question please let me know, It's my first one.
推荐答案
与图片玩我找到了答案。
Playing with images I found the answer.
使用当时32位巴纽RGBA8888,但没有告诉libgdx这一点。
Was using a 32 bit .png RGBA8888, but not telling libgdx that.
切换到取图像RGBA8888的:
Switched to take in the image as RGBA8888:
T =新的纹理(Gdx.files.internal(图像/ r3.png),Format.RGBA8888,真实);
我稍感不好意思,对不起所有。
I feel slightly sheepish, sorry all.
编辑:
奇怪的是,没有透明度虽然...
Strangely, no transparency though...
这篇关于LibGdx GLES2.0立方体纹理像素拉伸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!