tanema / light_world.lua

A lighting model made for love 2d
https://love2d.org/forums/viewtopic.php?f=5&t=78998
MIT License
222 stars 18 forks source link

Shaders on Android #17

Open sorakun opened 9 years ago

sorakun commented 9 years ago

It seems that shaders are not compatible with GLSL ES, I attempted to run an example on adroid and it was not able to create shaders.

WarpspeedSCP commented 7 years ago

gl es doesn't support implicit type casting between int and float or default uniform values. you need to edit the shaders to remove default values from extern statements, and also to explicitly cast int to float, and vice-versa.

to not break functionality, you should also edit the lua files to send the default values to the shader at the very start, to emulate how default values work in desktop glsl.

TangentFoxy commented 7 years ago

@WarpspeedSCP Can these changes be made on the PC without ill effect as well? Perhaps to fix this, the repo should just have modified shaders to start with.

WarpspeedSCP commented 7 years ago

@Guard13007 I think it would work on desktop as well since the ES version of GLSL is a restricted form of desktop GLSL. I've seen forum posts confirm this as well.

F483 commented 7 years ago

I would really like to use this lib for a cross platform game I'm making, so I placed a 100$ bounty on this issue to help out.

WarpspeedSCP commented 7 years ago

Well, I sort of managed it before, so I guess I'll just try it again and issue a pull request some time?

F483 commented 7 years ago

Sure, as long as the lib works on all platforms (win/mac/linux/android/ios) I'm happy. Would try it myself but haven't got the time, so money is the best help I can offer.

WarpspeedSCP commented 7 years ago

I'll get around to it as soon as possible.

Azorlogh commented 7 years ago

I added a util.loadShader function to load the shaders and send the initial extern values, and fixed the implicit conversions in the shaders : https://github.com/tanema/light_world.lua/pull/31

F483 commented 7 years ago

Would this also fix ios? The bounty and issue are for android, but it would be nice to get two birds with one stone. Sadly I cant test ios myself.

WarpspeedSCP commented 7 years ago

It should. There's nothing platform specific in the way love handles graphics.

Azorlogh commented 7 years ago

So is it good ?

WarpspeedSCP commented 7 years ago

It fixes most of it, but 1 shader(phosphor.glsl) will still stop love. see here

EDIT OK, I tried these changes on my phone (android) and it caused a kernel panic or something (it freezes, then reboots)

Maybe it's just the demo, but something in this code doesn't agree with android (maybe also ios?).

WarpspeedSCP commented 7 years ago

lw.zip Try it (if you dare) rename the .zip to .love. I haven't tested on desktop (though it probably wouldn't cause such problems)

EDIT - Desktop works fine. It's absoutely unusable on android though.

F483 commented 7 years ago

Fantastic! The zip above does work on my android setup. With low performance, but that is another issue.

I do however get the following error when I press the back button on the short example.

screenshot_2017-07-21-15-32-18

Azorlogh commented 7 years ago

Weird! I just tried the phosphor.glsl again, but it works fine on my phone. F483: I'm getting that too, I'll try to see what's going on.

F483 commented 7 years ago

Not all examples work and some crash the app without giving me a useful error. But this is great progress none the less.

Ultimately if I can get a 256x160 @ 60fps game on my phone I would be super happy. It may not work out and I will just have to use a classic tile based fog of war instead of using lighting to show only whats visible, but with the semi working zip above I am now at least hopeful we will get there. :)

WarpspeedSCP commented 7 years ago

@F483 Just curious, but what phone do you have? Which examples are you able to run?

That error with the read only thing happens in all android phones as far as I've seen. Seems to be an implementation issue on love's end.

F483 commented 7 years ago

A very run of the mill Samsung, not the most expensive but it does manage most games well. I figure for a low res pixel art game it should be manageable with some optimization.

First entry is the phone model number.

screenshot_2017-07-21-15-51-23

WarpspeedSCP commented 7 years ago

If you let it idle for a while at the title screen, does anything untoward happen? Which examples crash on your phone? Because it invariably drives my phone nuts and makes it reboot. My phone isn't any pushover either. Very inexplicable.

Azorlogh commented 7 years ago

Okay, I fixed the read-only file issue light_world.zip

Indeed, for me it seems after some time on the menu screen the example just crashes. It does only if I am on the menu screen though, if I select an example and stay it won't crash. Strange.

All the examples seem to work for me, although some take a while to load.

F483 commented 7 years ago

I really have a hard-time pinpointing any errors. Sometimes it crashes straight when opening an example. Other times it works fine. Sometimes even the main screen crashes. Maybe it is time based? Seems very random at least. Will give the new zip a try in a bit, got to go eat.

WarpspeedSCP commented 7 years ago

Seems like my phone is different from the rest, love just won't cooperate. Or not. With issues like this, maybe you should consider a different library to use for your game.

F483 commented 7 years ago

Can confirm the read only error is fixed. Still not sure about the crashes, they seem to be random and I have a hard time pinpointing it or getting any error.

Have you tried running it in the emulator? Can you get a console log from the emulator that is useful? Will setup the emulator over the weekend to see if I can get anything.

TangentFoxy commented 7 years ago

In reference to the error about the read-only FS, can someone confirm that it was an error in the permissions for the app or something else? (That was my first assumption but I want to know if that was it or not in preparation for the possibility of encountering a similar error myself later on.)

F483 commented 7 years ago

I can confirm that the fix by @SpaVec worked in regards to the read-only FS issue, it still does crash after some time.

TangentFoxy commented 7 years ago

@SpaVec What did you do that fixed the read-only FS issue?

Azorlogh commented 7 years ago

@Guard13007 I just used love.filesystem.write instead of the lua function, so that it tries to write to the LÖVE save folder instead of some place it doesn't have access

F483 commented 6 years ago

Any update on the status of the issue? Would love to use this for an android/ios game.

overjarko commented 6 years ago

Are you still searching? What do you need in the light engine(bodys -> raycasting, which effects(just lights or also water, blur etc.))?