Output Outline vs Outline Node

Node-based Shader Editor

Output Outline vs Outline Node

Postby DanielThomas » Mon Dec 10, 2018 5:47 pm

:? 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?
Attachments
shader1.jpg
Sprite Shader with the camera render image as texture.
shader1.jpg (74.62 KiB) Viewed 4958 times
DanielThomas
 
Posts: 6
Joined: Mon Dec 10, 2018 5:34 pm

Re: Output Outline vs Outline Node

Postby Amplify_Borba » Tue Dec 11, 2018 11:04 am

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
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Output Outline vs Outline Node

Postby DanielThomas » Tue Dec 11, 2018 11:12 am

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)
Attachments
shader2.jpg
shader2.jpg (215.74 KiB) Viewed 4944 times
DanielThomas
 
Posts: 6
Joined: Mon Dec 10, 2018 5:34 pm

Re: Output Outline vs Outline Node

Postby Amplify_Borba » Tue Dec 11, 2018 11:34 am

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.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Output Outline vs Outline Node

Postby DanielThomas » Tue Dec 11, 2018 12:10 pm

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.
DanielThomas
 
Posts: 6
Joined: Mon Dec 10, 2018 5:34 pm

Re: Output Outline vs Outline Node

Postby DanielThomas » Tue Dec 11, 2018 12:26 pm

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?
DanielThomas
 
Posts: 6
Joined: Mon Dec 10, 2018 5:34 pm

Re: Output Outline vs Outline Node

Postby Amplify_Borba » Tue Dec 11, 2018 2:21 pm

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
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Output Outline vs Outline Node

Postby DanielThomas » Tue Dec 11, 2018 2:39 pm

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.
DanielThomas
 
Posts: 6
Joined: Mon Dec 10, 2018 5:34 pm

Re: Output Outline vs Outline Node

Postby Amplify_Borba » Tue Dec 11, 2018 4:27 pm

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!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Output Outline vs Outline Node

Postby DanielThomas » Tue Dec 11, 2018 8:03 pm

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.
Attachments
shader4.jpg
shader4.jpg (227.47 KiB) Viewed 4912 times
DanielThomas
 
Posts: 6
Joined: Mon Dec 10, 2018 5:34 pm

Next

Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 0 guests