简体   繁体   English

如何在OpenGL中将纹理拉伸为3D?

[英]How do you extrude a texture to 3D in OpenGL?

First of all, I need to explain you all what I mean. 首先,我需要向大家解释我的意思。 An example of what I am talking about is the game Minecraft where the item the player is holding is rendered as a texture extruded into the third dimension. 我所讲的一个例子是游戏的Minecraft,玩家持有的项目呈现为挤压到第三维的纹理。

右侧-3D挤压出的钻石剑纹理。

So how do I take a texture and extrude it? 那么,如何获取纹理并进行拉伸呢?

Minecraft does not extrude any polygons. 我的世界不会挤压任何多边形。 Minecraft uses simple polygons such as a rectangle and places a 16x16 texture on it. Minecraft使用简单的多边形(例如矩形),并在其上放置16x16纹理。 (Mods may use different resolution ones). (模组可能使用不同的分辨率)。 The sword you are holding is made of polygons, it's not 2D. 您拿着的剑是由多边形制成的,不是2D的。

To answer your questions anyways, there are several ways to "extrude" from 2D textures. 无论如何要回答您的问题,有几种方法可以从2D纹理“挤出”。 Usually you use a technique called normal mapping or bump mapping. 通常,您使用一种称为法线贴图或凹凸贴图的技术。 You may also use parallax mapping. 您也可以使用视差映射。 Finally you can also use geometry shader to literally create new geometry. 最后,您还可以使用几何着色器从字面上创建新的几何。

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

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