This repository has been archived by the owner on Mar 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathConstantBuffers.h
69 lines (60 loc) · 1.81 KB
/
ConstantBuffers.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
// Developed by Minigraph
//
// Author: James Stanard
//
#pragma once
#include "../Core/Math/Matrix3.h"
#include "../Core/Math/Matrix4.h"
#include <cstdint>
__declspec(align(256)) struct MeshConstants
{
Math::Matrix4 World; // Object to world
Math::Matrix3 WorldIT; // Object normal to world normal
};
// The order of textures for PBR materials
enum { kBaseColor, kMetallicRoughness, kOcclusion, kEmissive, kNormal, kNumTextures };
__declspec(align(256)) struct MaterialConstants
{
float baseColorFactor[4]; // default=[1,1,1,1]
float emissiveFactor[3]; // default=[0,0,0]
float normalTextureScale; // default=1
float metallicFactor; // default=1
float roughnessFactor; // default=1
union
{
uint32_t flags;
struct
{
// UV0 or UV1 for each texture
uint32_t baseColorUV : 1;
uint32_t metallicRoughnessUV : 1;
uint32_t occlusionUV : 1;
uint32_t emissiveUV : 1;
uint32_t normalUV : 1;
// Three special modes
uint32_t twoSided : 1;
uint32_t alphaTest : 1;
uint32_t alphaBlend : 1;
uint32_t _pad : 8;
uint32_t alphaRef : 16; // half float
};
};
};
__declspec(align(256)) struct GlobalConstants
{
Math::Matrix4 ViewProjMatrix;
Math::Matrix4 SunShadowMatrix;
Math::Vector3 CameraPos;
Math::Vector3 SunDirection;
Math::Vector3 SunIntensity;
float IBLRange;
float IBLBias;
};