forked from 1b-agent/opencadstudio-upstream
first commit
This commit is contained in:
1 parent
d52c6440ff
commit
d2fdac7f1e
274 files changed
+89330
No files matched your search
@@ -0,0 +1,32 @@
|
||||
// ViewCube shader — Phong lighting + hover highlight.
|
||||
|
||||
struct Uniforms {
|
||||
view_proj: mat4x4<f32>,
|
||||
rotation: mat4x4<f32>,
|
||||
hover_region: vec4<f32>,
|
||||
}
|
||||
@group(0) @binding(0) var<uniform> u: Uniforms;
|
||||
|
||||
struct VIn { @location(0) pos: vec3<f32>, @location(1) normal: vec3<f32>, @location(2) color: vec3<f32>, @location(3) region_f: f32 }
|
||||
struct VOut { @builtin(position) clip: vec4<f32>, @location(0) color: vec3<f32>, @location(1) world_n: vec3<f32>, @location(2) region_f: f32 }
|
||||
|
||||
@vertex
|
||||
fn vs_main(in: VIn) -> VOut {
|
||||
var out: VOut;
|
||||
let rotated = (u.rotation * vec4<f32>(in.pos, 1.0)).xyz;
|
||||
out.clip = u.view_proj * vec4<f32>(rotated, 1.0);
|
||||
out.color = in.color;
|
||||
out.world_n = normalize((u.rotation * vec4<f32>(in.normal, 0.0)).xyz);
|
||||
out.region_f = in.region_f;
|
||||
return out;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main(in: VOut) -> @location(0) vec4<f32> {
|
||||
let is_hovered = abs(in.region_f - u.hover_region.x) < 0.001 && u.hover_region.x >= 0.0;
|
||||
var final_rgb = in.color;
|
||||
if is_hovered {
|
||||
final_rgb = mix(final_rgb, vec3<f32>(0.55, 0.78, 1.0), 0.45);
|
||||
}
|
||||
return vec4<f32>(final_rgb, 1.0);
|
||||
}
|
||||
Reference in new issue
Block a user