Closed itxiaoxian closed 1 year ago
Check the function here: https://github.com/LiangliangNan/Easy3D/blob/317334ef2da7569e65f209703746a1fad8cffb24/easy3d/renderer/state.h#L126
Please also refer to the example in Tutorial_305_Texture
I belive your question has been answered so I am closing this issue. Feel free to reopen it.
非常感谢您百忙之中给我回复,谢谢您。
您帮我说的这个是可以渲染一张贴图,我现在想实现材质贴图和法线贴图同时渲染。 我看到这个Easy3D/easy3d/renderer/state.h里面只提供了两个函数: const Texture texture() const { return texture_; } void set_texture(Texture tex) { texture_ = tex; } 如果同时渲染材质贴图和法线贴图,是不是这里应该是一个列表呢?请问改怎么做呢,谢谢您。盼复。
这个需要修改shader, 你可以提供两个texture,所涉及的修改为:
uniform sampler2D texColor;
uniform sampler2D texNormal;
然后在从sampler里面取出你需要的法向量或者颜色
vec3 color = texture(texColor, texcoord).xyz;
vec3 normal = texture(texNormal, texcoord).xyz;
剩下的处理和现有的无异。
所涉及的c++ 代码改动:
Texture *texColor= TextureManager::request(color_texture_file_name);
Texture *texNormal = TextureManager::request(normal_texture_file_name);
再将这两个texture上传到GPU:
program->bind_texture("texColor", texColor->id(), 0); // color
program->bind_texture("texNormal", texNormal->id(), 1); // normal
... 渲染代码
program->release_texture()
非常感谢您的解答,我尝试一下,有什么问题再向您请教,十分感谢。
请问我想展示法线贴图,该修改哪部分,谢谢,盼复。