|
|
@@ -1,51 +1,21 @@
|
|
|
-struct Uniforms {
|
|
|
- vec2 iResolution; // Resolution of the screen
|
|
|
- vec2 iMouse; // Normalized mouse position (0.0 to 1.0)
|
|
|
+struct VertexOutput {
|
|
|
+ @builtin(position) clip_position: vec4<f32>,
|
|
|
};
|
|
|
|
|
|
-fn getSky(uv: vec2<f32>) -> vec3<f32> {
|
|
|
- let atmosphere = sqrt(1.0 - uv.y);
|
|
|
- let skyColor = vec3<f32>(0.2, 0.4, 0.8);
|
|
|
-
|
|
|
- let scatter = pow((uniforms.iMouse.y / uniforms.iResolution.y), 1.0 / 15.0);
|
|
|
- let scatter = clamp(scatter, 0.8, 1.0);
|
|
|
-
|
|
|
- let scatterColor = mix(vec3<f32>(1.0), vec3<f32>(1.0, 0.3, 0.0) * 1.5, scatter);
|
|
|
- return mix(skyColor, scatterColor, atmosphere / 1.3);
|
|
|
-}
|
|
|
-
|
|
|
-fn getSun(uv: vec2<f32>) -> vec3<f32> {
|
|
|
- let sun = 1.0 - distance(uv, uniforms.iMouse.xy / uniforms.iResolution.y);
|
|
|
- let sun = clamp(sun, 0.0, 1.0);
|
|
|
-
|
|
|
- let mut glow = sun;
|
|
|
- glow = clamp(glow, 0.0, 1.0);
|
|
|
-
|
|
|
- sun = pow(sun, 100.0);
|
|
|
- sun *= 100.0;
|
|
|
- sun = clamp(sun, 0.0, 1.0);
|
|
|
-
|
|
|
- glow = pow(glow, 6.0) * 1.0;
|
|
|
- glow = pow(glow, uv.y);
|
|
|
- glow = clamp(glow, 0.0, 1.0);
|
|
|
-
|
|
|
- sun *= pow(dot(uv.y, uv.y), 1.0 / 1.65);
|
|
|
- glow *= pow(dot(uv.y, uv.y), 1.0 / 2.0);
|
|
|
-
|
|
|
- sun += glow;
|
|
|
+struct VertexInput{
|
|
|
+ @location(0) position : vec3<f32>
|
|
|
+};
|
|
|
|
|
|
- let sunColor = vec3<f32>(1.0, 0.6, 0.05) * sun;
|
|
|
- return sunColor;
|
|
|
+@vertex
|
|
|
+fn vs_main(in: VertexInput) -> VertexOutput {
|
|
|
+ var output : VertexOutput;
|
|
|
+ output.clip_position = vec4<f32>(in.position, 1.0);
|
|
|
+ return output;
|
|
|
}
|
|
|
|
|
|
-fn main_image(fragColor: out vec4<f32>, uv: in vec2<f32>) {
|
|
|
- let sky = getSky(uv);
|
|
|
- let sun = getSun(uv);
|
|
|
-
|
|
|
- fragColor = vec4<f32>(sky + sun, 1.0);
|
|
|
-}
|
|
|
+@fragment
|
|
|
+fn fs_main() -> @location(0) vec4<f32> {
|
|
|
+ var color = smoothstep(0.0, 1.0, 0.5);
|
|
|
|
|
|
-// Entry point for the shader pipeline
|
|
|
-fn main() {
|
|
|
- main_image(fragColor, gl_FragCoord.xy / uniforms.iResolution.y);
|
|
|
+ return vec4<f32>(color, 0.0, 0.0, 1.0); // red color
|
|
|
}
|