Page MenuHome

Blender 2.8: OpenGL: new immediate mode for wm_operators.c
ClosedPublic

Authored by Willian Padovani Germano (ianwill) on Oct 19 2016, 8:10 PM.

Details

Summary

This is the radial control that appears when we change the size of a brush in sculpt and vertex and texture painting modes, by pressing "f".

For texture painting the color of the texture shown is black in Blender 2.8 (even without this patch), but it's white in master and older Blender versions. Should we have another shader that combines texture and a uniform color or update GPU_SHADER_3D_IMAGE_MODULATE_ALPHA to do this job?

Anyway, sitting on this patch for a while, updating and testing, better put it here already.

Diff Detail

Repository
rB Blender

Event Timeline

Should we have another shader that combines texture and a uniform color or update GPU_SHADER_3D_IMAGE_MODULATE_ALPHA to do this job?

In general each shader should do exactly what you want -- no more no less. So make a new shader if you want different behavior. Sounds like a GPU_SHADER_2D_IMAGE_MODULATE_COLOR, yes? Would you like to do the GLSL part?

Right now it seems silly to have 2D and 3D versions of some shaders, but it will make more sense when the 2D matrix stack is ready!

Ah, forgot to mention: while testing this patch I found unfreed memory blocks. It happens if you go to Texture Painting, assign a texture (the object needs to have UV coords and a channel to paint on, just press the buttons indicated in the tool shelf in tex painting mode to add them). The error:

Error: Not freed memory blocks: 2, total unfreed memory 0.004738 MB

Here the info by running Blender in debug mode:

Error: Not freed memory blocks: 2, total unfreed memory 0.004738 MB
ImBuf_struct len: 2480 0x7f320349b438
imb_addrectImBuf len: 4 0x7f32034c7088

I debugged for some minutes yesterday, but will need to investigate more to see where it should be freed.

Should we have another shader that combines texture and a uniform color or update GPU_SHADER_3D_IMAGE_MODULATE_ALPHA to do this job?

In general each shader should do exactly what you want -- no more no less. So make a new shader if you want different behavior. Sounds like a GPU_SHADER_2D_IMAGE_MODULATE_COLOR, yes? Would you like to do the GLSL part?

Cool, will be fun to do it, thanks : ).

Updated the diff:

  • added a shader that takes alpha info from a texture and RGBA from a uniform color (final rgb is color.rgb, final alpha is tex.a * color.a)
  • substituted deprecated GL_ALPHA and GL_ALPHA8 by GL_RED and GL_R8 in wm_operators.c

Seems to be working as expected (same as the master branch and older Blender) for radial control resizing in all relevant modes (sculpt, weight, vertex painting, texture painting).

Thanks, Mike : ).

Mike Erwin (merwin) edited edge metadata.
This revision is now accepted and ready to land.Nov 8 2016, 4:50 PM

Landed in blender2.8. Thanks!!