OpenGL ES 2.0 lights study project

This is a very simple study style project for someone with 3D background. I'm just trying to learn OpenGL ES 2.0 lights and stuck on a problem with lighting correctly models with Phong edge smoothing normals.

Attached is a simple XCode project along with my simple 3d model .obj. This is a standard iOS 'OpenGL Game' template project generated by XCode with the only change I replaced their default cube model mesh data with the one from the included .obj. The other change is I'm rendering the model twice with slight translation on X axis.

The model actually appears to render correctly (see attached screenshot). However, each object instance is lit absolutely identical to the other despite them being offset in the scene. I suppose thats because the example XCode auto-generated vertex shader is not taking vertex position into account, only relying on the directional light vs vertex normal angle to calculate diffusion. The light is not interpolated across the whole scene, every object is just lit in the same way as the other.

This is what the auto-generated template vertex shader looks like:

void main()


vec3 eyeNormal = normalize(normalMatrix * normal);

vec3 lightPosition = vec3(0.0, 0.0, 1.0);

vec4 diffuseColor = vec4(0.4, 0.4, 1.0, 1.0);

float nDotVP = max(0.0, dot(eyeNormal, normalize(lightPosition)));

colorVarying = diffuseColor * nDotVP;

gl_Position = modelViewProjectionMatrix * position;


So this project is for changing the shaders code in such a way that actual vertex position is taken into account when computing per-vertex lighting. Please make sure you understand what I need exactly before you bid on it.

On that screenshot I attached, you can clearly see that the two blocks are lit identically which looks weird. You get a feeling that the second one is brighter while in fact if you check the actual pixel colors the two boxes are lit identicaly.

Instead, I want the light to be interpolated across the whole scene so there is no weird light step between two adjacent blocks as you can see on the screenshot. I believe this method is called Phong shading.


Beceriler: iPhone, Mobile App Development, OpenGL

Daha fazlasını gör: xcode 2.1, x-axis, vertex max, step 3d model, phone 3d model, opengl 3d model, opengl *, object 3d model, object 3d max, obj 3d model, need a 3d model for my game, mobile phone 3d model, mobile 3d model, method models, mesh 3d model, max vertex, learn to 3d model, learn rendering, learn ios, learn 3d rendering, learn 3d max model, dot pixel, blocks for 3d max, axis lighting, auto 3d model

İşveren Hakkında:
( 1 değerlendirme ) Braintree, United Kingdom

Proje NO: #4421424



I am ready for you. Thanks a lot.

%selectedBids___i_period_sub_7% gün içinde 144%project_currencyDetails_sign_sub_9% %project_currencyDetails_code_sub_10%
(8 Değerlendirme)

Bu iş için 3 freelancer ortalamada $202 teklif veriyor


Please check PMB.

in %bids___i_period_sub_35% gün içinde250%project_currencyDetails_sign_sub_37% %project_currencyDetails_code_sub_38%
(6 Değerlendirme)

Please check personal message for details

in %bids___i_period_sub_35% gün içinde242%project_currencyDetails_sign_sub_37% %project_currencyDetails_code_sub_38%
(4 Değerlendirme)

What a very easy job for me!!!!!! Dear sir. I can help you. Please check my PM! Thanks.

in %bids___i_period_sub_35% gün içinde315%project_currencyDetails_sign_sub_37% %project_currencyDetails_code_sub_38%
(6 Değerlendirme)

Fixed already, please check PMB

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% USD
(0 Değerlendirme)