このシンプルなシェーダーをインポートされたメッシュ (.obj メッシュ) に設定すると、ビルド時にエラーが発生する理由がわかりません。
問題は、現時点ではテクスチャを使用したくないということです。学習目的で、単純に赤いメッシュを用意して、そこから段階的に進めたいと考えていました..
ここにもいくつかのコードがあります:
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)