Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blender 2.8x] Add option to set OpenGL point size for particle debugging #484

Closed
PavelBlend opened this issue Dec 16, 2019 · 3 comments
Closed

Comments

@PavelBlend
Copy link

System Information

Blender Version (including hash): 2.81 (sub 16), branch: master, commit date: 2019-12-04 11:32, hash: rBf1aa4d18d49d
FLIP Fluids Version: 1.0.7
Operating System: Windows 7 64 bit
CPU: AMD A8 5600K
GFX: -
RAM: 8 GB

Describe the bug

Particle Size (Debug Panel) has disappeared in Blender 2.81.

Expected Behaviour

You can do it as follows:
bgl.glPointSize(particle_size)

Actual Behaviour

There is no way to specify the particle size.

@rlguy rlguy changed the title [Blender 2.8x] Debug Particles Size [Blender 2.8x] Add option to set OpenGL point size for particle debugging Dec 16, 2019
@rlguy
Copy link
Owner

rlguy commented Dec 16, 2019

Hi PavelBlend,

Thanks for the report! We had to remove the option to set pointsize for Blender 2.8x. The addon uses the new Blender 2.8x drawing system which uses the gpu module that uses vertex and fragment shaders instead of the old bgl module. As far as I could find, there is not a way to specify the point size in the gpu module.

Here is a code snippet of the shaders that we're using in Blender 2.8x:

vertex_shader = """
    uniform mat4 ModelViewProjectionMatrix;
    uniform float pointsize;

    in vec3 pos;
    in vec4 color;

    out vec4 finalColor;

    void main()
    {
        gl_PointSize = pointsize;
        gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
        finalColor = color;
    }
"""

fragment_shader = """
    in vec4 finalColor;
    out vec4 fragColor;

    void main()
    {
        fragColor = finalColor;
    }
"""

particle_shader = gpu.types.GPUShader(vertex_shader, fragment_shader)
particle_shader.uniform_float('pointsize', dprops.debug.particle_size)
particle_batch_draw = batch_for_shader(
    particle_shader, 'POINTS',
    {"pos": particle_vertices, "color": particle_vertex_colors},
)

We are setting the OpenGL pointsize in the shader with gl_PointSize = pointsize;. But this does not seem to affect how it is actually drawn in the Blender viewport when changing the size. I had posted a questions about this on the Blender Artists forums, but did not receive an answer. I may need to try the https://devtalk.blender.org/ forum to ask the developers why this does not work.

@PavelBlend
Copy link
Author

Everything works in my jet fluids addon:
https://github.com/PavelBlend/blender_jet_fluids_addon/blob/master/jet_fluids/render.py#L48
I ported it to blender 2.80.
Despite the fact that I am using the gpu module, I still specify the size of the points using the bgl module:
01

@rlguy
Copy link
Owner

rlguy commented Dec 16, 2019

Thank you so much for the tip! This fixes the problem. I did not know the bgl module would work like this.

I have added this fix to the addon. If you would like to add this fix to your installation, unzip the following file:

issue_484_patch.zip

And replace the scripts at these locations:

  • flip_fluids_addon/ui/domain_debug_ui.py
  • flip_fluids_addon/operators/draw_operators.py

@rlguy rlguy closed this as completed Dec 16, 2019
@rlguy rlguy added the bug label Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants