Workbench: Improve volume render by removing noise using temporal AA
This commit is contained in:
parent
8af53dbeab
commit
b23c68a937
|
@ -14,6 +14,7 @@ uniform sampler1D flameColorTexture;
|
|||
uniform sampler1D transferTexture;
|
||||
|
||||
uniform int samplesLen = 256;
|
||||
uniform float noiseOfs = 0.0f;
|
||||
uniform float stepLength; /* Step length in local space. */
|
||||
uniform float densityScale; /* Simple Opacity multiplicator. */
|
||||
uniform vec4 viewvecs[3];
|
||||
|
@ -115,7 +116,7 @@ vec4 volume_integration(
|
|||
float final_transmittance = 1.0;
|
||||
|
||||
ivec2 tx = ivec2(gl_FragCoord.xy) % 4;
|
||||
float noise = dither_mat[tx.x][tx.y];
|
||||
float noise = fract(dither_mat[tx.x][tx.y] + noiseOfs);
|
||||
|
||||
float ray_len = noise * ray_inc;
|
||||
for (int i = 0; i < samplesLen && ray_len < ray_max; ++i, ray_len += ray_inc) {
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include "BKE_modifier.h"
|
||||
|
||||
#include "BLI_rand.h"
|
||||
|
||||
#include "DNA_modifier_types.h"
|
||||
#include "DNA_object_force_types.h"
|
||||
#include "DNA_smoke_types.h"
|
||||
|
@ -91,6 +93,7 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Objec
|
|||
SmokeModifierData *smd = (SmokeModifierData *)md;
|
||||
SmokeDomainSettings *sds = smd->domain;
|
||||
WORKBENCH_PrivateData *wpd = vedata->stl->g_data;
|
||||
WORKBENCH_EffectInfo *effect_info = vedata->stl->effects;
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
DRWShadingGroup *grp = NULL;
|
||||
|
||||
|
@ -133,6 +136,8 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Objec
|
|||
DRW_shgroup_uniform_int_copy(grp, "sliceAxis", axis);
|
||||
}
|
||||
else {
|
||||
double noise_ofs;
|
||||
BLI_halton_1D(3, 0.0, effect_info->jitter_index, &noise_ofs);
|
||||
int max_slices = max_iii(sds->res[0], sds->res[1], sds->res[2]) * sds->slice_per_voxel;
|
||||
|
||||
GPUShader *sh = (sds->use_coba) ? e_data.volume_coba_sh : e_data.volume_sh;
|
||||
|
@ -143,6 +148,7 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, Scene *scene, Objec
|
|||
* is NOT unit length in object space so the required number of subdivisions
|
||||
* is tricky to get. */
|
||||
DRW_shgroup_uniform_float_copy(grp, "stepLength", 8.0f / max_slices);
|
||||
DRW_shgroup_uniform_float_copy(grp, "noiseOfs", noise_ofs);
|
||||
}
|
||||
|
||||
if (sds->use_coba) {
|
||||
|
|
Loading…
Reference in New Issue