سؤال

أحاول تقديم رباعي مزخرف في D3D ، ولا يستخدم قيم ألفا لقرارات الرباعية التي يتم تقديم الملمس إليها. بل هو يستخدم ألفا من الملمس.

أريد D3D استخدام ألفا من رؤوس المضلع الذي يتم وضعه عليه.

لدي فكرة لها علاقة setTexturestagEstate, ، لكن لا يمكنني العثور عليها بعد ..

هل كانت مفيدة؟

المحلول

حسنًا ، هذا ما حصلت عليه:

D3DTSS التعداد (يحتوي على القيم الافتراضية لإعدادات D3DTSS_*

D3DTA تعداد

// where does the SRC color come from?
// why, the currently bound texture of course!
d3d->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
// Default:  D3DTA_TEXTURE (anyway.  So this setting is redundant.)

التغيير الكبير يأتي بعد ذلك:

// let the alpha component be read from the
// diffuse color of the vertex..
d3d->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
// Default: D3DTA_TEXTURE (which would be "pull alpha from the texture")

// because my vertex declaration is set up to send 1 color, and
// D3DRS_DIFFUSEMATERIALSOURCE is set to D3DMCS_COLOR1, this means
// to use the vertex alpha i specify.  i think.

لا يغير الباقي أي شيء حقًا من القيم الافتراضية ، ولكن هنا يمكن رؤية كل شيء:

// DEST where does the alpha value come from?  also the
// diffuse component
d3d->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
// Default:  D3DTA_CURRENT.  I believe this means "the destination will
// be whatever the existing color in the framebuffer already is"

// setting up as is default, 
d3d->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);
// Default:  D3DTA_CURRENT.  No change.

أعتقد أن هذا يعمل.

كذلك إلى الفهم: هذا الرابط يحتوي على أداة قديمة ولكن أنيق للغاية تسمى MFCTEX:

MFCTex program

لذلك من السهل جدًا رؤية تأثير ما يجري عند استخدام ARGs مختلفة.

أنا أدرك هذا ليس الطريقة الرائعة للقيام بذلك بعد الآن ، وكانت الطريقة الرائعة حقًا لبعض الوقت لكتابة تظليل قمة الرأس والبكسل.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top