vec2.length() is not correct
michael8090 opened this issue · 2 comments
version:wgpu = "0.7.0"
os: windows 10
When I get the length of an unit vector inside a compute shader, it returns 2 instead of 1...
You could reproduce the issue by cloning https://github.com/michael8090/forcelayout_rust, setting a breakpoint after gpu_forcelayout_instance.compute()
inside main.rs
and checking the values of result
.
This is what GLSL has, apparently (TIL)!
See https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)
Also, here is a playground:
%float_2 = OpConstant %float 2
%14 = OpConstantComposite %v4float %float_2 %float_0_400000006 %float_0_800000012 %float_1
If you need the length of a vector, you want length(vector)
instead.
Finally, GLSL is not a part of WebGPU. Currently, we accept SPIR-V and WGSL shaders.
Thanks!