attackgoat / screen-13

Screen 13 is an easy-to-use Vulkan rendering engine in the spirit of QBasic.
Apache License 2.0
256 stars 12 forks source link

Add Ray Traced Triangle Example #34

Closed seabassjh closed 2 years ago

seabassjh commented 2 years ago

Adds the "hello world of graphics" triangle to examples. Similar to the existing triangle.rs but this one is ray-traced.

attackgoat commented 2 years ago

This is awesome! Thank you for the contribution!

The existing Cornell box example has double the LOC and isn't as clear so this will be super useful for first-time users. I'm ready to merge it but I want to provide this feedback in case you plan on making any changes:

These changes are not required and certainly could serve as places for new users to modify existing code to suit their needs.

seabassjh commented 2 years ago

Actually I referenced this, it's in C++ and is a bit old (still used the NV rt extension) but it covers the fundamentals nicely. I will change the link to this if you think it's good enough!

And those suggestions sounds good; will update the PR for them.

seabassjh commented 2 years ago

Also, I have a local branch with a working proof-of-concept for compiling the example shaders to SPIRV at runtime using shaderc, so we don't have to scroll through all that inlined shader code and they can be nested away in their own dedicated files. Do you think this would be a valuable contribution?

attackgoat commented 2 years ago

LGTM 😊

Compiling shaders at runtime would be a fine example; especially if it showed ways you could reload a shader and update a pipeline (create a new one, drop the old one). I do like the inline-spirv crate in the basic examples because it puts all the code right in one place for example purposes. I wouldn't use it in a real program because it increases build times for things which don't change often.

Another strategy is shown in the shader-toy example which uses build.rs to compile when shaders change (using shaderc).

attackgoat commented 1 year ago
  • I don't believe vk::BufferUsageFlags::STORAGE_BUFFER is required for any of these buffers.

Update: This was incorrect advice - a recent update to the Vulkan SDK added validation errors for the scratch buffers unless they include this. See 2b28faa.