????GPU???Shader??????????????
???????????4??
??????
?GPU Gems?1~3??GPU Pro?1~7???GPU Zen??????????11?????GPU????????????????????????????????????????????????????????????????????????????Trick??????????????????????????????
??????????
?????????GPU?????11????????GPU Gems 1????????????????GPU???Shader?????????????????1?5????
PS:?????????????????????????????GitHub???GPU Gems 1????????????????????????????????????????
?????????
????????Realistic Skin Rendering?
??????Subsurface Scattering?
??????Ambient Occlusion?
?????Real-Time Glow?
??????Shadow Rendering?
???????Perspective Shadow Maps?
????????????Managing Visibility for Per-Pixel Lighting?
??BRDF?Spatial BRDFs?
????????Image-Based Lighting,IBL?
?????Texture Bombing?
?????Color Controls?
???Depth of Field?
??????High-Dynamic-Range,HDR?
???????????4?????????????
???GitHub??
????????GitHub????????????
???MarkDown????????????????????????????????GitHub??????????????????????????????????Git???????????????????????????GitHub?Repo????
????GitHub???????
QianMo/Game-Programmer-Study-Notesgithub.com
????????Highlight
??????????????????????????????????????GPUGems 1??????????????????
??????????????????????????????????Real-Time
Glow????????????????????Real-Time Glow??
???????????????????
????????????????Effective Water Simulation from Physical
Models?
??Dawn Demo???????Skin in the Dawn Demo?
???????????????Rendering Countless Blades of Waving Grass?
?????????????Real-Time Approximations to Subsurface Scattering?
????????Ambient Occlusion?
???????Real-Time Glow?
?????????????????
?????????Rendering Water Caustics?
??Dawn Demo?????Animation in the"Dawn"Demo?
?????Perlin?????Implementing Improved Perlin Noise?
??Vulcan Demo???????Fire in the"Vulcan"Demo?
?????????Simulating Diffraction?
????????????Efficient Shadow Volume Rendering?
?????????Cinematic Lighting?
???????????Shadow Map Antialiasing?
???????????Omnidirectional Shadow Mapping?
???????????????????Generating Soft Shadows Using Occlusion Interval Maps?
??????????Perspective Shadow Maps:Care and Feeding?
???????????????Managing Visibility for Per-Pixel Lighting?
?????BRDF?Spatial BRDFs?
???????????Image-Based Lighting?
?????????Texture Bombing?
?????????Color Controls?
???????Depth of Field?
?????????????High-Quality Filtering?
?????????????????????Fast Filter-Width Estimates with Texture Maps?
????OpenEXR???????HDR?The OpenEXR Image File Format and HDR?
PS:????????????????1?5??????????????????????????????????????????????????????????????????????????????????????????GitHub???
QianMo/Game-Programmer-Study-Notesgithub.com
?GPU Gems 1?????????
??????????GPU Gems 1????????????????????
PS:?????????????????????????????exe?????????????????
?????Web???
GPU Gemsdeveloper.nvidia.com
?????????GPU-Gems-CD-Content?GitHub?????????GPU Gems?1~3??????????????????????????????????????????
QianMo/GPU-Gems-Book-Source-Codegithub.com
?????????????
?????????????Real-Time Approximations to Subsurface Scattering?
??????
??????Subsurface Scattering????SSS??3S?????????????????????????????????????????????????????????????????????????????
??????????
????????????
??????????????????????????????Subsurface Scattering???????????
???????????????????????????|??????????
?????????????4????????????????????????4??????????????????
????????????? ?????4?
??????????????????????????????????????????????????
????????
4.1???????????The Visual Effects of Subsurface Scattering?
???????????????????????????????????????????????????????????????????????????Subsurface
Scattering???????
1????????????????????????
2???????????????????????????????????
3?????????????????????
4?????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????
4.2????????Simple Scattering Approximations?
?????????????????Warp Lighting??????????????????????????Lambert??????????0??????????????????????????????????????????????????????????????????????????????????Oren-Nayar?????????????????????????????????Nayar and Oren 1995??
??????????????????????????????????
???wrap?????????????0?1??????????????????????
??????????
- float diffuse = max(0, dot(L, N));
- float wrap_diffuse = max(0, (dot(L, N) + wrap) / (1 + wrap));
复制代码
??????????????????????????????????????????????????
???????0??????????????????????????????????????????????????????????????????
??????????alpha?????????????????power???????????Example 16-1??FX??????????????????????
??a???????????b???????????c???????????????
Example 16-1????????????Shader??????Excerpt from the Skin
Shader Effect Incorporating Wrap Lighting?
- // ???????2D????Generate 2D lookup table for skin shading?
- float4 GenerateSkinLUT(float2 P : POSITION) : COLOR
- {
- float wrap = 0.2;
- float scatterWidth = 0.3;
- float4 scatterColor = float4(0.15, 0.0, 0.0, 1.0);
- float shininess = 40.0;
- float NdotL = P.x * 2 - 1; // remap from [0, 1] to [-1, 1]
- float NdotH = P.y * 2 - 1;
- float NdotL_wrap = (NdotL + wrap) / (1 + wrap); // wrap lighting
- float diffuse = max(NdotL_wrap, 0.0);
- // ????????????????add color tint at transition from light to
- dark?
- float scatter = smoothstep(0.0, scatterWidth, NdotL_wrap) *
- smoothstep(scatterWidth * 2.0, scatterWidth,
- NdotL_wrap);
- float specular = pow(NdotH, shininess);
- if (NdotL_wrap <= 0) specular = 0;
- float4 C;
- C.rgb = diffuse + scatter * scatterColor;
- C.a = specular;
- return C;
- }
- // ??????????Shade skin using lookup table?
- half3 ShadeSkin(sampler2D skinLUT,
- half3 N,
- half3 L,
- half3 H,
- half3 diffuseColor,
- half3 specularColor) : COLOR
- {
- half2 s;
- s.x = dot(N, L);
- s.y = dot(N, H);
- half4 light = tex2D(skinLUT, s * 0.5 + 0.5);
- return diffuseColor * light.rgb + specularColor * light.a;
- }
复制代码
4.3???????????Simulating Absorption Using Depth Maps?
???Absorption?????????????????????????????????????????????????????????????????????????????????????Depth Maps???[Hery 2002]?????????????(Shadow Mapping)???????????
????????????????????
?????Depth Maps????????
???????first pass?????????????????????????????????????????????standard projective texture mapping??????????????????rendering pass??????????????????????????????????????di????????????????????????do??????????????????????????????????S??????
????????????????????????Shader????????????????????????????
??????????????????????????
?????????????????????????????
????????????Single Scattering Approximation???????????????????????????????????????????????????????????????????????????????????????????????
?????????????Diffusion Approximation?????????????????????????
4.4?????????Texture-Space Diffusion?
???????????????????????????3D????????????????????Photoshop???Gaussian????????????????????????????????????
????????????[Borshukov and Lewis 2003]??????????Texture-Space Diffusion???????????????????????????????UV????????????????[0?1]???????????[-1?1]????????
?????????????????????????????????????????
??a??????b???????????????????????
???????????????
???????????????????????????Shader????????????????????????????
??????????????????????????
?????????????
????????????? ?????4?
????????????? ?????4?
????????
????????????????????????????
1????????Warp Lighting?????????Oren-Nayar?????
2??????????????????????????Absorption??
3???????????????Texture-Space Diffusion????????????????????????????
????????????
Example 16-1????????????Shader??????Excerpt from the Skin
Shader Effect Incorporating Wrap Lighting?
Example 16-2??Pass???Shader???The Vertex Program for the Depth Pass?
Example 16-3??Pass???Shader???The Fragment Program for the Depth
Pass?
Example 16-4????????????????Shader???The Fragment Program
Function for Calculating Penetration Depth Using Depth Map?
Example 16-5?????????????????Shader???A Vertex Program to
Unwrap a Model and Perform Diffuse Lighting?
Example 16-6??????????Shader???The Vertex Program for Diffusion
Blur?
Example 16-7??????????Shader???The Fragment Program for Diffusion
Blur?
???????
?????Skin Rendering?
??????Subsurface Scattering?
????????Texture-Space Diffusion?
?????Warp Lighting?
?????Depth Maps?
????????Ambient Occlusion?
??????
?????????????????????????
??????Ambient Occlusion????AO??????????????????????????????????
??????????????????????????????????????????????????????????
???????????1???????????
????????
5.1??
???????????????Ambient Occlusion???????????
1?????????????????????????????????????????
2?????????????????????????????????
??????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
5.2??????The Preprocessing Step?
??????????????????????????????????
?1?????????accessibility?-???????????????????????;
?2???????????????
????????????????????????P?????N?P?????2/3?????????????????1/3??????????????B???????N??????????P??????????????????B????????????????????
?????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
Example 17-1?????????????????Basic Algorithm for Computing Ambient Occlusion Quantities?
- For each triangle {
- Compute center of triangle
- Generate set of rays over the hemisphere there
- Vector avgUnoccluded = Vector(0, 0, 0);
- int numUnoccluded = 0;
- For each ray {
- If (ray doesn't intersect anything) {
- avgUnoccluded += ray.direction;
- ++numUnoccluded;
- }
- }
- avgUnoccluded = normalize(avgUnoccluded);
- accessibility = numUnoccluded / numRays;
- }
复制代码
????????????????????rejection sampling?????x?y?z?-1?1???3D???????????????????????????????
??????????????????????????17-2?????????????????
????????????????Monte Carlo??????????????????
Example 17-2????????????????????Algorithm for Computing
Random Directions with Rejection Sampling?
- while (true) {
- x = RandomFloat(-1, 1); // random float between -1 and 1
- y = RandomFloat(-1, 1);
- z = RandomFloat(-1, 1);
- if (x * x + y * y + z * z > 1) continue; // ignore ones outside unit
- // sphere
- if (dot(Vector(x, y, z), N) < 0) continue; // ignore "down" dirs
- return normalize(Vector(x, y, z)); // success!
- }
复制代码
??????????????????????????????
5.3??????????????Rendering with Ambient Occlusion Maps?
????????????????????
????????????????????????????????????????
?????????????
?1??????????????????????????????
?2???????????????
????????????????????????????????????????B????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????
????????????????????
???????????????????????????????????????????????????????????????????????????
????????
??????????????????????????????????
1?????????accessibility??
2???????????????
???????????????????????
???????????????????
?????????????????????????????????????????????
???????????????????????????????
????????????
Example 17-1?????????????????Basic Algorithm for Computing
Ambient Occlusion Quantities?
Example 17-2????????????????????Algorithm for Computing
Random Directions with Rejection Sampling?
Example 17-3??????????????????Shader?Fragment Shader for
Shading with Accessibility Values and an Environment Map?
Example 17-4 latlong()??????The latlong()Function Definition?
Example 17-5 computeBlur()??????The computeBlur()Function Definition?
???????
??????Ambient Occlusion?
?????Rejection Sampling?
????????Ambient Occlusion Maps?
??????
?????https://zhuanlan.zhihu.com/p/36499291
|