Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

More detailed demos and better doc coverage #16

Open
C0D3-M4513R opened this issue May 21, 2022 · 1 comment
Open

More detailed demos and better doc coverage #16

C0D3-M4513R opened this issue May 21, 2022 · 1 comment

Comments

@C0D3-M4513R
Copy link

C0D3-M4513R commented May 21, 2022

Given the following shader, with "sierra::ShaderLanguage::WGSL".
How would I need to adapt the shader, to get it to output a triangle?

The current example is simplistic sure, but it is too simplistic, to be usable.

I thought, that I maybe need to bind my own descriptor, to set the vertex input. I then spent 1-2 hours trying to understand the sierra::descriptors macro code, only to realise, that that is something completely different (for bindings, and sets).
The next day, I looked closer at the wgsl spec and a little at vulkan c code.
That gave me the insight, that I'd need to specifiy the layouts I need in the sierra::pipeline layout.
Now as I am writing this, I would probably also then need to modify the sierra::pass struct, to then actually specify the contents of the locations to the pipeline?

Ontop there is no description, on what the macros do.
That is exspecially true for proc_macro_attributes, since one might want to modify descriptors, the pipline, add pipline inputs and more.

The current state of this library is in my view horrible/unusable for programmers.
vulkano has great examples, but it's types are too complex for me to understand.
With vulkano I was however able to render my own simple shapes, and create circle shaders without a problem.
That is not something, that can be said for this crate.

Most basic programms will at least require a shader such as the one below.
It would go a long way for usablility, if you could provide an example with the next release, and better explain what the macros do.

Looking for 1-2 hours at a single proc-macro, just to understand, that it doesn't do what you want is frustrating.

struct VertexInput {
    [[location(0)]] a_position: vec3<f32>;
    [[location(2)]] a_color: vec4<f32>;
};
struct VertexOutput {
    [[builtin(position)]] Position: vec4<f32>;
    [[location(2)]] v_color: vec4<f32>;
};

[[stage(vertex)]]
fn vs_main(in: VertexInput) -> VertexOutput {
    var output: VertexOutput;
    output.Position=in.a_position;
    output.v_color=in.a_color;
    return output;
}
[[stage(fragment)]]
fn fs_main(in:VertexOutput) -> [[location(0)]] vec4<f32> {
    return in.v_color;
}

EDIT:
As it stands now, I could probably create a different shader for each possible vertex/color combination I need, and be done faster.
Creating the shader source code is simple, since only the vec values would change.
I don't know however if that approach would work at all for even rendering a simple triangle.
I also don't know, if runtime shader compilation is even something, that could be done (because I don't know how you compile the shaders).

@zakarumych
Copy link
Collaborator

Well sure, having more demos and examples would be great.
Right now you can use arcana engine as an example of sierra usage.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants