Point rendering in openGL and GLSL

Question: How to visualize points in openGL using GLSL?


Information: some time ago I made a simulation of gravity on a python and used a blender for rendering. It looked like this . As an exercise, I port it to openGL and openCL. I think I already worked in openCL. Only when I spent some time working in openCL did I realize that it was difficult to understand if this was correct without being able to see the result. So I started playing with openGL. I followed the openGL GLSL wikibooks tutorial, very informative, but it did not cover points or particles.

I don’t understand where to start. most of the tutorials that I find are for openGL by default. I want to do this using GLSL. I'm still very new to all of this, so forgive me for my potential idiocy if the answer is right under my nose. I am looking for how to make halos around points that merge with each other. I have a general idea of ​​how to do this in the fragment shader, but as far as I know, I can only capture pixels that are enclosed in polygons created by my points. I am sure there is a way around this, it would be crazy if it weren’t, but I am ignorant in my newcomer. Can someone give me some direction here? thanks.

+4
source share
2 answers

I think you want to display the particles as GL_POINTS with GL_POINTS enabled, and then use your fragment shader to either display the texture in the usual way or create a halo gradient procedurally.

When you render in GL_POINTS mode, set gl_PointSize in your vertex shader to set the particle size. The vec2 variable vec2 will give you the coordinates of your fragment in the fragment shader.

EDIT: The gl_PointSize setting will only work if GL_PROGRAM_POINT_SIZE enabled. Alternatively, just use glPointSize to set the same size for all points. In addition, with OpenGL 3.2 (kernel), the GL_POINT_SPRITE flag GL_POINT_SPRITE been removed and is in fact always on.

+7
source

just draw dot sprites (using GL_POINT_SPRITE), use the blending functions: gl_src_alpha and gl_one, and then the halo should be visible. Mixing should be responsible for the "ghosting", so look for more information about this topic. You also need to disable deep wrinkles.

here is a link to this: http://content.gpwiki.org/index.php/OpenGL:Tutorials:Tutorial_Framework:Particles

0
source

Source: https://habr.com/ru/post/1388492/


All Articles