我不明白为什么在构建时将这个简单的着色器设置为导入的网格(.obj 网格)时出现错误,我得到的错误是:“着色器中没有名称为 'diffuseTexture' 的统一”
问题是,我现在不想使用纹理,出于学习目的,我想从有一个红色网格开始,然后从那里一步一步地......
这里还有一些代码:
ObjLoader loader = new ObjLoader();
model = loader.loadObj(Gdx.files.internal("model.obj"),true);
String vertexShader = "" +
"attribute vec4 Position;" +
"uniform mat4 u_projView;" +
"void main() {" +
"gl_Position = u_projView * Position;" +
"}";
String fragmentShader = "void main() {" +
"gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);" +
"}";
ShaderProgram shader = new ShaderProgram(vertexShader,fragmentShader);
model.render(shader);
我得到的错误:
Exception in thread "LWJGL Application"
com.badlogic.gdx.utils.GdxRuntimeException:
java.lang.IllegalArgumentException: no uniform with name
'diffuseTexture' in shader at
com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
Caused by: java.lang.IllegalArgumentException: no uniform with name
'diffuseTexture' in shader at
com.badlogic.gdx.graphics.glutils.ShaderProgram.fetchUniformLocation(ShaderProgram.java:283)
at
com.badlogic.gdx.graphics.glutils.ShaderProgram.setUniformi(ShaderProgram.java:297)
at
com.badlogic.gdx.graphics.g3d.materials.TextureAttribute.bind(TextureAttribute.java:80)
at
com.badlogic.gdx.graphics.g3d.materials.Material.bind(Material.java:70)
at
com.badlogic.gdx.graphics.g3d.model.still.StillModel.render(StillModel.java:57)