Skip to content

Commit

Permalink
shaders usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDIMAS committed Nov 9, 2023
1 parent e2589b4 commit b4963e9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Binary file added src/fyrox/rendering/shader.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions src/fyrox/rendering/shaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,45 @@ Shader has rigid structure that could be described in this code snippet:
)
```

The engine can load such shaders if you save it in a file with `.shader` extension. After that, you can assign
the shader to your material in the Material Editor:

![shader](./shader.png)

Alternatively, you can load the shader from code. To do this, you can use this code:

```rust ,no_run
# extern crate fyrox;
# use fyrox::{
# asset::manager::ResourceManager,
# material::shader::{Shader, ShaderResource},
# };
#
fn load_shader(resource_manager: &ResourceManager) -> ShaderResource {
resource_manager.request::<Shader, _>("path/to/my/cool.shader")
}
```

After that you can use the shader to build a material from it:

```rust ,no_run
# extern crate fyrox;
# use fyrox::{
# asset::manager::ResourceManager,
# material::{shader::Shader, Material, SharedMaterial},
# };
#
fn create_material(resource_manager: &ResourceManager) -> SharedMaterial {
let shader = resource_manager.request::<Shader, _>("path/to/my/cool.shader");
SharedMaterial::new(Material::from_shader(
shader,
Some(resource_manager.clone()),
))
}
```

This material instance can be used for rendering. For example, you can assign it a surface of some mesh.

## Properties

Property is a named variable of some type. Properties are directly tied with the uniforms in the sub-shaders,
Expand Down

0 comments on commit b4963e9

Please sign in to comment.