About Motion Blur in T3D 1.0.1
by Nabarro · in Torque 3D Professional · 10/28/2009 (8:43 am) · 11 replies
Does T3D 1.0.1 support Motion Blur? If it does, which codes (.cpp files and .hlsl files) are related with the function? Sorry for the nooob question, and I'm freshman with the area. Thank you very much.
#2
10/28/2009 (11:21 am)
I am fairly sure that motion blur can be easily achieved within a postFX shader.
#4
10/28/2009 (3:27 pm)
The Advanced Lighting buffer conditioner feature can be used to implement motion blur without resorting to hacks. There are interfaces so you can add a new pre-pass buffer type (for velocity vectors) and you can change the shaderGen to add a velocity prepass feature, and finally write a postFX that reads the velocity vectors and perform the blur.
#5
10/28/2009 (6:09 pm)
I'd like to suggest to someone to write one and sell it. I am sure you would make a decent amount of money from the work.
#6
You can do camera based motion blur already in a PostEffect. It can pass the current and previous frames camera transform which you can use to do a directional blur effect. Its not ideal, but alot of games use it to avoid the cost of a per-pixel velocity vector.
I think Pat may have implemented one lately... don't know for sure.
10/28/2009 (10:31 pm)
We'll eventually get true per-pixel motion blur, but the cost is having a fatter deferred buffer.You can do camera based motion blur already in a PostEffect. It can pass the current and previous frames camera transform which you can use to do a directional blur effect. Its not ideal, but alot of games use it to avoid the cost of a per-pixel velocity vector.
I think Pat may have implemented one lately... don't know for sure.
#7
Any update on this? It seems I'm stalking you guys lately for updates, but I'm just curious what to see in future, and/or the topic has been left out.
clearly something should have happened, just look at the time space O_o (~9 months).
07/26/2010 (9:17 pm)
@ Tom & PatAny update on this? It seems I'm stalking you guys lately for updates, but I'm just curious what to see in future, and/or the topic has been left out.
clearly something should have happened, just look at the time space O_o (~9 months).
#8
09/20/2010 (2:45 am)
Pat, sell the shader and your soul too! Make it a package deal!
#9
and reference with http://http.developer.nvidia.com/GPUGems3/gpugems3_ch27.html
path to : shaders/common/postFx/motionBlurP.hlsl
path to : core/scripts/client/postFx/MotionBlurFx.cs
and use it console window
very simple code to use motion blur but it isn't complete code
11/20/2012 (2:48 am)
it is my simple test of motion blurand reference with http://http.developer.nvidia.com/GPUGems3/gpugems3_ch27.html
path to : shaders/common/postFx/motionBlurP.hlsl
#include "./postFx.hlsl"
#include "../torque.hlsl"
uniform float4x4 matPrevScreenToWorld;
uniform float4x4 matWorldToScreen;
uniform sampler2D backBuffer : register(S0);
uniform sampler2D depthSampler : register(S1);
float4 main(PFXVertToPix IN) : COLOR0
{
float samples = 5;
float zOverW = tex2D(depthSampler, IN.uv0);
float4 H = float4( IN.uv0.x * 2 - 1, (1 - IN.uv0.y) * 2 - 1,
zOverW, 1);
float4 D = mul(H, matWorldToScreen);
float4 worldPos = D / D.w;
float4 currentPos = H;
float4 previousPos = mul( worldPos, matPrevScreenToWorld );
previousPos /= previousPos.w;
float2 velocity = (currentPos - previousPos) / 1000.f;
float4 color = tex2D(backBuffer, IN.uv0);
IN.uv0 += velocity;
for(int i = 1; i<samples; ++i, IN.uv0 += velocity)
{
float4 currentColor = tex2D(backBuffer, IN.uv0);
color += currentColor;
}
return color / samples;
}path to : core/scripts/client/postFx/MotionBlurFx.cs
singleton ShaderData( PFX_MotionBlurShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl"; //as we don't need a specialized vertex shader, we use the bare-bones postFxV.hlsl
DXPixelShaderFile = "shaders/common/postFx/motionBlurP.hlsl"; //our new pixel shader
samplerNames[0] = "$inputTex";
pixVersion = 3.0;
};
singleton PostEffect(MotionBlurFX)
{
renderTime = "PFXAfterDiffuse";
shader = PFX_MotionBlurShader;
stateBlock = PFX_DefaultStateBlock;
texture[0] = "$backbuffer";
};and use it console window
MotionBlurFX.enbale();
very simple code to use motion blur but it isn't complete code
#10
Also
float4 D = mul(H, matWorldToScreen);
float4 previousPos = mul( worldPos, matPrevScreenToWorld );
should be replaced with:
float4 D = mul(matWorldToScreen, H);
float4 previousPos = mul( matPrevScreenToWorld , worldPos);
because you should treat worldPos is a column vector.
If this is not working for you, then you have a bug in postEffect.cpp, because the matrix construction of the current and previous matrices there is incorrect.
This effect was done here at liman3D but was excluded from the shader collection 1, because it required many source code changes. Also the effect is not a real motion blur, because you need a camera motion for that.
04/29/2013 (1:43 am)
Enel, tou should use matPrevScreenToWorld and matScreenToWorld in order to get the velocity offset at world space.Also
float4 D = mul(H, matWorldToScreen);
float4 previousPos = mul( worldPos, matPrevScreenToWorld );
should be replaced with:
float4 D = mul(matWorldToScreen, H);
float4 previousPos = mul( matPrevScreenToWorld , worldPos);
because you should treat worldPos is a column vector.
If this is not working for you, then you have a bug in postEffect.cpp, because the matrix construction of the current and previous matrices there is incorrect.
This effect was done here at liman3D but was excluded from the shader collection 1, because it required many source code changes. Also the effect is not a real motion blur, because you need a camera motion for that.
#11
Just as an FYI, camera based Motion Blur will be released/available in the 3.0 version of MIT.
Ron
05/01/2013 (4:42 pm)
All,Just as an FYI, camera based Motion Blur will be released/available in the 3.0 version of MIT.
Ron
Torque Owner Adam Beer
Ignition Games Inc.