prime31 / SpriteLightKit

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

Lights flipped on x axis flipped on Windows #6

Open jamespohalloran opened 7 years ago

jamespohalloran commented 7 years ago

Working fine on Mac build, but for Windows (on a macbook pro), the lights are showing up on the reverse y value based on the center of the screen. (So when the player jumps, the light goes down instead of up).

This old issue seems to accurately describe the problem: https://m.reddit.com/r/Unity2D/comments/4cmr4w/looking_for_anyone_who_has_a_clue_what_might_be/ Although setting the settings to OpenGLCore on Windows is not always an option.

prime31 commented 7 years ago

I don't use DirectX so I cant confirm but this line should take care of flipping the UVs. Unless you are using a different shader in which case you will just need to make sure the UV flip happens to account for DirectX being upside down.

jamespohalloran commented 7 years ago

Ah, ok. The fix for me was to remove that line, and replace it with `#if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1.0f - o.uv.y;

endif`

BUT, that needs to be in the vertex shader, not the fragment shader. This seems to align with Unity's documentation https://docs.unity3d.com/Manual/SL-PlatformDifferences.html