Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> การเขียนโปรแกรม C

A-Buffer Method ใน C/C++


A-Buffer technique ใน computer graphics เป็น hidden face detection mechanism เรียบง่ายสำหรับ medium scale virtual memory computers ยังรู้จักว่า anti-aliased หรือ area-averaged หรือ accumulation buffer เทคนิคนี้ขยาย algorithm ของ depth-buffer (Z Buffer) technique เนื่องจาก depth buffer ใช้ได้กับ opaque objects เท่านั้น ไม่ได้กับ transparent objects A-buffer technique ให้ข้อได้เปรียบในสถานการณ์นี้ แม้ A buffer ต้องการ memory มากกว่า แต่ surface colors ต่างๆ สามารถ compose ได้ถูกต้อง เป็น descendant ของ Z-buffer algorithm แต่ละตำแหน่งใน buffer สามารถ locate หรือ reference linked list ของ surfaces ได้ Key data structure ใน A buffer คือ accumulation buffer

แต่ละตำแหน่งใน A buffer มี 2 fields −

  • Intensity field หรือ Surface data field

  • Depth field

Depth field เก็บ real number บวกหรือลบ Surface data field เก็บ pointer ไป linked list ของ surfaces ที่ contribute ไปยัง pixel position หรือ surface intensity information

ถ้า depth >= 0 ตัวเลขที่เก็บคือ depth ของ single surface overlapping pixel area Field ที่สอง intensity field เก็บ RGB components ของ surface color ที่จุดนั้นและ percent of pixel coverage

ถ้า depth < 0 แสดง multiple-surface contributions to pixel intensity Field ที่สอง intensity field เก็บ pointer ไป linked list ของ surface data

A buffer technique ค่อนข้าง costly กว่า Z-buffer เพราะต้องการ memory มากกว่า ที่นี่ depth และ opacity ใช้กำหนด final color ของ pixel

Surface buffer ใน A buffer method ประกอบด้วย −

  • Surface Identifier

  • Depth

  • Percent of area coverage

  • Opacity Parameter

  • Pointer to the next surface

  • RGB intensity components

ข้อได้เปรียบอีกอย่างของ A buffer technique คือให้ anti-aliasing เพิ่มเติมนอกเหนือจาก Z-buffer