这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,6 @@ DerivedData/

## Gcc Patch
/*.gcno

# vscode
/**/.vscode/
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

#import <simd/simd.h>

#ifndef __METAL_VERSION__
#import <Foundation/Foundation.h>
#endif

typedef struct {
matrix_float4x4 modelMatrix;
matrix_float4x4 viewMatrix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

#import <simd/simd.h>

#ifndef __METAL_VERSION__
#import <Foundation/Foundation.h>
#endif

typedef struct {
matrix_float4x4 modelMatrix;
matrix_float4x4 viewMatrix;
Expand Down Expand Up @@ -81,7 +85,7 @@ typedef enum {
unused = 0,
Sun = 1,
Spot = 2,
Point = 3,
Point_ = 3,
Ambient = 4
} LightType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ float3 phongLighting(
}
break;
}
case Point: {
case Point_: {
float d = distance(light.position, position);
float3 lightDirection = normalize(light.position - position);
float attenuation = 1.0 / (light.attenuation.x +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ enum DebugLights {
encoder.label = "Debug lights"
for light in lights {
switch light.type {
case Point:
case Point_:
debugDrawPoint(
encoder: encoder,
uniforms: uniforms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

#import <simd/simd.h>

#ifndef __METAL_VERSION__
#import <Foundation/Foundation.h>
#endif

typedef struct {
matrix_float4x4 modelMatrix;
matrix_float4x4 viewMatrix;
Expand Down Expand Up @@ -81,7 +85,7 @@ typedef enum {
unused = 0,
Sun = 1,
Spot = 2,
Point = 3,
Point_ = 3,
Ambient = 4
} LightType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ float3 phongLighting(
}
break;
}
case Point: {
case Point_: {
float d = distance(light.position, position);
float3 lightDirection = normalize(light.position - position);
float attenuation = 1.0 / (light.attenuation.x +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ enum DebugLights {
encoder.label = "Debug lights"
for light in lights {
switch light.type {
case Point:
case Point_:
debugDrawPoint(
encoder: encoder,
uniforms: uniforms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

#import <simd/simd.h>

#ifndef __METAL_VERSION__
#import <Foundation/Foundation.h>
#endif

typedef struct {
matrix_float4x4 modelMatrix;
matrix_float4x4 viewMatrix;
Expand Down Expand Up @@ -85,7 +89,7 @@ typedef enum {
unused = 0,
Sun = 1,
Spot = 2,
Point = 3,
Point_ = 3,
Ambient = 4
} LightType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ enum DebugLights {
encoder.label = "Debug lights"
for light in lights {
switch light.type {
case Point:
case Point_:
debugDrawPoint(
encoder: encoder,
uniforms: uniforms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

#import <simd/simd.h>

#ifndef __METAL_VERSION__
#import <Foundation/Foundation.h>
#endif

typedef struct {
matrix_float4x4 modelMatrix;
matrix_float4x4 viewMatrix;
Expand Down Expand Up @@ -85,7 +89,7 @@ typedef enum {
unused = 0,
Sun = 1,
Spot = 2,
Point = 3,
Point_ = 3,
Ambient = 4
} LightType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ enum DebugLights {
encoder.label = "Debug lights"
for light in lights {
switch light.type {
case Point:
case Point_:
debugDrawPoint(
encoder: encoder,
uniforms: uniforms,
Expand Down
6 changes: 5 additions & 1 deletion 13-shadows/projects/final/Shadows/Shadows/Shaders/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ typedef struct {
matrix_float4x4 shadowViewMatrix;
} Uniforms;

#ifndef __METAL_VERSION__
#import <Foundation/Foundation.h>
#endif

typedef struct {
uint width;
uint height;
Expand Down Expand Up @@ -85,7 +89,7 @@ typedef enum {
unused = 0,
Sun = 1,
Spot = 2,
Point = 3,
Point_ = 3,
Ambient = 4
} LightType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ enum DebugLights {
encoder.label = "Debug lights"
for light in lights {
switch light.type {
case Point:
case Point_:
debugDrawPoint(
encoder: encoder,
uniforms: uniforms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct SceneLighting {
var lights: [Light] = []
for _ in 0..<count {
var light = Self.buildDefaultLight()
light.type = Point
light.type = Point_
let x = Float.random(in: min.x...max.x)
let y = Float.random(in: min.y...max.y)
let z = Float.random(in: min.z...max.z)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ typedef struct {
matrix_float4x4 shadowViewMatrix;
} Uniforms;

#ifndef __METAL_VERSION__
#import <Foundation/Foundation.h>
#endif

typedef struct {
uint width;
uint height;
Expand Down Expand Up @@ -86,7 +90,7 @@ typedef enum {
unused = 0,
Sun = 1,
Spot = 2,
Point = 3,
Point_ = 3,
Ambient = 4
} LightType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ float3 computeDiffuse(
diffuseTotal += calculateSun(light, normal, params, material);
break;
}
case Point: {
case Point_: {
diffuseTotal += calculatePoint(light, fragmentWorldPosition, normal, material);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ enum DebugLights {
encoder.label = "Debug lights"
for light in lights {
switch light.type {
case Point:
case Point_:
debugDrawPoint(
encoder: encoder,
uniforms: uniforms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

#import <simd/simd.h>

#ifndef __METAL_VERSION__
#import <Foundation/Foundation.h>
#endif

typedef struct {
matrix_float4x4 modelMatrix;
matrix_float4x4 viewMatrix;
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Metal by Tutorials: Materials

NOTE: Some samples have been modified to compile with XCode 16.


This repo contains all the downloadable materials and projects associated with the **[Metal by Tutorials](https://www.kodeco.com/books/metal-by-tutorials)** from [Kodeco](https://www.kodeco.com).

Each edition has its own branch, named `editions/[EDITION]`. The default branch for this repo is for the most recent edition.
Expand Down