Cocos3d lighting problem

Posted by Parasithe on Game Development See other posts from Game Development or by Parasithe
Published on 2012-12-17T01:36:41Z Indexed on 2012/12/17 5:14 UTC
Read the original article Hit count: 534

Filed under:
|
|
|
|

I'm currently working on a cocos3d project, but I'm having some trouble with lighting and I have no idea how to solve it. I've tried everything and the lighting is always as bad in the game.

The first picture is from 3ds max (the software we used for 3d) and the second is from my iphone app. http://prntscr.com/ly378

http://prntscr.com/ly2io

As you can see, the lighting is really bad in the app.

I manually add my spots and the ambiant light. Here is all my lighting code :

_spot = [CC3Light lightWithName: @"Spot" withLightIndex: 0];

// Set the ambient scene lighting.
ccColor4F ambientColor = { 0.9, 0.9, 0.9, 1 };
self.ambientLight = ambientColor;
//Positioning

_spot.target = [self getNodeNamed:kCharacterName];
_spot.location = cc3v( 400, 400, -600 );
// Adjust the relative ambient and diffuse lighting of the main light to
// improve realisim, particularly on shadow effects.
_spot.diffuseColor = CCC4FMake(0.8, 0.8, 0.8, 1.0);
_spot.specularColor = CCC4FMake(0, 0, 0, 1);
[_spot setAttenuationCoefficients:CC3AttenuationCoefficientsMake(0, 0, 1)];
// Another mechansim for adjusting shadow intensities is shadowIntensityFactor.
// For better effect, set here to a value less than one to lighten the shadows
// cast by the main light.
_spot.shadowIntensityFactor = 0.75;

[self addChild:_spot];

_spot2 = [CC3Light lightWithName: @"Spot2" withLightIndex: 1];

//Positioning
_spot2.target = [self getNodeNamed:kCharacterName];
_spot2.location = cc3v( -550, 400, -800 );
_spot2.diffuseColor = CCC4FMake(0.8, 0.8, 0.8, 1.0);
_spot2.specularColor = CCC4FMake(0, 0, 0, 1);
[_spot2 setAttenuationCoefficients:CC3AttenuationCoefficientsMake(0, 0, 1)];
_spot2.shadowIntensityFactor = 0.75;

[self addChild:_spot2];

I'd really appreciate if anyone would have some tip on how to fix the lighting. Maybe my spots are bad? maybe it's the material? I really have no idea. Any help would be welcomed.

I already ask some help on cocos2d forums. I had some answers but I need more help.

© Game Development or respective owner

Related posts about 3d

Related posts about iphone