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 piter909 · Feb 22, 2019 at 02:52 PM · c#shaderlightingmaterial

How to create light like in minecraft?

How to create light like in Minecraft in unity3d where quads are fully and evenly lightened from corner to corner?
It may be simple but I am trying to find my answer up from hours. I found only descriptions how it works or how to create in own game engine.
Thanks for any help.

Comment
Add comment · Show 8
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 RobAnthem · Feb 22, 2019 at 03:20 PM 2
Share

I believe it isn't a normal type of lighting, it's a type of vertex lighting because of how $$anonymous$$ecraft terrain works. I think it would be easier to replicate with a marching cubes terrain system, because at that point you're only applying lighting to a single section of a localized mesh. Sorry if this doesn't help, but what you want is rather complicated. A useful quoute from Stackoverflow

Voxel based lighting is generally performed using a flood-fill algorithm. $$anonymous$$any implementations are recursive, but you can get an increase in execution speed by using a queue or stack to process the flood-fill in one method call ins$$anonymous$$d.

However it is worth nothing that if you user a Pixel light and set it's rendering importance to "not important" it will switch to a Vertex lighting method, which may be more of what you're looking for.

avatar image piter909 RobAnthem · Feb 22, 2019 at 05:39 PM 0
Share

Yes, it is not normal lighting. Also, I actualy have combined meshes of all quads into one chunk that is single game object for better optimalization so material is applied to all quads in one chunk. I have an idea to create shader that will have in input 2 variables: 1. vec4 array that will be collection of coordinates xyz and block face id (1-6), 2. float array that will be collection of light power. I am newbie in creating shaders and I need help. Is it possible to use arrays in shaders as input? How to change then pixels in small part of chunk that is block face on xyz using shader? I think I have to go this way. If it is not nessesary, can you please help me finding better and easier way to make lighting like this? Thank you very much for helping.

avatar image Ymrasu piter909 · Feb 22, 2019 at 06:06 PM 0
Share

You might not need to make a custom shader. mesh.colors and mesh.colors32 are arrays that match your mesh.vertices. So you'll just need to apply a flood-fill algorithm as Rob suggested to get your light values. Some tips for your light values is that only transparent and light emitting blocks have a light value (since light can't go through solid blocks) then have your solid blocks pick the neighbor with the highest lightValue - 1, and apply that to your mesh.colors.


You would have your light values in a separate data structure that matches your blocks (like light$$anonymous$$ap[x][y][z]) and preform the flood fill on that. Then afterward when you are building your vertices you can double up with colors for your mesh.colors.

Show more comments
avatar image piter909 RobAnthem · Feb 22, 2019 at 05:40 PM 0
Share

I have found video on youtube where someone created exactly that lighting type what I want. https://www.youtube.com/watch?v=tmn-sa5x46s

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by JxWolfe · Feb 22, 2019 at 08:27 PM

ok, if you want you objects to be fully lit from any angle, you are going to want to set your texture to 'unlit'. Then lights will not effect the color. Hope that helps

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

195 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Image Effect lighting 0 Answers

Light based texture change on material 0 Answers

How to change RGB base of material via scripting (Normal map + base RGB) ? 1 Answer

Shaders in Project Aren't Transferring Over to .EXE 1 Answer

Distribute terrain in zones 3 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