0
AreaLight를 구현하고 싶습니다. DirectX 9를 사용하여 Plz을 시작하면 어떻게 시작할 수 있습니까? 나는 연구 두 세 개의 링크를하지만DirectX9 또는 DX11로 영역 조명 구현
AreaLight를 구현하고 싶습니다. DirectX 9를 사용하여 Plz을 시작하면 어떻게 시작할 수 있습니까? 나는 연구 두 세 개의 링크를하지만DirectX9 또는 DX11로 영역 조명 구현
구형 영역의 빛 HLSL
float specTrowbridgeReitz(float HoN,float a,float aP)
{
float a2 = a*a;
float ap2 = aP*aP;
return (a2 * ap2)/pow(HoN * HoN * (a2 - 1.0) + 1.0, 2.0);
}
float visSchlickSmithMod(float NoL, float NoV, float r)
{
float k = pow(r * 0.5 + 0.5, 2.0) * 0.5;
float l = NoL * (1.0 - k) + k;
float v = NoV * (1.0 - k) + k;
return 1.0/(4.0 * l * v);
}
float fresSchlickSmith(float HoV, float f0)
{
return f0 + (1.0 - f0) * pow(1.0 - HoV, 5.0);
}
float sphereLight(float3 pos,float3 N,float3 V,float3 r,float f0,float
roughness,float NoV,out float NoL)
{
float3 L = lightPositions - pos;
float3 centerToRay = dot(L,r)*r-L;
float3 closestPoint = L + centerToRay * clamp(fLightRadius/length(
centerToRay), 0.0, 1.0);
float3 l = normalize(closestPoint);
float3 h = normalize(V+l);
NoL = clamp(dot(N,l),0.0,1.0);
float HoN = clamp(dot(h,N),0.0,1.0);
float HoV = dot(h,V);
float distL = length(L);
float alpha = roughness * roughness;
float alphaPrime = clamp(fLightRadius/(distL*2.0)+alpha,0.0,1.0);
float specD = specTrowbridgeReitz(HoN, alpha, alphaPrime);
float specF = fresSchlickSmith(HoV, f0);
float specV = visSchlickSmithMod(NoL, NoV, roughness);
return specD * specF * specV*NoL;
}
float3 areaLights(float3 pos,float3 nor,float3 V)
{
float f0 = FO;
float NoV = clamp(dot(nor,V),0.0,1.0);
float3 r = reflect(-V,nor);
float NdotLSphere;
float specSph = sphereLight(pos,nor,V,r,f0,roughness,NoV,NdotLSphere);
float3 color = 0.3183*(NdotLSphere*lightcolor)+
(specSph*lightcolor)+albedo;
return pow(color,1.0/2.2);
}
float4 ps_main(PS_INPUT Input) : COLOR0
{
float3 N = normalize(Input.Normal);
float3 viewDir = normalize(campos.xyz -
float3(Input.WSPosition.xyz));
float3 color = areaLights(Input.WSPosition,N,viewDir);
return float4(color,0.0);
}
에게이 질문을 렌더에 구현하거나 샘플과 직접 할 수는 스택 오버 플로우에 대한 너무 광범위하다. 영역 조명은 렌더링 아키텍처 (앞으로 렌더링, 지연 렌더링, 앞으로 +, 광선 추적, 방사선 등)에 크게 의존하는 복잡한 기능입니다. 대화 형 실시간 속도를 지원하거나 오프라인 렌더링을 지원해야하는지 여부 문제의 장면이 정적, 동적 또는 둘 다의 혼합 인 경우. –
https://www.gamedev.net/forums/topic/552315-glsl-area-light-implementation/ (앞으로 렌더링, 지연 렌더링, 앞으로 +, 광선 추적, radioscity 등을 사용하는 대신이 링크를 사용했습니다. 구현할 간단한 단계를 원합니다. –