The complete list of promoted extensions in WebGL2 - webgl

I got a chance to update our renderer we use to WebGL2. To make the renderer as backward compatible as possible we keep tracking of loaded extensions( as we did before the upgrade ) and emulate extensions even if such extension was promoted. The renderer does a few relevant things with extensions. From outside, everything is quite transparent.
To make it work smoothly, I need the complete list of promoted extensions. Have found few blogs, but those lists are not complete. Other lists which I have found on GitHub look wrong because they have redundant extensions which were in fact not promoted or were dropped. I have not found much in the docs.
So, I did some empirical research and found :
// 12 extensions were promoted in WebGL2 without surprises
[
'ANGLE_instanced_arrays',
'EXT_blend_minmax',
'EXT_frag_depth',
'EXT_shader_texture_lod',
'EXT_sRGB',
'OES_element_index_uint',
'OES_standard_derivatives',
'OES_texture_float',
'OES_texture_half_float',
'OES_vertex_array_object',
'WEBGL_depth_texture',
'WEBGL_draw_buffers',
]
Particularly I'm concerned about OES_texture_float_linear and OES_texture_half_float_linear extensions which are not in my list. Implementation of WebGL2 I have locally has OES_texture_float_linear but does not have OES_texture_half_float_linear, while WebGL had both of them. I'm aware that in the WebGL1 context OES_texture_float_linear acts a bit differently, so my intuition says there could be problems.
Also, something weird happened with the disjoint_timer_query extension. That extension was merged in partially. WebGL2 contexts got some properties of that extension. I have disjoint_timer_query_webgl2 in Chrome which has all the properties except one getQueryObject which was renamed to getQueryParameter, but in Firefox the disjoint_timer_query extension is still available with a WebGL2 context.
So, is that list complete? And, particularly, should OES_texture_half_float_linear be on the list? And why is it gone, while the analogous OES_texture_float_linear stayed?
Appreciate your help.
-
So final answer ( probably ) should be :
// 14 extensions were promoted in WebGL2
[
'ANGLE_instanced_arrays',
'EXT_blend_minmax',
'EXT_frag_depth',
'EXT_shader_texture_lod',
'OES_element_index_uint',
'OES_standard_derivatives',
'OES_texture_float',
'OES_texture_half_float',
'OES_vertex_array_object',
'WEBGL_depth_texture',
'WEBGL_draw_buffers',
/* with caveats */
'EXT_sRGB',
'OES_texture_half_float_linear',
'EXT_disjoint_timer_query',
]
Please note that last three extensions were promoted with caveats.
Extension EXT_sRGB lost a constant SRGB_ALPHA.
Extension OES_texture_half_float_linear was promoted while analogous OES_texture_float_linear was not.
Extension EXT_disjoint_timer_query promoted partially. Some properties of that extension appeared in WebGL2 context, while other properties were moved to EXT_disjoint_timer_query_webgl2 extension. Also, currently ( 2017.05.16 ) Firefox WebGL2 context still has EXT_disjoint_timer_query extensions and no EXT_disjoint_timer_query_webgl2 extension.

WebGL2 requires support for half and floating point textures. It also requires filtering for half textures but it does not require support for filtered floating point textures.
That's why OES_texture_half_float_linear missing and OES_texture_float_linear is optional. Most mobile devices do not support filtering for floating point textures.
In other words you should add OES_texture_half_float_linear to your list of promoted extensions.
Another extension that has a strange history is EXT_color_buffer_float. WebGL1 shipped without it. It was assumed to render to a floating point texture all you needed was first OES_texture_float and then make a floating point texture, attach it to a framebuffer and check gl.checkFramebufferStatus. But, a year or so after WebGL shipped someone pointed out that was not enough and so EXT_color_buffer_float was added but it was not enforced because doing so would have broke pages.
In WebGL2 it is enforced. You can not render to a floating point texture without enabling EXT_color_buffer_float. Same for EXT_color_buffer_half_float.

Related

Is reusing a WebGLProgram a good idea?

Instead of creating new WebGlProgram's using gl.createProgram() is it a good idea to keep reusing one?
I am listing the steps that I should be doing if I am to reuse one:
AttachShader(s): in my case I need to attach a new Fragment shader only. (Question: Can I hang on to a compiled shader?)
linkProgram
useProgram
getAttribLocation
getUniformLocation
What are you trying to do? 99.9% of all GPU apps make shader programs and are done. They might make 1, they might make 5000, but they aren't ever in a position where they would even need to consider your question. So what are you really trying to do?
Those few apps that do allow you to edit shaders (shadertoy, glslsandbox, vertexshaderart, ...) either make new ones and delete old or reuse. There's no benefit to one or the other it's just a matter of style.
Yes you can hold on to shaders. You can use shaders with multiple programs. It's common to do so.
If you change a shader it won't affect a program unless/until you relink that program with gl.linkProgram. Anytime you call gl.linkProgram and it's successful all your previous uniform locations for that program are obsolete and you have to query new ones.

MantisBT not listing changelog

I am making use of MantisBT to track issues and have so far collected a number of issues. However, my changelog remains empty
No Change Log information available. Issues are included once projects
have versions and issues are resolved with "fixed in version" set.
Each bug report has
Product version, target version (needed for roadmap) and a fixed in version (needed for changelog).
Likewise I have released certain versions.
I have customized my workflow and I suspect this is part of the reason.
# custom access list
$g_access_levels_enum_string = '10:VIEWER,20:REPORTER,30:ENGINEER,40:CCB,90:ADMINISTRATOR';
# custom resolution list
$g_resolution_enum_string = '10:OPEN,20:REOPEN,30:WONTFIX,60:DISPOSITIONED, 70:FIXED';
From what I have been able to determine, for a changelog to appear you need
1) a released version (done)
2) a bug with a fixed in version matching this (done
3) a bug closed as "fixed"
now in a fresh MantisBT (and testing shows changelog works), FIXED has a constant of 20 so part of me suspect it is my g_resolution_enum_string but this would also imply that there should be another variable that sets which threshold should be used
$g_bug_resolution_fixed_threshold = FIXED;
This does not work
What am I missing? Also if it is of importance... my versions are labeled: v0.0, v0.1, v0.2 (ie prepended by 'v')
I suggest you read the documentation's Enumerations section, in particular
The strings included in the enumerations here are just for documentation purposes
So, your enum definition of 70:FIXED does not actually match the constant FIXED which, as you have pointed out, is still set to 20 which means that $g_bug_resolution_fixed_threshold actually points to your 20:REOPEN... You may want to define your own constants.
Also note that there is another important threshold in this context, $g_bug_resolution_not_fixed_threshold - resolutions above it are considered to be resolved in an unsuccessful way. By default it is set to _UNABLE_TO_REPRODUCE_ (40).
In other words, for an issue to appear in the Changelog, it must match all of the following criteria (reference):
status >= bug_resolution_fixed_threshold
resolution >= bug_resolution_fixed_threshold
resolution < bug_resolution_not_fixed_threshold
Note that this standard behavior can be changed with a custom function.
So your problem is indeed caused by your custom resolution_enum_string, most likely in combination with the values in the 2 above-mentioned thresholds.

Shaders in gltf 2.0

I have previously worked on gltf 1.0 and is now trying to update my application to render gltf2.0 sample models provided by khronos. I understand that shaders(glsl) and techniques are no longer part of the core properties in gltf 2.0.
So my question is that:
Are shader information now separated from .gltf? I know there is KHR_technique_webgl extensions which consist of the technique and shader properties(exactly like how gltf1.0 represent shader), are we suppose to be use that if our material arent pbr?
How do rendering engines now grab shader information from normal .gltf now(without the extensions)? Do we do it like old school way ie loading our own shader and manually map the model attributes to shaders attribute?
The KHR_technique_webgl extension will eventually be finished, and will provide a way to include custom shaders with your glTF2.0 model. But as of this writing, the extension is not fully defined and tools cannot implement it.
The more general case (and recommended if it suits your needs) would be to use PBR or Blinn-Phong materials. These are declared abstractly in glTF, so that rendering engines can build their own shaders for these material types, and will generally integrate better with engines' own lighting and/or shadows.

Multisampling in SharpDX

So I have recently started using SharpDX, and have stumbled into a problem. I have no idea how to get SharpDX to multisample. I have found two things related; you can specify a SampleDescription when creating the SwapChainDescription, but any input other than (1, 0) throws a Wrong Parameter exception.
The other thing I found was SamplerState, which I put on my pixel shader, didn't do anything. I played around a lot with the parameters, but there was no visible change whatsoever.
I am sure I am missing something, but without any previous directX knowlegde I have no idea really what exactly to look for.
This will come in handy in your case:
int maxsamples = Device.MultisampleCountMaximum;
int res = device.CheckMultisampleQualityLevels(SharpDX.DXGI.Format.R8G8B8A8_UNorm, samplecount);
If res returns 0 then this Sample count is not supported.
Also please note that some options are not compatible, so if you create your SwapChain with:
sd.Usage = (other usages) | Usage.UnorderedAccess;
You are not allowed to use multisampling.
Another very useful technique to spot the problems for those errors:
Create your device with DeviceCreationFlags.Debug
In your startup project properties (debug section), tick "Enable native code debugging".
Any API call that fails will give you an error description in the debug output window.
I had the same problem, could not get Multisampling to work until I enabled the debugging and got a good hint (really wished I had done this hours ago and saved a whole lot of testing!).
Initially I read somewhere that the DepthStencilBuffer had the same SampleDescription as the Render texture - but I'm not so sure as it appears to work without this as a quick test just showed.
The thing for me was to create the DepthStencilView with a DepthStencilViewDescription that has "Dimension = DepthStencilViewDimension.Texture2DMultisampled".
Just a heads up on when you are doing multisampling.
When you set your rendertarget, if passing a rendertarget and depthstencil, you need to ensure they both have the same multisampling level.
So, for rendering to the backbuffer you have defined with MSAA, you will need to create a depth buffer with the same MSAA level.
BUT, if you are have a rendertarget that will be a texture that is fed back into the pipeline, you can define a non MSAA texture and a NON MSAA depth buffer, which is handy as you can use a sampler on the texture (you cant use a normal sampler for a MSAA Resource texture).
Most of this info maybe not new for you.

How to make a change in Qualcomm's Vuforia Sample App

I have been looking through the threads at the Qualcomm Forums but no luck since I don't know exactly how to look for what I want.
I'm working with the ImageTargets Sample for iOS and I want to change the teapot to another image (a text rather) I had.
I already have the render and I got the .h using opengl library but I can't figure out what do I need to change to make this work and since this is the very basic and I haven't been able to make it work I really haven't ventured to try anything else.
Could anyone please help me out?
I would paste code here but it's a whole project so I don't know exactly what to put if needed please let me know.
If the case is still valid, here's what you have to do:
get header file for 3D object
get texture image for this object
in EAGLView.mm make this changes:
import "yourobject3d.h"
add your texture to textureFilenames array(this should be at the begining of EAGLView
eventually take care about kObjectScale (by deafult it was about 3.0f, for one object I did have to change it even up to 120.0f)
in setup3dObjects method assign proper arrays of vertices/normals/texture coords (check in "yourobject3d.h" file for proper arrays and naming) to Object3D *object
make this change in renderFrameQCAR
//glDrawElements(GL_TRIANGLES, obj3D.numIndices, GL_UNSIGNED_SHORT, (const GLvoid*)obj3D.indices);
glDrawArrays(GL_TRIANGLES, 0, obj3D.numVertices);
I believe that is all... if something take a look at Vuforia's forum, i.e. here: https://developer.vuforia.com/node/2047669
NOTE: default teapot.h does (!) have indices, which are not present in banana.h (from comment below) so take care about that too
Have a look at the EAGLView.mm file. There you'll have to load the textures (images) and 3d objects (you'll need to import your .h instead of teapot.h and modify setup3dObjects accordingly).
They are finally rendered by calling the renderFrameQCAR function.
Actually, teapot is not an image. It's a 3D model stored in .h format which includes Vertices, Normals, and Texture coordinates. You should have a good knowledge of OpenGL ES to understand those codes in sample app.
An easier way to change the 3D model to whatever you want is to use a rendering engine which facilitates the drawing and rendering stuffs and you don't need to bother OpenGL APIs. I've done it with jPCT-AE for Android platform but for iOS there is a counterpart called OpenFrameworks engine. It has some plugins to load 3Ds or MD2 files and since it's written in C++ you can easily integrate it with QCAR.
This is a short video of my result with jPCT and QCAR:
Qualcomm Vuforia + jPCT-AE test video

Resources