You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
105 lines
3.0 KiB
Plaintext
105 lines
3.0 KiB
Plaintext
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
GpuSkinCacheCommon.usf: Common properties and defines for GPU Skinning Cache
|
|
=============================================================================*/
|
|
|
|
#pragma once
|
|
|
|
#include "Common.ush"
|
|
|
|
// These offsets are in uint32/floats; they attempt to match TGPUSkinVertexBase<> & derived classes:
|
|
// TGPUSkinVertexBase
|
|
// TGPUSkinVertexFloat16Uvs<1..N>
|
|
// TGPUSkinVertexFloat32Uvs<1..N>
|
|
|
|
// As we know the properties of the Vertices, the layout looks like this (offset, size in u32):
|
|
// MEMBER TGPUSkinVertexBase TGPUSkinVertexFloat16Uvs<1..N> TGPUSkinVertexFloat32Uvs<1..N>
|
|
// TangentX 0,1 0,1 0,1
|
|
// TangentZ 1,1 1,1 1,1
|
|
// Position 2,3 2,3 2,3
|
|
// UVs[1..N] N/A 5,1..N 5,(1..N)*2
|
|
|
|
#define GPUSKIN_VB_OFFSET_TANGENT_X 0
|
|
#define GPUSKIN_VB_OFFSET_TANGENT_Z 1
|
|
|
|
#ifndef GPUSKIN_USE_EXTRA_INFLUENCES
|
|
#define GPUSKIN_USE_EXTRA_INFLUENCES 0
|
|
#endif
|
|
|
|
#ifndef GPUSKIN_BONE_INDEX_UINT16
|
|
#define GPUSKIN_BONE_INDEX_UINT16 0 // 16-bit bone index if 1, otherwise 8-bit bone index
|
|
#endif
|
|
|
|
#ifndef GPUSKIN_UNLIMITED_BONE_INFLUENCE
|
|
#define GPUSKIN_UNLIMITED_BONE_INFLUENCE 0
|
|
#endif
|
|
|
|
#define GPUSKIN_VB_OFFSET_INFLUENCEBONES 0
|
|
#define GPUSKIN_VB_OFFSET_INFLUENCEWEIGHTS ((1 + GPUSKIN_USE_EXTRA_INFLUENCES) * (1 + GPUSKIN_BONE_INDEX_UINT16))
|
|
|
|
|
|
#ifndef GPUSKIN_RWBUFFER_OFFSET_TANGENT_X
|
|
#define GPUSKIN_RWBUFFER_OFFSET_TANGENT_X 0
|
|
#endif
|
|
|
|
#ifndef GPUSKIN_RWBUFFER_OFFSET_TANGENT_Z
|
|
#define GPUSKIN_RWBUFFER_OFFSET_TANGENT_Z 1
|
|
#endif
|
|
|
|
// @return 0..255
|
|
uint4 UnpackU8x4(uint Packed)
|
|
{
|
|
uint4 Unpacked;
|
|
Unpacked.x = (Packed >> 0) & 0xff;
|
|
Unpacked.y = (Packed >> 8) & 0xff;
|
|
Unpacked.z = (Packed >> 16) & 0xff;
|
|
Unpacked.w = (Packed >> 24) & 0xff;
|
|
return Unpacked;
|
|
}
|
|
|
|
// @return 0..1
|
|
float4 UnpackU8x4N(uint Packed)
|
|
{
|
|
return UnpackU8x4(Packed) / 255.0f;
|
|
}
|
|
|
|
// @return -1..1
|
|
float4 UnpackS8x4N(uint Packed)
|
|
{
|
|
return UnpackU8x4(Packed) / 127.5f - 1;
|
|
}
|
|
|
|
// @param Unpacked -1..1
|
|
// @return layout 0xWWZZYYXX where 0..0xff is mapped to -1..1
|
|
uint PackS8x4N(float4 Unpacked)
|
|
{
|
|
uint Packed = asuint(
|
|
(uint((Unpacked.x + 1.0f) * 127.499f) << 0) |
|
|
(uint((Unpacked.y + 1.0f) * 127.499f) << 8) |
|
|
(uint((Unpacked.z + 1.0f) * 127.499f) << 16) |
|
|
(uint((Unpacked.w + 1.0f) * 127.499f) << 24));
|
|
return Packed;
|
|
}
|
|
|
|
// @param Unpacked -1..1
|
|
// @return layout 0x00ZZYYXX where 0..0xff is mapped to -1..1
|
|
uint PackS8x3N(float3 Unpacked)
|
|
{
|
|
uint Packed = asuint(
|
|
(uint((Unpacked.x + 1.0f) * 127.499f) << 0) |
|
|
(uint((Unpacked.y + 1.0f) * 127.499f) << 8) |
|
|
(uint((Unpacked.z + 1.0f) * 127.499f) << 16));
|
|
return Packed;
|
|
}
|
|
|
|
#if OPENGL_PROFILE
|
|
// GL does not support SNORM images, so instead we write to SINT
|
|
#define TANGENT_RWBUFFER_FORMAT int4
|
|
#define TangentBias_SkinCache(X) ConvertTangentUnormToSnorm8(X)
|
|
#define TangentUnbias_SkinCache(X) round(X * 32767.0)
|
|
#else
|
|
#define TANGENT_RWBUFFER_FORMAT SNORM float4
|
|
#define TangentBias_SkinCache(X) (X)
|
|
#define TangentUnbias_SkinCache(X) (X)
|
|
#endif // OPENGL_PROFILE |