Post on 24-Feb-2016
description
GPU Gems 3Chapter 13. Volumetric Light Scattering
as a Post-Process
http://www.kindnap.pe.krhttp://cafe.naver.com/shader
introduction간단한 후처리 방법으로 대기중의 그림자에 반응하는
volumetric light scattering 효과를 구현해본다 .
Figure 13-1 Volumetric Light Scat-tering on a Highly Animated Scene in Real Time
introduction대기중의 차폐물에 반응하여 산란하는 효과를 보이는 빛을 만드는 것이 목표정밀한 산란공식을 적용하기 보단 , 단순화된 공식을 적용 근사한 효과를 얻어냄
Shader CodeExample 13-1. Post-Process Shader Implementation of Additive Sampling
float4 main(float2 texCoord : TEXCOORD0) : COLOR0 {
// Calculate vector from pixel to light source in screen space. half2 deltaTexCoord = (texCoord - ScreenLightPos.xy); // Divide by number of samples and scale by control factor. deltaTexCoord *= 1.0f / NUM_SAMPLES * Density; // Store initial sample. half3 color = tex2D(frameSampler, texCoord); // Set up illumination decay factor. half illuminationDecay = 1.0f; // Evaluate summation from Equation 3 NUM_SAMPLES iterations. for (int i = 0; i < NUM_SAMPLES; i++) { // Step sample location along ray. texCoord -= deltaTexCoord; // Retrieve sample at new location. half3 sample = tex2D(frameSampler, texCoord); // Apply sample attenuation scale/decay factors. sample *= illuminationDecay * Weight; // Accumulate combined color. color += sample; // Update exponential decay factor. illuminationDecay *= Decay; } // Output final color with a further scale control factor. return float4( color * Exposure, 1);
}
Implementation화면을 구성합니다 .
Implementation새로운 RT 를 생성하여 태양을 그림 스텐실을 사용하여 보이는 부분만을 걸려냄다운 사이즈 (Next Pass)
ImplementationShader 적용
Implementation화면과 결과물의 조합
- 동영상 -
Other Solution언리얼
Other SolutionCrysis
Other Solutionunigine
Screen Space Sun Shafts in CrysisS6172i1.pdf 문서 참조