Texture Buffers in GL3
A new addition in the GL3 engine is a feature called texture-buffers. Texture-buffers use the new jit.gl.buffer object in conjunction with jit.gl.mesh and allow you to access any of the buffers of a jit.gl.mesh (position, normal, vertex_attr, etc.) as a 1D texture in any of the mesh's shader programs, using the texelFetch command.
You can declare a mesh's buffer as a texture-buffer via the new jit.gl.buffer using the attribute texbuf 1 and must specify the name of the buffer to bind as a texture (position, normal, vertex_attr, etc.) using the attribute type. It is important to note that any normal textures will be bound first, and then texture-buffers. Texture-buffers are declared in the shader as samplerBuffer uniforms.
So if you have two texture-buffers patched into a jit.gl.mesh that look like this:
then in your shader params declaration you need something like:
[ jit.gl.buffer @type vertex_attr0 @texbuf 1 ] [ jit.gl.buffer @type vertex_attr1 @texbuf 1 ]
and in the program body:
<param name="tex1" type="int" default="0" /> <param name="tex2" type="int" default="1" /> <param name="texbuf1" type="int" default="2" /> <param name="texbuf2" type="int" default="3" />
This allows you access to the sampled texture for use in the rest of the shader. To sample, use texelFetch:
uniform sampler2DRect tex1; uniform sampler2DRect tex2; uniform samplerBuffer texbuf1; uniform samplerBuffer texbuf2;
where index is an integer between 0 and the buffer width minus one.
vec3 bufval = texelFetch(texbuf1, index).xyz;
|GL3 Package Topics||GL3 Package Topics|
|jit.gl.mesh||Generate GL geometry from matrices|