Double Sided *Material*
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Unity Community Index // ShaderLab
View previous topic :: View next topic  
Author Message
p3x797



Joined: 30 Mar 2009
Posts: 6

PostPosted: Fri Apr 24, 2009 4:51 pm    Post subject: Double Sided *Material* Reply with quote
Hi everyone!

I really need to be able to create a double sided material.

For example one face (two tris, 1 poly) that shows the material on the reverse side of it.

I know alot of people have enquired about this, but i really can't afford to physically have the reverse side as part of the geometry.

My actual question is, does unity support this type of material option and if so does it need to be scripted in or is there a prefab or a shader that someone has made that is able to do it

Any info regarding this would be amazing!

Many thanks
Back to top
View user's profile Send private message
Eric5h5



Joined: 19 Jul 2006
Posts: 10865

PostPosted: Fri Apr 24, 2009 9:35 pm    Post subject: Re: Double Sided *Material* Reply with quote
This has been asked and answered many times...a search will easily find the solution.

--Eric
Back to top
View user's profile Send private message Visit poster's website
Daniel Brauer



Joined: 11 Aug 2006
Posts: 1554
Location: GMA950

PostPosted: Fri Apr 24, 2009 9:46 pm    Post subject: Reply with quote
If you don't need lighting to work properly, rendering backfaces as well as front faces is easy. Check out either of these shaders:

http://www.unifycommunity.com/wiki/index.php?title=UnlitAlpha
http://www.unifycommunity.com/wiki/index.php?title=VegetationVertexLit

If you want lighting to work properly, you'll have to use a shader that does two passes: one with backface culling and no changes to normals, and one with frontface culling and flipped normals.
Back to top
View user's profile Send private message
p3x797



Joined: 30 Mar 2009
Posts: 6

PostPosted: Fri Apr 24, 2009 9:49 pm    Post subject: Reply with quote
Hi eric

Thank you for your insightful response, maybe if i had spent time making four thousand and something posts i may recall a vague reference to it, but unfortunately i have just the two posts for now.

I have looked alot using the search and all i can find is information from people that don't really seem to actually know the answer to my specific question and just describe physically making another polygon mirrored fr the solution to a two sided *material*.

i.e.

"I know alot of people have enquired about this, but i really can't afford to physically have the reverse side as part of the geometry."

if you can find a post relating to the material settings i need to use that can answer my question, you may receive a gold star.

or

you may not

either way don't make condescending posts for the sake of it, its slightly immature, and will waste a lot of your time. Much appreciated.

But to anyone else that may be able to help, i would love some constructive feedback it will help alot as i really can not find any information relating to this and i felt posting a more specific question would be more efficient.

Many thanks

Kind regards
Back to top
View user's profile Send private message
p3x797



Joined: 30 Mar 2009
Posts: 6

PostPosted: Fri Apr 24, 2009 9:50 pm    Post subject: Ta much! Reply with quote
Hi Muriac,

Thank you very very much! ill look into that then, i wasn't sure on what avenue to approach on this. But this will really help.

Thanks so much!
Back to top
View user's profile Send private message
Eric5h5



Joined: 19 Jul 2006
Posts: 10865

PostPosted: Fri Apr 24, 2009 10:15 pm    Post subject: Re: Ta much! Reply with quote
My post was not condescending, it was factual. If you do a search on "double-sided", you get many relevant results. This is to your benefit, since you would have instantly gotten your answer without having to wait for a reply. Please refrain from reading negative intent into posts where there isn't any.

--Eric
Back to top
View user's profile Send private message Visit poster's website
Charles Hinshaw
Unity Graphic Designer


Joined: 06 Feb 2008
Posts: 1071
Location: Indianapolis, IN

PostPosted: Fri Apr 24, 2009 10:19 pm    Post subject: Reply with quote
I don't think Eric's response was inappropriate -- this really has been asked before. And that comes up through searching.
_________________
Charles Hinshaw
Back to top
View user's profile Send private message
Animaleante



Joined: 03 Apr 2009
Posts: 26
Location: Curitiba - Brazil

PostPosted: Fri Apr 24, 2009 11:25 pm    Post subject: Reply with quote
Here am I, a complete newb, having to answer such a popular question, shame on you!!! Very Happy jk
here is my code for a DoubleSided Shader mate. Not like the ones Eric posted, this one is for any model, lighted or not:

Code:
Shader "DoubleSided" {
   Properties {
      _Color ("Main Color", Color) = (1,1,1,1)
      _MainTex ("Base (RGB)", 2D) = "white" {}
      //_BumpMap ("Bump (RGB) Illumin (A)", 2D) = "bump" {}
   }
   SubShader {      
      //UsePass "Self-Illumin/VertexLit/BASE"
      //UsePass "Bumped Diffuse/PPL"
      
      // Ambient pass
      Pass {
      Name "BASE"
      Tags {"LightMode" = "PixelOrNone"}
      Color [_PPLAmbient]
      SetTexture [_BumpMap] {
         constantColor (.5,.5,.5)
         combine constant lerp (texture) previous
         }
      SetTexture [_MainTex] {
         constantColor [_Color]
         Combine texture * previous DOUBLE, texture*constant
         }
      }
   
   // Vertex lights
   Pass {
      Name "BASE"
      Tags {"LightMode" = "Vertex"}
      Material {
         Diffuse [_Color]
         Emission [_PPLAmbient]
         Shininess [_Shininess]
         Specular [_SpecColor]
         }
      SeparateSpecular On
      Lighting On
      Cull Off
      SetTexture [_BumpMap] {
         constantColor (.5,.5,.5)
         combine constant lerp (texture) previous
         }
      SetTexture [_MainTex] {
         Combine texture * previous DOUBLE, texture*primary
         }
      }
   }
   FallBack "Diffuse", 1
}

[/code]
Back to top
View user's profile Send private message MSN Messenger
p3x797



Joined: 30 Mar 2009
Posts: 6

PostPosted: Sat Apr 25, 2009 11:35 am    Post subject: Reply with quote
Thanks guys :D
Back to top
View user's profile Send private message
Hanford



Joined: 28 Aug 2008
Posts: 154
Location: Mountain View, CA

PostPosted: Sat May 02, 2009 9:02 pm    Post subject: Reply with quote
This gets asked/answered so often, i think it's worth Unity looking into providing this functionality with the standard assets package.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Hanford



Joined: 28 Aug 2008
Posts: 154
Location: Mountain View, CA

PostPosted: Sat May 02, 2009 9:15 pm    Post subject: Reply with quote
PS: What part of that shader code actually renders it double-sided?

I wish more shader source had comments in them; I feel lost trying to figure it out.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Animaleante



Joined: 03 Apr 2009
Posts: 26
Location: Curitiba - Brazil

PostPosted: Sat May 02, 2009 9:17 pm    Post subject: Reply with quote
...SeparateSpecular On
Lighting On
Cull Off
...

Just the cull off part
Back to top
View user's profile Send private message MSN Messenger
Hanford



Joined: 28 Aug 2008
Posts: 154
Location: Mountain View, CA

PostPosted: Mon May 04, 2009 1:21 am    Post subject: Reply with quote
Animaleante wrote:
...SeparateSpecular On
Lighting On
Cull Off
...

Just the cull off part


Wow, so you can take any shader with Cull off, remove that line, and you get double-sided?

Seems like comments in the default shader code could cut down this problem being asked/answered so often.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Animaleante



Joined: 03 Apr 2009
Posts: 26
Location: Curitiba - Brazil

PostPosted: Mon May 04, 2009 12:59 pm    Post subject: Reply with quote
Hanford wrote:
Animaleante wrote:
...SeparateSpecular On
Lighting On
Cull Off
...

Just the cull off part


Wow, so you can take any shader with Cull off, remove that line, and you get double-sided?

Seems like comments in the default shader code could cut down this problem being asked/answered so often.


Actually, is not taking that line off. It is more like:
Cull On //Don't render "inner" faces
Cull Off // Render double-sided
Back to top
View user's profile Send private message MSN Messenger
GI_JOEJK



Joined: 11 Nov 2008
Posts: 80
Location: Sacramento, CA

PostPosted: Wed May 06, 2009 9:33 am    Post subject: Reply with quote
Animaleante wrote:
...SeparateSpecular On
Lighting On
Cull Off
...

Just the cull off part


It would be EXTREMELY helpful to have a simple "on/off" button next to the shader for this function...

This is giving me shades of TGEA nauseum.
Back to top
View user's profile Send private message Visit poster's website
Post new topic   Reply to topic    Unity Community Index // ShaderLab All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum