OSG.JS Deferred Rendering WebGL - deferred-rendering

Is is possible to do deferred rendering in OSG.JS?
I found this example doing it using THREE.JS but I am unable to find one example for OSG.JS.
http://alteredqualia.com/three/examples/webgl_lights_deferred_pointlights.html
I do have seen the SDK examples doing RTT, but why aren't there any deferred rendering example on the web (or where are they)?
Thanks

I made it, it is indeed possible.
The postprocess example is the closest one that I used to achieve it. I now have normals, depth and colors as G-Buffers and I render the final quad with the composition shader.

Related

Face Detection in Preview Camera Feed on Flutter

How do we "draw a square" on detected faces on camera preview feed in Flutter? Is there a cross platform solution to this?
Flutter provides a Camera Plugin, but is there a way for us to draw a square box detecting faces on the preview feed? Any thoughts on this please?
.
SOMETHING LIKE THIS EXAMPLE CAMERA PREVIEW FEED
Firstly, get the image data. This can be done by either using the camera plugin's output, or even directly communicate with the SurfaceView/TextureView.
Secondly, run face detection algorithm. If you do not need cross-platform, https://medium.flutterdevs.com/face-detection-in-flutter-2af14455b90d?gi=f5ead7c6d7c9 MLKit sounds good. If needing cross-platform, you can use Rust algorithms like https://github.com/atomashpolskiy/rustface and bind Rust code to Flutter via https://github.com/fzyzcjy/flutter_rust_bridge. Or, use C++ face detection algorithms and bind to Flutter (though setup may be a bit harder).
Lastly, once you know the face, draw a box around it. For example, Container widget.

How do I draw concurrent custom shapes in flutter like this?

I want to create the shapes which are at the bottom of the design, but I'm unable to think of an approach I tried transform.rotate on a container but there are overflow issues. Any kind of help is appreciated. Thanks!
Here's the link to the design, that I want to create.
There are a few solutions for this UI:
You can export the background as an image.
Pros: Save time, easy.
Cons: Performance is not good as solution 2 below (for loading image and app size).
Use canvas (and paint) to draw those curves. If you're not familiar with Canvas in Flutter, you can check this tutorial.
Pros: performance is better (render time is faster and app size is smaller).
Cons: time consuming, sometimes you will need to have good maths knowledge to draw complex UI.
I found a better option for creating custom shapes.
There is this website, which converts shapes to code.
Here's the link: https://fluttershapemaker.com
It saves a lot of time. Thanks.

Unity shader to render objects with same material to subsequent GrabPasses

Overview
I'm working on a shader in Unity 2017.1 to enable UnityEngine.UI.Image components to blur what is behind them.
As some of the approaches in this Unity forum topic, I use GrabPasses, specifically a tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(<uv with offset>)) call to look up the pixels that I use in my blur summations. I'm doing a basic 2-pass box blur, and not looking to optimize performance right now.
This works as expected:
I also want to mask the blur effect based on the image alpha. I use tex2D(_MainTex, IN.uvmain) to look up the alpha color of the sprite on the pixel I am calculating the blur for, which I then combine with the alpha of the blur.
This works fine when working with just a single UI.Image object:
The Problem
However when I have multiple UI.Image objects that share the same Material created from this shader, images layered above will cut into the images below:
I believe this is because objects with the same material may be drawn simultaneously and so don't appear in each other's GrabPasses, or at least something to that effect.
That at least would explain why, if I duplicate the material and use each material on its own object, I don't have this problem.
Here is the source code for the shader: https://gist.github.com/JohannesMP/8d0f531b815dfad07823d44bc12b8112
The Question
Is there a way to force objects of the same material to draw consecutively and not in parallel? Basically, I would like the result of a lower object's render passes to be visible to the grab pass of subsequent objects.
I could imagine creating a component that dynamically instantiates materials to force this, or using render textures, but I would really like a solution that doesn't require adding components or creating multiple materials to swap out.
I would love a solution that is entirely self-contained within one shader/one material but is unsure if this is possible. I'm still only starting to get familiar with shaders so I'm positive there are some features I am not familiar with.
It turns out that it was me re-drawing what I grabbed from the _GrabTexture that was causing the the issue. By correctly handling the alpha logic there I was able to get exactly the desired behavior:
Here is the updated sourcecode: https://gist.github.com/JohannesMP/7d62f282705169a2855a0aac315ff381
As mentioned before, optimizing the convolution step was not my priority.

Are there tutorials or simplified examples for how to use OpenGL texture blur?

I have a UIKit app (no OpenGL included yet) and I need to blur an image in there. Some people suggested to go with OpenGL texture blur for this. There's an sample project from Apple called "GLImageProcessing" but it's such a huge source base and filled with just too much of different stuff.
Maybe someone knows another source that showcases the texture blur on it's own, making it simple to follow the process how to set up an EAGLView that just does that one thing?
You probably want to apply a Gaussian blur effect. Here's a library somebody has provided to do this on a UIImage:
http://code.google.com/p/simple-iphone-image-processing/

Create lightning in OpenGL ES 1.1

I need to create good looking lightning using OpenGL ES 1.1 (iPhone) and was planning on using shaders. However, when I asked about it in a previous question (OpenGL ES 1.x Shaders) I was informed there that this was probably not an option on the iPhone.
So now I am back at square one, wondering how I might make a lightning animation. It does not need to look ultra-realistic. I have already tried to use things like triangles stripped together. While this method does work, it is not as good as I had hoped it would look.
Does anyone have any ideas on the subject?
Thanks again,
~Eric
Try using a triangle strip textured with a gradient from black to a low-saturation blue or purple, to white. Set your blending to additive (GL_SRC_ALPHA, GL_ONE).
The usual approach is to compute the path of the lightning bolt using a Perlin function, rendering it to a glow buffer, creating a nice looking blur using a Gaussian blur shader and then merge it with your scene.
You could maybe adapt the code from this project. Although it's not ObjC/C, it does use OpenGL.
Here is an article that describes the effect in more detail and provides a VB/DirectX implementation.
Maybe I'm missing something but what's wrong with simply using glLight() and the fixed functionality like everybody else?
Would have to be a very bright light to make it look like lightning and wouldn't you need to shine the light on or through something?