Sample as Lamp option for world shaders, to enable multiple importance sampling.

By default lighting from the world is computed solely with indirect light
sampling. However for more complex environment maps this can be too noisy, as
sampling the BSDF may not easily find the highlights in the environment map
image. By enabling this option, the world background will be sampled as a lamp,
with lighter parts automatically given more samples.

Map Resolution specifies the size of the importance map (res x res). Before
rendering starts, an importance map is generated by "baking" a grayscale image
from the world shader. This will then be used to determine which parts of the
background are light and so should receive more samples than darker parts.
Higher resolutions will result in more accurate sampling but take more setup
time and memory.

Patch by Mike Farnsworth, thanks!
This commit is contained in:
Brecht Van Lommel
2012-01-20 17:49:17 +00:00
parent bddc01a7e1
commit 5873301257
26 changed files with 505 additions and 66 deletions

View File

@@ -175,9 +175,8 @@ __device void svm_node_tex_environment(KernelGlobals *kg, ShaderData *sd, float
decode_node_uchar4(node.z, &co_offset, &out_offset, &alpha_offset, &srgb);
float3 co = stack_load_float3(stack, co_offset);
float u = (atan2f(co.y, co.x) + M_PI_F)/(2*M_PI_F);
float v = atan2f(co.z, hypotf(co.x, co.y))/M_PI_F + 0.5f;
float4 f = svm_image_texture(kg, id, u, v);
float2 uv = direction_to_equirectangular(co);
float4 f = svm_image_texture(kg, id, uv.x, uv.y);
float3 r = make_float3(f.x, f.y, f.z);
if(srgb) {