코가손의 블로그
[ Graphics ] 빛의 굴절 본문
구에 빛이 들어갈 때, 총 2번의 굴절 일어남
const float ior = 1.5f; // 유리
float eta; // 굴절률
vec3 normal;
// Air to Glass 1번째 굴절
if (glm::dot(ray.dir, hit.normal) < 0.0f)
{
eta = ior;
normal = hit.normal;
}
// Glass to Air 2번째 굴절
else
{
eta = 1.0f / ior;
normal = -hit.normal; // 재질 내부 상황, 표면의 normal과는 반대방향임
}
재질별 굴절률
재질에서 다시 밖으로 향하는 굴절률은 역수
transmission벡터 유도과정
cosθ1 > sinθ1 > sinθ2 > cosθ2 순으로 구할 수 있음
m벡터 = -d 와 n벡터의 내적(스칼라) * n(벡터)
1. cosθ1
>> 단위벡터의 경우 -d 와 n벡터의 내적은 cosθ1
2. sinθ1
>> cosθ * cosθ + sinθ * sinθ = 1을 활용
3. sinθ2
>> 굴절률 = sinθ1 / sinθ2
>> sinθ2 = sinθ1 / 굴절률
>> 재질안->밖으로의 굴절률은 sinθ2 / sinθ1
4. cosθ2
>> sinθ2값 알고 있음, cosθ * cosθ + sinθ * sinθ = 1을 활용
결과
'GameDevLog > Graphics' 카테고리의 다른 글
[ Graphics ] Barycentric Coordinates(무게중심 좌표계) (0) | 2023.04.04 |
---|---|
[ Graphics ] Lighting - Phong Reflection Model (0) | 2023.04.03 |
[ Graphics ] 구-직선 충돌 & 평면-직선 충돌 (0) | 2023.04.03 |
[ Graphics ] 블룸(Bloom) 효과 (0) | 2023.04.02 |
Comments