Oultine shader?

Has anyone ever done this? If so, what did you do? I’m new to shaders so I’m kinda stuck :smiley:

What do you mean? Like the cartoon shader thats in jME?

1 Like

Like, drawing an outline around a model. In screen space. I need this to higlight objects that are “selected”.

Here:

You can use Cartoon Edge.

Ok, is that a shader?

Because, I need several functionalities in my shader. Currently I made a modified version of the default Light/Lighting shader that is included. I added this functionality: Shader Nodes, Inputs for LightMapping node? (Solved) - #6 by afflicto

Yes it is but it’s registered as a filter by jme.

You can take the code and use it as you want.

Ok, I’ll looking into that, thanks!

Ok, so apparently the cartoon edge filter works on the entire scene, not just on specific objects. (according to this post: Cartoon Edge Filter - insight needed - #2 by nehon)

So I can’t use it :\

Maybe is it a good idea to highlight the entire object?
The most easy way to do is to make an Class that implements SceneProcessor. Such renderer should have an setObjectForHighlight or addObjectForHighlight, I dont know if you need to highlight just one or more objects at a time. Anyway, in postFrame you need to test if the object is on viewport’s queue, if so:

    _renderManager.setForcedTechnique("Highlight");
    
    Camera cam = _viewPort.getCamera();
    _viewPort.getQueue().renderShadowQueue(_list, _renderManager, cam, false);
    
    //_renderManager.setForcedMaterial(null);
    _renderManager.setForcedTechnique(null);
    _renderManager.setCamera(cam, false);

Where _list contains your object.

And the entire magic comes with .frag:

void main()
{
    gl_FragColor = vec4(0.2, 0.2, 0.2, 0.5);
}

Set Blend to Additive in Technique.

The result:

in the Shaderblow plugin I think there is an outline capability directly in the lighting shader.

unofrtunately Google decided to make google code painful so you can’t consult the code online anymore because there are too much sub folders in the ocntribution repo…so you either have to checkout the SVN repo, either to use the plugin int he SDK and look at the code
Edit look for lightBlow.j3md

Hi, thanks. I suppose I could do that. The only issue is, I’m using color to distinguish between players (I’m making an RTS), so changing the entire color is not the best approach.

For some reason, it seems I can’t install any plugins in the SDK. It just says it failed to install the plugin. Running 3.0 stable on Ubuntu 14.04.

I guess I can checkout the SVN repo and copy-paste :\

Is the player’s color an parameter passed to the shader? If so, use it in Highlight too.

What I mean is that, changing the entire color of the object is not a good idea because of UX (user experience) since the color of the object serves a purpose (to distinguish players). I’m working on implementing this though for testing purposes.

My guess is that they are rendering the object twice.

for each highlighted object
Pass 1: increase the size a little bit, cull front faces, render solid color
Pass 2: render as usual

Might be also possible to render pass 1 after pass 2 as post filter

chown +x jmonkeyplatform/jdk/bin/*

Hm, interesting approach. Although, since it’s rendering the object twice, wouldn’t this be costly?

Easy to test i guess :wink:
As a shot in the dark, i would assume way cheaper then a fullscreen pass.

Did that, still get the same error:

The Plugin Installer found problem timeout of loading shaderblowlib[shaderblowlib/0.1.1469]
while install the following plugins:

shaderblowlib

I’m gonna move this to a separate topic. I can’t seem to be able to update the core JME application either.

Actually, there seems to me other topics about the exact same issue.

Sure. Not sure how though, gotta read up on SceneProcessor and stuff, I guess.