1
저는 광선 추적기, 반사 부분에 대해 작업 중입니다. 그림자가있는 구체를 만드는 것을 포함하여 모든 것이 올바르게 작동합니다. 이제 반사 부분을 구현하고 있습니다. 그러나 나는 그것을 얻을 수 없었다. 나는 반사를 얻으려고 노력하지만, 그것을 얻을 수 없었다광선 추적 - 반사
traceRay(Ray ray, int counter){
// look through the intersection between ray and list of objects
// find the final index aka the winning index, (if final index == -1, return background color)
// then calculate the intersection point
// perform reflection calculation here
if(counter > 1 && winning object's reflectivity > 1){
//get the intersection normal, vector N
//Calculate the reflection ray, R
// let I is the inverse of direction of incoming ray
//Calculate R = 2aN - I (a = N dotProduct I)
// the reflection ray is origin at the point of intersection between incoming ray and sphere with the R direction
Ray reflecRay (intersection_poisition, R);
Color reflection = traceRay(reflecRay, counter + 1);
// multiply by fraction ks
reflection = reflection * ks;
}
// the color of the sphere calculated using phong formula in shadeRay function
Color prefinal = shadeRay();
// return the total color of prefinal + reflection
}
, 사람이 traceRay 기능에 대한 내 알고리즘이 맞다면 알려 주시기 바랍니다 수 있습니다 내 알고리즘은 아래?
코드가 수행해야 할 작업에 대한 설명이 있지만 실제로 무엇을하는지는 알 수 없습니다. –
반사 벡터를 어떻게 계산하고 있습니까? 또한 자기 교차를 방지하기 위해 처음에 충돌 한 객체에서 오프셋을 제거해야합니다 (일반적으로 반사 된 벡터 또는 표면 법선을 따라 오프셋). – Necrolis
원본 광선 데이터 및 중간 미디어 계산 결과를 인쇄하면 다소 유용 할 수 있습니다. –