I’ve looked for this matrix throughout all the SimpleApplication fields and i cannot find it. If someone could direct me to where i can get it or create from the camera’s viewProjectionMartix and the model matrix i would be very greatful.

Its the camera and model location and rotation?

You have to combine the camera ViewProjectionMatrix (camera.getViewProjectionMatrix()) and the geometry worldMatrix (geom.getWorldMatrix()).

just go camera.getViewProjectionMatrix().mult(geom.getWorldMatrix()) and that’s the WorldViewProjectionMatrix for this spatial.

@nehon said: You have to combine the camera ViewProjectionMatrix (camera.getViewProjectionMatrix()) and the geometry worldMatrix (geom.getWorldMatrix()). just go camera.getViewProjectionMatrix().mult(geom.getWorldMatrix()) and that's the WorldViewProjectionMatrix for this spatial.

Just to clarify for the OP, the WorldViewProjectionMatrix is unique to each geometry. You (the OP) probably knew this already, but just in case you didn’t.

One Last question the ModelViewProjectionMatrix is the same as the WorldViewProjectionMatrix right? Also thankyou for answering my question

@Vandel-Savage said: One Last question the ModelViewProjectionMatrix is the same as the WorldViewProjectionMatrix right? Also thankyou for answering my question

Yes these are the same.

@Vandel-Savage said: One Last question the ModelViewProjectionMatrix is the same as the WorldViewProjectionMatrix right? Also thankyou for answering my question

Just to be sure, where are you seeing ModelViewProjectionMatrix.

I agree that it sounds the same but it’s hard to be sure.

this is from http://john-chapman-graphics.blogspot.co.uk/2013/01/per-object-motion-blur.html and in this vertex shader you are generating a velocity buffer he uses modelViewProjectionMat.

[java]

uniform mat4 uModelViewProjectionMat;

uniform mat4 uPrevModelViewProjectionMat;

smooth out vec4 vPosition;

smooth out vec4 vPrevPosition;

void main(void) {

vPosition = uModelViewProjectionMat * gl_Vertex;

vPrevPosition = uPrevModelViewProjectionMat * gl_Vertex;

```
gl_Position = vPosition;
```

}[/java]

[java] smooth in vec4 vPosition;

smooth in vec4 vPrevPosition;

out vec2 oVelocity;

void main(void) {

vec2 a = (vPosition.xy / vPosition.w) * 0.5 + 0.5;

vec2 b = (vPrevPosition.xy / vPrevPosition.w) * 0.5 + 0.5;

oVelocity = a - b;

}

[/java]

@Vandel-Savage said: this is from http://john-chapman-graphics.blogspot.co.uk/2013/01/per-object-motion-blur.html and in this vertex shader you are generating a velocity buffer he uses modelViewProjectionMat.[java]

uniform mat4 uModelViewProjectionMat;

uniform mat4 uPrevModelViewProjectionMat;smooth out vec4 vPosition;

smooth out vec4 vPrevPosition;void main(void) {

vPosition = uModelViewProjectionMat * gl_Vertex;

vPrevPosition = uPrevModelViewProjectionMat * gl_Vertex;`gl_Position = vPosition;`

}[/java]

[java] smooth in vec4 vPosition;

smooth in vec4 vPrevPosition;out vec2 oVelocity;

void main(void) {

vec2 a = (vPosition.xy / vPosition.w) * 0.5 + 0.5;

vec2 b = (vPrevPosition.xy / vPrevPosition.w) * 0.5 + 0.5;

oVelocity = a - b;

}

[/java]

Can’t wait to see your implementation. Interestingly enough, because you are gathering the previous model view matrix outside of the geometry shader, you can actually set how often this updated… in essence, you can control how predominant the motion blur is. On the down side, motion blur will have to be applied to individual objects.

@Vandel-Savage said: this is from http://john-chapman-graphics.blogspot.co.uk/2013/01/per-object-motion-blur.html and in this vertex shader you are generating a velocity buffer he uses modelViewProjectionMat.In that case modelViewProjection matrix is the same, yes.

I had Game engine gems 1 for Christmas and I fiddled a bit with their implementation of motion blur. It goes a bit further because it also gather skinning in formation from previous frame, so that you can have motion blur even with character movements.

But I found it so impractical I searched a bit about it on google and read different white papers.

The thing is…they all discuss on how to have a proper blur with no artifact and good performance and they all go like “first just render your classic velocity buffer”… meh…

Gpu gem 3 re project depth from the previous frame and previous projection matrix but that only account for camera movements…

I guess there is no way around retaining a shitload of data from previous frame…and to have an additional geometry pass.

@nehon said: In that case modelViewProjection matrix is the same, yes.I had Game engine gems 1 for Christmas and I fiddled a bit with their implementation of motion blur. It goes a bit further because it also gather skinning in formation from previous frame, so that you can have motion blur even with character movements.

But I found it so impractical I searched a bit about it on google and read different white papers.

The thing is…they all discuss on how to have a proper blur with no artifact and good performance and they all go like “first just render your classic velocity buffer”… meh…

Gpu gem 3 re project depth from the previous frame and previous projection matrix but that only account for camera movements…

I guess there is no way around retaining a shitload of data from previous frame…and to have an additional geometry pass.

In this implementation I don’t need to do a geometry pass since i gather all the matrix information on the cpu i simply generate the velocity buffer and pass it into a post processing filter. Also i implemented Camera motion blur already it looks really good and has a controllable shutter speed and a varying sample number pre-fragment to increase framerate let me know if you would like to see it.

@Vandel-Savage said: i simply generate the velocity bufferDamn... you're one of them ;)

@Vandel-Savage said: In this implementation I don't need to do a geometry pass since i gather all the matrix information on the cpu i simply generate the velocity buffer and pass it into a post processing filter.You mean you generate the velocity buffer on the CPU? I don't get it.

@nehon said:You mean you generate the velocity buffer on the CPU? I don’t get it.

No i gather all the necessary matrix information on the cpu and pass it into the vertex shader and the velocity buffer is generated based on that information.

Still don’t get it.

You have a WorldViewProjectionMatrix for each geometry from the previous frame.right?

So if you pass all that to a post process shader, how do you know the one to use for what fragment?

@Vandel-Savage said: this is from http://john-chapman-graphics.blogspot.co.uk/2013/01/per-object-motion-blur.html and in this vertex shader you are generating a velocity buffer he uses modelViewProjectionMat.[java]

uniform mat4 uModelViewProjectionMat;

uniform mat4 uPrevModelViewProjectionMat;smooth out vec4 vPosition;

smooth out vec4 vPrevPosition;void main(void) {

vPosition = uModelViewProjectionMat * gl_Vertex;

vPrevPosition = uPrevModelViewProjectionMat * gl_Vertex;`gl_Position = vPosition;`

}[/java]

[java] smooth in vec4 vPosition;

smooth in vec4 vPrevPosition;out vec2 oVelocity;

void main(void) {

vec2 a = (vPosition.xy / vPosition.w) * 0.5 + 0.5;

vec2 b = (vPrevPosition.xy / vPrevPosition.w) * 0.5 + 0.5;

oVelocity = a - b;

}

[/java]

This is the shader to generate the Velocity buffer. I write the result to a Frame Buffer and pass that texture into another shader that uses the velocity buffer to generate the blurs

Well this shader is not a 2d shader, it works for rendering a geometry…so at some point, I guess you’re doing an extra geometry pass.

@nehon said: Well this shader is not a 2d shader, it works for rendering a geometry...so at some point, I guess you're doing an extra geometry pass.

Sorry i didn’t get what you were saying at first yes you have to render the geometry a second time with different materials. I thought you were talking about something with the geometry shader.

I guess it can be possible to only render the moving geometries, since you have the matrix from last frame, so it mitigate the cost of the extra pass.

Unless the camera moves then you’d have to render it all anyway I think.

Just a guess, but it should be possible to use multiple render targets and render the velocity buffer at the same time as the “normal” rendering?