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

**URL:** https://discourse.processing.org/t/3d-objects-render-as-flat-no-depth-shading-at-all/16408
**Category:** Coding Questions
**Created:** [December 15, 2019, 12:08am UTC](https://discourse.processing.org/t/3d-objects-render-as-flat-no-depth-shading-at-all/16408 "2019-12-15T00:08:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![thejoelpatrol](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@thejoelpatrol](https://discourse.processing.org/u/thejoelpatrol)
#### Post date: [December 15, 2019, 12:08am UTC](https://discourse.processing.org/t/3d-objects-render-as-flat-no-depth-shading-at-all/16408/1 "2019-12-15T00:08:25Z")

</div>

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:

```auto
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](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](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:

 ![Screen Shot 2019-12-14 at 19.03.54](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/432c251f96dc88a85302a7fffa12df6656293b3c.jpeg)

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [December 15, 2019, 1:11am UTC](https://discourse.processing.org/t/3d-objects-render-as-flat-no-depth-shading-at-all/16408/2 "2019-12-15T01:11:44Z")

</div>

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/](http://www.cutsquash.com/2015/04/better-obj-model-loading-in-processing/)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c8cfb8971f6c73d9e3c0a188ce62ad91318e5ca4.png)

You will have to add lights();

🙂

---

<div class="post-metadata">

### Author: ![thejoelpatrol](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@thejoelpatrol](https://discourse.processing.org/u/thejoelpatrol)
#### Post date: [December 15, 2019, 1:20am UTC](https://discourse.processing.org/t/3d-objects-render-as-flat-no-depth-shading-at-all/16408/3 "2019-12-15T01:20:33Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![thejoelpatrol](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@thejoelpatrol](https://discourse.processing.org/u/thejoelpatrol)
#### Post date: [December 15, 2019, 1:49am UTC](https://discourse.processing.org/t/3d-objects-render-as-flat-no-depth-shading-at-all/16408/4 "2019-12-15T01:49:34Z")

</div>

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)`
