124 lines
3.2 KiB
Objective-C
124 lines
3.2 KiB
Objective-C
//
|
|
/**
|
|
* Copyright (c) 2019 Razeware LLC
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* Notwithstanding the foregoing, you may not use, copy, modify, merge, publish,
|
|
* distribute, sublicense, create a derivative work, and/or sell copies of the
|
|
* Software in any work that is designed, intended, or marketed for pedagogical or
|
|
* instructional purposes related to programming, coding, application development,
|
|
* or information technology. Permission for such use, copying, modification,
|
|
* merger, publication, distribution, sublicensing, creation of derivative works,
|
|
* or sale is expressly withheld.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
|
|
|
|
#ifndef Common_h
|
|
#define Common_h
|
|
|
|
#import <simd/simd.h>
|
|
|
|
typedef struct {
|
|
matrix_float4x4 modelMatrix;
|
|
matrix_float4x4 viewMatrix;
|
|
matrix_float4x4 projectionMatrix;
|
|
matrix_float3x3 normalMatrix;
|
|
} Uniforms;
|
|
|
|
typedef enum {
|
|
unused = 0,
|
|
Sunlight = 1,
|
|
Spotlight = 2,
|
|
Pointlight = 3,
|
|
Ambientlight = 4
|
|
} LightType;
|
|
|
|
typedef struct {
|
|
vector_float3 position;
|
|
vector_float3 color;
|
|
vector_float3 specularColor;
|
|
float intensity;
|
|
vector_float3 attenuation;
|
|
LightType type;
|
|
float coneAngle;
|
|
vector_float3 coneDirection;
|
|
float coneAttenuation;
|
|
} Light;
|
|
|
|
typedef struct {
|
|
uint lightCount;
|
|
vector_float3 cameraPosition;
|
|
uint tiling;
|
|
} FragmentUniforms;
|
|
|
|
typedef enum {
|
|
Position = 0,
|
|
Normal = 1,
|
|
UV = 2,
|
|
Tangent = 3,
|
|
Bitangent = 4,
|
|
Color = 5,
|
|
Joints = 6,
|
|
Weights = 7
|
|
} Attributes;
|
|
|
|
typedef enum {
|
|
BaseColorTexture = 0,
|
|
NormalTexture = 1,
|
|
RoughnessTexture = 2,
|
|
MetallicTexture = 3,
|
|
AOTexture = 4
|
|
} Textures;
|
|
|
|
typedef enum {
|
|
BufferIndexVertices = 0,
|
|
BufferIndexUniforms = 11,
|
|
BufferIndexLights = 12,
|
|
BufferIndexFragmentUniforms = 13,
|
|
BufferIndexMaterials = 14,
|
|
BufferIndexInstances = 15,
|
|
BufferIndexSkybox = 20,
|
|
BufferIndexSkyboxDiffuse = 21,
|
|
BufferIndexBRDFLut = 22
|
|
} BufferIndices;
|
|
|
|
typedef struct {
|
|
vector_float3 baseColor;
|
|
vector_float3 specularColor;
|
|
float roughness;
|
|
float metallic;
|
|
vector_float3 ambientOcclusion;
|
|
float shininess;
|
|
} Material;
|
|
|
|
struct NatureInstance {
|
|
uint textureID;
|
|
uint morphTargetID;
|
|
matrix_float4x4 modelMatrix;
|
|
matrix_float3x3 normalMatrix;
|
|
};
|
|
|
|
struct Instances {
|
|
matrix_float4x4 modelMatrix;
|
|
matrix_float3x3 normalMatrix;
|
|
};
|
|
|
|
#endif /* Common_h */
|