MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / acos_approx

Function acos_approx

examples/shaders/shared/src/lib.rs:55–61  ·  view source on GitHub ↗

Based on:

(v: f32)

Source from the content-addressed store, hash-verified

53
54/// Based on: <https://seblagarde.wordpress.com/2014/12/01/inverse-trigonometric-functions-gpu-optimization-for-amd-gcn-architecture/>
55pub fn acos_approx(v: f32) -> f32 {
56 let x = v.abs();
57 let mut res = -0.155972 * x + 1.56467; // p(x)
58 res *= (1.0f32 - x).sqrt();
59
60 if v >= 0.0 { res } else { PI - res }
61}
62
63pub fn smoothstep(edge0: f32, edge1: f32, x: f32) -> f32 {
64 // Scale, bias and saturate x to 0..1 range

Callers 2

sun_intensityFunction · 0.85
skyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected