问题标签 [bump-mapping]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
257 浏览

python - OpenGL:法线贴图(凹凸贴图)的哪些着色器?

我找不到在 PyOpenGL 中生成法线/凹凸贴图的方法。具体来说,我想要一张我可以阅读的地图glReadPixels()。我不知道如何获得表格的地图:(宽度,高度,法线)即形状应该是(wxhx 3)。

我怎样才能得到这样的地图?为此需要哪些片段、顶点、几何着色器?

我向顶点着色器提供以下输入:

我想得到一个平滑的法线贴图,其中每个像素对应一个归一化的法线向量。我需要哪些着色器?我需要做的是从场景中渲染法线贴图。我使用行进立方体来获取三角形、法线和顶点。我添加了一个普通的缓冲区。我没有质感。

我用它来绘制三角形并绑定缓冲区对象。

是否可以使用着色器渲染法线贴图以及如何渲染?可以这样读吗?

0 投票
1 回答
585 浏览

xna - 2D 水凹凸贴图 - Monogame

感谢您花时间检查我的问题。

在我第一次尝试游戏时,我正在努力改善海洋。我决定在我的海洋瓷砖上使用凹凸贴图来为水添加一点纹理。为此,我将水瓦绘制到 renderTarget,然后在将渲染目标绘制到后台缓冲区时应用像素着色器。

我遇到的问题是像素着色器似乎偏移或置换了绘制的渲染目标的位置。观察这两张照片:


此图像是没有运行像素着色器的游戏。注意岛屿周围的“浅水”,这里是纯色的。 在此处输入图像描述


随着像素着色器的运行,浅水始终向右偏移。 在此处输入图像描述

我正在使用riemers 新手凹凸映射中提供的凹凸贴图。我有一个可能的想法是这个凹凸贴图的尺寸与我应用它的渲染目标不匹配。但是,我不完全确定如何创建/调整此凹凸贴图的大小。

我的 HLSL 像素着色器如下所示:

我的monogame draw call看起来像这样:

任何人都可以看到我的代码或其他可能导致此偏移问题的问题吗?

任何帮助深表感谢。谢谢!

编辑

如果我修改 xWaveHeight 着色器参数,它会改变偏移出现的位置。值 0 不会偏移,但不会应用凹凸贴图。有没有办法解决?

我知道偏移是由像素着色器扰动引起的,但我想知道是否有办法在保留凹凸贴图的同时撤消此偏移。在链接的 riemer 的教程中,包含了一个顶点着色器。我不太确定我是否需要这个,但是当我在该技术中包含我的顶点着色器并将像素着色器修改为以下内容时,不会绘制水。

0 投票
1 回答
218 浏览

opencv - 如何使用 OpenCV 检测凹凸映射

我有一张带有凹凸贴图的图像,就像这里的图像(最右边的那个):

https://en.wikipedia.org/wiki/Bump_mapping#/media/File:Bump-map-demo-full.png

我想知道我是否可以使用 OpenCV 检测凹凸贴图区域。该图像是没有深度信息的普通 RGB 图像。知道如何进行检测吗?非常感谢!

0 投票
1 回答
549 浏览

three.js - 带有凹凸贴图或法线贴图或粗糙度贴图的three.js的blender2.8 gltf导出?

我看到一些讨论说 gltf 不会导出凹凸贴图,但是如果我查看导出的 gltf 文件(单独文件模式),则会有一个凹凸贴图文件带有凹凸比例(还有法线贴图)。加载到 three.js 后,我得到一个带有凹凸贴图对象和比例值以及法线贴图对象的网格标准材质。但它们似乎对渲染对象没有影响。使用 gltf 将浮雕效果从 Blender 导出到 Three.js 究竟允许做什么?

0 投票
0 回答
90 浏览

c++ - Tangent 和 Bitangent 与法线不正交

我正在尝试为我的地形计算 Tangent 和 Bitangent 向量。我按照教程弄清楚如何计算这两个向量,据我了解,Tangent Bitangent 和 Normal 向量都应该相互正交,对吧?我正在检查,似乎我做错了什么,因为它们不是正交的。有人可以向我解释我在这里做错了什么吗?这是我的代码。

以下是我在第一次迭代中获得的调试输出作为示例。

Tangent 和 Normal 的点积对于第一次迭代来说非常小,但对于其中一些迭代来说它会变得更大。我是否正确理解了这个概念?这三个向量必须是正交的吗?我从使用 ASSIMP 导入的导入网格中检查了相同的点积,它们都是正交的。

- 编辑:这是我计算法线的方法。

正如评论中所指出的,每个顶点都有自己的法线,它们可能彼此不同。在这种情况下,我将如何处理切线和双切线计算?

0 投票
0 回答
113 浏览

three.js - 在 Three.js 中禁用凹凸贴图上的线性过滤时出现网格伪影

如果magFilterThree.js 中的凹凸贴图的 设置为THREE.NearestFilter,则对象上会出现奇怪的网格伪影。网格的间距相当于凹凸贴图像素。一旦将 magFilter 恢复为默认值 ( THREE.LinearFilter),一切都很好。

但是,我需要禁用过滤,因为我是从 RGB 编码的高度图计算高度值。

有趣的是,在尝试随机法线贴图时,将 设置为magFilter不会NearestFilter产生此类伪影。

凹凸贴图伪影

尝试使用和不使用阴影贴图,使用各种凹凸贴图和法线贴图。目标是摆脱它们。

——</p>

编辑:一个示例(不是我的代码,而是用于演示) https://codepen.io/Mombasa/pen/ivdyC

使用线性过滤,事情看起来很完美:

在此处输入图像描述

只需bmap.magFilter = THREE.NearestFilter;在第 14 行之后添加 - 即禁用线性过滤,凹凸贴图就会减少到凹凸贴图受影响区域的轮廓

在此处输入图像描述

0 投票
1 回答
626 浏览

opengl - OpenGL Normal Mapping

I'm trying to implement Normal Mapping, using a simple cube that i created. I followed this tutorial https://learnopengl.com/Advanced-Lighting/Normal-Mapping but i can't really get how normal mapping should be done when drawing 3d objects, since the tutorial is using a 2d object.

In particular, my cube seems almost correctly lighted but there's something i think it's not working how it should be. I'm using a geometry shader that will output green vector normals and red vector tangents, to help me out. Here i post three screenshot of my work.

Directly lighted

directly lighted

Side lighted

side lighted

Here i actually tried calculating my normals and tangents in a different way. (quite wrong)

another trial

In the first image i calculate my cube normals and tangents one face at a time. This seems to work for the face, but if i rotate my cube i think the lighting on the adiacent face is wrong. As you can see in the second image, it's not totally absent.

In the third image, i tried summing all normals and tangents per vertex, as i think it should be done, but the result seems quite wrong, since there is too little lighting.

In the end, my question is how i should calculate normals and tangents. Should i consider per face calculations or sum vectors per vertex across all relative faces, or else?

EDIT --

I'm passing normal and tangent to the vertex shader and setting up my TBN matrix. But as you can see in the first image, drawing face by face my cube, it seems that those faces adjacent to the one i'm looking directly (that is well lighted) are not correctly lighted and i don't know why. I thought that i wasn't correctly calculating my 'per face' normal and tangent. I thought that calculating some normal and tangent that takes count of the object in general, could be the right way. If it's right to calculate normal and tangent as visible in the second image (green normal, red tangent) to set up the TBN matrix, why does the right face seems not well lighted?

EDIT 2 --

Vertex shader:


In the VS i set up my TBN matrix and i transform all light, fragment and view vectors to tangent space; doing so i won't have to do any other calculation in the fragment shader.

Fragment shader:

enter image description here

0 投票
0 回答
158 浏览

c++ - 计算归一化立方体上的切线

我之前发过一个类似的帖子,但从那以后我获得了更多的见解。对于上下文,我正在创建一个基于 DX11 的 3D 渲染引擎,其中中心焦点是一个大行星,它是一个标准化立方体。我正在尝试在地球上实现法线贴图,但在计算切线时遇到问题。顶点法线工作正常,但我尝试了各种计算切线信息的方法都无济于事。

第一种方法是从这篇文章中实现的,并且似乎产生了正确的结果,因为切线和双切线正确地映射到了 UV 坐标。但是,您会注意到在立方体面的顶点处,几何体的 UV 发生了变化,这导致了不同方向的法线,因此产生了硬光照接缝。 方法1

第二种方法,从这个页面掺杂,不依赖于顶点 UV,因此在球体周围提供平滑的切线。但是,由于 UV 没有排列,新的凹凸法线最终会明显关闭。 方法2

(好像太黑了) 看似黑暗

任何建议都可以帮助我解决这个问题,无论是切线本身还是我的基础球体几何,或者至少更好地理解它。提前致谢。

0 投票
1 回答
169 浏览

image - 如何使用 GIMP 防止色带?

只需在 python GIMP 中做一个简单的 bump_map 操作。但结果有色带!

如果我删除“plug_in_bump_map”操作,我保存的最终结果中没有色带。如果我对灰度图像应用高斯模糊,最终结果中的色带会消失,但会留下不希望的模糊,我该怎么办?所有图像均为PNG。

条带示例 示例二