简体   繁体   English

地形高度图-C ++ /顶点着色器具有不同的值

[英]Terrain Height Map - C++/Vertex Shader has different values

I have been working on a terrain and have had to come to a complete stop. 我一直在地形上工作,不得不完全停下来。 I am programming in C++, DirectX9 and HLSL to create the terrain but I am also using height maps that are BMP format. 我正在使用C ++,DirectX9和HLSL进行编程以创建地形,但是我还使用了BMP格式的高度图。 I am loading the information in from the height map in both the C++ side as well as the shader side. 我正在从C ++端和着色器端的高度图中加载信息。 On the C++ side, I am using D3DXCreateTextureFromFile and surfaces (D3DXSaveSurfaceToFile) to load the information, whereas on the shader side, I am using tex2Dlod to load my information for the terrain vertices. 在C ++方面,我使用D3DXCreateTextureFromFile和曲面(D3DXSaveSurfaceToFile)加载信息,而在着色器方面,我使用tex2Dlod加载有关地形顶点的信息。 These two are getting different values from the height map. 这两个从高度图获得不同的值。 Upon further research, I found out that the tex2Dlod function utilizes mip maps (still don't understand those fully) to load the information. 经过进一步的研究,我发现tex2Dlod函数利用Mip映射(仍然无法完全理解这些映射)来加载信息。

Would anyone know a way on how to get the two numbers to match up? 有人知道如何使两个数字匹配吗? If you need more information (the numbers, pictures or whatever) just let me know! 如果您需要更多信息(数字,图片或其他信息),请告诉我!

Thanks! 谢谢!

First question is why do you stick with DX9 what is a reason ? 第一个问题是为什么您坚持使用DX9是什么原因? I would understand at least DX10. 我至少会理解DX10。 Can u show me HLSL code ? 您能给我看HLSL代码吗?

tex2Dlod is the texture sampling function which takes two params. tex2Dlod是具有两个参数的纹理采样函数。 1. sampler2D 2. float4(texture coordinates). 1. sampler2D 2. float4(纹理坐标)。

Actualy tex2dlod is the function which does texture mip maping(detailing of textures) and texel offsetting. 实际上tex2dlod是执行纹理贴图映射(纹理细节)和texel偏移的功能。 But fully i did not understand where is problem ? 但是我完全不明白哪里出了问题? Could u be more specific ? 您能更具体一点吗?

And by the way entire function only supported in shader model 3.0 at least. 顺便说一句,整个功能至少仅在shader model 3.0中受支持。

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

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