javascript - 通过网络浏览器访问 GPU

标签 javascript 3d gpu famo.us

我今天早些时候(在 TechCrunch.com 上)看到了这个概念证明,我对他们如何设法实现最终结果感到震惊和好奇。他们声明他们不使用 webGL 或任何插件,但他们能够直接与 GPU 交互并仅使用 Javascript 以高达 60 fps 的速度渲染 3D 视觉效果。有什么想法可以做到这一点,或者如何在不使用插件的情况下从 Javascript 访问 GPU?

站点地址是:famo.us

ps:尝试使用箭头键将方向移远!!

最佳答案

他们使用标准的 HTML5 Javascript API 来实现这一点。

我在他们的代码中看到了多个对 requestAnimationFrame 的引用。此方法允许使用兼容浏览器的人显示更流畅和优化的动画,具有比基于 setInterval 的动画更好的帧速率。这当然是通过使用 GPU 和可用的硬件背景来实现的。

不能使用任何 Javascript 例程直接访问 GPU 或所有其他硬件组件。相反,浏览器会根据调用的 JS 指令和执行上下文如果可能使用 GPU 来优化一些特定的处理、微积分和渲染。

编辑

为了将来引用,我最近发现(在原始答案 7 年后)一项新举措 - W3C GPU for the Web Community Group ,最近于 2020 年创建,就是为了做到这一点。它 self 描述如下。

The mission of the GPU on the Web Community Group is to provide an interface between the Web Platform and modern 3D graphics and computation capabilities present in native system platforms. The goal is to design a new Web API that exposes these modern technologies in a performant, powerful and safe manner. It should work with existing platform APIs such as Direct3D 12 from Microsoft, Metal from Apple, and Vulkan from the Khronos Group. This API will also expose the generic computational facilities available in today's GPUs to the Web, and investigate shader languages to produce a cross-platform solution.

从长远来看,此计划可能允许开发人员从所有网络浏览器直接与 GPU 交互。您可以跟踪 WebGPU API Spec 的实现状态在 Github 上 here .

关于javascript - 通过网络浏览器访问 GPU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15213216/

相关文章:

javascript - 如何在网络浏览器中检测设备是否具有陀螺仪?

c# - 访问控件 - 缺少 using 指令或程序集引用

c# - Windows Mobile 上的 GPU 访问

c++ - OpenCL:在 dll 中找不到 clRetainDevice

javascript - Object.create 未按预期工作

javascript - 使用 JavaScript 的底部边距

javascript - ajax成功后,Javascript不起作用

opengl - 具有养育问题的骨骼动画

c++ - 从 Nvidia PTX 访问 bool (C++11) 数组的可移植方法

javascript - 使用 "this"关键字对整个选择进行 jquery 点击事件