Skip to main content
This appears to be a purely technical issue unrelated to your game-design.
Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345
Post Closed as "Duplicate" by DMGregory
Source Link

handling obj file without normal

I am trying to build an obj file loader and I have written code to read an obj file with face f with v/vt/vn - vertex, texture coordinate, and normal.

While going through the obj file, there are so many files without normal coordinates.

My shader code in Fragment shader is:

float lambertianFactor = clamp(dot(normal, lightDirectionNormalized), 0.0, 1.0);
vec3 diffuseTextureData = texture(diffuseSampler, v_texCord).rgb;
vec3 effectiveDiffuse = diffuseTextureData*diffuse*lambertianFactor*directionalLight;    
effectiveDiffuse = diffuseTextureData*diffuse*lambertianFactor;

for obj file without normal coordinate but with diffuse texture, how am I supposed to handle diffuse lighting?