updating fragment shaders so some fields are always used

This commit is contained in:
Peter Li 2025-04-20 17:32:44 -07:00
parent 8647ac8bc9
commit 25178e07bc
9 changed files with 42 additions and 11 deletions

View File

@ -10,8 +10,8 @@ float4 main(float2 UV : TEXCOORD0, float3 WorldPos: TEXCOORD1) : SV_Target0
{ {
float4 col = pow(Texture.Sample(Sampler, UV), 0.4545); float4 col = pow(Texture.Sample(Sampler, UV), 0.4545);
float SPEEEEEEEEEEEEEED = 0; float SPEEEEEEEEEEEEEED = 0.0001 * time;
float strength = 0.0; float strength = 0.00001;
col.r = col.r + strength * sin(time * SPEEEEEEEEEEEEEED) * WorldPos.x + strength * cos(time * SPEEEEEEEEEEEEEED) * WorldPos.y; col.r = col.r + strength * sin(time * SPEEEEEEEEEEEEEED) * WorldPos.x + strength * cos(time * SPEEEEEEEEEEEEEED) * WorldPos.y;

View File

@ -5,11 +5,28 @@
"mode" : "frag" "mode" : "frag"
} }
], ],
"types" : {
"_10" : {
"name" : "type.Uniforms",
"members" : [
{
"name" : "time",
"type" : "float",
"offset" : 0
}
]
}
},
"inputs" : [ "inputs" : [
{ {
"type" : "vec2", "type" : "vec2",
"name" : "in.var.TEXCOORD0", "name" : "in.var.TEXCOORD0",
"location" : 0 "location" : 0
},
{
"type" : "vec3",
"name" : "in.var.TEXCOORD1",
"location" : 1
} }
], ],
"outputs" : [ "outputs" : [
@ -34,5 +51,14 @@
"set" : 2, "set" : 2,
"binding" : 0 "binding" : 0
} }
],
"ubos" : [
{
"type" : "_10",
"name" : "type.Uniforms",
"block_size" : 4,
"set" : 3,
"binding" : 0
}
] ]
} }

View File

@ -37,7 +37,6 @@ Output main(Input input)
output.TexCoord = input.UV; output.TexCoord = input.UV;
float4 pos = float4(input.Position, 1.0); float4 pos = float4(input.Position, 1.0);
pos.y = pos.y - 50;
// pos.x += 0.2 * sin(time * 0.5 ) * pos.y * 0.5; // pos.x += 0.2 * sin(time * 0.5 ) * pos.y * 0.5;
// pos.y += 0.2 * cos(time * 0.5 ) * pos.z * 0.5; // pos.y += 0.2 * cos(time * 0.5 ) * pos.z * 0.5;

View File

@ -3,6 +3,11 @@
using namespace metal; using namespace metal;
struct type_Uniforms
{
float time;
};
struct main0_out struct main0_out
{ {
float4 out_var_SV_Target0 [[color(0)]]; float4 out_var_SV_Target0 [[color(0)]];
@ -11,14 +16,16 @@ struct main0_out
struct main0_in struct main0_in
{ {
float2 in_var_TEXCOORD0 [[user(locn0)]]; float2 in_var_TEXCOORD0 [[user(locn0)]];
float3 in_var_TEXCOORD1 [[user(locn1)]];
}; };
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> Texture [[texture(0)]], sampler Sampler [[sampler(0)]]) fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], texture2d<float> Texture [[texture(0)]], sampler Sampler [[sampler(0)]])
{ {
main0_out out = {}; main0_out out = {};
float4 _27 = powr(Texture.sample(Sampler, in.in_var_TEXCOORD0), float4(0.4544999897480010986328125)); float4 _40 = powr(Texture.sample(Sampler, in.in_var_TEXCOORD0), float4(0.4544999897480010986328125));
_27.x = _27.x; float _45 = Uniforms.time * (9.9999997473787516355514526367188e-05 * Uniforms.time);
out.out_var_SV_Target0 = _27; _40.x = (_40.x + ((9.9999997473787516355514526367188e-06 * sin(_45)) * in.in_var_TEXCOORD1.x)) + ((9.9999997473787516355514526367188e-06 * cos(_45)) * in.in_var_TEXCOORD1.y);
out.out_var_SV_Target0 = _40;
return out; return out;
} }

View File

@ -35,11 +35,10 @@ struct main0_in
vertex main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_Scene& scene [[buffer(1)]], uint gl_InstanceIndex [[instance_id]]) vertex main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_Scene& scene [[buffer(1)]], uint gl_InstanceIndex [[instance_id]])
{ {
main0_out out = {}; main0_out out = {};
float4 _42 = float4(in.in_var_TEXCOORD0, 1.0); float4 _41 = float4(in.in_var_TEXCOORD0, 1.0);
_42.y = in.in_var_TEXCOORD0.y - 50.0;
out.out_var_TEXCOORD0 = in.in_var_TEXCOORD3; out.out_var_TEXCOORD0 = in.in_var_TEXCOORD3;
out.out_var_TEXCOORD1 = _42.xyz; out.out_var_TEXCOORD1 = _41.xyz;
out.gl_Position = Uniforms.ViewProjection * (scene._m0[gl_InstanceIndex].Model * _42); out.gl_Position = Uniforms.ViewProjection * (scene._m0[gl_InstanceIndex].Model * _41);
return out; return out;
} }