mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-22 06:45:13 +00:00
Update shared to use shorter glam vec functions for consistency (#333)
Co-authored-by: DGriffin91 <git@dgdigital.net>
This commit is contained in:
parent
2d7541cde4
commit
57b49d932a
@ -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/
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user