嗨,我正在实现蒙特卡洛路径跟踪,并且工作正常,但看起来交集代码存在一些问题。以下是图片
如果您在左上角看到红色,似乎是在显示背景颜色。
以下是
float intersectQuad(Ray r, float3 p1, float3 p2, float3 p3, float3 p4,
float3* outNormal)
{
const float3 x1 = p2 - p1;
const float3 x2 = p4 - p1;
const float3 n = (cross(x2, x1));
const float denom = dot(n, r.dir);
if (denom < 0.00000000001f) return 0.0f;
const float3 p0l0 = (p1 - r.origin);
const float t = dot(p0l0, n) / denom;
if( t < 0.000000000001f ) return 0.0f;
const float3 hitPoint = r.origin + r.dir * t; …Run Code Online (Sandbox Code Playgroud) 我正在尝试将GL_RGB9_E5格式与3D纹理配合使用。为此,我创建了一个简单的测试来了解格式的用法。不知何故我没有得到我所期望的。以下是测试程序
GLuint texture;
const unsigned int depth = 1;
const unsigned int width = 7;
const unsigned int height = 3;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_3D, texture);
const float color[3] = { 0.0f, 0.5f, 0.0f };
const rgb9e5 uColor = float3_to_rgb9e5(color);
GLuint * t1 = (GLuint*)malloc(width*height*depth* sizeof(GLuint));
GLuint * t2 = (GLuint*)malloc(width*height*depth* sizeof(GLuint));
int index = 0;
for (int i = 0; i < depth; i++)
for (int j = 0; j < width; j++)
for (int k = 0; …Run Code Online (Sandbox Code Playgroud)