小编Par*_*rni的帖子

ray quad相交代码出现问题(看起来像撕裂)

嗨,我正在实现蒙特卡洛路径跟踪,并且工作正常,但看起来交集代码存在一些问题。以下是图片

在此处输入图片说明

如果您在左上角看到红色,似乎是在显示背景颜色。

以下是

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)

c++ math graphics raytracing opencl

2
推荐指数
1
解决办法
73
查看次数

如何使用GL_RGB9_E5格式?

我正在尝试将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)

c++ opengl opengl-es opengl-4

2
推荐指数
1
解决办法
105
查看次数

标签 统计

c++ ×2

graphics ×1

math ×1

opencl ×1

opengl ×1

opengl-4 ×1

opengl-es ×1

raytracing ×1