Search Tutorials


Top WebGL Interview Questions | JavaInUse



WebGL Interview Questions.

In this post we will look at WebGL questions. Examples are provided with explanation.


Q: What is WebGL?
A:
WebGL (Web Graphics Library) is a JavaScript API for rendering interactive 2D and 3D graphics within any compatible web browser without the use of plug-ins. WebGL is integrated completely into all the web standards of the browser, allowing GPU-accelerated usage of physics and image processing and effects as part of the web page canvas.

Q: What are the advantages of WebGL?
A:
The advantages of using WebGL are as follows-
  • Tasks - It can perform tasks that are just not possible with other technologies - or, more accurately, would be difficult to accomplish (good luck producing complex lighting and reflective material effects in SVG!).
  • Performance - WebGL is blindingly fast and fully utilizes hardware acceleration, making it suitable for games or complex visualizations. Although other options can benefit from hardware acceleration, WebGL is written with performance in mind and should perform better than other options in many cases.
  • Shaders - WebGL applications can utilize mini programs known as "shaders" to produce complex visual effects. A simple shader might produce a sepia coloring effect, while a more complex implementation might simulate water or flames. For more on this, check out Shadertoy.

Q: what is a mesh in WebGL?
A:
To draw 2D or 3D objects, the WebGL API provides two methods namely, drawArrays() and drawElements(). Thereafter, using those primitive polygons, we can form a mesh. A 3D object drawn using primitive polygons is called a mesh.

Q: What are shader programs in webgl?
A:
WebGL provides a solution to reduce the communication overhead. Since it uses ES SL (Embedded System Shader Language) that runs on GPU, we write all the required programs to draw graphical elements on the client system using shader programs (the programs which we write using OpenGL ES Shading Language / GLSL).
These shaders are the programs for GPU and the language used to write shader programs is GLSL. In these shaders, we define exactly how vertices, transformations, materials, lights, and camera interact with one another to create a particular image.

Q: What are the different types of Shaders?
A:
  • Vertex Shader - Vertext shader is the program code called on every vertex. It is used to transform (move) the geometry (ex: triangle) from one place to another. It handles the data of each vertex (per-vertex data) such as vertex coordinates, normals, colors, and texture coordinates.
  • Fragment Shader - A mesh is formed by multiple triangles, and the surface of each of the triangles is known as a fragment. Fragment shader is the code that runs on all pixels of every fragment. It is written to calculate and fill the color on individual pixels.


See Also

Top Java Data Structures and Algorithm Interview Questions
Spring Boot Interview Questions Apache Camel Interview Questions Drools Interview Questions Enterprise Service Bus- ESB Interview Questions. JBoss Fuse Interview Questions Top ElasticSearch frequently asked interview questions Angular 2 Interview Questions