Clean up a little bit of API code. Fix an issue with missing operator. Port random semi complex shader.
This commit is contained in:
78
test/night_time.ink
Normal file
78
test/night_time.ink
Normal file
@@ -0,0 +1,78 @@
|
||||
p :: properties {
|
||||
input_tex : Texture2D;
|
||||
tex_sampler : Sampler;
|
||||
|
||||
hour_of_day : float;
|
||||
}
|
||||
|
||||
VS_Input :: struct {
|
||||
pos : float3 @position;
|
||||
uv : float2 @uv;
|
||||
}
|
||||
|
||||
VS_Output :: struct {
|
||||
pos : float4 @outposition;
|
||||
uv : float2 @uv;
|
||||
}
|
||||
|
||||
vertex main :: (input : VS_Input) -> VS_Output {
|
||||
output : VS_Output;
|
||||
output.pos = float4(input.pos, 1.0);
|
||||
output.uv = input.uv;
|
||||
return output;
|
||||
}
|
||||
|
||||
apply_night :: (color : float4) -> float4 {
|
||||
result := color;
|
||||
result -= float4(0.3, 0.2, 0.0, 0.0);
|
||||
result *= 0.8;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
apply_twilight :: (color : float4) -> float4 {
|
||||
result := color;
|
||||
result += float4(0.2, -0.1, 0.1, 0.0);
|
||||
result *= 0.9;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
apply_morning :: (color : float4) -> float4 {
|
||||
return color * 1.3;
|
||||
}
|
||||
|
||||
apply_dawn :: (color : float4) -> float4 {
|
||||
return color;
|
||||
}
|
||||
|
||||
pixel main :: (input : VS_Output) -> float4 @outposition {
|
||||
sampled_color : float4 = sample(p.input_tex, p.tex_sampler, input.uv);
|
||||
|
||||
t := 0.0;
|
||||
a := float4(0, 0, 0, 0);
|
||||
b := float4(0, 0, 0, 0);
|
||||
|
||||
if p.hour_of_day > 16 {
|
||||
t = (p.hour_of_day - 16) / 6;
|
||||
a = apply_twilight(sampled_color);
|
||||
b = apply_night(sampled_color);
|
||||
} else if p.hour_of_day > 12 {
|
||||
t = (p.hour_of_day - 12) / 6;
|
||||
a = sampled_color;
|
||||
b = apply_twilight(sampled_color);
|
||||
} else if p.hour_of_day > 6 {
|
||||
t = (p.hour_of_day - 6) / 6;
|
||||
a = apply_morning(sampled_color);
|
||||
b = sampled_color;
|
||||
} else if p.hour_of_day >= 0 {
|
||||
t = p.hour_of_day / 6;
|
||||
a = apply_night(sampled_color);
|
||||
b = apply_morning(sampled_color);
|
||||
}
|
||||
|
||||
return lerp(a, b, t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user