Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Velocity function #3

Open
Ahleroy opened this issue Nov 5, 2018 · 10 comments
Open

Velocity function #3

Ahleroy opened this issue Nov 5, 2018 · 10 comments

Comments

@Ahleroy
Copy link

Ahleroy commented Nov 5, 2018

I am not sure to understand the content of this custom function.
Would you mind giving an explanation ?

float2 Velocity = inVelocity.xy;
if(Velocity.x > 0.0){
const float InvDiv = 1.0f / (0.499f * 0.5f);
	
Velocity = Velocity * InvDiv - 32767.0f / 65535.0f * InvDiv;
}
else {
float4 ThisClip = float4( inUV, ConvertToDeviceZ(inDepth), 1 );
	float4 PrevClip = mul( ThisClip, View.ClipToPrevClip );
	float2 PrevScreen = PrevClip.xy / PrevClip.w;
	Velocity = inUV - PrevScreen;
}

return Velocity * 100;

Thanks.

@ProfFan
Copy link
Owner

ProfFan commented Jan 27, 2019

Unreal does not calculate the velocity of static objects, so you need to interpolate using camera transform :)

@el3ment
Copy link

el3ment commented Feb 21, 2019

Should you be testing PrevClip.w to ensure it is positive?

@ProfFan
Copy link
Owner

ProfFan commented Feb 22, 2019

Why?

@ywu40
Copy link

ywu40 commented Mar 22, 2020

Hello,

Which file includes the above mentioned velocity code? I searched in all source code files and project, I did not find the code

Thanks

@ProfFan
Copy link
Owner

ProfFan commented Mar 22, 2020

@ywu40 It is in a UE4 material shader, you need to open it in UE4's Blueprint view.

@ywu40
Copy link

ywu40 commented Mar 22, 2020

@ProfFan Thanks. I found it now.

@ywu40
Copy link

ywu40 commented Apr 10, 2020

@ProfFan One more question, I saw the return value code "return Velocity * 100;". May I know why do you multiply 100? What is the meaning of 100 here? How/where do you get the value 100? Is it the value of Field of View?

Thanks for your help.

@ProfFan
Copy link
Owner

ProfFan commented Apr 10, 2020

@ywu40 From what I remember it is arbitrary (as the original value is too small). You can also do a log or so to increase the dynamic range

@ywu40
Copy link

ywu40 commented Apr 10, 2020

@ProfFan Thanks very much for the quick response. So multiply 100 is just for better visualization, the actual value should be just "Velocity" itself, right?

@ProfFan
Copy link
Owner

ProfFan commented Apr 10, 2020

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants