Hot answers tagged

15 votes
Accepted

What is an index buffer and how is it related to vertex buffers?

Could someone ELI5 to me, what is an index buffer and how is it related to vertex buffers Your vertex buffer contains the X and Y coordinates of 5 vertices. They are: ...
user avatar
  • 433
9 votes
Accepted

How much should I rely on Geometry shaders in WebGL?

WebGL doesn't even currently support geometry shaders, so to directly answer the question: 100% of all users.
user avatar
8 votes
Accepted

Help me find out what this texture mapping technique is called

What you see in the image called a UV map. That is, it is simply texture coordinates to be looked up encoded in a image. Same thing happens in all texture lookup in 3D there is a underlying sampler ...
user avatar
  • 8,169
7 votes

Can a scene graph be stored in the GPU?

Short answer: Yes, It can be done. But no one does so. Long answer: Scene graphs can be stored and processed on a GPU using OpenCL/WebCL. But it is not practical to do so. Updating scene graphs (a ...
user avatar
7 votes
Accepted

Why does substracting -1 in shader fail for a float data type?

Without seeing the error message I can't be sure but I think it's failing on the 1 being int instead of a float. float inv_coord = v_coord - 1.0; There is a ...
user avatar
7 votes
Accepted

WebGL Omnidirectional Shadow Mapping Issue

SOLUTION After a couple of days I realized that I was computing my projection matrix using a FOV angle in degrees and It should be in radians. I made the conversion and now everything works great. ...
user avatar
  • 161
7 votes

Fading particles and transition

I made a visualization a little like yours years ago, and used a similar technique, because it's the natural approach to the problem. After I spent a few years writing drivers for modern GPUs, I ...
user avatar
  • 6,490
6 votes
Accepted

Cost of parameter passing in webgl pixel shaders?

My experience working with shader compiler stacks a few years back is that they are extremely aggressive, and I doubt you will see any perf difference, but I would suggest testing as much as you can. ...
user avatar
6 votes

Is it possible to create minimal glTF files with vertex and index buffers?

While creating a set of glTF models for a tutorial, I also intended to create THE minimal glTF file. Update: The following referred to glTF 1.0/1.1. See below for an update of this example to glTF 2....
user avatar
  • 218
6 votes

What is an index buffer and how is it related to vertex buffers?

If you have a vertex buffer like this: var vertices = [ 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.6, 0.0, 1.0, 0.6, 0.0, 0.5, 1.0, 0.0 ] And simply draw it ...
user avatar
  • 603
6 votes

What actually happens in frame buffer when an image or document is scrolled?

In the olden days of text-mode terminals, the "frame buffer" was a buffer of text, not an image. Scrolling worked in the way you described. The buffer was larger than would fit on the screen, and to "...
user avatar
  • 6,490
5 votes
Accepted

How to use 32 bit Integers for Element Indices in WebGL 1.0?

Enabling the extension is as simple as: var uints_for_indices = gl.getExtension("OES_element_index_uint"); if ...
user avatar
5 votes
Accepted

Can we use PhysX in WebGL?

PhysX is a C++ API and can thus not directly be integrated with the JavaScript-based WebGL. Depending on your needs, you have the following options: Use a JavaScript-based physics engine, mostly ...
user avatar
  • 2,223
4 votes

Is it possible to create minimal glTF files with vertex and index buffers?

You can put the data into a data uri to store the data inline in base64 format. ...
user avatar
4 votes
Accepted

Rendering same vertex-array in different modes

Your shaders are fine, the problem is topological, that is the way the vertices are connected to create triangles. For cases 1 & 2: You cannot really draw a grid of points in this mode (...
user avatar
  • 2,244
4 votes
Accepted

Optimizing performance on hardware

Although you may be able to detect what hardware is available as a first approximation of a computer's capability, depending on this might not be useful since the same hardware may behave differently ...
user avatar
  • 5,902
4 votes

WebGL: Why are my textures black?

Okay, I figured it out. It has to do with the texture not loading before the first display function is called. The texture displays after a mouse or keyboard event. To remedy this, I added a timer to ...
user avatar
4 votes
Accepted

Inverse matrix order of operation

Yes. If you're compounding operations to make a matrix, then the inverse matrix will be the compound of the inverse operations, in the reverse order. So if $C = AB$ then $C^{-1} = B^{-1}A^{-1}$ Think ...
user avatar
  • 2,302
4 votes
Accepted

Triangulation of vertices of an ellipsoid

If you sample the two parameters $\eta$ and $\omega$ with steps $d\eta$ and $d\omega$, then you'll get a grid of points $v_{ij} = f(i\;d\eta,j\;d\omega)$. Any four adjacent points will define a ...
user avatar
  • 836
3 votes

Only show opaque objects behind transparent objects

The simplest solution is to do three passes: Render opaque meshes to a buffer (front-to-back, depth read/write on) Render translucent meshes to another buffer (front-to-back, depth read/write on) ...
user avatar
  • 541
3 votes
Accepted

How to know when rendering is complete in WebGL?

You can utilize ARB_sync or in other words sync objects which have been core since 3.2. From the point-of-view of OpenGL then right after issuing a specific command (you want to know whether has ...
user avatar
  • 251
3 votes

Is it possible to store the plain buffer data in gltf files?

Embedding human readable data is not supported. However you can put the data into a data uri to store the data inline in base64 format. ...
user avatar
3 votes
Accepted

Bitpacking into buffers with webgl (shadertoy)

Assuming you are not going to filter the buffer using HW texture filtering: since you only need 4 values for the material index, pack it in the sign bits of uv x and y.
user avatar
3 votes
Accepted

Is it possible to create minimal glTF files with vertex and index buffers?

After spending a hard time to understand the way how the binary buffers work in the gltf files I finally managed to generate a truely minimal gltf file. It's a single yellow triangle (demo). I tried ...
user avatar
  • 603
3 votes
Accepted

Are there any gltf example datasets available?

Also check out the glTF models used in Cesium: https://github.com/AnalyticalGraphicsInc/cesium/tree/master/Apps/SampleData/models https://github.com/AnalyticalGraphicsInc/cesium/tree/master/Specs/...
user avatar
  • 46
3 votes
Accepted

Emission of light from texture on WebGL

Presumably you are using a lighting system already, let's say Lambert shading for simplicity.. So we have a texture which is going to be illuminated by some light source. The following psuedo/shader ...
user avatar
  • 2,244
3 votes

Need help reasoning about video oscillation >60hz

Yeah, that makes sense. Most flat panel monitors on the market have a 60Hz refresh rate! So you are not going to be able to flicker faster than 60Hz due to technical limitation. Were you to do this ...
user avatar
  • 8,169
3 votes
Accepted

What happens to float values written to UNSIGNED_BYTE texture?

Unsigned byte textures in a graphics API are usually "normalized"—the byte values are interpreted as ranging from 0.0 to 1.0, with a byte of 255 mapping to 1.0. So no, they aren't truly floating-point ...
user avatar
  • 23.7k
3 votes

Unable to render a Waveront model in WebGL2

The problem is with how wavefront files and OpenGL work with indices. OpenGL OpenGL allows you to have different buffers, allowing your vertex to have multiple attributes. However, for every vertex ...
user avatar
  • 1,575
3 votes

What is the technique to generate an oblique 3d cone?

The general equation for a upright cone with the tip at $Z=0$ is $$ 0 = X^2 + Y^2 - Z^2$$ (Ignoring the points for which $Z>0$). If you consider slices for some constant $Z$ you get circles ...
user avatar
  • 246

Only top scored, non community-wiki answers of a minimum length are eligible