Update shared to use shorter glam vec functions for consistency (#333)

Co-authored-by: DGriffin91 <git@dgdigital.net>
This commit is contained in:
DGriffin91 2020-12-09 23:25:06 -08:00 committed by GitHub
parent 2d7541cde4
commit 57b49d932a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -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.
@ -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/

View File

@ -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)]
@ -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,