The question of the hour is: How to make a transparent block with a visible outline? I am trying to make a platform who's outline is visible and it can't be stepped on. upon flipping a switch the block becomes solid. How can I make it invisible, but still have an out line? I've seen some solutions using shaders, but I have absolutely no clue how to manipulate that code. Or how I could turn it off when hitting a button. Any ideas?
Answer by Lo0NuhtiK
May 22, 2012 at 11:37 AM
A quick way be to just make a 32x32 image with a transparent background and a thin border (2px on mine) around the edges. Then make a material (transparent diffuse shader) and use that image for the texture. Then your box is transparent with a border. When looking 'through' the box, you won't see the other sides border's. Only see the borders on the outside of the box.
I tried making a texture in photoshop, the top layer being a dotted line for the outline, then the 2nd layer behind that had 0% fill. I added it to a transparent diffuse shader but the box still had a white fill on the face facing the camera, then a semi transparent for all the others, I can see inside the cube but I can't see through the cube. Any thoughts on that?
Don't know. Worked fine for me.
How did you make the initial image?
Used GIMP, made a 32x32 image with transparent background, then lined the edges with 2px color border. Exported as .png .
So is it on 2 Layers or one?
Answer by kirpigiller
May 22, 2012 at 03:05 PM
You can try to use Alpha mask. For example, render your mesh with ColorMask A and Blend One Zero, then render the same but slightly scaled with ColorMask RGB(A) and Blend DstAlpha OneMinusDstAlpha.
Based on the number of things in here that I didn't understand, it sounds like it could work. I'm going to assume this has to deal with writing a shader script, as of yet I have no clue how to do that, I am looking that up now. And not that I want to be spoon fed, but, could you please provide a slightly dumbed down example?
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
8 People are following this question.
rendering part of a ghost when my player passes close to it
Outlined Specular shader?
Fire outline shader
Shader that makes every other pixel not render?