Hi, I studied hard about optiX.
I have questions while studying and I want to ask a question.
I have modified the optiX tutorial sample basically to perform the calculations I want to do, and the calculations are progressing more smoothly than I thought.
Before this topic, I didn’t mentioned about what I do and how I modified the code.
I’have study about radiative heat transfer, view factor using optiX ray tracing.
So, I calculated the viewfactor using classic raytracing and got the accuracy of the old papers.
But the error is as big as I thought. We think that it is necessary to carry out an extended analysis through detailed division.
I am getting the projection of the required object based on the hit area, and doing the recalculation by expanding only that part.
Partially there is a problem, but my problem is divided into mathematical problem and coding. What I would like to ask about this topic is the size of the buffer.
here’s resize code I used:
1. Read the buffer and calculate hit area of object
void PR_T(const char* filename, RTbuffer buffer)
{
int i, j;
RTsize B_W, B_H;
void *Data;
RT_CHECK_ERROR(rtBufferMap(buffer, &Data));
RT_CHECK_ERROR(rtBufferGetSize2D(buffer, &B_W, &B_H));
CORE *TMP = (CORE*)Data;
const int W = static_cast<int>(B_W);
const int H = static_cast<int>(B_H);
viewfactor *RE;
RE = (viewfactor*)malloc(sizeof(viewfactor)*W*H);
float total_viewfactor = 0.0f;
unsigned int total_hit = 0;
unsigned int maxx = 0;
unsigned int maxy = 0;
unsigned int distx = 0;
unsigned int disty = 0;
for (i = 0; i < W; i++)
{
for (j = 0; j < H; j++)
{
RE[i*H + j].x = TMP[i*H + j].point.x;
RE[i*H + j].y = TMP[i*H + j].point.y;
RE[i*H + j].z = TMP[i*H + j].point.z;
RE[i*H + j].VFT = TMP[i*H + j].VFT;
RE[i*H + j].hit = TMP[i*H + j].hit;
RE[i*H + j].idx = TMP[i*H + j].index.x;
RE[i*H + j].idy = TMP[i*H + j].index.y;
if(RE[i*H + j].hit==true)
{
total_hit ++;
if (W - RE[i*H + j].idx > minx) minx = W - RE[i*H + j].idx;
if (H - RE[i*H + j].idy > miny) miny = H - RE[i*H + j].idy;
if (RE[i*H + j].idx > maxx) maxx = RE[i*H + j].idx;
if (RE[i*H + j].idy > maxy) maxy = RE[i*H + j].idy;
}
total_viewfactor += RE[i*H + j].VFT;
}
}
minx = W - minx;
miny = H - miny;
distx = maxx - minx+1;
disty = maxy - miny+1;
if (sub == true)
{
ARS(distx, disty, minx, miny);
}
free(RE);
RT_CHECK_ERROR(rtBufferUnmap(buffer));
}
2. ResizeBuffer
void ARS(int w, int h, int iw, int ih)
{
W = (int) w*SDX;
H = (int) h*SDY;
context["AW"]->setUint(SDX);
context["AH"]->setUint(SDY);
context["WW"]->setUint(w);
context["HH"]->setUint(h);
context["WS"]->setUint(iw);
context["HS"]->setUint(ih);
sutil::ensureMinimumSize(W, H);
sutil::resizeBuffer(GOBUF(), W, H);
}
3. related variables, structures
uint32_t W = 400u;
uint32_t H = 400u;
//////////////////////////////////////////////////////////////////////////////////////
unsigned int SDX =6;
unsigned int SDY =6;
bool sub = true;
//////////////////////////////////////////////////////////////////////////////////////
struct viewfactor
{
bool hit;
float VFT;
float x;
float y;
float z;
unsigned int idx;
unsigned int idy;
};
This code works well based on generally calculated values.
But sometimes it does not work. At that time, it involves the following error.
OptiX Error: ‘Unknown error (Details: Function “_rtContextLaunch2D” caught exception: Encountered a CUDA error: cudaDriver().CuEventSynchronize( m_event ) returned (719): Launch failed)’
The problem is that sometimes it does not work. I am wondering what steps I need to take to overcome this problem.