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
0
Question by Recluse · Aug 12, 2011 at 09:12 AM · shaderlightingvertexopenglbeast

Lighting and lightmapping - OpenGL ES 1.1?

Hi, I'd like to get some advice regarding multiple platform support.

I'm targeting iPhone 3G and up (I'm also building for Android, but let's stick to iOS for the moment).

In my game I use a realtime vertex point light, which illuminates my level geometry. It's the only realtime light in the game.

If I lightmap my levels using Beast it seems I can only get the point light to work if it is set to a pixel light (rendering set to 'important'). This doesn't work on older 3G devices and anyway pixel light is too slow for my purposes - I only need a vertex point light. It seems 2.0 can't handle this so I am targeting ES1.1.

However it seems it's not possible to have a vertex point light illuminating a Beast lightmapped object in ES1.1 - only a non-beast lightmapped object shows the lighting effect.

Is there a solution that would work for 3G and up that provides?

1 vertex point light Beast Lightmapped level, with mobile/vertex lit shader

  1. and 2.0 seem too different to have a "one size fits all solution" (assuming I want the gfx to look the same on each device). Could I script material / light property changes depending on the device?

Novice with shaders and this field of Unity is not my strong point... any help would be great!

Comment
Add comment · Show 2
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 Jessy · Aug 12, 2011 at 12:55 PM 0
Share

Try using "primary" in the VertexL$$anonymous$$ pass, and please let us know if it works. You'll have to make use of the $$anonymous$$aterial block, of course. Let me know if you don't know how to work with all that. http://unity3d.com/support/documentation/Components/SL-PassTags.html http://unity3d.com/support/documentation/Components/SL-SetTexture.html

avatar image Recluse · Aug 14, 2011 at 07:42 AM 0
Share

Thanks Jessy, I will attempt to write a shader or modify the vertex lit one... stumbling through with this as I haven't touched shaders before really...

3 Replies

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

Answer by Jessy · Aug 14, 2011 at 02:40 PM

This will work for OpenGL ES 1.1 and 2.0, but you won't get optimal performance in 2.0 without a GLSL shader. Make sure you only bake the lights that can be baked. Also, name it; forward slashes create folders.

 Shader "Give this a name you like" {
 
 Properties {
     _Color ("Color", Color) = (1,1,1)
     _MainTex ("Base", 2D) = "white"
 }
 
 SubShader {
     Lighting On Material {Diffuse[_Color]}
     BindChannels {
         Bind "vertex", vertex
         Bind "normal", normal
     }
     
     Pass {
         Tags {"LightMode"="Vertex"}
         Material {Ambient[_Color]}
         BindChannels {Bind "texcoord", texcoord}
         SetTexture[_MainTex] {Combine primary * texture Double}
     }
 
     Pass {
         Tags {"LightMode"="VertexLM"}
         BindChannels {
             Bind "texcoord1", texcoord0
             Bind "texcoord", texcoord1
         }
         SetTexture[unity_Lightmap] {Matrix[unity_LightmapMatrix] Combine primary + texture}
         SetTexture[_MainTex] {Combine previous * texture Double}
     }
 }
 
 }
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 Recluse · Aug 18, 2011 at 03:25 PM 0
Share

This works nicely :-) thanks.

avatar image
0

Answer by Recluse · Aug 18, 2011 at 03:00 PM

Thanks Jessy. I will try that shader out.

In the meantime, after following your tutorials and through a process of trial and error I ended up with this shader, which blends two textures (one can be a base texture and the other a lightmapped texture) and also uses vertex lighting. It works well on my iPhone 3G and on my iPhone4. I also managed to cobble together a version which blends in vertex colors as well - however I was unable to get that to work in a single pass. So I am using this currently:

 Shader "Mobile/Blend 2 Textures, 1Pass, Lit" 
 
 { 
 
 Properties
 
     {
 
     _Color ("Color", Color) = (1,1,1)
     
     _MainTex ("Texture 1", 2D) = "" 
 
     _Texture2 ("Texture 2", 2D) = ""
 
     }



 Category 
 
 {
 
 Lighting On
 
 Fog { Mode Global }
 
 
 Material 
 
     {
     
     Ambient[_Color]
     
     Diffuse[_Color]
 
     }

 
 SubShader 
 
 {
 
 Pass 
 
     {        
     
     BindChannels
     
         {
   
            Bind "Vertex", vertex
            
            Bind "Color", color
            
            Bind "texcoord", texcoord0
            
            Bind "texcoord1", texcoord1
         
         } 

     
     SetTexture[_MainTex]
     
     {
     
     constantColor [_Color]
     
     Combine texture * primary DOUBLE, texture * constant
         
     }
     
     SetTexture[_Texture2] 
     
         {
                 
         Combine texture * previous DOUBLE 
         
         }
             
     }
     
 }

} } code here

Comment
Add comment · Show 2 · 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 Recluse · Aug 18, 2011 at 04:11 PM 0
Share

Your example works with Beast, which is perfect. If I use a beast lightmap with my attempt, it displays correctly in the editor, but not on the device... using a lightmap rendered in Blender works fine with my version though. I wonder why? I'm sticking with yours anyway, many thanks!

avatar image Jessy · Aug 18, 2011 at 04:22 PM 0
Share

$$anonymous$$aybe Unity doesn't allow you to use the "unity_Lightmap" texture directly, on the device. I don't know why they'd let it be emulated, though.

avatar image
0

Answer by shinja · Nov 25, 2011 at 09:03 AM

Hi Jessy on the shader that you wrote above was looking for a version with alpha and alpha cutout in it I tried programming it but as usual i am not good at this kind of stuff :(

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

Vertex colour transparency and Beast lightmapping? 3 Answers

Mobile BEAST lightmapping shader/lighting question 0 Answers

How to calculate light from behind a quad? (and other light positions) 1 Answer

Transparent Vertex Shader Error 1 Answer

Beast Lightmapped object can't be lit by realtime lights? 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