Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
slowriot committed Dec 8, 2024
2 parents c2b3dea + 938c0c0 commit 9e4d014
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ For the previous demos, see:
- https://github.com/Armchair-Software/webgpu-demo2
- https://github.com/Armchair-Software/boids-webgpu-demo

Details: TODO
This demo just renders a simple full-screen quad, useful for testing shaders.

## Live demo
Live demo: https://armchair-software.github.io/webgpu-shader-demo/
Expand Down
4 changes: 2 additions & 2 deletions render/shaders/default.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ fn mandelbrot(c: vec2f) -> mandelbrot_out {
var out: mandelbrot_out;
var z: vec2f = vec2(0.0, 0.0);
var dist: f32 = 0.0;
for (var i: u32 = 0; i < 64u; i = i + 1u) {
for(var i: u32 = 0; i < 64u; i = i + 1u) {
z = vec2(
z.x * z.x - z.y * z.y,
2.0 * z.x * z.y
) + c;

if (dot(z, z) > 128.0) {
if(dot(z, z) > 128.0) {
out.unbounded = f32(i) - log2(log2(dot(z, z)));
return out;
}
Expand Down
8 changes: 4 additions & 4 deletions render/shaders/default.wgsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace render::shaders {

inline constexpr char const *default_wgsl{R"358856f02cd59c3a(struct vertex_input {
inline constexpr char const *default_wgsl{R"890c9c6d52412f30(struct vertex_input {
@location(0) position: vec2f,
@location(1) uv: vec2f,
};
Expand All @@ -24,12 +24,12 @@ fn mandelbrot(c: vec2f) -> mandelbrot_out {
var out: mandelbrot_out;
var z: vec2f = vec2(0.0, 0.0);
var dist: f32 = 0.0;
for (var i: u32 = 0; i < 64u; i = i + 1u) {
for(var i: u32 = 0; i < 64u; i = i + 1u) {
z = vec2(
z.x * z.x - z.y * z.y,
2.0 * z.x * z.y
) + c;
if (dot(z, z) > 128.0) {
if(dot(z, z) > 4096.0) {
out.unbounded = f32(i) - log2(log2(dot(z, z)));
return out;
}
Expand Down Expand Up @@ -60,6 +60,6 @@ fn fs_main(in: vertex_output) -> @location(0) vec4f {
);
return vec4f(color, 1.0);
}
)358856f02cd59c3a"};
)890c9c6d52412f30"};

} // namespace render::shaders

0 comments on commit 9e4d014

Please sign in to comment.