|
|
|
| View previous topic :: View next topic |
lucaderiu

Joined: 05 May 2009 Posts: 4 Location: Milan
|
Posted: Mon May 11, 2009 10:42 am Post subject: 2 sided material - Backface culling |
|
|
|
Hi, This is my first post here. I noticed there are tons of requests about 2-side material. In effect it's strange there is no a flag to enable/disable this option.
I noticed lot of artists, here being disappointed about effective modeling 2-side in 3D models, I agree with them.
Unity is a great engine and optimize by default some things, in this case the back side of the normals.
The only thing you have to do is simple, you have to disable this optimization. How? Simply add this in your shader's code:
Cull off
I suggest you to start reading this page
http://unity3d.com/support/documentation/Components/SL-Reference.html
Hope this helps!
[/code] |
|
| Back to top |
|
|
Eric5h5
Joined: 19 Jul 2006 Posts: 10865
|
Posted: Mon May 11, 2009 3:52 pm Post subject: Re: 2 sided material - Backface culling |
|
|
|
Yes, but the lighting is wrong on the back side if you do that. Sometimes that's not a problem, but other times modeling two sides is the correct answer.
--Eric |
|
| Back to top |
|
|
yosh
Joined: 13 Mar 2009 Posts: 124
|
Posted: Wed Aug 19, 2009 3:26 pm Post subject: |
|
|
|
Hi,
i want to add the "Cull Off" to the Reflective/Specular-BuiltinShader.
If i add it, i get a syntax-error.
I´m unexperienced at shader-programming.
I´ve already tested with it, but no way.
Can somebody explain it where to put it in?
| Code: | Shader "Reflective/SpecularBackface" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
_Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect }
}
SubShader {
UsePass "Reflective/VertexLit/BASE"
UsePass "Specular/PPL"
Cull Off
}
FallBack "Reflective/VertexLit", 1
} |
|
|
| Back to top |
|
|
Joe Robins Unity Support

Joined: 21 Apr 2008 Posts: 390 Location: Copenhagen, Denmark
|
Posted: Wed Aug 19, 2009 4:13 pm Post subject: |
|
|
|
Cull Off
Cull off
Notice any differences?
My guess is that is what is up _________________ Joe Robins
Support Team | Unity Technologies
www.unity3d.com |
|
| Back to top |
|
|
Daniel Brauer
Joined: 11 Aug 2006 Posts: 1554 Location: GMA950
|
Posted: Wed Aug 19, 2009 4:42 pm Post subject: |
|
|
|
| Joe Robins wrote: | Cull Off
Cull off
Notice any differences?
My guess is that is what is up |
No, you have to set culling before you do your passes. Just move "Cull off" so that it's the first thing in the SubShader block. With the exception of identifiers and the contents of Cg programs, Shaderlab is case-insensitive.
I'd like to reiterate that simply turning culling off is not going to work in a lot of cases. It will mess up lighting and shadows. Sometimes you might not notice, but if you need any lighting, it's much better practice to make double-sided models. |
|
| Back to top |
|
|
yosh
Joined: 13 Mar 2009 Posts: 124
|
Posted: Wed Aug 19, 2009 4:46 pm Post subject: |
|
|
|
Thanks for your fast reply.
I´ve already tested it with "Cull Off and Cull off".
I think its in the wrong statement of the code, isnt it?
Although getting the error the inside plane gets red... |
|
| Back to top |
|
|
Daniel Brauer
Joined: 11 Aug 2006 Posts: 1554 Location: GMA950
|
Posted: Wed Aug 19, 2009 7:26 pm Post subject: |
|
|
|
| yosh wrote: | | Thanks for your fast reply. |
I think you might have missed my reply above. |
|
| Back to top |
|
|
|
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 can attach files in this forum You can download files in this forum
|
|
|
|
|
|