且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C++ 球体光线追踪中的纹理映射

更新时间:2021-11-29 01:22:14

计算 N 后,尝试使用此算法计算 (u, v):

After calculating N, try calculating (u, v) using this algorithm:

u = 0.5 + arctan2(dz, dx) / (2*pi)
v = 0.5 - arcsin(dy) / pi

我怀疑这是你的问题.

尝试通过仅使用您的 UV 坐标生成颜色来隔离您的问题,而不是从纹理中选择它们.你可以试试:

Try to isolate your problem by generating a colour solely using your UV coordinates, rather than picking them from the texture. You could try:

int red = u % 255;
int green = 0;
int blue = 0;

检查结果.它们是您希望看到的吗?

Examine the results. Are they what you'd expect to see?