SpriteLightKit icon indicating copy to clipboard operation
SpriteLightKit copied to clipboard

Build not working for Mac

Open tidyui opened this issue 9 years ago • 14 comments

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 avatar Mar 09 '16 11:03 tidyui

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 avatar Mar 09 '16 12:03 tidyui

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

tidyui avatar Mar 10 '16 09:03 tidyui

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 [email protected] wrote:

MultiplicativeFactor

prime31 avatar Mar 10 '16 15:03 prime31

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 avatar Mar 10 '16 15:03 tidyui

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.

tidyui avatar Mar 11 '16 15:03 tidyui

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 [email protected] 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.

prime31 avatar Mar 11 '16 16:03 prime31

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

tidyui avatar Mar 11 '16 17:03 tidyui

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...

prime31 avatar Mar 11 '16 20:03 prime31

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!

tidyui avatar Mar 13 '16 09:03 tidyui

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.

prime31 avatar Mar 13 '16 14:03 prime31

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!

tidyui avatar Mar 16 '16 13:03 tidyui

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.

prime31 avatar Mar 16 '16 16:03 prime31

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.

slonermike avatar Jul 28 '16 17:07 slonermike

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.

prime31 avatar Jul 28 '16 17:07 prime31