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
1
Question by JoeStrout · Feb 01, 2011 at 04:25 AM · shadertexturelightingfast

Any shader simpler/faster than Vertex-Lit?

I'm working on a game where I will control the shading myself, by changing the baseColor of the textures. So I don't want a shader that does ANY lighting at all. I know I can get that effect by having no lights in the scene and turning up the ambient light on the render settings, but I still worry that the renderer will be working harder than it needs to.

According to the docs, Vertex-Lit is the simplest/fastest renderer, but even that computes light and applies it on a vertex basis. Is there any "None" shader that just draws flat textures exactly as they are, not affected by lighting at all?

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

4 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Eric5h5 · Feb 01, 2011 at 04:55 AM

This shader on the wiki is about the simplest and fastest you can get:

Shader "Texture Only"{

Properties { _MainTex ("Texture", 2D) = "" }

SubShader { Pass {SetTexture[_MainTex]} }

}

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 gazialankus · Mar 06, 2012 at 08:19 AM 0
Share

Alpha transparency does not work with this one. Is there a version of this that respects transparency?

avatar image
0

Answer by Peter G · Feb 01, 2011 at 04:41 AM

You can turn Lighting Off:

Shader "No Lighting" { Properties { _Color ("Main Color", COLOR) = (1,1,1,1) } SubShader { Pass { Material { Diffuse [_Color] Ambient [_Color] }

         //---------------------------
         Lighting Off
         //---------------------------

     }
 }

}

And just set the texturing to take a mainColor into account with a texture.

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 Jessy · Feb 01, 2011 at 10:08 AM

I'm thinking that when you say "baseColor", you mean the a solid color that gets multiplied into the whole material. That's what happens with "ambient light", anyway.

I know I can get that effect by having no lights in the scene and turning up the ambient light on the render settings.

Or maybe you just mean that you're making the ambient setting white, and "baseColor" is something else entirely? Please let us know.

If you actually wanted to use the color in the render settings, you could use this (it won't display right in the material preview for some reason, but looks fine in the scene; I'm reporting a bug right now):

Shader "Ambient Lit Texture" {

Properties { _MainTex ("Texture", 2D) = "" }

SubShader { Lighting On Material {Ambient (2, 2, 2)} Pass{ SetTexture[_MainTex] {Combine texture * primary} } }

}

If you want to use Material.color, then these will yield the same result. The first one sets the vertex colors of the mesh to be a solid color, and the second one defines a constant in the texturing stage. I don't know which is faster, but I'd love for someone to tell me about that. ;-) (Daniel Brauer told me that grabbing vert lighting values can be faster than using constants, which seems counterintuitive to me, but I never designed a GPU.)

Shader "Tinted Texture" {

Properties { _Color ("Base Color", Color) = (1,1,1) _MainTex ("Texture", 2D) = "" }

SubShader { Color[_Color] Pass{ SetTexture[_MainTex] {Combine texture * primary} } }

}

.

Shader "Tinted Texture" {

Properties { _Color ("Base Color", Color) = (1,1,1) _MainTex ("Texture", 2D) = "" }

SubShader { Pass{ SetTexture[_MainTex] {Combine texture * constant ConstantColor[_Color]} } }

}

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 davedev · Mar 28, 2012 at 09:42 AM

Unlit shader should be the fastest and sounds like it does what you want.

http://unity3d.com/support/documentation/Components/shader-Performance.html

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

2 People are following this question.

avatar image avatar image

Related Questions

Help with adding a normalmap to a shader 1 Answer

Torchlight effect in 2D 3 Answers

World coordinates for texture on procedural mesh 0 Answers

If not lit, use different texture 2 Answers

Shader light fix? 1 Answer


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