pub struct PolygonState {
    pub matrix: Matrix4,
    pub material: Material,
    pub texture: Option<Arc<Texture>>,
    pub backface_culling: bool,
}
Expand description

Configures of instances.

Fields§

§matrix: Matrix4

instance matrix

§material: Material

material of instance

§texture: Option<Arc<Texture>>

texture of instance

§backface_culling: bool

If this parameter is true, the backface culling will be activated.

Implementations§

Creates a UNIFORM buffer of instance matrix.

The bind group provided by the instances holds this uniform buffer.

Shader Examples
layout(set = 1, binding = 0) uniform ModelMatrix {
    mat4 uniform_matrix;
};
Examples found in repository?
src/polygon_instance.rs (line 56)
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    fn non_textured_bg(&self, device: &Device, layout: &BindGroupLayout) -> BindGroup {
        bind_group_util::create_bind_group(
            device,
            layout,
            vec![
                self.state.matrix_buffer(device).binding_resource(),
                self.state.material.buffer(device).binding_resource(),
            ],
        )
    }
    #[inline(always)]
    fn textured_bg(&self, device: &Device, layout: &BindGroupLayout) -> BindGroup {
        let (view, sampler) = self.state.textureview_and_sampler(device);
        bind_group_util::create_bind_group(
            device,
            layout,
            vec![
                self.state.matrix_buffer(device).binding_resource(),
                self.state.material.buffer(device).binding_resource(),
                BindingResource::TextureView(&view),
                BindingResource::Sampler(&sampler),
            ],
        )
    }

Creates a UNIFORM buffer of material.

The bind group provided by the instances holds this uniform buffer.

Shader Examples
layout(set = 1, binding = 1) uniform Material {
    vec4 albedo;
    float roughness;
    float reflectance;
    float ambient_ratio;
};

Creates texture view and sampler of the instance’s texture image.

The bind group provided by the instances holds this uniform buffer.

Shader Examples
layout(set = 1, binding = 2) uniform texture2D texture_view;
layout(set = 1, binding = 3) uniform sampler texture_sampler;
Examples found in repository?
src/polygon_instance.rs (line 63)
62
63
64
65
66
67
68
69
70
71
72
73
74
    fn textured_bg(&self, device: &Device, layout: &BindGroupLayout) -> BindGroup {
        let (view, sampler) = self.state.textureview_and_sampler(device);
        bind_group_util::create_bind_group(
            device,
            layout,
            vec![
                self.state.matrix_buffer(device).binding_resource(),
                self.state.material.buffer(device).binding_resource(),
                BindingResource::TextureView(&view),
                BindingResource::Sampler(&sampler),
            ],
        )
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.