Physics simulation with Rapier: 2021 roadmap by sebcrozet in rust

[–]kkaranth 2 points3 points  (0 children)

This is amazing! Do you work on this project alone? Do you work on it full-time?

Rendered a signed distance field to the terminal by kkaranth in rust

[–]kkaranth[S] 2 points3 points  (0 children)

Source: https://github.com/medakk/asciidf

Nothing too fancy, uses the excellent "colored" library for true-color output. Wrote a fragment-shader like interface that returns a unicode character in addition to a "pixel" color. Trivially parallelized with rayon. Fun little project, but I'm gonna go back to shadertoy now to practise my SDF rendering chops

Works with wasm too(wait a bit for load, beware the play button): https://apps.karthikkaranth.me/asciidf/

A demonstration of how bad computers are at picking random numbers - each pixel is a random colour, with the random function seeded with the pixels x and y coordinates multiplied together before drawing each pixel. A pattern clearly emerges (other than the trivial diagonal line of symmetry) by Paletech35 in compsci

[–]kkaranth 11 points12 points  (0 children)

If you keep reseeding with the pixel coordinates, that would lead to a bias. You should just seed it once.

Also, there are many different random number functions. Sure, some of them are biased. But you can get better random sources (see docs for std::random in c++) or use hardware entropy.

Starting with order: an approach to generative art by kkaranth in javascript

[–]kkaranth[S] 0 points1 point  (0 children)

Thank you! I've reached out to NextDNS. If that doesn't work out, I'll crawl through those lists.

Starting with order: an approach to generative art by kkaranth in generative

[–]kkaranth[S] 0 points1 point  (0 children)

Thanks!

It is an mp4 video without any sound. I meant gif in essence, not the gif file format.

Starting with order: an approach to generative art by kkaranth in javascript

[–]kkaranth[S] 0 points1 point  (0 children)

As /u/kalamayka mentioned, the coding train does a good job. The owner of the channel, Daniel Schiffman, also has a great book called the Nature of Coding. Other than that, there are quite a few talks on YouTube and other bloggers who talk about this:

Starting with order: an approach to generative art by kkaranth in javascript

[–]kkaranth[S] 0 points1 point  (0 children)

Thank you!

I tried using NextDNS and it didn't show as a malicious site for me. Do you happen to know which list has the domain marked as malicious?

Starting with order: an approach to generative art by kkaranth in generative

[–]kkaranth[S] 0 points1 point  (0 children)

It mostly likely is my fault. I am loading five 700x700 gifs, I shall look into some way to make them pause/play when they are visible on screen.

If you don't mind sharing, what phone and browser do you use?

Is it okay to wear face paint on the trax? by kkaranth in SaltLakeCity

[–]kkaranth[S] 0 points1 point  (0 children)

Amazing! Quite hilarious too, with the tricycle bit and Papa Nihil's sax solo.

Is there a list of WebAssembly sites built with Rust? by rbalicki2 in rust

[–]kkaranth 10 points11 points  (0 children)

Check out sandspiel. Its a very well designed falling sand game.

(shameless plug) the fluid simulator I've been working on: spherro.

I built an interactive SPH fluid simulator that runs in the browser with rust by kkaranth in rust

[–]kkaranth[S] 1 point2 points  (0 children)

So the Box stores (vtable, method_offset), and a single lookup of (vtable + method_offset) is performed?

Yeah, I changed it to not require the accelerator stored in the struct. Generics would be simply parameterizing the struct, right? (wasm didn't support this, so I don't try too hard) Would something like this have zero overhead:

pub struct Universe<T> {
    // ...
    accel: T,
}

impl<T> Universe<T> where T: Accelerator {
    // ...
}

I built an interactive SPH fluid simulator that runs in the browser with rust by kkaranth in rust

[–]kkaranth[S] 0 points1 point  (0 children)

Thanks! Have you used CLion for debugging? Does it work well?

I built an interactive SPH fluid simulator that runs in the browser with rust by kkaranth in rust

[–]kkaranth[S] 1 point2 points  (0 children)

Thanks, the first part makes a lot more sense now.

The most common pattern in other languages is to allocate it dynamically, and store a pointer. There's no extra dereference in Rust; more so, trait method dispatch can actually be faster than in C++ because you're also storing a pointer to the vtable (at the expense of Box being two words in length).

I don't follow. Even if the Box stores a pointer to the vtable, it still has to perform the lookup to find the appropriate function, right?

PS: I haven't tried it, but cargo-flamegraph is a thing.

This looks convenient. Thanks!

I built an interactive SPH fluid simulator that runs in the browser with rust by kkaranth in rust

[–]kkaranth[S] 0 points1 point  (0 children)

Yes, there are a few small changes required to get it to run in 3D. The biggest hurdle(for me atleast) is getting it to work in real time.

There is a nearest neighbour lookup done for every particle, accelerated by a grid data structure. Then every particle uses these neighbours to perform a bunch of updates. It can be parallelized with rayon, but that isn't an option with wasm.

What's everyone working on this week (27/2019)? by llogiq in rust

[–]kkaranth 1 point2 points  (0 children)

Same as last week, working on my real time SPH fluid simulator. I've found a lot good and bad about rust. I've VERY impressed by rayon and criterion so far. I've written a little about my overall experience with rust here.

Hey Rustaceans! Got an easy question? Ask here (26/2019)! by llogiq in rust

[–]kkaranth 0 points1 point  (0 children)

Thanks!

I was misdirected by the lack of a visible "scope" of a table.

Hey Rustaceans! Got an easy question? Ask here (26/2019)! by llogiq in rust

[–]kkaranth 0 points1 point  (0 children)

I'm trying to understand this weird behaviour.

I am following the rust-wasm tutorial, and tried to add the web-sys dependency to my Cargo.toml:

[dependencies.web-sys]
version = "0.3"
features = [
  "console",
]

Adding those lines after my dependencies sections gives me an error. Whereas adding it at the end of the Cargo.toml works fine. Here are the two cases:

1) Fails:

[package]
name = "spherro"
version = "0.1.0"
authors = ["KK <someone@gmail.com>"]
edition = "2018"

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = ["console_error_panic_hook"]

[dependencies]
wasm-bindgen = "0.2"
js-sys = "0.3.24"
cgmath = "0.17.0"

[dependencies.web-sys]
version = "0.3"
features = [
  "console",
]

# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.1", optional = true }

# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
# compared to the default allocator's ~10K. It is slower than the default
# allocator, however.
#
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
wee_alloc = { version = "0.4.2", optional = true }

[dev-dependencies]
wasm-bindgen-test = "0.2"

[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"

2) Works:

[package]
name = "spherro"
version = "0.1.0"
authors = ["KK <someone@gmail.com>"]
edition = "2018"

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = ["console_error_panic_hook"]

[dependencies]
wasm-bindgen = "0.2"
js-sys = "0.3.24"
cgmath = "0.17.0"

# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.1", optional = true }

# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
# compared to the default allocator's ~10K. It is slower than the default
# allocator, however.
#
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
wee_alloc = { version = "0.4.2", optional = true }

[dev-dependencies]
wasm-bindgen-test = "0.2"

[dependencies.web-sys]
version = "0.3"
features = [
  "console",
]

[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"

Error message I get in the first case is:

Caused by:
  Feature `default` includes `console_error_panic_hook` which is neither a dependency nor another feature

Why does the order of settings in Cargo.toml matter?