태그 : 라이트
2007/05/31   기본 조명 공식(3) + 라이트 구조 [3]
기본 조명 공식(3) + 라이트 구조
* n개의 라이트를 계산할 때 ( Diffuse + Ambient + Specular )

Atten = 1/( att0i + att1i * d + att2i * d2);
diffuse_Color = max(0, dot(n,l)) * light diffuse * Atten;                // Lambert 공식
specular_Color = pow( max(0, dot(n,h)), material_shininess );    // Blinn 반영 공식

AmbientColor = Material_Emissive + sum( Light_Ambient(+globalAmbient)*Material_Ambient );
DiffuseColor = sum( Material_Diffuse * diffuse_Color ) * VertexColor;
SpecularColor = sum( Material_Specular * specular_Color* SpecularIndensity );
최종 색상 = AmbientColor + DiffuseColor +SpecularColor;

* Tip
float4 GlobalAmbient = Material_ems + Global_amb*Material_amb : 미리 계산해둔다.
float4 LightAmbient = Material_amb*Light_amb : 미리 계산
Specular는 Shininess 값으로, Specular가 적용되는 범위를 넣어주고, 강도(Indensity)값을 주어서 반짝임의 강도를 적용한다.

최종 색상 = GlobalAmbient + sum( Material_dif*diffuse_Color + LightAmbient  );

Directional Light 와 Point/Spot 라이트를 구별해두면, 나중에 계산을 조금 줄일 수 있음..


씬 그래프 상의 라이트 구조는?!?!
by cagetu | 2007/05/31 15:07 | 개발 노트 | 트랙백 | 덧글(3)
< 이전페이지 다음페이지 >