-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGpuSceneData.cs
More file actions
33 lines (30 loc) · 1.01 KB
/
Copy pathGpuSceneData.cs
File metadata and controls
33 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Numerics;
using System.Runtime.InteropServices;
namespace SilkWebGpuPbr;
[StructLayout(LayoutKind.Sequential)]
public struct GpuSceneData
{
public Matrix4x4 ViewProjection;
public Vector4 CameraPosition;
public Vector4 LightDirection;
public Vector4 LightColorAndIntensity;
public Vector4 AmbientColorAndIntensity;
public static GpuSceneData Create(
Matrix4x4 viewProjection,
Vector3 cameraPosition,
Vector3 lightDirection,
Vector3 lightColor,
float lightIntensity,
Vector3 ambientColor,
float ambientIntensity)
{
return new GpuSceneData
{
ViewProjection = viewProjection,
CameraPosition = new Vector4(cameraPosition, 1.0f),
LightDirection = new Vector4(Vector3.Normalize(lightDirection), 0.0f),
LightColorAndIntensity = new Vector4(lightColor, lightIntensity),
AmbientColorAndIntensity = new Vector4(ambientColor, ambientIntensity)
};
}
}