Friends link: exam 70-450 cert 9a0-125 Adobe 9A0-127 exam Apple 9l0-410 Certification a00-202 Exam dumps IBM a2010-570 Exam dumps Pass A2160-669 Exam asc-029 Exam Dumps BCP-240 Actual Exam ISEB bh0-006 exam
GLOW » Interleaved Attributes
Parajumpers sale Parajumpers sale http://www.unifem.ch canada goose sale http://www.canadagooseoutlets.be https://www.gasinc.nl Canada Goose jas
2011+07+15

Interleaved Attributes

GLOW had one feature, the cache, but we just added its second – automatically interleaved attribute data.

Interleaved attributes is a performance improvement, which in some cases can make a big difference but really is a very nerdy feature. It’s not widely supported by existing WebGL frameworks so I’ll try to explain what it is and why you like to have it.

Instead of having one VBO for vertices, another for normals and a third for UV coordinates, you simply interleave them into one VBO. So instead of…

VBO A: Vertex Vertex Vertex...
VBO B: Normal Normal Normal...
VBO C: UV UV UV...

…you get…

VBO: Vertex Normal UV Vertex Normal UV...

The good thing with this is that you only have to bind one buffer instead of one per attribute, when setting up the attributes prior to the draw call.

To get the right data to the right attribute, WebGL uses something called Stride and Offset (or Pointer). You can read all about it here. This is all handled internally by GLOW, and you’ll not even notice unless you use WebGL Inspector and look at the trace.

Most of the time you like this to be enabled and just work but in some cases you might want to control how the attributes are interleaved or not interleaved at all. This is possible through the shader definition object that you pass into the GLOW.Shader constructor…

var shaderInfo = {
  vertexShader: "...vertex shader code...",
  fragmentShader: "...fragment shader code...",
  data: { ...all uniform, attribute and texture data... },
  elements: [ ...UInt16Array containing element info... ],
  interleave: {
    vertices: false,
  }
}

In this example the attribute called ”vertices” won’t be interleaved (and work just as an ordinary GLOW.Attribute) and all other attributes will be automatically interleaved.

var shaderInfo = {
  vertexShader: "...vertex shader code...",
  fragmentShader: "...fragment shader code...",
  data: { ...all uniform, attribute and texture data... },
  elements: [ ...UInt16Array containing element info... ],
  interleave: {
    vertices: false,
    normals: 5,
    uvs: 5,
    speed: 1,
    acceleration: 1
  }
}

In this example the ”vertices” attribute won’t be interleaved, ”normals” and ”uvs” will be interleaved together and ”speed” and ”acceleration” will be interleaved together. The number can be any number you like – think of it as the id of the interleaved VBO you’re creating. If you happen to have even more attributes than the ones controlled in the interleave object, they will be automatically interleaved.

You can even control the usage for interleaved attributes by…

var shaderInfo = {
  vertexShader: "...vertex shader code...",
  fragmentShader: "...fragment shader code...",
  data: { ...all uniform, attribute and texture data... },
  elements: [ ...UInt16Array containing element info... ],
  interleave: {
    vertices: false,
    normals: 5,
    uvs: 5,
    speed: 1,
    acceleration: 1
  },
  usage: {
    normals: GL.DYNAMIC_DRAW,
    uvs: GL.DYNAMIC_DRAW
  }
}

…which will make the ”normals” and ”uvs” buffer use DYNAMIC_DRAW. If you only define usage for one of the attributes in an interleaved buffer, GLOW will throw a warning and default back to STATIC_DRAW.

Last, some details, a new object called GLOW.InterleavedAttributes has been introduced. You cannot use the clone except-property on an interleaved attribute (as it’s now part of a set of interleaved attributes). The interleaved attribute name is generated by the attributes in the set – like ”vertices_uvs_normals” for example, and is accesible directly on the GLOW.Shader like other attributes (and uniforms).