Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by muchitto · Jun 09, 2011 at 08:10 AM · shadernormalsdouble-sided

Problems with two sided textured shader

I have a simple plane I made in Blender, exported to a fbx file and imported to Unity. Then I made a shader, that should allow a two sided textured plane (if I'm reading the past two sided shader discussions right).

Now when I look the plane in the editor, it looks fine. Both sides look like they are supposed to, but when I run the game, the other side is completely black. Is it because of the normals or the lighting or what? I'm kinda new to writing shaders.

Here are some images from the editor: http://imageshack.us/g/43/plane1.png/

Here is the shader code:

 Shader "Shader test" {
     Properties {
         _AmbientColor ("Ambient Color", Color) = (1, 1, 1, 1)
         _DiffuseColor ("Diffuse Color", Color) = (0, 0, 0, 0)
         _Emission ("Emmisive Color", Color) = (0,0,0,0)
         _SideOne ("Side 1", 2D) = "white" {}
         _SideTwo ("Side 2", 2D) = "white" {}
     }
     
     SubShader {
         Pass {
             Material {
                 Diffuse [_DiffuseColor]              
                 Ambient [_AmbientColor]
             }
             Cull Off
             Lighting On
             
             SetTexture [_SideOne] {
                 Combine Primary * Texture
             }
         }
 
         Pass { 
             Material {
                 Diffuse [_DiffuseColor]              
                 Ambient [_AmbientColor]
             }
             Lighting On

             SetTexture [_SideTwo] {
                 Combine Primary * Texture
             }
         }
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by jonas-echterhoff · Jun 09, 2011 at 08:24 AM

Not 100% sure this is your problem, but in your first pass, you have "Cull Off". That makes the first pass show both sides. If you want to have one pass to only show the back sides, change it to "Cull Front".

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image muchitto · Jun 09, 2011 at 08:34 AM 0
Share

Seems like the Cull Front has the exact same effect as Cull Off. And btw, I'm using $$anonymous$$acBook Pro and Unity 3.3.

avatar image
0

Answer by muchitto · Jun 13, 2011 at 06:04 AM

Has anyone got any suggestions? I still haven't found a solution to this.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by testure · Jun 13, 2011 at 07:26 AM

I'd wager that the problem you're having is lighting-related. The thing with a two sided shader is that you can still only receive light on one side. It's not "really" two sided, it's just one side being drawn twice. Most people have the exact opposite problem, where both sides are super bright.. you're probably not having that problem because of the nature of your two texture implementation.

Personally, I don't mess with two sided shaders.. I see zero benefit from it- those backfacing triangles still count. In your case, you could potentially save a draw call by using a single material- but you could still get away with a single draw call if you combine your textures into a single atlas and adjust the UVs on both sides to match up with the atlas. You lose the ability to tile in this case, but based on the images in your screenshot that doesn't look like it would be an issue..

When I'm working on models, I'll keep all of the stuff that will eventually be two sided on a separate layer so they're easily accessable, and then when I'm ready to export to an FBX I'll duplicate the layer, flip the normals, export to FBX, then delete the 'other side' layer. I use modo, so it was easy to write a script that did that for me- now i just name my layer "two-sided" and when I run my exporter script it does all that for me.

Just my two cents, hope you find the solution you're looking for.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

3D Texture and normals 0 Answers

colorize mesh based on dot product 1 Answer

Camera spaced normals for a surface shader 1 Answer

Weird sphere normals??? 2 Answers

A shader that ignores the direction of normals, but takes distance into account 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges