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
2
Question by Dave 5 · Sep 09, 2010 at 05:14 PM · shaderlightingcell

Cell-based Lighting?

Say I wanted to have a 3D grid of cells where each cell is affected by only its content and its immediate neighbors. In such a scenario, the light in one cell causes each of it's neighbors to have a slightly lesser light value in a neighboring cell. For instance, imagine this is a 2D map of one layer of the game world:

+---+---+---+---+---+---+
| 0 | 0 | 1 | 0 | 0 | 0 |
+---+---+---+---+---+---+
| 0 | 1 | 2 | 1 | 0 | 0 |
+---+---+---+---+---+---+
| 1 | 2 | 3 | 2 | 1 | 0 |
+---+---+---+---+---+---+
| 0 | 1 | 2 | 1 | 0 | 0 |
+---+---+---+---+---+---+
| 0 | 0 | 1 | 0 | 0 | 0 |
+---+---+---+---+---+---+
| 0 | 0 | 0 | 0 | 0 | 0 |
+---+---+---+---+---+---+

The cell with the "3" contains a light of intensity 3. This causes the surrounding cells to have a light of intensity 2, and the cells surrounding that intensity 1, etc. The 0's should be completely dark (black color for the material). Within a cell, the lighting should be constant, and in fact can be as simple as adjusting the color brightness for any textures that touch that cell. For example, you could imagine in the map above that each cell has a square floor. Each floor square would have a texture multiplied by the light intensity for that cell. If there is any obstruction (wall, block, etc.), it would prevent the light propagation to that cell.

Any idea how to get something like this working? Can it be done in shaders alone, or will each light level need its own submesh?

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

2 Replies

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

Answer by Eric5h5 · Sep 09, 2010 at 09:40 PM

I did something like this for Realmaze3D. The lighting is calculated for each cell, and stored in the vertex colors for the meshes. I used this shader for most of the objects, but if you want real-time lighting on top of that, you'd need a different shader that includes lighting. Using this method, the cell lighting can be updated by recomputing the lighting and updating the vertex colors for the meshes.

Edit: oops, slightly too late. ;)

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
2

Answer by Dave 5 · Sep 09, 2010 at 09:39 PM

Well I was overthinking this one. All that I needed to do was set the proper vertex colors for each cell and it works. Voila. :)

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

No one has followed this question yet.

Related Questions

Diffuse 2-sided shader only accepts light on one side? 2 Answers

Customize Standard Shader Light Rig - Help 1 Answer

Trying to create 2D pixel art lighting 1 Answer

2D Sprite Shader Acting like Light 0 Answers

Custom shader behaves differently on WebGL deployment (correct) and editor view (incorrect) 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