학교용 소프트웨어 래스터 라이저를 만들고 있는데, 기존의 매트릭스 계산 대신 비정상적인 렌더링 방법을 사용하고 있습니다. pinhole camera을 기반으로합니다. 나는 3D 공간에서 몇 가지 포인트를 가지고 있고, 나는 그와 카메라 사이의 거리를 복용하고이 나에게 카메라를 향해 방향 벡터를 제공 그것을핀홀 카메라 렌더링 시스템 최적화
Vec3 ray_to_camera = (a_Point - plane_pos).Normalize();
을 정상화 2D 화면 좌표로 변환합니다. 그런 다음 광선의 원점을 카메라에 배치하고 카메라 뒤의 평면과 광선 평면 교차를 수행하여 광선으로 그 방향을 전환합니다.
Vec3 plane_pos = m_Position + (m_Direction * m_ScreenDistance);
float dot = ray_to_camera.GetDotProduct(m_Direction);
if (dot < 0)
{
float time = (-m_ScreenDistance - plane_pos.GetDotProduct(m_Direction))/dot;
// if time is smaller than 0 the ray is either parallel to the plane or misses it
if (time >= 0)
{
// retrieving the actual intersection point
a_Point -= (m_Direction * ((a_Point - plane_pos).GetDotProduct(m_Direction)));
// subtracting the plane origin from the intersection point
// puts the point at world origin (0, 0, 0)
Vec3 sub = a_Point - plane_pos;
// the axes are calculated by saying the directional vector of the camera
// is the new z axis
projected.x = sub.GetDotProduct(m_Axis[0]);
projected.y = sub.GetDotProduct(m_Axis[1]);
}
}
이 기능은 훌륭하지만 궁금합니다. 알고리즘이 더 빨라질 수 있습니까? 지금은 장면의 모든 삼각형에 대해 3 개의 법선을 계산해야합니다. 그것도 매우 까다로운 될 것 빠른 상호 제곱근 근사 (1/sqrt(x)
)와
float length = 1/sqrtf(GetSquaredLength());
x *= length;
y *= length;
z *= length;
.
내 질문은 다음과 같습니다.
세 법선을 근사하는 좋은 방법이 있습니까?
이 렌더링 기술은 무엇입니까?
센트 로이드의 법선을 사용하여 3 개의 꼭지점을 근사 할 수 있습니까? ((v0 + v1 + v2)/3)
미리 감사드립니다.
P. "이 분야의 전문가의 도움을 받아 앞으로 7 주 이내에 완벽한 기능의 소프트웨어 래스터 라이저를 만들 것입니다." 나는 내 교육을 경솔하다. :)
편집 :이 올바른 결과를 반환
Vec2 projected;
// the plane is behind the camera
Vec3 plane_pos = m_Position + (m_Direction * m_ScreenDistance);
float scale = m_ScreenDistance/(m_Position - plane_pos).GetSquaredLength();
// times -100 because of the squared length instead of the length
// (which would involve a squared root)
projected.x = a_Point.GetDotProduct(m_Axis[0]).x * scale * -100;
projected.y = a_Point.GetDotProduct(m_Axis[1]).y * scale * -100;
return projected;
그러나이 모델은 카메라 위치의 현재 독립적이다. :(
그것은 훨씬 짧고 빠른 생각의
동료들과 함께 여기에있는 멋진 IGAD 학생들을 만나서 반갑습니다 :-) –
핀홀 카메라 모델 동질적인 좌표를 가진 행렬 계산을 사용하여 종종 구현됩니다. 그럼 왜 그걸 사용하지 않니? –