prime31 / SpriteLightKit

Blended lighting system for Unity that works with standard Sprites
241 stars 43 forks source link

Build not working for Mac #5

Open tidyui opened 8 years ago

tidyui commented 8 years ago

I forked the repo & included the latest version in my project. Everything runs fine on my Macbook Pro when starting it from the Unity Editor, however when I build it for Mac & run it the blending does not work properly and produces the following result in windowed mode:

skarmavbild 2016-03-09 kl 12 24 27 Screenshot taken from the SpriteLightKitDemo/SpriteLightKitScene

In full screen mode it works even less. I have confirmed that the windows build is working properly though.

I'll try to see if I can find out what's causing the problem, however if you have any ideas it would be appriciated as I like the core concept & implementation of it!

Regards

tidyui commented 8 years ago

Ok, so half way there. I noticed that disabling anti-aliasing in quality settings makes it run properly in windowed mode. However fullscreen is still pitch black.

tidyui commented 8 years ago

Also when building a Debug build and running in fullscreen I get an Debug.LogError that "A render texture attached to a camera has been released". I'm guessing the screen goes black as the light texture in SpriteLightKit-BlendImageEffect.shader returns 0 causing the following calculation to return zero.

return _MultiplicativeFactor * main * lights;

Again, I haven't managed to find out why it's happening

prime31 commented 8 years ago

Are you setting the MultiplicativeFactor to 0 for some reason? It should be greater than 0 and less than ~2 to function correctly.

On Mar 10, 2016, at 1:35 AM, Håkan Edling notifications@github.com wrote:

MultiplicativeFactor

tidyui commented 8 years ago

At this point I've kept it at the default value of 1. I'm gonna add some more debug printouts from the shader and I'll get back to you with the results.

tidyui commented 8 years ago

Not getting any smarter at this point. Still getting this error printout in full screen mode:

skarmavbild 2016-03-11 kl 15 59 25

I added some additional debug printouts to see what's happening and noticed that the rendertexture is actually created twice during init. When moving the startup code from OnEnabled to Start it was only executed once, but the problem remained in full screen however.

prime31 commented 8 years ago

That is very odd indeed. I have 2 Macs here and it works on both of them without issue.

Mike

On Mar 11, 2016, at 7:04 AM, Håkan Edling notifications@github.com wrote:

Not getting any smarter at this point. Still getting this error printout in full screen mode:

I added some additional debug printouts to see what's happening and noticed that the rendertexture is actually created twice during init. When moving the startup code from OnEnabled to Start it was only executed once, but the problem remained in full screen however.

— Reply to this email directly or view it on GitHub.

tidyui commented 8 years ago

Weird, could you share a build somehow just to check if the error is related to my unity build?

prime31 commented 8 years ago

Ha. I just updated to the latest Unity build and I am seeing the same thing but only on Mac. Looks like its time to open yet another bug report with Unity. Looks like there is some kind of render texture corruption going on. These releases are becoming like mine fields lately...

tidyui commented 8 years ago

Well the it's just not me :) let know if you get any response from unity, I'll use the code as is at the moment!

prime31 commented 8 years ago

Apparently OpenGL Core is buggy as all hell right now. I'm hearing people having issues with all kinds of stuff. Word on the street is the latest patch release fixed some of the issues but I don't install those dang patches. Too buggy for me.

tidyui commented 8 years ago

Ok, so I got it working on the latest version of Unity by pulling the code out and reworking it a bit. There are some tweaks to it.

  1. When running full screen on Mac the render texture is for some reason destroyed. I'm pretty sure your code picks this up and re-creates it, but for some reason it seems like the shader material is using the old discarded render texture. I solved this by only having one script attached to the main camera that handled both the Light Source camera, and the main camera with the shader.
  2. In the current Unity version there are some inconsistencies for platforms. On windows the shader only works with anti-aliasing enabled, on mac it only works without it. I had to fix this by changing the quality settings at startup depending on application platform.

If you want I can try to pull my more generic changes out and try to incorporate them into your code and send you a pull request, otherwise I'm pretty sure you can get it working with the above information :)

Thanks again for you time & ideas on the issue!

prime31 commented 8 years ago

I'm currently waiting on Unitys GL Core fixes. I'm afraid to touch anything RenderTexture related since it seems that there are lots of related bugs at the moment.

slonermike commented 8 years ago

Any news on this? I haven't pulled since February-ish, but was curious if a resolution was found. I was also able to repro this on my Mac.

prime31 commented 8 years ago

Everything seems to be working with Unity 5.4 since Unity got the GL fixes in. I tested on 3 Macs and they all seem to work with anti aliasing on or off through window resizes and full screen/windowed mode switches.