fullbright bug in iminib3d

BlitzMax Forums/MiniB3D Module/fullbright bug in iminib3d

jhocking(Posted 2010) [#1]
My apologies if this is already discussed in other threads, I can't find any mention.

I think there may be a bug with the fullbright setting in iminib3d. I have EntityFX set to 1, but the brightness changes when the camera rotates. Is there a known bug here, or am I just doing something wrong?

The entity of concern is a sprite parented to the camera, other objects aren't changing brightness. And actually now that I think about that, I'm thinking maybe I need to change the sprite's default blend mode or something.

Here's the code setting up my sprites:
//setup the GUI
	for (int i = 0; i < 3; i++) {
		gui[i] = Sprite::CreateSprite(camera);
		gui[i]->PositionEntity(9, i * 5 - 5, 15);
		
		int color = i * 30 + 50;
		gui[i]->EntityColor(color, color, color);
		gui[i]->EntityOrder(-10);		//always on top
		gui[i]->EntityFX(1);				//full-bright		//BRIGHTNESS CHANGES AS CAMERA ROTATES***************
		gui[i]->EntityPickMode(3);
		gui[i]->EntityBox(-1, -1, -.1, 2, 2, .2);
	}



ima747(Posted 2010) [#2]
I was having some lighting issues a while back and my game didn't need much in the way of lighting so I just decided to forgo a light source and use the ambient light setting which looked surprisingly good since my world space was shadowed through textures anyway.

Not really a solution for you I would assume but related and perhaps can help someone.


jhocking(Posted 2010) [#3]
Actually that's a good point, I may just want to crank up the ambient light because all of the lighting is going to be through textures and vertex colors.

Somehow I suspect that if there is a bug with fullbright on sprites then it'll affect them even with the ambient light turned all the way up, but that's something to test.


Warner(Posted 2010) [#4]
I did have some issues with lighting. Can't remember what they were, but I solved it using this line:
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR)'GL_SEPARATE_SPECULAR_COLOR)<--original value set by minib3d
after Graphics3D.
Also, don't use Max2D as it puts this mode back.
For a more permanent solution, I changed this setting in TGlobal and TBlitz2D.


ima747(Posted 2010) [#5]
Were your problems related to a specific graphics card Warner? I think jhocking is referring to iMiniB3D for iPhone OS, rather than minib3d in blitzmax...


jhocking(Posted 2010) [#6]
aha so I just got around to trying a few things with the lights as a test and have discovered more about this bug. First off the problem isn't simply that the brightness changes, but that they are just plain too bright. I didn't notice that before, but when I changed their color to red they ended up looking pink.

Second, the problem affects anything with full-bright, not just sprites. Furthermore, the bug isn't just when setting EntityFX, it's also when I turn up the ambient light all the way. That is, when I set ambient to 255 everything looked like the sprites, too bright.

But here's the really interesting thing; there's only a problem when there's a light in the scene. When I tested turning up ambient light without removing the scene light yet, everything turned bright and washed out but still shaded. When I removed the directional light then everything turned full bright as expected.

So the bug seems to be with lights themselves. Given that things get too bright but still shaded, it looks like the brightness of the directional light is getting added to the object's full brightness, rather than replaced. Now I'm going to test if this is a problem for point lights as well or only directional lights.


@warner: yeah what he said, I'm talking about iminib3d, not minib3d.


jhocking(Posted 2010) [#7]
whoah so um lights in iminib3d are really screwy. As I said at the end of my long post, I tested putting in a point light. Now everything is waaaay too bright; most surfaces are white, the only exceptions are really oblique surfaces that aren't getting much light. Even if the light is too close and I need to reduce the LightRange, full-brightness should be the color of the object, not white.

At any rate, now I'm thinking/hoping there would be a simple fix here where I can go into the iminib3d code and tell the lights not to affect anything with EntityFX 2.


ADDITION: I've commented out these two lines in the middle of Mesh->Render:

float ambient[]={ambient_red,ambient_green,ambient_blue};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambient);

Fullbright is working correctly now, but we'll see what negative repercussions this little edit will have.


ima747(Posted 2010) [#8]
Thanks for all the effort jhocking, when I ran into lighting being odd I just killed all my lights and used ambient (as I stated above) and my next project will actually be doing the same but for different reasons so I'm glad someone is doing some digging, hopefully if simon hasn't got this squashed yet you'll be pointing him in the right direction.

Interestingly I didn't notice any lighting issues that I can recall in the demos, only in my own code... either I'm not remembering correctly or perhaps a look into the demo sources could help (avoiding a pun there was very hard...)


jhocking(Posted 2010) [#9]
just an fyi for anyone stumbling on this thread, simon fixed this bug in iminib3d 0.4