Differential D16243 Diff 58431 source/blender/draw/engines/eevee/shaders/effect_velocity_tile_frag.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/shaders/effect_velocity_tile_frag.glsl
| /** | /** | ||||
| * Shaders that down-sample velocity buffer, | * Shaders that down-sample velocity buffer, | ||||
| * | * | ||||
| * Based on: | * Based on: | ||||
| * A Fast and Stable Feature-Aware Motion Blur Filter | * A Fast and Stable Feature-Aware Motion Blur Filter | ||||
| * by Jean-Philippe Guertin, Morgan McGuire, Derek Nowrouzezahrai | * by Jean-Philippe Guertin, Morgan McGuire, Derek Nowrouzezahrai | ||||
| * | * | ||||
| * Adapted from G3D Innovation Engine implementation. | * Adapted from G3D Innovation Engine implementation. | ||||
| */ | */ | ||||
| uniform sampler2D velocityBuffer; | |||||
| uniform vec2 viewportSize; | |||||
| uniform vec2 viewportSizeInv; | |||||
| uniform ivec2 velocityBufferSize; | |||||
| out vec4 tileMaxVelocity; | |||||
| vec4 sample_velocity(ivec2 texel) | vec4 sample_velocity(ivec2 texel) | ||||
| { | { | ||||
| texel = clamp(texel, ivec2(0), velocityBufferSize - 1); | texel = clamp(texel, ivec2(0), velocityBufferSize - 1); | ||||
| vec4 data = texelFetch(velocityBuffer, texel, 0); | vec4 data = texelFetch(velocityBuffer, texel, 0); | ||||
| /* Decode data. */ | /* Decode data. */ | ||||
| return (data * 2.0 - 1.0) * viewportSize.xyxy; | return (data * 2.0 - 1.0) * viewportSize.xyxy; | ||||
| } | } | ||||
| vec4 encode_velocity(vec4 velocity) | vec4 encode_velocity(vec4 velocity) | ||||
| { | { | ||||
| return velocity * viewportSizeInv.xyxy * 0.5 + 0.5; | return velocity * viewportSizeInv.xyxy * 0.5 + 0.5; | ||||
| } | } | ||||
| #ifdef TILE_GATHER | #ifdef TILE_GATHER | ||||
| uniform ivec2 gatherStep; | |||||
| void main() | void main() | ||||
| { | { | ||||
| vec4 max_motion = vec4(0.0); | vec4 max_motion = vec4(0.0); | ||||
| float max_motion_len_sqr_prev = 0.0; | float max_motion_len_sqr_prev = 0.0; | ||||
| float max_motion_len_sqr_next = 0.0; | float max_motion_len_sqr_next = 0.0; | ||||
| ivec2 texel = ivec2(gl_FragCoord.xy); | ivec2 texel = ivec2(gl_FragCoord.xy); | ||||
| texel = texel * gatherStep.yx + texel * EEVEE_VELOCITY_TILE_SIZE * gatherStep; | texel = texel * gatherStep.yx + texel * EEVEE_VELOCITY_TILE_SIZE * gatherStep; | ||||
| ▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines | |||||