Page MenuHome

Immediate Mode: curve draw stroke
AbandonedPublic

Authored by Dalai Felinto (dfelinto) on Feb 6 2017, 1:05 PM.

Details

Summary

How to test this drawing: create and edit a curve and press shift + drag your mouse (or tablet). The Curve needs a Bevel Depth > 0.0.

@Mike Erwin (merwin): this has a problem. Basically the GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR doesn't really work for world sized points.
When not using a tablet stroke_elem_radius returns the cu->ext2 (aka the bevel depth). Which is the expected size of the points in Blender units.

Any suggestion on how to handle it?

Part of T49043

Diff Detail

Repository
rB Blender
Branch
imm-editcurve
Build Status
Buildable 423
Build 423: arc lint + arc unit

Event Timeline

Dalai Felinto (dfelinto) retitled this revision from to Immediate Mode: curve draw stroke.
Dalai Felinto (dfelinto) updated this object.

Something like this should give you what you want.

radius /= gl_ProjectionMatrix[2][3] * position.z + gl_ProjectionMatrix[3][3];

Basically you want the final radius in screen space (what the shader expect) but have only the world space radius. The code above should do the conversion (I haven't tested).

Remember to test in persp and ortho views.

But I'm not sure about replacing sphere by points though.
Points will have depth problem on viewfacing surfaces and will be cut in half most of the time.
So either use points and disable depth test, and let point leak bellow surfaces.
Or use instancing like I did in clay engine to instance a sphere batch. (might be less trouble than all of this)

Yes I ended up using the sphere batch for that. Better safe than sorry. But it's good to know an alternative, thanks @Clément Foucault (fclem)