2017-04-26 64 views
0

即時繪製一個2d線如何添加輝光效果?directx11添加輝光繪製2d

auto renderer::draw_line(point<float> const& start_point, point<float> const& end_point, float const stroke_width, color const& stroke_color) -> void { 

    brush->SetColor(D2D1::ColorF(stroke_color.r, stroke_color.g, stroke_color.b, stroke_color.a)); 

    device_context_d2d1->DrawLine(
     D2D1::Point2F(start_point.x + offsetX, start_point.y + offsetY), 
     D2D1::Point2F(end_point.x + offsetX, end_point.y + offsetY), 
     brush.get(), stroke_width 
    ); 

} 

我覺得它有什麼待辦事項使用此功能

ID2D1Effect* shadowEffect; 
device_context_d2d1->CreateEffect(CLSID_D2D1Shadow, &shadowEffect); 

回答

0

您可以申請Gaussian blur effect(即實際上是在陰影效果使用),然後(可選)apply Brightness effect到模糊的圖像,然後最後得出模糊圖像在原始線圖像的頂部。

blurred line

+0

不是100%確定你的意思。不會只是模糊我的路線,沒有更多? – vusuzireru

+0

是的,但這就是所有這些發光效果的典型工作方式,拍攝圖像的「發光」部分(在這種情況下爲線條),將其模糊並在原始圖像的頂部繪製(可能調整後的亮度)。如果將模糊的圖像顏色變成黑色,並在其上繪製原始圖像,則會產生陰影效果。 – VTT

+0

感謝您的信息,即時通訊有點困惑如何應用模糊線,因爲'SetInput'需要一個圖像?我怎麼會只模糊一邊是否有某種地區的函數在directx11? – vusuzireru