3D objects render as flat, no depth/shading at all

I’m having trouble figuring out why some models appear with 3D shading, as expected, and some are flat with no depth. Here’s a minimal example with two models that don’t/do work:

PShape bunny;
PShape ladybug;

void setup() {
    size(800, 800, P3D);
    bunny = loadShape("bunny.obj");
    ladybug = loadShape("ladybug.obj");
}

void draw() {
    background(#FFFFFF);
    lights();    
    shape(bunny, width/2, height/2, 200, 200); // bad, flat
    //shape(ladyBug, width/2, height/2, 200, 200); // good, 3D
}

Here’s the ladybug obj, which renders ok: http://www.cadnav.com/plus/download.php?open=2&id=48686&uhash=575855a99c364c1025fac85f

And here’s the bunny, which is flat: https://graphics.stanford.edu/~mdfisher/Data/Meshes/bunny.obj

I’m not worried about texture or materials, which I know the bunny doesn’t have here. The same thing happens if I add a material in the .obj file. I’m only worried about the 3D shading. I have a number of other objects that have the same problem, some of which have both vertex normals (vn) and texture vertices (vt), which don’t seem to make any difference.

What am I missing?

Here’s the flat bunny result:

1 Like

Hello,

Same result here…

I modified code from here and was able to render it in 3D:
http://www.cutsquash.com/2015/04/better-obj-model-loading-in-processing/

You will have to add lights();

:slight_smile:

1 Like

Thank you, that’s interesting. What did you have to modify in the code from that page? When I copy and paste the createShapeTri() function from there directly, it seems to help somewhat in that the resulting bunny has a different color depending on the angle, but it’s still totally flat for me.

Solved! Doubtless that the other linked method of creating the shapes helped, but the final problem I had to fix was the call to shape(bunny, width/2, height/2, 200, 200);. This only scaled the x and y sizes of the bunny, not z, so it had very little depth. This is better: bunny.scale(200)

4 Likes