Jump to content

Is BabylonJS using DirectX or Webgl?


binarez
 Share

Recommended Posts

Hi,

I could answer this question by reading babylonJS code so pardon me for my lazyness. I would rather ask here because it looks like some of the devs of BabylonJS sometimes come here and I'm short on time.

Is BabylonJS written to use WebGL natively or is it using some library to convert DirectX calls to WebGL (Angle or Anglers?? I read that somewhere I can't find)? Is that behavior different depending on the browser it runs in? (MS Edge vs others)

If there's some converting going on, do we have a measurement of the overhead cost (flippin' matrices, normals, transpiling shaders, etc).

On the plus side... if it is using DirectX somehow, does it mean I can use DDS on all browsers?

Thanks! BabylonJS looks great, I'm still trying to figure out if I should go lower-level WebGL-only Three.JS or use a higher-level "game engine" like BabylonJS.

Link to comment
Share on other sites

Hi,

Babylon.js is based on WebGL as stated on our main page: http://www.babylonjs.com . 

It uses WebGL 1.0 on most browsers and WebGL 2.0 when available in a transparent way. 

Depends on your project, but it's much better and productive to use a framework like Babylon.js where we're taking care of shaders, loader, exporters, services such as offline with IndexedDB and cross-platforms compatibility, etc.  You'll find the complete list here: http://www.babylonjs.com/#specifications You shouldn't under estimate that.

Regarding DirectX, you seems to be confused, mixing several concepts. WebGL is an abstraction layer on top of OpenGL for JavaScript. It uses GLSL shaders. But the browsers can implement it in several ways. For Edge & IE for instance, we're using a GLSL to HLSL (DirectX) transpiler for the shader and binding the WebGL calls to DirectX. Chrome is using ANGLE to either targer DirectX on Windows or OpenGL on Linux & MacOS.

But at the user/developer level, this is transparent. You're doing WebGL, that's all and this is the case of all 3D frameworks you'll find for the Web: Babylon.js, Three.js, PlayCanvas, A-Frame, React VR and so on.  

Bye,

David

Link to comment
Share on other sites

I'm not sure why I'm coming thru as confused. I'm a professional graphics programmer so maybe it's the way I'm writing. It seems like you are transpiling and converting, instead it goes the other way around that I imagined, from WebGL to DirectX. Why are you using DirectX in MS browsers and Windows platform (Chrome)? Does Edge/IE not support WebGL? Is it for perf gains? I'm just trying to understand why the choices you made were made.

Edit: when you say "we" do you mean "we Microsoft" or "we BJS"? I'm interested in what BJS does, not what Edge/IE or what Google does to support WebGL on Windows. Thanks.

Link to comment
Share on other sites

These aren't our choices, but the W3C ones : all the browsers only know the WebGL layer.

How they communicate with the native or lower layers is just a matter of OS and/or browser implementation, things on what we don't have any control at the javascript level.

In short : up now, when you're using a browser, you're using only WebGL.

Link to comment
Share on other sites

Part of the confusion was that the answers were including what the browsers are doing to support WebGL (see my edit above). I was imagining that you guys were starting up some ActiveX component to do DirectX or something like that and that for other platforms you were converting to regular webgl.

edit: is -> was

Link to comment
Share on other sites

You say

41 minutes ago, binarez said:

Part of the confusion is that

if the is is now was please ignore what follows

Ignorance is bliss they say, so my lack of knowledge on things like DDS or transpilers makes the answers clear to me.

32 minutes ago, binarez said:

that for other platforms

The only platform for BJS is a browser, any browser.

1 hour ago, davrous said:

Babylon.js is based on WebGL

 

36 minutes ago, jerome said:

all the browsers only know the WebGL layer

 

39 minutes ago, jerome said:

How they communicate with the native or lower layers is just a matter of OS and/or browser implementation

For example

1 hour ago, davrous said:

For Edge & IE  (uses)  a GLSL to HLSL (DirectX) transpiler for the shader and binding the WebGL calls to DirectX.

 

1 hour ago, davrous said:

Chrome is using ANGLE to either targer DirectX on Windows or OpenGL on Linux & MacOS.

but as far as BJS goes

43 minutes ago, jerome said:

when you're using a browser, you're using only WebGL

 

Link to comment
Share on other sites

I guess, to restate previous responses, BJS connects to the GPU in the exact same way as Three JS.  Therefore, it is not a valid way to differentiate between the 2.

On the compressed textures front, I do not know what Three does, but for BJS 3.0, Multiplatform Compressed Textures are now supported using the Khronos Texture Container format.

DXT format, whether inside a DDS file container or not, is technically obsolete.  This is despite the fact that practically every desktop gpu in use today supports it.  Problem with it is 2 fold.  First, the newer formats like ASTC are way more advanced.  2nd, DXT is not supported anywhere but the desktop.

To use compressed textures for WebGL, your application needs to determine at run-time what compressed formats are possible on the hardware, pick the best available, and load versions of that format.  Fortunately, BJS 3.0 does that for you automatically with 1 or 2 lines of code.

BTW, there is a very old port of DXT inside of DDS in BJS.  Virtually no one uses it.  Until 2.5, it did not even fallback to image formats when DXT was not available.  @Deltakosh, should it not be depreciated in 3.0?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...