Page 1 of 2

Output Outline vs Outline Node

PostPosted: Mon Dec 10, 2018 5:47 pm
by DanielThomas
:? Hi,
I'm using a 3D Model which a camera renders an image of that I use on a flat plane(like a sprite).
I want an outline for the 3D model. So my problem/question is:
Using the Output Outline option works great. But when I use an outline-node and connect it to the Local Vertex Offset the outline renders on the 3D Model, _but_ it doesn't show up on the sprite plane the camera renders, but rather shows up and transparent pixel. Outline is however in the image file which makes me think it can be the sprite shader?

The sprite shader is a basic one with transparent cutout. If I set the cutout clip value to zero the outline shows on the sprite plane(but obviously no transparency). But as I said, using the output outline checked works. So is there something I need to tweak in the sprite shader (see attachment) to make it render the outline from the image?

Re: Output Outline vs Outline Node

PostPosted: Tue Dec 11, 2018 11:04 am
by Amplify_Borba
Hello, thank you for getting in touch and for your support!

I'm not entirely sure on what to suggest, but using the Alpha for masking the texture will definitely not work as expected since in this situation the alpha channel won't have the correct data to account for both the object and its outline.

Image

As a possible workaround, you could try masking out the outline before dealing with the 3D Object:

Image

Do note that in the example above the shader for the object is set to unlit, so that its color information won't interfere with the outline mask.

Image

Re: Output Outline vs Outline Node

PostPosted: Tue Dec 11, 2018 11:12 am
by DanielThomas
After some investigating it's not the shader that renders the image, but the image from the camera itself. When I toggle alpha in the inspector image preview it shows that the outline is black, so it's transparent. But using the output nodes Outline option doesn't make it transparent in the image.
So something with the outline node outline makes the camera target texture have backfaces(outline) transparent.

Any ideas? What's the difference between making an outline with the vertex offset and the output outline option? Why does one read as alpha?

(see attachment, I have extra thick outline to demonstrate)

Re: Output Outline vs Outline Node

PostPosted: Tue Dec 11, 2018 11:34 am
by Amplify_Borba
The Outline node is similar to the Outline option available over the Standard Output properties, the difference is that it allows for a higher degree of customization.

As I've mentioned in my previous reply, you'll likely need to mask the outline separately from the object itself in order to be able to handle the data individually. However, I'm not entirely sure if using Render Textures is the best approach for this situation.

Re: Output Outline vs Outline Node

PostPosted: Tue Dec 11, 2018 12:10 pm
by DanielThomas
Not sure how this works, it only masks out the channel, but the render texture image have colorinformation in it so it masks out other parts.

BUT I'm not sure why I need to do this workaround, as I mentioned the output node outline works perfect, other shaders with outline works perfect, I just don't understand why using the outline node in the vertex offset doesn't work but give black in the alpha channel of the render texture image.

Re: Output Outline vs Outline Node

PostPosted: Tue Dec 11, 2018 12:26 pm
by DanielThomas
I solved it, I compared both shader codes, I just needed to add "o.Alpha = 1;" in void outlineSurf.
Just everytime I save the shader in the shader editor I need to add the line again. Anything I can add in editor to make it keep alpha 1 on outline?

Re: Output Outline vs Outline Node

PostPosted: Tue Dec 11, 2018 2:21 pm
by Amplify_Borba
Thank you for letting us know! You should be able to force that parameter through Outline node, by setting its Alpha Mode to Transparent, so that the Alpha port becomes exposed.

Image

Re: Output Outline vs Outline Node

PostPosted: Tue Dec 11, 2018 2:39 pm
by DanielThomas
When I do that I got some sorting error on the model. With some investigation, it seems like alpha:fade in #pragma surface was added when adding alpha mode transparent to the outline node, removing that from the shader code made it work again, which is fine since I don't have semitransparent pixels. But as before, updating shader in editor adds this line to the shader again.

Don't know if that's helpful.

Re: Output Outline vs Outline Node

PostPosted: Tue Dec 11, 2018 4:27 pm
by Amplify_Borba
The alpha:fade is added as a shortcut to allow for traditional fade transparency, and it is necessary for it to work correctly, so we can't remove it. Also, any manual edit to the code will be dismissed by the editor, which is expected since it can't account for such specific cases.

We would love to provide more insight in regards to the effect you're trying to create, however we're not entirely sure we understand why you're using render textures to add the outline effect to the 3D model, so could you please elaborate on the reason behind this? Thanks!

Re: Output Outline vs Outline Node

PostPosted: Tue Dec 11, 2018 8:03 pm
by DanielThomas
I understand, just wanted to give the information if it pops up again. It's solved so I didn't expect to the editor changed, I was only curious if there was anything/a setting that could help me. I consider the problem solved.

I'm making a 2D game, I use 3D model for characters to save time, but since there would be clipping on a 3D character moving around with 2D planes (like trees). So this is why I have a dedicated camera out of the game camera which renders a texture that I can then just apply to a plane in the game environment.

I'm adding an outline to the 3D model because I'm trying to replicate 2D aesthetics. I'm not applying the outline to the render texture. For the plane with the render texture, I just use a standard shader with the render texture in the color/albedo map.
The problem was that the render texture, when "captured" by the camera directed at the 3D character made the outline-mesh black pixels on the render texture - meaning they will read as fully transparent.

I attached an image to show the setup.