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 treehuggernicky · Apr 10, 2017 at 12:43 PM · gameobjectlightingrangegroupintensity

Merging Lights

Consider I have two point light's of the same type which have their own atrributes i.e. intensity, colour, range etc... At the moment I am using public float getArea(Light l){return l.intensity* l.range} as the weights for the lights.

Therefore, a single light to approximate the two would look something like:

 Light light1Comp = light1.GetComponent<Light>();
 Light light2Comp = light2.GetComponent<Light>();
 float light1Area =getArea(light1Comp );
 float light2Area = getArea(light2Comp );
 float totalArea= light1Area +light2Area;
 
 GameObject lightGameObject = new GameObject();
 lightGameObject.transform.position= (light1.transform.position *light1Area+light2.transform.position * light2Area)/totalArea;
 Light lightComp = lightGameObject.AddComponent<Light>();
 float combinedIntensity = light1Comp.intensity + light2Comp.intensity;
 lightComp.colour = (((light1Comp.colour * light1Area) + (light2Comp.colour * light2Area)) / totalArea);
 lightComp.intensity =combinedIntensity ;
 lightComp.range = totalArea / combinedIntensity;

It seems like this approximation is not so good though, am I missing something? are intensities non-linear?

here are some images to show what is happening

This image uses unmerged lights alt text

This image uses merged lights alt text

rsz-1capture.png (162.2 kB)
rsz-capture2.png (170.1 kB)
Comment
Add comment · Show 4
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 Oliver-Bogdan · Apr 10, 2017 at 01:22 PM 0
Share

$$anonymous$$aybe this can help you:

https://docs.unity3d.com/$$anonymous$$anual/LinearRendering-LinearOrGammaWorkflow.html https://unity3d.com/learn/tutorials/topics/graphics/choosing-color-space?playlist=17102

Also if you are using Forward Rendering one light can look differently from two lights if you have only one light in Pixel Light Count (The maximum number of pixel lights when Forward Rendering is used)

You can check the Pixel Light Count here: https://docs.unity3d.com/$$anonymous$$anual/class-QualitySettings.html

You should also read about Forward Rendering and how Pixel Light Count Lights affects the color here: https://docs.unity3d.com/$$anonymous$$anual/RenderTech-ForwardRendering.html

Hope it helps

avatar image treehuggernicky Oliver-Bogdan · Apr 10, 2017 at 02:49 PM 0
Share

I am actually using deferred rendering, but I had already increased the light count in the Graphics settings. I am using Gamma blending but in reality all light sources have the same colour at the moment.

avatar image hexagonius · Apr 11, 2017 at 08:46 PM 0
Share

I'm pretty sure they're not linear

avatar image treehuggernicky hexagonius · Apr 11, 2017 at 10:32 PM 0
Share

so how would one go about it?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by FortisVenaliter · Apr 11, 2017 at 08:54 PM

From the documentation:

The intensity diminishes with distance from the light, reaching zero at a specified range. Light intensity is inversely proportional to the square of the distance from the source. This is known as ‘inverse square law’ and is similar to how light behaves in the real world.

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 treehuggernicky · Apr 11, 2017 at 10:34 PM 0
Share

So how would one go about merging two lights?

avatar image
0

Answer by treehuggernicky · Apr 12, 2017 at 07:42 PM

What really helped me was checking the camera HDR option.

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

6 People are following this question.

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

Related Questions

How to make a GameObject not hittable by shadows ? 2 Answers

The "intensity multiplier" of "environment reflections" does not do anything 1 Answer

Shader: Changing a Ramp Size 1 Answer

Accessing light's range value within a fragment shader? 0 Answers

GameObject with a lot of Layer 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