<!// VelocityWrite.slh// libraries/render-utils/src//// Created by Olivier Prat on 10/19/18.// Copyright 2018 High Fidelity, Inc.// Copyright 2024 Overte e.V.//// Distributed under the Apache License, Version 2.0.// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html!><@if not VELOCITY_WRITE_SLH@><@def VELOCITY_WRITE_SLH@><@include gpu/Transform.slh@><$declareStandardCameraTransform()$>vec2 getEyeTexcoordPos() { // No need to add 0.5 as, by default, frag coords are pixel centered at (0.5, 0.5) vec2 texCoordPos = gl_FragCoord.xy; texCoordPos *= cam_getInvWidthHeight(); texCoordPos.x -= cam_getStereoSide(); return texCoordPos;}vec2 packVelocity(vec4 prevPositionCS) { vec2 uv = getEyeTexcoordPos(); vec2 prevUV = (prevPositionCS.xy / prevPositionCS.w) * 0.5 + 0.5; vec2 deltaUV = uv - prevUV; // Velocity should be computed without any jitter inside. return deltaUV;}<@endif@>
<!
// VelocityWrite.slh
// libraries/render-utils/src
//
// Created by Olivier Prat on 10/19/18.
// Copyright 2018 High Fidelity, Inc.
// Copyright 2024 Overte e.V.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
!>
<@if not VELOCITY_WRITE_SLH@>
<@def VELOCITY_WRITE_SLH@>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
vec2 getEyeTexcoordPos() {
// No need to add 0.5 as, by default, frag coords are pixel centered at (0.5, 0.5)
vec2 texCoordPos = gl_FragCoord.xy;
texCoordPos *= cam_getInvWidthHeight();
texCoordPos.x -= cam_getStereoSide();
return texCoordPos;
}
vec2 packVelocity(vec4 prevPositionCS) {
vec2 uv = getEyeTexcoordPos();
vec2 prevUV = (prevPositionCS.xy / prevPositionCS.w) * 0.5 + 0.5;
vec2 deltaUV = uv - prevUV;
// Velocity should be computed without any jitter inside.
return deltaUV;
}
<@endif@>