Outline model problem

Hi.

I forked this project and trying to modify it.

My goal is outline model and I got some questions and problems.

First of all, I don’t understand why my model gets different outline size with the same shader:
Left model from original project and right one is mine.

So in vertex shader I multiply normal to value

void main(void) {
    vec3 pos = position;

    if (edge) {
        pos += normal * 0.1;
    }
    
    // transform normal
    vNormal = normalize(matrix_normal * normal);
    
    gl_Position = matrix_viewProjection * matrix_model * vec4(pos, 1.0);
}

Afterwards, I thought about size and make my multiplier to 3, to make my model solid. What I’ve got:

I don’t know what’s wrong with it, but you can see separated polygons and it looks awkward.

So the next problem is when another model is behind mine, scaled model get inside and I cant see part of it, so I lost outline effect

Is there a way to make it render over all of models? In Editor we have common effect:

By the way, this is exactly what I need.

Thanks.

So… I looked into Editor’s code and found solution inside.

I implemented it as script component and it works nice.

But… I’m not sure it’s legal to reverse engine and public parts of code from Editor
Obviously, I made some changes, but code is still dirty as my English.
So, anyway, here it is. If admins find it’s not allowed, just delete my post please.

Download component

I added some attributes, so you can just link it to your project and use.

If somebody can fork it and make code cleaner, I (and suppose whole community) would be really appreciate.
I think it’s really useful tool.

1 Like

That’s pretty cool!

I’m glad you’ve managed to find the implementation inside editor’s code. We do not minify it, as I personally find it is useful to debug and sometimes users can check internals of it for the good.

If you make simple project showcasing this component as well, will be cool.

Thanks a lot!

Okay, it’s on my way, but first of all, I have to to fix some bugs :slight_smile:

3 Likes

Does this still work?

I tried the script @mikefinch posted and couldn’t make it work.
I added it to a model entity in my level, got no error but no outlines either.

Hay @PixiLabo! Take a look at my post:

Thank you very much @Albertos , this help!

1 Like