Replace vectors and matrix4x4s to floatx from Mathematics
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Misaki.AoVolume
|
||||
@@ -7,28 +7,28 @@ namespace Misaki.AoVolume
|
||||
internal struct GPUFrustum
|
||||
{
|
||||
// The data of the 6 planes of the frustum
|
||||
public Vector3 normal0;
|
||||
public float3 normal0;
|
||||
public float dist0;
|
||||
public Vector3 normal1;
|
||||
public float3 normal1;
|
||||
public float dist1;
|
||||
public Vector3 normal2;
|
||||
public float3 normal2;
|
||||
public float dist2;
|
||||
public Vector3 normal3;
|
||||
public float3 normal3;
|
||||
public float dist3;
|
||||
public Vector3 normal4;
|
||||
public float3 normal4;
|
||||
public float dist4;
|
||||
public Vector3 normal5;
|
||||
public float3 normal5;
|
||||
public float dist5;
|
||||
|
||||
// The data of the 8 corners of the frustum
|
||||
public Vector4 corner0;
|
||||
public Vector4 corner1;
|
||||
public Vector4 corner2;
|
||||
public Vector4 corner3;
|
||||
public Vector4 corner4;
|
||||
public Vector4 corner5;
|
||||
public Vector4 corner6;
|
||||
public Vector4 corner7;
|
||||
public float4 corner0;
|
||||
public float4 corner1;
|
||||
public float4 corner2;
|
||||
public float4 corner3;
|
||||
public float4 corner4;
|
||||
public float4 corner5;
|
||||
public float4 corner6;
|
||||
public float4 corner7;
|
||||
}
|
||||
|
||||
[GenerateHLSL(PackingRules.Exact, false)]
|
||||
@@ -36,32 +36,32 @@ namespace Misaki.AoVolume
|
||||
{
|
||||
// 4 x float3 = 48 bytes.
|
||||
// TODO: pack the axes into 16-bit UNORM per channel, and consider a quaternionic representation.
|
||||
public Vector3 center;
|
||||
public Vector3 right;
|
||||
public Vector3 up;
|
||||
public float3 center;
|
||||
public float3 right;
|
||||
public float3 up;
|
||||
|
||||
public Vector3 extent;
|
||||
public float3 extent;
|
||||
|
||||
//public ushort quatX;
|
||||
//public ushort quatY;
|
||||
//public ushort quatZ;
|
||||
//public ushort quatW;
|
||||
|
||||
public readonly Vector3 Forward => Vector3.Cross(up, right);
|
||||
public readonly float3 Forward => math.cross(up, right);
|
||||
|
||||
public OrientedBoundingBox(Matrix4x4 trs)
|
||||
public OrientedBoundingBox(float4x4 trs)
|
||||
{
|
||||
var vecX = (Vector3)trs.GetColumn(0);
|
||||
var vecY = (Vector3)trs.GetColumn(1);
|
||||
var vecZ = (Vector3)trs.GetColumn(2);
|
||||
float3 vecX = trs.c0.xyz;
|
||||
float3 vecY = trs.c1.xyz;
|
||||
float3 vecZ = trs.c2.xyz;
|
||||
|
||||
center = trs.GetColumn(3);
|
||||
right = vecX * (1.0f / vecX.magnitude);
|
||||
up = vecY * (1.0f / vecY.magnitude);
|
||||
center = trs.c3.xyz;
|
||||
right = vecX * (1.0f / math.length(vecX));
|
||||
up = vecY * (1.0f / math.length(vecY));
|
||||
|
||||
extent.x = 0.5f * vecX.magnitude;
|
||||
extent.y = 0.5f * vecY.magnitude;
|
||||
extent.z = 0.5f * vecZ.magnitude;
|
||||
extent.x = 0.5f * math.length(vecX);
|
||||
extent.y = 0.5f * math.length(vecY);
|
||||
extent.z = 0.5f * math.length(vecZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,17 +16,17 @@ struct CullingData
|
||||
// PackingRules = Exact
|
||||
struct GPUFrustum
|
||||
{
|
||||
float3 normal0;
|
||||
float4 normal0;
|
||||
float dist0;
|
||||
float3 normal1;
|
||||
float4 normal1;
|
||||
float dist1;
|
||||
float3 normal2;
|
||||
float4 normal2;
|
||||
float dist2;
|
||||
float3 normal3;
|
||||
float4 normal3;
|
||||
float dist3;
|
||||
float3 normal4;
|
||||
float4 normal4;
|
||||
float dist4;
|
||||
float3 normal5;
|
||||
float4 normal5;
|
||||
float dist5;
|
||||
float4 corner0;
|
||||
float4 corner1;
|
||||
@@ -42,10 +42,10 @@ struct GPUFrustum
|
||||
// PackingRules = Exact
|
||||
struct OrientedBoundingBox
|
||||
{
|
||||
float3 center;
|
||||
float3 right;
|
||||
float3 up;
|
||||
float3 extent;
|
||||
float4 center;
|
||||
float4 right;
|
||||
float4 up;
|
||||
float4 extent;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
@@ -10,12 +11,12 @@ namespace Misaki.AoVolume
|
||||
{
|
||||
[HideInInspector]
|
||||
[NonSerialized]
|
||||
public Matrix4x4 worldMatrix;
|
||||
public float4x4 worldMatrix;
|
||||
[HideInInspector]
|
||||
[NonSerialized]
|
||||
public Matrix4x4 inverseWorldMatrix;
|
||||
public float4x4 inverseWorldMatrix;
|
||||
|
||||
public Vector3 size;
|
||||
public float3 size;
|
||||
|
||||
[Range(0.0f, 1.0f)]
|
||||
public float intensity;
|
||||
@@ -26,7 +27,7 @@ namespace Misaki.AoVolume
|
||||
|
||||
public static VolumeData Default => new()
|
||||
{
|
||||
size = Vector3.one,
|
||||
size = new float3(1f),
|
||||
intensity = 1.0f,
|
||||
falloff = 0.25f,
|
||||
normalFalloff = 0.0f
|
||||
|
||||
Reference in New Issue
Block a user