created new velocity buffer dilation patterns;

fixed hairparticle velocity buffer generation;
This commit is contained in:
turanszkij
2017-09-09 11:10:05 +02:00
parent 7724b9543c
commit faf1e8fd57
5 changed files with 79 additions and 7 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
#define DILATE_VELOCITY
#define DILATE_VELOCITY_AVG_FAR
#include "postProcessHF.hlsli"
#include "reconstructPositionHF.hlsli"
+75 -3
View File
@@ -8,7 +8,8 @@
float2 GetVelocity(in int2 pixel)
{
#ifdef DILATE_VELOCITY
#ifdef DILATE_VELOCITY_BEST_3X3 // search best velocity in 3x3 neighborhood
float bestDepth = g_xFrame_MainCamera_ZFarP;
int2 bestPixel = int2(0, 0);
@@ -18,19 +19,90 @@ float2 GetVelocity(in int2 pixel)
[unroll]
for (int j = -1; j <= 1; ++j)
{
float depth = texture_lineardepth[pixel];
int2 curPixel = pixel + int2(i, j);
float depth = texture_lineardepth[curPixel];
[flatten]
if (depth < bestDepth)
{
bestDepth = depth;
bestPixel = pixel + int2(i, j);
bestPixel = curPixel;
}
}
}
return texture_gbuffer1[bestPixel].zw;
#elif defined DILATE_VELOCITY_BEST_FAR // search best velocity in a far reaching 5-tap pattern
float bestDepth = g_xFrame_MainCamera_ZFarP;
int2 bestPixel = int2(0, 0);
// top-left
int2 curPixel = pixel + int2(-2, -2);
float depth = texture_lineardepth[curPixel];
[flatten]
if (depth < bestDepth)
{
bestDepth = depth;
bestPixel = curPixel;
}
// top-right
curPixel = pixel + int2(2, -2);
depth = texture_lineardepth[curPixel];
[flatten]
if (depth < bestDepth)
{
bestDepth = depth;
bestPixel = curPixel;
}
// bottom-right
curPixel = pixel + int2(2, 2);
depth = texture_lineardepth[curPixel];
[flatten]
if (depth < bestDepth)
{
bestDepth = depth;
bestPixel = curPixel;
}
// bottom-left
curPixel = pixel + int2(-2, 2);
depth = texture_lineardepth[curPixel];
[flatten]
if (depth < bestDepth)
{
bestDepth = depth;
bestPixel = curPixel;
}
// center
curPixel = pixel;
depth = texture_lineardepth[curPixel];
[flatten]
if (depth < bestDepth)
{
bestDepth = depth;
bestPixel = curPixel;
}
return texture_gbuffer1[bestPixel].zw;
#elif defined DILATE_VELOCITY_AVG_FAR
float2 velocity_TL = texture_gbuffer1[pixel + int2(-2, -2)].zw;
float2 velocity_TR = texture_gbuffer1[pixel + int2(2, -2)].zw;
float2 velocity_BL = texture_gbuffer1[pixel + int2(-2, 2)].zw;
float2 velocity_BR = texture_gbuffer1[pixel + int2(2, 2)].zw;
float2 velocity_CE = texture_gbuffer1[pixel].zw;
return (velocity_TL + velocity_TR + velocity_BL + velocity_BR + velocity_CE) / 5.0f;
#else
return texture_gbuffer1[pixel].zw;
#endif // DILATE_VELOCITY
}
+1 -1
View File
@@ -37,7 +37,7 @@ void main(
float3 color = saturate(xColor.xyz + sin(pos.x - pos.y - pos.z)*0.013f)*0.5;
float3 normal = /*normalize(*/input[0].nor.xyz * 2 - 1/*-wind)*/;
float3 wind = sin(g_xFrame_Time + (pos.x + pos.y + pos.z))*g_xFrame_WindDirection.xyz*0.03*grassLength;
float3 windPrev = sin(g_xFrame_Time + (pos.x + pos.y + pos.z))*g_xFrame_WindDirection.xyz*0.03*grassLength;
float3 windPrev = sin(g_xFrame_TimePrev + (pos.x + pos.y + pos.z))*g_xFrame_WindDirection.xyz*0.03*grassLength;
frame.xy *= grassLength;
pos.xyz -= normal*0.1*grassLength;
+1 -1
View File
@@ -1,5 +1,5 @@
// This can retrieve better velocity vectors so moving objects could be better anti aliased:
#define DILATE_VELOCITY
#define DILATE_VELOCITY_BEST_3X3
#include "postProcessHF.hlsli"
#include "reconstructPositionHF.hlsli"
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 13;
// minor bug fixes, alterations, refactors, updates
const int revision = 3;
const int revision = 4;
long GetVersion()