GLBasic forum

Main forum => GLBasic - en => Topic started by: Crivens on 2011-Aug-28

Title: iPhone lighting
Post by: Crivens on 2011-Aug-28
Ok so I'm using 3D (Entity system found on forum) in my latest game and so far so good.

I then tried a bit of lightning which worked fine on the PC and on WebOS. I've included images that show no light used, standard light (255,255,255), and blue light (0,0,255). No worries really. Code was pretty much EntityCreateLight(RGB(255,255,255)) (with changes for blue light and not used at all for no light) with a move afterwards although that makes no difference to the problem it seems.

Then I tried on iOS (3GS and 4G Touch). Everything is too bright. And on the blue light is much too blue. If I reduce the brightness (say by lowering the colour from (255,255,255) then it just changes the colour but still looks too bright).

I guess I could muck around with the light settings and get it just so for iPhone (everything looks a little higher contrast even with no light on WebOS for example but it's acceptable compared to the serious brightness of the iPhone) but does anyone know if iDevices need different light settings or another command used to keep it in line?

Attached is white light (255,255,255) of PC and iOS. You can see the PC is fine, but the iPhone is much too bright. Both have used lighting as can be seen by shading on the spheres in the background.

Cheers

[attachment deleted by admin]
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-28
And here is when blue light is used (0,0,255). Again the iPhone has gone a bit nutty on the lighting compared to the PC.

[attachment deleted by admin]
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-28
And here is with no lighting at all.

[attachment deleted by admin]
Title: Re: iPhone lighting
Post by: Dark Schneider on 2011-Aug-29
I remember I used 3D lighting much time ago with bad results too, you only get normal render results when lighting is OFF. It could be because the OpenGL ES that uses Q16 (fixed-point) format and it not receive the values it expects.
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-29
That's a bit of a bummer. For iOS then I may have to muck around with textures to get the same effect on the spheres. Annoying though as you can see the lighting is working on the spheres for iOS it's just too bright and mucking around with lighting colour doesn't seem to help. It changes the colour and that get's a darker shade but still is off with that misty brightness. Annoying.

Also can shaders be used on iOS? I was thinking of altering colours of 3D objects.

Any thoughts Gernot?

Cheers

Title: Re: iPhone lighting
Post by: Kitty Hello on 2011-Aug-29
no shaders. I use OpenGL|ES 1.1
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-29
Fair enough. Any thoughts on the lighting issue? Is about the only thing that I've come across that makes one device different to another. Obviously it does do it though as you can see the shade on the spheres plus the lighting does change colour. Just too bright...

Cheers
Title: Re: iPhone lighting
Post by: mentalthink on 2011-Aug-29
HI Crivens, the light I think are a little poor yet in Glbasic, if you permet a counsil, make a litghmap or complete map in your prefered 3d suite, for me it´s the better, quick and easy solutions for themes about ligths.

Title: Re: iPhone lighting
Post by: Slydog on 2011-Aug-29
Quote from: Kitty Hello on 2011-Aug-29
no shaders. I use OpenGL|ES 1.1

Ha, that explains why my shaders aren't working on my iPhone!
(I've since changed my code to not use shaders, so no problem)

Any plans on upgrading OpenGL ES to 2.x any time soon?
Title: Re: iPhone lighting
Post by: Kitty Hello on 2011-Aug-29
I think it's a lot of work and would break compatibility with the older devices.
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-29
What about the original lighting issue? Is it a bug or something that just doesn't work the same on the iPhone?

Cheers
Title: Re: iPhone lighting
Post by: ampos on 2011-Aug-29
Quote from: Kitty Hello on 2011-Aug-29
I think it's a lot of work and would break compatibility with the older devices.

Perhaps let be GLBasic 10 for old devices, and GLB 11 for new devices (OpenGL 2.x)?

Sometime you have to leave backward compatibility with older devices, or we would be on Win 98 and DirectX 4, just to set an example...

Do the "big" platforms (win, mac, linux, iOs, Android, (webos?)) all of the OpenGL 2.x?

BTW, it is not a thing I care a lot, I am not using any 3D at the moment  :nana:
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-30
So no ideas why the iPhone is so bright when compared to WebOS and Windows? Any ideas then on how to darken it? Using different coloured lighting changes the colour but you still have that too bright look even on a dark colour it seems. But the shadowing is working on the spheres so it's just that annoying brightness...

Cheers
Title: Re: iPhone lighting
Post by: Kitty Hello on 2011-Aug-30
try creating a spot light instead of the ambient one. Maybe.
Try angles 360 and 180, alternatively.
Title: Re: iPhone lighting
Post by: bigsofty on 2011-Aug-30
Try this version, on iPhone only, see if improves anything?



[attachment deleted by admin]
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-30
Ok brilliant, I will try it tonight. Which bits have changed BTW as I modified one or two things to make things easier in my version.

Cheers
Title: Re: iPhone lighting
Post by: Kitty Hello on 2011-Aug-30
http://www.winmerge.org (http://www.winmerge.org)
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-30
Good point considering I've used code merging comparison tools everyday for years at work :-[ Funny how you run on autopilot sometimes, especially the day after a bank holiday.

Cheers
Title: Re: iPhone lighting
Post by: bigsofty on 2011-Aug-30
Well these are the modifications I used to get iVCL running at a descent  speed, also I seem to remember having the same problems with dim lighting, which I 'think' I sorted out. Be warned though, anything that requires 2 render passes has been removed. Oh, and not all the changes have been documented, sorry.
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-30
Ok I will see how it goes. I'm getting more the opposite of "dim" though. It is too bright. Although you can sort of see it that way in that everything his harder to see because of the sort of haze put on things.

2 render passes? Such as? I'm not doing anything amazing BTW. It's mainly cubes and spheres. Utterly brilliant (sort of) in it's simplicity if you ask me. I'm not even texturing the spheres (just modified the createsphere routines to allow a passed in colour) to keep it simple.

Also if you sorted it out before then are you saying that the dimness might be something to do with the entity system (strange as works on PC and WebOS fine) rather than GLB? Would it be an idea, considering how simple my game is, to remove the entity system and use standard GLB? Hmm. Make that a no. I can always use textures to give a nice effect if necessary, although I am quite liking the extra effects (eg. shadows and a sort of police strobe effect I bunged in) through lighting.

Cheers
Title: Re: iPhone lighting
Post by: bigsofty on 2011-Aug-30
Stencil shadows for example are two passes, also anything 2D IIRC has been removed, multiple lights etc...

Well the iVCL apps lighting is fine and it uses the entity system but I had a lot of trouble with the lighting at the beginning. Again, on the PC it was fine, on the iPhone it was dim(and too bright). This is, unfortunately, the only piece of iVCL code that I can publish as the entity system is opensource.
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-30
Fair enough. Hopefully it does the job. If not then not sure what to do. Might be worth mucking around with the colour of the light but doesn't look great so far. Alternatively I may try the spot light suggestion. How do you that with the entity system?

Cheers
Title: Re: iPhone lighting
Post by: Kitty Hello on 2011-Aug-30
entity already uses a spot light.
Try uncommenting the INLINE part, that's dealing with light attentuation.
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-30
Which function is that? Entity_intern_lights? Not sure where I see the comment. Or is it only in the newly posted code (haven't looked at yet)? Out of interest I just noticed that Entity_intern_lights has a @ sign before the function command. What does that mean?

Cheers
Title: Re: iPhone lighting
Post by: Kitty Hello on 2011-Aug-30
@ means it can be hidden from the jump-tree on the right side.
Title: Re: iPhone lighting
Post by: Crivens on 2011-Aug-30
Ah ok. That's a good idea for internal functions and the like. So which function did you mean to uncomment?

Cheers
Title: Re: iPhone lighting
Post by: Kitty Hello on 2011-Aug-30
the inline stuff. There's 3 OPENGL calls.
Title: Re: iPhone lighting
Post by: Crivens on 2011-Sep-02
Hmm, not getting very far with this. I've tried the iOS specific entity system (or least took out this bits that are different and put it into my own modified version) and no joy. Setting the spotlight to 180 does make it darker, but it's darker not dimmer if you know what I mean. If you want the grass to stay really green, for instance, then it doesn't it's really dark green and you still have that kind of bright dimness thing going on that's hard to explain...

I changed the INLINE code to be commented and not. Because it wasn't commented to begin with I assume you meant comment it like this:-
Code (glbasic) Select
IF o.cnst > 0 OR o.linear > 0 OR o.quadratic > 0
INLINE
#ifdef HAVE_OPENGL
    #define GL_LIGHT0 0x4000
    #define GL_CONSTANT_ATTENUATION 0x1207
    #define GL_LINEAR_ATTENUATION             0x1208
    #define GL_QUADRATIC_ATTENUATION          0x1209
    //glLightf(GL_LIGHT0+iLight, GL_CONSTANT_ATTENUATION,  o.cnst);
    //glLightf(GL_LIGHT0+iLight, GL_LINEAR_ATTENUATION, o.linear);
    //glLightf(GL_LIGHT0+iLight, GL_QUADRATIC_ATTENUATION, o.quadratic);
    #else
    // #error no light attentiation
    #endif
ENDINLINE
ENDIF
Doesn't seem to make any difference.

Very confusing. I'm one step away from just leaving lights out on iOS and just using textures to look like smooth spheres, or possibly try different textures for the grass to see if it looks any better with the brightness effect iOS seems to be doing.

Out of interest does anyone have any example code that shows 3D lighting (doesn't have to be the 3Dentity system I guess) that also works fine on iOS without mucking around with the brightness?

Cheers
Title: Re: iPhone lighting
Post by: Ian Price on 2011-Sep-02
The thing is, YOU know the difference between the pc and iOS versions. Would anyone else really notice the difference if they didn't know about it? Is this really that important to the overall enjoyment of the app? Can you not fake it with just a simple screengrab from the pc version?

Sometimes it's impossible to get the desired result exactly as you want it - sometimes it really isn't worth spending valuable time trying to implement a feature that is insignificant? Is this that sometimes?
Title: Re: iPhone lighting
Post by: Crivens on 2011-Sep-03
Possibly. It's just annoying as the lighting is working it just has this stupid brightness to everything. If I change the colours just for iOS then it is better but still not right and everything looks sort of cloudy. Dont get me wrong I can do without the lighting it just looks better with it. Annoying...

Cheers
Title: Re: iPhone lighting
Post by: bigsofty on 2011-Sep-04
I had a tonne of trouble with the entity system lighting on iOS. The spots were created but not affected by the rest of the entity commands. I did finally overcome the wacky lighting but I can't remember the code changes I made specifically, as it's over a year ago and I don't have a dev license to test the code today. I marked some changes in the code but by no means all, I would use my entity version as is, if possible though.

The current entity system needs a mobile branch as it's not tailored for GLES enough to use IMHO.
Title: Re: iPhone lighting
Post by: Kitty Hello on 2011-Sep-05
so, it's ES issue. I made a 3D project with lighting the other day, and it worked very good.
I'll have to investigate why it doesn't work with the ES. Might be some matrix issue. Very strange, because I do all the math in GLBasic and it's the exact same code.
Title: Re: iPhone lighting
Post by: Crivens on 2011-Sep-05
QuoteThe current entity system needs a mobile branch as it's not tailored for GLES enough to use IMHO
Depends which mobile. It looks excellent on my Pre2.

QuoteI'll have to investigate why it doesn't work with the ES
Cool. It would be nice to keep in the shading :)

Cheers