Object selected border


I’m doing something like the Blender editor (WAY simpler, of course), and I want to show when an object is selected. Right now, for testing, I’m just changing the object material to another one, but what I really want is something exactly like Blender or any other 3D modelling package out there, just a border around my object, and some selection indicators (like the white circle or the object center in blender).

So, this is really two questions: how to do the border selection (I thought about using some kind of pixel shader to find the border, a la toon shader, or some post processing filter, but I don’t know if there is something simpler) and how to do the indicators (maybe something attached to the guiNode, but then I have to keep track of the rotation of the camera and all that, and that’s just tedious)

Thanks in advance!

  1. create a box with the size of the object ( boundingbox contains object size ?),
  2. render it wireframe or create the box using lines instead.
  3. if you want better graphics instead of using wireframe make the box transparent and use a texture with cool lines (e.g lines that have a nice pattern).

Thanks for your responses.

I’m using already the wireframe trick, but it’s far from ideal. I want the exact border of the object being selected. The box selection is good, maybe I’ll use that, although I prefer the perfect match.

Anyway, thank you again

It’s not easy, i tried to do it for JMP, but ended up with something very complicated compared to the wireBox selection and with not that much benefit. So i roll backed my changes.

But if you want to try yourself, the idea is to render the object in a pre viewport in the border color and scaled by a little, then render the main viewport without clearing the color buffer.

It’s far from ideal because you’ll encounter some glitches with other objects.

Hmm… I see. Well, I’ll try to do that.

Do you know how I can render the indicators?

Thanks for your response!

It’s not exactly what you asked for, but if you’re looking for something simple (without using wireframe) something else you could do is shade your ‘selected’ object in some way. You could do this by setting a boolean flag in your shader, using #ifdef to modify the color however you’d like.



varying vec2 texCoord;

uniform sampler2D m_ColorMap;

uniform vec4 m_Color;

void main(){

vec4 texColor = texture2D(m_ColorMap, texCoord);

vec4 c = vec4(mix(m_Color.rgb, texColor.rgb, texColor.a), 1.0);


c = c * vec4(1.2, 1.2, 1.2, 0);



c = c * vec4(1.5, 1.0, 1.0, 0);


gl_FragColor = c;



With this in your j3md:


MaterialParameters {

Texture2D ColorMap

Color Color

Boolean Highlighted

Boolean Selected


Technique {

VertexShader GLSL100: Shaders/CustomShader.vert

FragmentShader GLSL100: Shaders/CustomShader.frag

WorldParameters {



Defines {

HIGHLIGHTED : Highlighted

SELECTED : Selected




And to enable/disable the flag on your object’s material:


someGeometryObj.getMaterial().setBoolean(“Selected”, false);// (Or “Highlighted” in this example)


I use this to make a mesh brighter on mouseover or tinted-red when selected.

arcnor said:
Do you know how I can render the indicators?

In jMP we just have a toolNode attached to a post viewPort (that does not clear the color too). In that node we attach and detach the tools gizmos.

Thank both of you for your responses.

I’ll try some things based on all your responses, thanks again!

@tebriel you could just attach an ambient light to the object, no shaders needed, i dont think ambient light will reduce the fps of the program.

1 Like

I’m not sure that’d have quite the same effect, but simple, sure.