| Blockland Forums > Suggestions & Requests |
| motion blur |
| << < (3/3) |
| rlcbm:
heres code --- Code: ---uniform sampler2D tex; uniform sampler2D tex2; uniform mat4 PrevMatrix; varying vec2 vTexCoord; void main(void) { vec4 color = texture2D(tex, vTexCoord); vec4 zOverW = texture2D(tex2, vTexCoord); // H is the viewport position at this pixel in the range -1 to 1. vec4 H = vec4(vTexCoord.x * 2 - 1, (1 - vTexCoord.y) * 2 - 1, zOverW.g, 1); // Transform by the view-projection inverse. vec4 D = gl_ModelViewProjectionMatrixInverse * H; // Divide by w to get the world position. vec4 worldPos = D / vec4(D.w); // Current viewport position vec4 currentPos = H; // Use the world position, and transform by the previous view-projection matrix. vec4 previousPos = PrevMatrix * worldpos; // Convert to nonhomogeneous points [-1,1] by dividing by w. previousPos = previousPos / vec4(previousPos.w); // Use this frame's position and last frame's to compute the pixel velocity. vec2 velocity = vec2(currentPos.xy - previousPos.xy)/2.0; //velocity = (velocity + 1.0 ) / 2.0; gl_FragColor = vec4(velocity.x, velocity.y, color.g, 1.0); } --- End code --- |
| Port:
--- Quote from: rlcbm on December 16, 2012, 12:17:04 PM ---heres code --- Code: ---... --- End code --- --- End quote --- Nope, that doesn't compile in the scope that Blockland provides. |
| rlcbm:
oh |
| Klocko:
shaders |
| Port:
--- Quote from: Klocko on December 17, 2012, 09:27:49 PM ---shaders --- End quote --- Pointless post much? |
| Navigation |
| Message Index |
| Previous page |