Skip to content

Commit

Permalink
Update shared to use shorter glam vec functions for consistency (#333)
Browse files Browse the repository at this point in the history
Co-authored-by: DGriffin91 <git@dgdigital.net>
  • Loading branch information
DGriffin91 and DGriffin91 authored Dec 10, 2020
1 parent 2d7541c commit 57b49d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions examples/shaders/shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#![register_attr(spirv)]

use core::f32::consts::PI;
use spirv_std::glam::Vec3;
use spirv_std::glam::{vec3, Vec3};

// Note: This cfg is incorrect on its surface, it really should be "are we compiling with std", but
// we tie #[no_std] above to the same condition, so it's fine.
Expand All @@ -27,11 +27,11 @@ pub fn saturate(x: f32) -> f32 {
}

pub fn pow(v: Vec3, power: f32) -> Vec3 {
Vec3::new(v.x.powf(power), v.y.powf(power), v.z.powf(power))
vec3(v.x.powf(power), v.y.powf(power), v.z.powf(power))
}

pub fn exp(v: Vec3) -> Vec3 {
Vec3::new(v.x.exp(), v.y.exp(), v.z.exp())
vec3(v.x.exp(), v.y.exp(), v.z.exp())
}

/// Based on: https://seblagarde.wordpress.com/2014/12/01/inverse-trigonometric-functions-gpu-optimization-for-amd-gcn-architecture/
Expand Down
6 changes: 3 additions & 3 deletions examples/shaders/simplest-shader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#![feature(register_attr)]
#![register_attr(spirv)]

use spirv_std::glam::Vec4;
use spirv_std::glam::{vec4, Vec4};
use spirv_std::storage_class::{Input, Output};

#[allow(unused_attributes)]
#[spirv(fragment)]
pub fn main_fs(mut output: Output<Vec4>) {
output.store(Vec4::new(1.0, 0.0, 0.0, 1.0))
output.store(vec4(1.0, 0.0, 0.0, 1.0))
}

#[allow(unused_attributes)]
Expand All @@ -18,7 +18,7 @@ pub fn main_vs(
#[spirv(position)] mut out_pos: Output<Vec4>,
) {
let vert_id = vert_id.load();
out_pos.store(Vec4::new(
out_pos.store(vec4(
(vert_id - 1) as f32,
((vert_id & 1) * 2 - 1) as f32,
0.0,
Expand Down

0 comments on commit 57b49d9

Please sign in to comment.