本文介绍了具有漫反射和法线贴图纹理的3D模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用libgdx的资源加载器加载具有漫反射纹理和法线贴图的3D模型.据我所知,fbx(以及转换后的g3dj/g3db)格式可以包含漫反射纹理,如我在fbx-conv示例中所见. (knight.g3db)

I want to load a 3D model with a diffuse texture and a normal map using the asset loader of libgdx.As far as I figured out the fbx (and the converted g3dj/g3db) format can contain a diffuse texture, as I could see in the fbx-conv example. (knight.g3db)

如何向其添加法线贴图纹理?我是否需要为此编写自己的着色器,或者是否有简化的方法? (例如漫反射纹理)

How do I add a normal map texture to it?Do I have to write my own shader for that or is there a simplified method for that? (like for the diffuse texture)

推荐答案

从FBX一直到从DefaultShader类一直支持法线贴图.因此,如果模型(FBX文件)包含法线贴图,则它应该在着色器中可用.但是,默认着色器(GLSL文件)不支持法线贴图.因此,您必须编写自己的着色器.这些测试包含一些有关法线贴图(ShaderCollectionTest)的示例,尽管可能有点难以理解.

Normal map is supported from FBX all the way up to the DefaultShader class. So if your model (FBX file) contains a normal map, it should be available in your shader. However the default shader (GLSL files) don't support normal map. So you'll have to write your own shader. The tests contain some examples on normal mapping (ShaderCollectionTest) although it might be a bit hard to read.

统一名称为u_normalTexture,并在此处设置: https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g3d/shaders/DefaultShader.java#L228

The uniform name is u_normalTexture, and set here: https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g3d/shaders/DefaultShader.java#L228

这篇关于具有漫反射和法线贴图纹理的3D模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 23:31