A note about draw layers
Users browsing this thread: 1 Guest(s)

Hey, I attempted to edit the wiki a bit with my findings. It won't let me but I thought to mention them here before I forget to.

^ Layer ^ Description ^
| 00 | Unused |
| 01 | Entirely Solid |
​| 02 | Decals or triangles that draw on top of geometry near the same depth |
| 03 | Unused |
| 04 | Transparent pixels, no semi transparency. Allows perfect layering with other transparencies around it. |
| 05 | Semi transparency enabled. Layering must be handled with the order of drawn faces. |
| 06 | Semi transparency enabled. Layering must be handled with the order of drawn faces. This layer is always drawn behind layer 05, usually for shadows. |

It would seem that the below is true:

**0!=(iLayer&1)** Depth write //[solids 01/semi transparents 05]//

**0!=(iLayer&2)** Polygon offset (glPolygonOffset(-1,-1) or similar) //[decals 02/shadows 06]//

**0!=(iLayer&4)** Alpha blended, Z-sorted //[transparents 04/ semi transparents 05/ shadows 06]//


I've yet to run into a 03 layer in use, but it would likely have a meaning of depth write and polygon offset, as 07 would also likely be depth write, polygon offset and alpha blend. An example of the use of draw layer 02 would be the carpet in front of the castle's front entry.

Also, I'm still looking into command 0x11 but I think it is something along the lines of Start Geo Layout (0x0B) with vector [0x11] [XX] [YY] [ZZ]. The two front doors of castle grounds use this command.

In the attached image, the first picture of the doors displays them with the vector omitted 0x11 offset, second shows with the vector added to translation, third shows the vector negated then added. the image on the bottom shows the door with the vector omitted but with 90 degrees of rotation (which is done at the layout transform). So to me this looks to be some sort of pivot vector that is translated to the transform (second picture) to center the door's rotation on the hinge, some how animation rotation is then applied and then once rotated un-translated.

(Just to clarify, the vector should not be added or subtracted like in the 2nd and 3rd pictures as a 0x10 or 0x13 command would, but it seems likely that it is used for rotation with animation. More importantly though, i should further clarify that this does seem to only run at the start of layout, which is why i think it likely inherits the functionality of 0x0B)
(This post was last modified: 13-10-2017, 08:22 PM by Arbys. Edit Reason: clarification )


Attached Files    

Useful information! I never ran into drawing layer 02, but after a quick search in the ROM, I do see its usage (though rare). I suppose it could help significantly with Z-buffer issues. I went ahead and added it in.
(This post was last modified: 14-10-2017, 02:46 PM by Trenavix.)

(14-10-2017, 02:33 PM)cpuHacka101 Wrote: Useful information! I never ran into drawing layer 02, but after a quick search in the ROM, I do see its usage (though rare). I suppose it could help significantly with Z-buffer issues. I went ahead and added it in.


Yea, as I mentioned I believe that what we know as the draw layer is really just a 3 bit option flag. Shadows are usually on 6, which is 2|4 (polygon offset + alpha blend), semitransparents 5 1|4 (z-write + alpha blend). The lack of 3 being used it probably because the combo of z-write and polygon offset doesn't make much sense, same as 7 which would be z-write, polygon-offset and alpha blend.

If i had to guess, things are drawn in order of 1,2 then transparents (4,5,6) drawn from back to front regardless of layer number (2,5,6) so there would be no fighting when the depth write is on or off. At least thats how you would do it with open gl.

Thanks for adding it to the wiki, If you would also mention the note about layout command 0x11 i think that would be helpful for others too! thanks
(This post was last modified: 15-10-2017, 02:18 AM by Arbys.)

A note about draw layers
Users browsing this thread: 1 Guest(s)