Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_lightprobes.c
| Show First 20 Lines • Show All 1,047 Lines • ▼ Show 20 Lines | void EEVEE_lightbake_filter_glossy(EEVEE_ViewLayerData *sldata, | ||||
| /* 2 - Let gpu create Mipmaps for Filtered Importance Sampling. */ | /* 2 - Let gpu create Mipmaps for Filtered Importance Sampling. */ | ||||
| /* Bind next framebuffer to be able to gen. mips for probe_rt. */ | /* Bind next framebuffer to be able to gen. mips for probe_rt. */ | ||||
| EEVEE_downsample_cube_buffer(vedata, rt_color, (int)(pinfo->lod_rt_max)); | EEVEE_downsample_cube_buffer(vedata, rt_color, (int)(pinfo->lod_rt_max)); | ||||
| /* 3 - Render to probe array to the specified layer, do prefiltering. */ | /* 3 - Render to probe array to the specified layer, do prefiltering. */ | ||||
| int mipsize = GPU_texture_width(light_cache->cube_tx.tex); | int mipsize = GPU_texture_width(light_cache->cube_tx.tex); | ||||
| for (int i = 0; i < maxlevel + 1; i++) { | for (int i = 0; i < maxlevel + 1; i++) { | ||||
| float bias = (i == 0) ? -1.0f : 1.0f; | float bias = 0.0f; | ||||
| pinfo->texel_size = 1.0f / (float)mipsize; | pinfo->texel_size = 1.0f / (float)mipsize; | ||||
| pinfo->padding_size = (i == maxlevel) ? 0 : (float)(1 << (maxlevel - i - 1)); | pinfo->padding_size = (i == maxlevel) ? 0 : (float)(1 << (maxlevel - i - 1)); | ||||
| pinfo->padding_size *= pinfo->texel_size; | pinfo->padding_size *= pinfo->texel_size; | ||||
| pinfo->layer = probe_idx; | pinfo->layer = probe_idx; | ||||
| pinfo->roughness = i / (float)maxlevel; | pinfo->roughness = i / (float)maxlevel; | ||||
| pinfo->roughness *= pinfo->roughness; /* Disney Roughness */ | pinfo->roughness *= pinfo->roughness; /* Disney Roughness */ | ||||
| pinfo->roughness *= pinfo->roughness; /* Distribute Roughness accros lod more evenly */ | pinfo->roughness *= pinfo->roughness; /* Distribute Roughness accros lod more evenly */ | ||||
| CLAMP(pinfo->roughness, 1e-8f, 0.99999f); /* Avoid artifacts */ | CLAMP(pinfo->roughness, 1e-8f, 0.99999f); /* Avoid artifacts */ | ||||
| #if 1 /* Variable Sample count (fast) */ | #if 1 /* Variable Sample count and bias (fast) */ | ||||
| switch (i) { | switch (i) { | ||||
| case 0: | case 0: | ||||
| pinfo->samples_len = 1.0f; | pinfo->samples_len = 1.0f; | ||||
| bias = -1.0f; | |||||
| break; | break; | ||||
| case 1: | case 1: | ||||
| pinfo->samples_len = 16.0f; | pinfo->samples_len = 32.0f; | ||||
| bias = 1.0f; | |||||
| break; | break; | ||||
| case 2: | case 2: | ||||
| pinfo->samples_len = 32.0f; | pinfo->samples_len = 40.0f; | ||||
| bias = 2.0f; | |||||
| break; | break; | ||||
| case 3: | case 3: | ||||
| pinfo->samples_len = 64.0f; | pinfo->samples_len = 64.0f; | ||||
| bias = 2.0f; | |||||
| break; | break; | ||||
| default: | default: | ||||
| pinfo->samples_len = 128.0f; | pinfo->samples_len = 128.0f; | ||||
| bias = 2.0f; | |||||
| break; | break; | ||||
| } | } | ||||
| #else /* Constant Sample count (slow) */ | #else /* Constant Sample count (slow) */ | ||||
| pinfo->samples_len = 1024.0f; | pinfo->samples_len = 1024.0f; | ||||
| #endif | #endif | ||||
| /* Cannot go higher than HAMMERSLEY_SIZE */ | /* Cannot go higher than HAMMERSLEY_SIZE */ | ||||
| CLAMP(filter_quality, 1.0f, 8.0f); | CLAMP(filter_quality, 1.0f, 8.0f); | ||||
| pinfo->samples_len *= filter_quality; | pinfo->samples_len *= filter_quality; | ||||
| ▲ Show 20 Lines • Show All 220 Lines • Show Last 20 Lines | |||||