Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by aaronflippo · Feb 17, 2013 at 08:23 PM · lightingshadersoptimizationdiffuse

Cheap options for making diffuse-lit objects "interesting"

Question for you shader/lighting/efficiency experts:

Take a look at this scene - it has a single directional light: https://twitter.com/AeornFlippout/status/300133754565976064/photo/1

I like the dramatic contrast on those cubes, but the one thing I don't like is that the faces opposite to and parallel to the light all have exactly the same shade. I realize this is "realistic" for a diffuse shader, but I want just a bit of variance so I can pick out the shapes a little bit better when looking at them. We also have some faceted, roughly spherical shapes, and have the same issue. Basically the whole game is looking at objects from the backsides as you fly past them, and we just want a bit more definition.

Can anyone suggest a cheap way to achieve something like this? We can add a 2nd light to the scene pointing in the opposite direction, but our goal is 60fps on tablets, and I'm worried about performance. The other idea I thought of is some kind of a fresnel shader.

But I wonder if there's something like a diffuse-type lighting shader that breaks the rules a bit and adds some lighting gradient even on the backfaces, perhaps just very slightly increasing light values as the faces face more and more away from the light?

Generally speaking, would it be cheaper to come up with some kind of shader solution, or to add a 2nd light to the scene? Or maybe there's an even cheaper method I'm not thinking of.

I'm open to suggestions!

Comment
Add comment · Show 3
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 robertbu · Feb 17, 2013 at 08:28 PM 0
Share

How about going to Edit/Render Settings and giving the scene a bit of Ambient Light?

avatar image aaronflippo · Feb 17, 2013 at 09:24 PM 0
Share

We do have some ambient light in the scene, but it adds equally to all surfaces so doesn't really solve our problem...

avatar image Benproductions1 · Feb 18, 2013 at 03:27 AM 0
Share

How about trying to make a "diffuse" texture, that makes it seem a bit more interesting (a little gradient effect maybe?)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by electricsauce · Feb 18, 2013 at 04:34 AM

Try the Unity diffuse wrapped shader. It adds a little lighting to the sides of an object. http://docs.unity3d.com/Documentation/Components/SL-SurfaceShaderLightingExamples.html

Shader "Example/Diffuse Wrapped" { Properties { _MainTex ("Texture", 2D) = "white" {} } SubShader { Tags { "RenderType" = "Opaque" } CGPROGRAM #pragma surface surf WrapLambert

       half4 LightingWrapLambert (SurfaceOutput s, half3 lightDir, half atten) {
           half NdotL = dot (s.Normal, lightDir);
           half diff = NdotL * 0.5 + 0.5;
           half4 c;
           c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten * 2);
           c.a = s.Alpha;
           return c;
       }
 
       struct Input {
           float2 uv_MainTex;
       };
       sampler2D _MainTex;
       void surf (Input IN, inout SurfaceOutput o) {
           o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
       }
       ENDCG
     }
     Fallback "Diffuse"
   }
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

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why is this outline diffuse shader making the scene darker than the regular diffuse shader? 0 Answers

Lighting support in Unlit shader 0 Answers

Optimise adding shadows in scene using Unity iPhone 2 Answers

How can I enable 'normal' shadows on a dithered -> transparent object? 0 Answers

Custom shader with unlit textures is too bright 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