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:
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.
Bu iş için 3 freelancer ortalamada $202 teklif veriyor
What a very easy job for me!!!!!! Dear sir. I can help you. Please check my PM! Thanks.