How to use OpenGL to achieve the effect of light curve - opengl

I want to achieve a glowing line effect
I tried to use a texture map, but it's hard to avoid the redraw that caused the transparency overlay. The input data is input from the mouse in real time. The result is as shown
We are currently studying the use of Gaussian blurring.
Ask if the seniors can use Gaussian blurring to achieve an effect or have other ideas.

Related

How to implement a Gaussian blur in DirectX?

I'm rendering a partially transparent rectangle over my game (d3d9) (eventually to be part of a GUI) and I want to blur the contents behind this rectangle. I understand the best way to do with would be with a shader, but that's basically the extent of what I know. Many of the implementations I've found seem far more complex than I should need or they are blurring an image whereas I'm blurring stuff that's already been drawn. A similar question has been asked here for C# but received fairly vague answers.
Rather than drawing the objects you want to blur to the screen, draw them to a texture that is bound as the render target. Then, you bind that texture to a compute shader and save the blur result in some other texture. Then you can draw the blurred final result as a "full screen quad", basically a 2d rect that covers the entire screen and will have your scene texture on it. This article is from 2003, so the source code might not be useful, but, it covers the basic idea.

How to XOR the colors under a shape? (SDL2)

I have an artsy side-project that is running slower than I want it to. Basically, I want to draw a bunch of shapes and colors such that they XOR the shapes and colors that I've already drawn. The program makes things like this:
Which is seven black circles XORed onto the screen.
My method is quite slow, for each pixel, I'm looping through each circle to determine if it should be XORed.
I can draw circles with SDL_gfx, but I can't seem to find a drawing mode that XORs. My current thought process is to use a blending mode that will at least tell me if a specific pixel is odd or even. However, creating an SDL_Texture that can be rendered to ( SDL_TEXTUREACCESS_TARGET ) makes it unable to be directly manipulated ( SDL_TEXTUREACCESS_STREAMING ).
The simple question is, how do I apply a black circle such that it XORs the pixels below it?
I don't think there is a way to do this with SDL_Renderer and still have reasonable performance. You would have to do the work in an SDL_Surface and upload it again.
I wrote SDL_gpu to enable modern graphical effects with a similar style to SDL's built-in render API. This particular effect is trivial in GLSL if you've used it much. If you want to avoid custom shaders, this effect is probably possible with the expanded blend mode options that SDL_gpu has.

WebGL glow effect

I started learning shaders, playing around on ShaderToy.com. For a project I want to make, I need to create an arbitrary glow filter on WebGL (not Bloom). I want to calculate alpha that I can then use to draw a color glow or use for some animated texture like fire etc.
So far I thought of a few ideas:
Averaging alpha across some area near each pixel - obviously slow
Going in circle around each pixel in one loop then over distance in another to calculate alpha based on how close the shape is to this pixel - probably just as slow
Blur entire shape - sounds like an overkill since I just need the alpha
Are there other ideas for approaching this? All I can find are gaussian blur techniques from bloom-like filters.
Please find this nvidia document for the simple glow effect.
The basic idea is to
render the scene in the back buffer
activate the effect
render some elements of the scene in a FBO
compute the Glow effect
bind the final FBO as a texture and blend this effect with the previously rendered scene in the backbuffer

Draw shiny lights in OpenGL to simulate a old monitor scanline

I'm writing a terminal emulator that simulates the look of a old monitor (software link). Here's a screenshot:
For this version, I use 2D graphics. My intention is to migrate to OpenGL to achieve higher perfomance and to be able to have a screen curvature, such as this:
Screenshot 2 http://www.meeho.net/blog/wp-content/uploads/Cathode.png
To achieve a higher realism, I want to draw the scanlines individually. This way, it would look something like this when greatly amplified:
So my question is: what would be the best strategy to achieve this (that is, draw these grainy shiny lights over a curved surface with a high framerate) with OpenGL?
I should point out that not all terminals had shadow mask CRTs (which was responsible for the bulge). Higher end terminals had (relatively) flat aperture grille CRTs. On the other extreme, really cheap terminals had somewhat annoying scrolling horizontal bars.
My fondest memories are programming on a SONY Trinitron terminal, which didn't have issues with brightness on horizontal scan lines, but did have a very pronounced vertical pitch between pixels.
Here's what things looked like on aperture grille CRTs:
I haven't seen any CRT emulating shaders that ever replicate this though.
To me, there's more than one way to skin a CRT... you might want to emulate a dot matrix grid, darken alternate fields, have a horizontal line that slowly scrolls up/down the screen, apply a pincushion distortion to simulate non-flat CRTs.
In any case, don't think of this as drawing lights. Draw the basic text into an FBO and then modulate the luminance of each pixel and apply the pincushion distortion in a fragment shader.
To achieve the effect in your final screenshot, you are going to need more than scanlines. You will also have to simulate the shadow mask dot matrix, you can probably do this with a simple texture.

GLSL object glowing

is it possible to create a GLSL shader to get any object to be surrounded by a glowing effect?
Let's say i have a 3d cube and if it's selected the cube should be surrounded by a blue glowing effect. Any hints?
Well there are several ways of doing this. If each object is also represented in a winged edge format then it is trivial to calculate the silhouette and then extrude it to generate a glow. This however is, very much, a CPU method.
For a GPU method you could try rendering to an offscreen buffer with the stencil set to increment. If you then perform a blur on the image (though only writing to pixels where the stencil is non zero) you will get a blur around the edge of the image which can then be drawn into the main scene with alpha blending. This is more a blur than a glow but it would be relatively easy to re-jig the brightness so that it renders a glow.
There are plenty of other methods too ... here are a couple of links for you to look through:
http://http.developer.nvidia.com/GPUGems/gpugems_ch21.html
http://www.codeproject.com/KB/directx/stencilbufferglowspart1.aspx?display=Mobile
Have a hunt round on google because there is lots of information :)