Home Game Development opengl – How to cover a post-processed mesh define when/the place the mesh is hidden

opengl – How to cover a post-processed mesh define when/the place the mesh is hidden

0
opengl – How to cover a post-processed mesh define when/the place the mesh is hidden

[ad_1]

I’m engaged on establishing an lively define in my 3d engine, a spotlight impact for chosen 3d characters or surroundings within the display screen. After working with the stencil buffer and getting some unsatisfactory outcomes (points with concave shapes, define thickness on account of distance from digicam, and inconsistencies between my desktop and laptop computer), I switched to edge detection and body buffer sampling and obtained a top level view I’m fairly happy with.

However, I’m not capable of conceal the define when the chosen mesh is behind one other mesh. This is smart given my course of, since I merely render second shader define from a body buffer after rendering the remainder of the scene.

Two display screen captures of my outcomes are beneath. The first is a “good” define, the second is the place the define is seen over a mesh that blocks the define supply.

enter image description here

The rendering course of runs like this:
1) Draw solely the alpha of the highlighted mesh, capturing a black silhouette in a body buffer (framebuffer1).

2) Pass the feel from framebuffer1 to a second shader that performs the sting detection. Capture edge in framebuffer2.

3) Render your entire scene.

4) Render the feel from framebuffer2 on top of the scene.

I’ve just a few concepts on how one can accomplish and am hoping to get suggestions on their validity, or on easier or higher strategies.

First, I’ve considered rendering your entire scene to a body buffer and storing the seen silhouette of the highlighted mesh within the alpha channel (all white save the place the highlighted mesh is seen). I’d then carry out the sting detection on the alpha channel, render the scene body buffer after which render the sting on top. Resulting in one thing like this:

result

To accomplish this, I considered setting a outline solely throughout the render cross of the highlighted object that might draw all black within the alpha for any seen pixels.

My second concept is to make use of the present render course of outlined above, but additionally retailer the X, Y and Z coordinates within the R, G and B channels of framebuffer1 when rendering the silhouette of the chosen mesh. Edge detections could be carried out and saved in framebuffer2, however I’d cross on the RGB/XYZ values from the sides of the alpha to the silhouette. Then, when rendering the scene, I’d check if the coordinate is throughout the edge saved in framebuffer2. If so, I’d then check the depth of the present fragment to find out whether it is in entrance of or behind the coordinates extracted from the RGB channels (transformed to digicam area). If the fragment is in entrance of the depth coordinates, the fragment could be rendered usually. If the fragment is behind, it might be rendered because the strong define colour. This looks like a extra convoluted and error inclined technique…I have never totally grasped packing and unpacking floats in OpenGL but, however my feeling is I could run into floating level precision points when making an attempt to retailer the XYZ coordinates within the RGB channels.

I’m utilizing LibGDX for this undertaking and wish to assist WebGL and OpenGL ES, so not one of the options involving geometry shaders or newer GLSL capabilities can be found to me. If anybody may touch upon my proposed approaches or suggest one thing higher I’d actually respect it.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here