RayTracing-1 by honee

완전 대충 수도코드........
저, Local Illumination 구하는 식은 정확하게 무슨 의미였는지, 어떤 벡터인지 생각이 안난다ㅋ 그건 나중에 참고해서 봐야지..


Color getColor(Coord camera, Coord pixel){
    Ray ray = getRay(Camera, pixel);
    HitPoint hit = getHitPoint(ray);
    return getLocalColor(hit) + hit.specular * getColor(hit.position, hit.position + hit.reflectionVector) 
        + hit.transparent * getColor(hit.position,  hit.position + hit.transmissionVector);
}

Image rayTracing(Scene scene){
    Image image = new Image(width, height);
    for i, j in width, height {
        image[i][j].color = getColor(camera, new Coord(i, j));
    }
}

Color getLocalColor(HitPoint hit){
    Color color = new Color();
    for light in Scene.getLights() {
        color += hit.difuse* hit.nomalVector (dot) (hit.position - light.position);
        color += hit.specular * hot...................................................;
        color *= light.specular * hit........................................
    }

    color += hit.emission + hit.ambient;
}


1 2 3 4 5 6 7 8 9 10 다음