zesterer / euc

A software rendering crate that lets you write shaders with Rust
Apache License 2.0
294 stars 18 forks source link

Semicolon skips matrix multiplication #1

Closed sunjay closed 5 years ago

sunjay commented 5 years ago

Hi, I think there is a typo in this example:

https://github.com/zesterer/euc/blob/d535c6a2a21be10ff8ebb675062696846b9cd084/examples/spinning_cube.rs#L48-L53

Notice the two semicolons at the end. That means that the last matrix won't actually get multiplied in. That should probably be fixed :)

Thanks for the great crate!

zesterer commented 5 years ago

You're absolutely correct, thanks for the information! I'll update this now.

sunjay commented 5 years ago

I really like your crate by the way! I've managed to write a basic cel shader in it and I'm using that to generate what looks like pixel art from a 3D model.

Peek 2019-03-10 21-41

(The gif is a bit choppy because of the software I used, the renderer is actually very fast!)

zesterer commented 5 years ago

Wow, that's very cool!

If you're looking for performance tips... The fragment shader tends to overwhelmingly be the most expensive part of rendering. The less you can put in it, the better.

sunjay commented 5 years ago

Thanks! Are you planning to parallelize execution using rayon or anything?

zesterer commented 5 years ago

I've considered it. However, doing such a thing is not as trivial as you may expect: it requires doing a fair bit of synchronisation between the depth buffer, rasterizer, etc. (which becomes even more complex when you start trying to use shortcut methods to elide occluded surfaces) One option I've considered is to split the workload up at a much higher level than a GPU, confining whole polygons to a single thread. That way, the overhead of context switching and thread synchronisation is minimised.

If it's something you're very interested in, I can prioritise it?

sunjay commented 5 years ago

I am definitely interested! That being said, as an open source maintainer myself, I don't want to burden you. :)

If you think it is possible (and you think it would help with speed), it would definitely be something worthwhile to work on. I am very curious to see what the difference would be.

sunjay commented 5 years ago

By the way, the typo is also in the teapot.rs example. We can probably close this issue once that is fixed.

Thank you for your quick responses! :smile:

zesterer commented 5 years ago

Thanks! All fixed now.