LIBGDX 3D:关闭着色器上的纹理:OpenGL
对不起,如果问题有点小。几年前我写了一些代码,为了提高性能,它将许多网格渲染为一个大网格 我现在要做的是只渲染没有纹理的网格,所以只有一种颜色LIBGDX 3D:关闭着色器上的纹理:OpenGL,opengl,libgdx,kotlin,Opengl,Libgdx,Kotlin,对不起,如果问题有点小。几年前我写了一些代码,为了提高性能,它将许多网格渲染为一个大网格 我现在要做的是只渲染没有纹理的网格,所以只有一种颜色 boxModel = modelBuilder.createBox(10f, 10f, 10f, Material(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.RED), FloatAttribute.createShininess(15f)
boxModel = modelBuilder.createBox(10f, 10f, 10f, Material(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.RED), FloatAttribute.createShininess(15f)), (VertexAttributes.Usage.Position or VertexAttributes.Usage.Normal or VertexAttributes.Usage.TextureCoordinates).toLong()) // or VertexAttributes.Usage.TextureCoordinates
for (x in 1..10) {
for (y in 1..10) {
modelInstance = ModelInstance(boxModel, x * 15f, 0.0f, y * 15f)
chunks2[0].addMesh(modelInstance.model.meshes, modelInstance.transform, btBoxShape(Vector3(10f, 10f, 10f)))
}
}
chunks2[0].mergeBaby()
因此,我建立了巨大的网格,然后渲染它
shaderProgram.begin()
texture.bind()
shaderProgram.setUniformMatrix("u_projTrans", camera.combined)
shaderProgram.setAttributef("a_color", 1f, 1f, 1f, 1f)
shaderProgram.setUniformi("u_texture", 0)
renderChunks()
shaderProgram.end()
这适用于有纹理的材料,很好,显示了正确的纹理等,但基本颜色(我猜是“a_颜色”设置为白色)实际上我希望它使用我在材质属性中提供的颜色。为什么要使用着色器?你可以创建一个材质并选择消隐颜色。我正在使用这里的函数回答为什么要使用着色器?你可以创建一个材质并选择除霜颜色。我正在使用这里的函数回答