Skip to content

Commit

Permalink
Code format feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
colincornaby committed Nov 11, 2023
1 parent a49e7f1 commit 2400954
Show file tree
Hide file tree
Showing 20 changed files with 351 additions and 439 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ fragment half4 PreprocessAvatarFragmentShader(PreprocessAvatarTexturesInOut in [
address::clamp_to_zero);

half4 colorSample = layer.sample(colorSampler, in.uvPosition.xy) * half4(blendColor);

return colorSample;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,26 @@ typedef struct {
vertex vs_BiasNormalsOut vs_BiasNormals(Vertex in [[stage_in]],
constant vs_BiasNormalsUniforms & uniforms [[ buffer(VertexShaderArgumentMaterialShaderUniforms) ]]) {
vs_BiasNormalsOut out;

out.position = float4(in.position, 1.0);

out.texCoord0 = float4(
dot(float4(in.texCoord1, 1.0), uniforms.TexU0),
dot(float4(in.texCoord1, 1.0), uniforms.TexV0),
0,
1
);

out.texCoord1 = float4(
dot(float4(in.texCoord1, 1.0), uniforms.TexU1),
dot(float4(in.texCoord1, 1.0), uniforms.TexV1),
0,
1
);

out.color1 = uniforms.ScaleBias.xxzz;
out.color2 = uniforms.ScaleBias.yyzz;

return out;
return out;
}

fragment float4 ps_BiasNormals(vs_BiasNormalsOut in [[stage_in]],
Expand All @@ -109,11 +108,10 @@ fragment float4 ps_BiasNormals(vs_BiasNormalsOut in [[stage_in]],
//
// So c[0].z = 1, but all other c[i].z = 0
// Note also the c4 used for biasing back at the end.

constexpr sampler colorSampler = sampler(mip_filter::linear,
mag_filter::linear,
min_filter::linear,
address::repeat);
min_filter::linear, address::repeat);
float4 sample1 = t0.sample(colorSampler, in.texCoord0.xy);
float4 sample2 = t1.sample(colorSampler, in.texCoord0.xy);
float4 out = float4(sample1.rgb - 0.5 + sample2.rgb - 0.5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,45 +45,42 @@ using namespace metal;

#include "ShaderVertex.h"

typedef struct {
typedef struct {
float4 c0;
float4 c1;
float4 c2;
float4 c3;
float4 c4;
} vs_CompCosinesUniforms;

typedef struct {
float4 position [[position]];
float4 texCoord0;
float4 texCoord1;
float4 texCoord0; float4 texCoord1;
float4 texCoord2;
float4 texCoord3;
} vs_CompCosinesnInOut;

vertex vs_CompCosinesnInOut vs_CompCosines(Vertex in [[stage_in]],
constant vs_CompCosinesUniforms & uniforms [[ buffer(VertexShaderArgumentMaterialShaderUniforms) ]]) {
vs_CompCosinesnInOut out;

out.position = float4(in.position, 1.0);

float4 texCoord = float4(0, 0, 0, 1);
texCoord.x = dot(float4(in.texCoord1, 1.0), uniforms.c0);
out.texCoord0 = texCoord;
texCoord.x = dot(float4(in.texCoord1, 1.0), uniforms.c1);
out.texCoord0 = texCoord; texCoord.x = dot(float4(in.texCoord1, 1.0), uniforms.c1);
out.texCoord1 = texCoord;
texCoord.x = dot(float4(in.texCoord1, 1.0), uniforms.c2);
out.texCoord2 = texCoord;
texCoord.x = dot(float4(in.texCoord1, 1.0), uniforms.c3);
out.texCoord3 = texCoord;

return out;
}

typedef struct {
float4 c0;
float4 c1;
float4 c2;
float4 c1; float4 c2;
float4 c3;
float4 c4;
float4 c5;
Expand All @@ -109,16 +106,15 @@ fragment float4 ps_CompCosines(vs_CompCosinesnInOut in [[stage_in]],
//
// So c[0].z = 1, but all other c[i].z = 0
// Note also the c4 used for biasing back at the end.

constexpr sampler colorSampler = sampler(mip_filter::linear,
mag_filter::linear,
min_filter::linear,
address::repeat);

float4 out = 2 * (t0.sample(colorSampler, fract(in.texCoord0.xy)) - 0.5) * uniforms.c0;
out += 2 * (t1.sample(colorSampler, fract(in.texCoord1.xy)) - 0.5) * uniforms.c1;
out += 2 * (t2.sample(colorSampler, fract(in.texCoord2.xy)) - 0.5) * uniforms.c2;
out += 2 * (t3.sample(colorSampler, fract(in.texCoord3.xy)) - 0.5) * uniforms.c3;
out += 2 * (t2.sample(colorSampler, fract(in.texCoord2.xy)) - 0.5) * uniforms.c2; out += 2 * (t3.sample(colorSampler, fract(in.texCoord3.xy)) - 0.5) * uniforms.c3;
// Now bias it back into range [0..1] for output.
out *= uniforms.c4;
out += uniforms.c5;
Expand Down
Loading

0 comments on commit 2400954

Please sign in to comment.