简体   繁体   English

在OpenGL中在3D形状上平铺子纹理

[英]Tiling subtexture over 3D shape in OpenGL

I have a texture which is a grid of smaller textures and which I am not able in this application to split into individual files. 我有一个纹理,它是一个较小纹理的网格,在此应用程序中我无法将其拆分为单个文件。 I need to tile these subtextures over a model. 我需要将这些子纹理平铺在模型上。

Splitting the geometry could work, but would increase scene complexity and potentially introduce visual artifacts if thin triangles are generated. 分割几何体虽然可行,但会增加场景复杂性,并且如果生成细三角形,可能会引入视觉伪像。

Allocating new textures copied from the original at runtime could work, but would increase texture-memory usage and would involve stale data if the primary texture changes (which I cannot detect in this application). 在运行时分配从原始副本复制的新纹理可以工作,但是会增加纹理内存的使用,并且如果主要纹理发生变化(我在此应用程序中无法检测到),则会涉及到陈旧数据。

If there really is no way to directly bind a subtexture to allow OpenGL tiling to work, what would be the next best way to do it? 如果真的没有办法直接绑定子纹理以允许OpenGL切片工作,那么下一个最佳方法是什么?

If you need to do this, the correct way is to use a fragment shader to tile your texture coordinates directly. 如果需要这样做,正确的方法是使用片段着色器直接平铺纹理坐标。

That seems like massive overkill and might interfere with the application's existing rendering pipeline 这似乎是过大的杀伤力,并且可能会干扰应用程序现有的渲染管道

The only way it would interfere is if you're not using fragment shaders. 唯一会干扰的方法是不使用片段着色器。 And if you're not... you should be. 如果不是,那应该是。

Modern hardware design doesn't generally add fixed functionality anymore; 现代硬件设计通常不再添加固定功能。 it's all about giving shaders more power and options. 这就是为着色器提供更多功能和更多选择。 If you need a feature, "code it in a shader" is generally the correct solution. 如果需要功能,则“正确地在着色器中编码”通常是正确的解决方案。

But if you're not allowed to use shaders, the only alternative is to modify your geometry, as you suggested. 但是,如果不允许使用着色器,则唯一的选择就是按照您的建议修改几何。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM