Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Outlines only on some objects

Discussion in 'Shaders' started by Smileys, Apr 11, 2014.

  1. Smileys

    Smileys

    Joined:
    Feb 27, 2014
    Posts:
    81
    Im using a edge detection post processing effect to create the Borderlands-outlines. But i only want outlines at rocks, buildings etc - not on grass and leaves. Another problem of the edge detection is the depth sensitivity. If you look close at a Screenshot from Borderlands you will notice that there is a outline around the whole model (for example a human) - but in my case the outline ends at the knees.

    example screenshot: http://www.destructoid.com//ul/2533...psycho-bandit/Psycho_Krieg_combat-noscale.jpg

    Does anyone knows how to fix this issues?
     
  2. WhiskyJoe

    WhiskyJoe

    Joined:
    Aug 21, 2012
    Posts:
    143
    you can't really exclude objects from a postprocessing effect, not easily anyway. You can cheat your way through it by making use of ImageEffectOpaque with another way involving compositing in the edge detection color buffer with the original one, but I'd say that's not very feasible. Your best bet would be to find/make an outline shader that works properly for your needs.

    As for the sensitivity, I don't know how the shader works exactly, but I can imagine there would be some parameter you can adjust to tweak it?
     
  3. Smileys

    Smileys

    Joined:
    Feb 27, 2014
    Posts:
    81
    Ive tried nearly every combination of the edge detection parameters. Theres no way to achieve a look like in borderlands.
    There must be a way because they did it. It is a post processing effect in borderlands and they dont have outlines on grass etc - just black lines in textures.
    If you studie the screenshots youll notice that the outline of for example the enemys is not dependent of the objects behind them. Looks like every object outline is rendered seperate from the scene.
    Im a beginner when it comes to shading and i dont want to waste my time learning shaders inside out when it is simple not possible.
    Right now the outline post processing shader is really disappointing.
     
  4. WhiskyJoe

    WhiskyJoe

    Joined:
    Aug 21, 2012
    Posts:
    143
    Keep in mind that Unity generally provides general purpose whereas in borderlands, it is the whole style where have put a lot of effort in and probably spent a lot of time tweaking to get the desired result.

    Of course there is a way, they did this, but it isn't like they found some implementation, tried playing around with some parameters, didn't get what they wanted and threw it away. They have people specialized in this kind of stuff, they studied how it can be implemented and made the effect. Even if they did use an out of the box solution, they took their time to understand how it works so they can get the results they want.

    Take some time to get to know how shaders work, specifically how post processing works in this case before you dismiss it as not possible.

    When looking more properly at the image a bit more closely (couldn't before, I was at work) you can also see that the edges that are "inside" the model do not have an outline, but the outline is generally just around the silhouette of the object. This suggests that this might be a multi-pass technique where they first render the silhouette of an object, apply some edge detection algorithm to it and composite it in the final image.

    Or perhaps they base it on the normal information of a model and transform it according to the viewing angle.

    I can imagine there are multiple more ways of getting this effect with each their own up and down sides and it's up to the developer to say what they can and want to work with.

    That all being said, the borderlands style of rendering is something a lot of people have been trying to reproduce with various people getting pretty close, though not every implementation is made in Unity. You could try to find the best looking solution for you and port it over to unity should it be needed.

    Whichever way you will take, I strongly advice on getting your shader knowledge up, once you get to know how to achieve certain things, it's an addicting hobby to push the limits to see what you can do :)
     
  5. Smileys

    Smileys

    Joined:
    Feb 27, 2014
    Posts:
    81
    Thanks for the infos. I know that Borderlands has a specific style and a lot of people who are responsible for that.
    Do you have any tips where to start my research
     
  6. WhiskyJoe

    WhiskyJoe

    Joined:
    Aug 21, 2012
    Posts:
    143
    I would first of all begin with gaining some more knowledge about shaders in general. The CG Tutorial is probably a good place to start to get a better grasp on shaders, so you know exactly how they work. They're almost directly implementable in the Unity shaders.

    When you're convinced you know enough to get your hands more dirty, take a look at the various shaders and image effects unity has. In case of the image effects, don't just look at the shaders, but check out how they're working with the scripts as well. Unity also has plenty of resources online that will give you some good information on the topic. I also found that 9 out of 10 times when I am stuck on something unity related, a google search with "unity3d how do I ..." gives me plenty of proper results or a push in the right direction.

    Once you get a better understanding, search for various edge detection shaders and try to understand how they work. Only when you are able to figure out how something works, you are able to perform tweaks and alter code to get your desired result.

    You can also search directly for borderlands shaders and see if people have something close to it and see how they achieved it.