mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2024-11-09 22:32:55 +01:00
max
f2b6a61d1e
Custom vector3 encoding/decoding test. removed normal decoding from VA functions, this should now be done outside this function to allow easy switching of decoders. Co-Authored-By: Neeto-rzo <68438932+Neeto-rzo@users.noreply.github.com>
52 lines
1.3 KiB
HLSL
52 lines
1.3 KiB
HLSL
|
|
#ifndef VERTEXANIMATIONUTILS_INCLUDED
|
|
#define VERTEX_ANIMATION_INCLUDED
|
|
|
|
#include "VectorEncodingDecoding.hlsl"
|
|
#include "SampleTexture2DArrayLOD.hlsl"
|
|
|
|
float2 VA_UV_float(float2 uv, int maxFrames, float time)
|
|
{
|
|
float2 uvPosition;
|
|
|
|
float timeInFrames = frac(time);
|
|
timeInFrames = ceil(timeInFrames * maxFrames);
|
|
timeInFrames /= maxFrames;
|
|
timeInFrames += (1 / maxFrames);
|
|
|
|
uvPosition.x = uv.x;
|
|
uvPosition.y = (1 - (timeInFrames)) + (1 - (1 - uv.y));
|
|
|
|
return uvPosition;
|
|
}
|
|
|
|
void VA_float(float2 uv, SamplerState texSampler, Texture2D positionMap, float time, int maxFrames,
|
|
out float3 position, out float3 alpha)
|
|
{
|
|
float2 uvPosition = VA_UV_float(uv, maxFrames, time);
|
|
|
|
// Position.
|
|
float4 texturePos = positionMap.SampleLevel(texSampler, uvPosition, 0);
|
|
position = texturePos.xyz;
|
|
|
|
// Normal.
|
|
//FloatToFloat3_float(texturePos.w, outNormal);
|
|
alpha = texturePos.w;
|
|
}
|
|
|
|
void VA_ARRAY_float(float2 uv, SamplerState texSampler, Texture2DArray positionMap, float positionMapIndex, float time, int maxFrames,
|
|
out float3 position, out float3 alpha)
|
|
{
|
|
float2 uvPosition = VA_UV_float(uv, maxFrames, time);
|
|
|
|
// Position.
|
|
float4 texturePos;
|
|
SampleTexture2DArrayLOD_float(positionMap, uvPosition, texSampler, positionMapIndex, 0, texturePos);
|
|
position = texturePos.xyz;
|
|
|
|
// Normal.
|
|
//FloatToFloat3_float(texturePos.w, outNormal);
|
|
alpha = texturePos.w;
|
|
}
|
|
|
|
#endif |