Is it possible to create WebGL programs with only vertex shaders? - webgl2

I'm getting a "missing shader" error when I try to link a WebGL2 shader program with only vertex shaders attached. I'm trying to use Transform Feedback, and I thought that since the output of the vertex shader is written out, there should not be a need for a fragment shader.
From this blog post: link it seems that you should be able to do this. Is there something special about WebGL that I'm missing?

WebGL 2 is based on OpenGL ES 3.0 which per specification requires vertex and fragment shaders to be present on program objects:
Linking can fail for a variety of reasons as specified in the OpenGL
ES Shading Language Specification, as well as any of the following
reasons:
[...]
program does not contain both a vertex shader and a
fragment shader.
OpenGL ES 3.0 Specification, Page 49
You may attach a simple solid color or discarding fragment shader instead.

Related

glShadeModel in Qt3D

When using OpenGL there is function glShadeModel using which you can change normals calculation. It seems that when you using Qt3D default glShadeModel is GL_SMOOTH. Is it possible to set glShadeModel to GL_FLAT using QML Qt3D?
There is theme (Qt3d + glShadeModel) about this question, but it seems that it obsolete.
Qt3D is built around a programmable pipeline, so there's no such thing as a "shade model". You must supply a Material that does flat shading.
I'm not sure if there's one provided out of the box, but you can easily write your own.
If you're using a decent version of GLSL it's just a matter of propagate outputs from the vertex shader to inputs the fragment shader and mark them as flat. flat in GLSL means "disable interpolation of this value across the primitive; instead, use the value of the provoking vertex across all the fragments rasterized from that primitive".
If instead you want to support older versions of GLSL there's no way to disable such interpolation, so you must duplicate vertex data for all the primitives, and give each copy of vertex data for a given primitive the same value (say, on a "color" attribute).

Which formats of 3D models are supported by Qt to use with OpenGL?

Qt is involved here so I want to know which 3D models does Qt support when it works with OpenGL?
Is there a list somewhere of the 3D model formats supported by Qt?
which 3D models does openGL support when it works with Qt?
None and everything!
There's nothing "special" when using OpenGL in a Qt application. The QtOpenGL wrappers are just convenience functions that help with context and function pointer management.
OpenGL by itself has no(!) support for 3D models whatsoever. It just draws points, lines and triangles by the programmers commands. The programmer (you) is programming a general purpose computing machine and thereby you can read and draw the contents of whatever 3D model format you're able to write a parser and OpenGL drawing code for; and by the virtue of running on general purpose hardware this is: Every 3D model format.
Of course it puts the burden on you to actually program it. That there is Qt involved does not matter at all.

Java 3D to JavaFX 8 conversion

I have an application written in in Java 3D. As Java 3D is now virtually dead I am thinking about converting the code to JavaFX (JavaFX 8 supports 3D objects).
The question is whether it is relatively simple to convert Java 3D code to Java FX code?
Are there straightforward counterparts of Java 3D methods in JavaFX or would it be more like a total redesign of the code?
Here is a little list of packages used in the Java 3D code:
javax.media.j3d.Alpha;
javax.media.j3d.Appearance;
javax.media.j3d.Behavior;
javax.media.j3d.BoundingSphere;
javax.media.j3d.BranchGroup;
javax.media.j3d.Canvas3D;
javax.media.j3d.GeometryArray;
javax.media.j3d.LineArray;
javax.media.j3d.PointLight;
javax.media.j3d.Shape3D;
javax.media.j3d.Switch;
javax.media.j3d.Transform3D;
javax.media.j3d.TransformGroup;
javax.media.j3d.WakeupOnElapsedFrames;
javax.media.j3d.WakeupOnElapsedTime;
javax.vecmath.Matrix4f;
javax.vecmath.Vector3d;
javax.vecmath.Vector3f;
Java 3D isn't dead, you're completely wrong as you can see here. There is a wide choice of scenegraph APIs more capable than JavaFX 3D API which is particularly poor in my humble opinion.
I don't know what gouessej is saying about Java 3D not being dead, there will not be feature development for Java3D going forward.
However he/she is correct that the base JavaFX 3D API is very lacking in features.
If you want to port your application to JavaFX 3D, you will have to rewrite the rendering portions to match the new JavaFX API. From the list that you provided only PointLight and Shape3D have DIRECT counterparts. Alpha transparency is an undocumented unsupported feature as of 8u40 that will get compiled into the official build for Java 9. The F(X)yz team has a demo of it working just fine but we had to recompile the platform from sources ;-).
You are not alone though, there is now free open source third party support via F(X)yz: (shameless plug....)
http://www.fxyz3d.org

Vertex shader to create and animate geometry in QQuickItem

I'm reading through the comments on this Qt bug report:
https://bugreports.qt-project.org/browse/QTBUG-32741
That bug report suggests using a vertex shader with the QSGGeometry and animating in C++. I know the QML side supports shaders, but how do you access a shader from a QSGGeometry material that is handled via a C++ subclass of QQuickItem (as I interpret the bug report to suggest)? The vertex shaders accessed within QML are generally for deforming existing geometry, not really for creating new geometry or animating geometry, from what I can tell.
Or is the report suggesting to bypass QML completely for this task?
It would be pretty cool to pass data to a vertex shader for raw drawing and have the GL viewport be the Quick Item, but I don't think the QML shaders are designed for this.
In your subclass of QQuickItem override updatePaintNode() method should create (and update when needed) instance of QSGGeometryNode and set it up with a QSGGeometry configured for specific geometry type. That will allow you to directly control Vertex Buffer Object (just one, but with arbitrary layout of vertex attributes) and use your custom shaders.
See "Custom Geometry" example in qt documentation. Full project is in official repository.
Even more interesting example is "Texture in SGNode". It uses QQuickWindow::beforeRendering() signal to be able to run completely arbitrary OpenGL code. In this example custom rendering goes to Frame Buffer Object. Later this FBO is used as texture in a QSGSimpleTextureNode subclass.

jogl picking example

hi guys
i am in trouble with add picking object in a JOGL project.
i know that this could be done with pick buffer.. but i can't find examples
anyone?
In general, as you are probably aware, JOGL code translates directly from any other OpenGL examples you might see on the web.
GL_SELECT based picking seems to be very much out of favour these days; deprecated in the spec and poorly implemented by drivers.
Alternatives you can use are:
Rendering each object with a unique color (and all lighting / fog etc disabled) so you can determine which object the mouse is over via glReadPixels. (Clearing buffers after the picking stage so that you can then render your normal graphics). This approach is explained by the top rated answer in OpenGL GL_SELECT or manual collision detection? for example.
Ray-casting into your geometry (see the selection FAQ link below). This also means that you don't have to have an active gl context in the thread you call the code from, fwiw.
I've used both of these methods in the same application, currently having good results with the latter, but since most of the objects in that application are spheres it is a lot cheaper than it might be with arbitrary models.
http://www.opengl.org/resources/faq/technical/selection.htm

Resources