【问题标题】:how to achieve split screen effect in directx11directx11如何实现分屏效果
【发布时间】:2020-11-14 06:03:53
【问题描述】:

嘿,我正在使用 Directx11 中的 msaa,这很容易实现。

但现在尝试制作分屏,例如,屏幕左侧没有 MSAA 渲染,右侧有 MSAA,所以我可以看到两者之间的差异。

对于我的想法,我认为,我必须创建两个不同的交换链和不同的场景,并并排一起渲染,因为我们可以在创建交换链时设置 msaa 计数。 我的意见是不是太多了? 在directx11中是否有任何标准或通用(?!)方式来实现这种效果? 只是一些想法将不胜感激!

【问题讨论】:

    标签: split screen directx-11 antialiasing msaa


    【解决方案1】:

    您可以设置2个不同的视口,例如:

    //You can adjust these numbers as you like
    //Left viewport
    D3D11_VIEWPORT left_vp;
    left_vp.Width = screen_width / 2;
    left_vp.Height = screen_height / 2;
    left_vp.MinDepth = 0;
    left_vp.MaxDepth = 1;
    left_vp.TopLeftX = 0;
    left_vp.TopLeftY = 0;
    device_context->RSSetViewports(1u, &left_vp);
    
    device_context->Draw(3, 0);
    
    //Right viewport
    D3D11_VIEWPORT right_vp;
    vp.Width = screen_width / 2;
    vp.Height = screen_height / 2;
    vp.MinDepth = 0;
    vp.MaxDepth = 1;
    vp.TopLeftX = screen_width / 2;
    vp.TopLeftY = screen_height / 2;
    device_context->RSSetViewports(1u, &right_vp);
    
    device_context->Draw(3, 0);
    

    虽然你每帧有 2 个绘图调用,但这可能没问题

    阅读本文了解更多信息:

    Getting Started with the Rasterizer Stage

    【讨论】:

    • 感谢您的回复。但不幸的是,我想为每个应用不同的 msaa 设置,只能在创建交换链时设置。按照您的方式,每个屏幕必须具有相同的 msaa
    猜你喜欢
    • 2019-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多