Discussion:
[osg-users] Idea to implement a kind of 'rubber mode'
Christoph Dohmen
2018-09-11 11:51:48 UTC
Permalink
Hi all,

I'm looking for some inspiration for solving the following 'problem':
Currently I'm drawing basic line geometries like in attachment line.png. And I'm able to draw items above the geometries (combo.png). But the final goal must be some kind of 'rubber mode' which makes the geometry transparent and keeps the background (liek in symbol.png).

What may be the technique to solve this?

Thank you!

Cheers,
Christoph

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74703#74703
Chris Hanson
2018-09-11 15:31:29 UTC
Permalink
I think there's a little bit of communication issue here.

You are saying you want the look of symbol.jpg? How do you mean "rubber
mode"? What is "rubber" about it?

You could possibly create a dummy quad with the background blue color on it
that encompasses the screen-space bounding box of the green line, and
render it after the black line but before the green one. Would that give
you the effect you want?
Post by Christoph Dohmen
Hi all,
Currently I'm drawing basic line geometries like in attachment line.png.
And I'm able to draw items above the geometries (combo.png). But the final
goal must be some kind of 'rubber mode' which makes the geometry
transparent and keeps the background (liek in symbol.png).
What may be the technique to solve this?
Thank you!
Cheers,
Christoph
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74703#74703
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
Chris 'Xenon' Hanson, omo sanza lettere. ***@AlphaPixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775)
623-PIXL [7495]
Christoph Dohmen
2018-09-11 17:09:26 UTC
Permalink
Well, Chris, thanks for the question. It shows that I was not precise enough.
Currently I'm drawing the black line on top of a quite complex background (light blue). And as a second item I draw the quad with the red frame showing the green symbol and having transparent colour in the background so the scene background hat visible and the black line.
My goal is to use the textured quad as a rubber and remove the black line but not the scene background like in symbol.png.

I hope that clarified it a bit more?!

Thank you!

Cheers,
Christoph

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74709#74709
Chris Hanson
2018-09-11 19:35:39 UTC
Permalink
I think some parts were lost in translation. I think the word you want to
use is "eraser" instead of "rubber", though I can see how it could be
mistranslated from another language.

I can think of a way to do this with your current draw order (black line
then green line) by using a shader and a texture holding the background
image.

Otherwise, you'd have to probably change the draw order so that the black
line was drawn later than the green line.


I often recommend users with complex questions "take a step back" and
explain the non-simple-abstract problem. Many times we find people asking a
specific question believing it is the only solution, and finding no good
ways to achieve it, when in fact the same overall goal could easily be
accomplished a different way if we knew what they were really trying to do.

Could you explain more about the real-world problem you're trying to solve,
instead of this simplified abstract summary?

As an example, imagine if someone came to you asking how to safely operate
a flamethrower in their kitchen, and you answered it was impossible. Later
you found out that all they wanted to do was make tea, but had pre-decided
on "flamethrower" as the way to get there, but if they'd just said "I want
to make tea", an electric kettle would have neatly solved the problem.
Don't be the flamethrower tea guy.
Post by Christoph Dohmen
Well, Chris, thanks for the question. It shows that I was not precise enough.
Currently I'm drawing the black line on top of a quite complex background
(light blue). And as a second item I draw the quad with the red frame
showing the green symbol and having transparent colour in the background so
the scene background hat visible and the black line.
My goal is to use the textured quad as a rubber and remove the black line
but not the scene background like in symbol.png.
I hope that clarified it a bit more?!
Thank you!
Cheers,
Christoph
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74709#74709
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
Chris 'Xenon' Hanson, omo sanza lettere. ***@AlphaPixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775)
623-PIXL [7495]
Daniel Trstenjak
2018-09-12 07:12:33 UTC
Permalink
Hi Christoph,
Post by Christoph Dohmen
Well, Chris, thanks for the question. It shows that I was not precise
enough. Currently I'm drawing the black line on top of a quite
complex background (light blue). And as a second item I draw the quad
with the red frame showing the green symbol and having transparent
colour in the background so the scene background hat visible and the
black line. My goal is to use the textured quad as a rubber and
remove the black line but not the scene background like in symbol.png.
are you making some kind of drawing program, and you want to be able
to move the rubber/erasier around and delete the previously drawn lines?

If this is the case, then you most likely don't want to implement the
erasing operation as an OpenGL graphics operation, but as an operation
on your program data describing the lines.

You're modifying the internal program state and then draw this new state.

Greetings,
Daniel
Tony Vasile
2018-09-12 01:32:46 UTC
Permalink
Hi Chris
Actually in non US English the words rubber and eraser are interchangeable.

Tony

------------------------
Tony V

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74715#74715
Christoph Dohmen
2018-09-12 06:00:50 UTC
Permalink
Hi Chris,

the original goal is drawing a decorated line where the decoration interrupts and keep the background visible. I tried to visualize the elements and the seps which are acutally working. I got a few keywords like 'stencil', 'render to texture' but the samples are all related to textured items covering textured items and not to polylines covered by textured items.

Thank you!

Cheers,
Christoph

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74716#74716
Voerman, L.
2018-09-12 09:06:52 UTC
Permalink
Hi Christoph,
attached is an osg file that does what I think you want,
unzip and view with:
"osgviewer cow.osg.0,-5,0.trans erasor.osg.10,10,10.scale"

The osg file works by using a low (negative) render bin number to force the
draw order,
first renderbin -2 draws the erasor geometry and the outline,
than renderbin -1 renders an invisible quad (colormast all OFF)
to fill the depth buffer with 0 (depth range 0-0),
so it's pixels won't be overwritten by the normal rendering done later.
Laurens.
Post by Christoph Dohmen
Hi Chris,
the original goal is drawing a decorated line where the decoration
interrupts and keep the background visible. I tried to visualize the
elements and the seps which are acutally working. I got a few keywords like
'stencil', 'render to texture' but the samples are all related to textured
items covering textured items and not to polylines covered by textured
items.
Thank you!
Cheers,
Christoph
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74716#74716
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Christoph Dohmen
2018-09-12 09:10:34 UTC
Permalink
Hi Daniel,

it's not a drawing programm.

Thank you!

Cheers,
Christoph

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74718#74718
Christoph Dohmen
2018-09-12 11:51:58 UTC
Permalink
Yes, Laurens, that's exactely what I was looking for!

Do you have any source which created the file?

Thank you!

Cheers,
Christoph

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74720#74720
Voerman, L.
2018-09-12 13:31:15 UTC
Permalink
Hi Christoph,
I don't have a piece of source code that will create this file, I exported
the basic shapes from 3dsmax and edited the file to set the renderbins,
depth and colormask.
Laurens.
Post by Christoph Dohmen
Yes, Laurens, that's exactely what I was looking for!
Do you have any source which created the file?
Thank you!
Cheers,
Christoph
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74720#74720
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Christoph Dohmen
2018-09-12 15:19:29 UTC
Permalink
Thank you, Laurens!

Cheers,
Christoph

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74725#74725
Chris Hanson
2018-09-12 21:49:18 UTC
Permalink
That's a clever trick. Will it work with more than one layer of
red-frame-green-symbol objects?

Does it need to work in that situation?

"Rubber" means something else in US English. ;)
Post by Christoph Dohmen
Thank you, Laurens!
Cheers,
Christoph
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74725#74725
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
Chris 'Xenon' Hanson, omo sanza lettere. ***@AlphaPixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775)
623-PIXL [7495]
Voerman, L.
2018-09-13 07:36:41 UTC
Permalink
Hi Chris,
Will it work with more than one layer of red-frame-green-symbol objects?
I don't fully understand your question. The renderBin numbers can force the
render order of lots of "layers",
but the invisible quad fills the depth buffer with zeros - so that will not
really scale with a layer system.
Laurens.
That's a clever trick. Will it work with more than one layer of
red-frame-green-symbol objects?
Does it need to work in that situation?
"Rubber" means something else in US English. ;)
Post by Christoph Dohmen
Thank you, Laurens!
Cheers,
Christoph
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74725#74725
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4
• GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775)
623-PIXL [7495]
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Christoph Dohmen
2018-09-13 08:00:37 UTC
Permalink
Hi Laurens,

it's working if I reduce the current drawing sources to fixed function pipeline. But unfortunately we use several shaders. As far as I understand the idea, I will need to access the ColorMask from within the fragment shader, right? Any hints for that or am I totally wrong?

Thank you!

Cheers,
Christoph

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74736#74736
Voerman, L.
2018-09-13 08:25:22 UTC
Permalink
Hi Christoph,
I can combine this with a scene that uses shaders without modification. If
that's not working for you I don't understand why.
Using the depth buffer to block further rendering will need the
GL_DEPTH_TEST to be active, did that change for your shader/fixed scene?
Laurens.
Post by Christoph Dohmen
Hi Laurens,
it's working if I reduce the current drawing sources to fixed function
pipeline. But unfortunately we use several shaders. As far as I understand
the idea, I will need to access the ColorMask from within the fragment
shader, right? Any hints for that or am I totally wrong?
Thank you!
Cheers,
Christoph
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74736#74736
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Continue reading on narkive:
Loading...