Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration of point lighting. Shader allows for up to 8 point lights…
… with different properties, plus ShadedColorMaterial allows for material properties. Normalisation of shader attribute and uniform names. demos directory added to show different features: modify the GLView instantiated inside AppController.
- Loading branch information
1 parent
1099142
commit c74710c
Showing
18 changed files
with
655 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@import <Foundation/CPObject.j> | ||
|
||
@implementation GLLight : CPObject { | ||
Array _position; | ||
|
||
Array _ambientLight; | ||
Array _diffuseLight; | ||
Array _specularLight; | ||
|
||
float _attenuation; | ||
} | ||
|
||
- (id)initWithHexColor:(String)color specularColor:(String)specularColor { | ||
self = [super init]; | ||
|
||
if (self) { | ||
_position = [0, 0, 0]; | ||
_attenuation = 0; | ||
|
||
_ambientLight = hexToRGB(color); | ||
_diffuseLight = [_ambientLight[0], _ambientLight[1], _ambientLight[2], 1.0]; | ||
_specularLight = hexToRGB(specularColor); | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)setPosition:(Array)position { | ||
_position = position; | ||
} | ||
|
||
- (void)setAttenuation:(float)attenuation { | ||
_attenuation = attenuation; | ||
} | ||
|
||
- (Array)position { | ||
return [_position[0], _position[1], _position[2], 1]; | ||
} | ||
|
||
- (Array)ambientLight { | ||
return _ambientLight; | ||
} | ||
|
||
- (Array)diffuseLight { | ||
return _diffuseLight; | ||
} | ||
|
||
- (Array)specularLight { | ||
return _specularLight; | ||
} | ||
|
||
- (float)attenuation { | ||
return _attenuation; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
varying vec4 vColor; | ||
varying vec4 v_color; | ||
|
||
void main(void) { | ||
gl_FragColor = vColor; | ||
gl_FragColor = v_color; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
varying vec2 vTexCoord; | ||
uniform sampler2D sTexture; | ||
varying vec2 v_texCoord; | ||
uniform sampler2D s_texture; | ||
|
||
void main(void) { | ||
gl_FragColor = texture2D(sTexture, vTexCoord); | ||
gl_FragColor = texture2D(s_texture, v_texCoord); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
varying vec4 v_color; | ||
|
||
void main() { | ||
gl_FragColor = v_color; | ||
} | ||
|
||
|
Oops, something went wrong.