zoukankan      html  css  js  c++  java
  • Vertex Shader顶点着色入门

    Vertex Shader是什么?

    顶点着色是一段执行在GPU上的程序(一般用HLSL来编写),用来取代fixed pipeline中的transformation和lighting,Vertex Shader主要操作顶点。当然前提是硬件要支持,软件模拟的不算

    有图则一目了然

    Vertex Shader做了什么工作

    由上图知,Vertex Shader对输入顶点完成了从local space到homogeneous clip space的变换过程,homogeneous clip space即projection space的下一个space。在这其间共有world transformation, view transformation和projection transformation及lighting几个过程。

    优点(与fix pipeline比较)

    由于Vertex Shader是用户自定义程序,所以有很大的灵活性,不必再局限于D3D固定的算法,可以应用许多其他算法,比如可以操作顶点位置模拟衣服效果,操作顶点大小模拟例子系统及顶点混合,变形等,此外,顶点的数据结构也更加灵活。

    如何查看显卡所支持的Vertex Shader版本

    工具法,看这里

    程序法,代码如下

    Code

    或者

    代码
    1 // Check shader version
    2 bool CheckShaderVersion(LPDIRECT3DDEVICE9 g_pd3dDevice)
    3 {
    4 // Get device capabilities
    5 D3DCAPS9 caps ;
    6 g_pd3dDevice->GetDeviceCaps(&caps);
    7
    8 // Make sure vertex shader version greater than 2.0
    9 if (caps.VertexShaderVersion < D3DVS_VERSION(2, 0))
    10 {
    11 returnfalse ;
    12 }
    13
    14 // Make sure pixel shader version greater than 2.0
    15 if (caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
    16 {
    17 returnfalse ;
    18 }
    19
    20 returntrue ;
    21 };
    作者:zdd
    出处:http://www.cnblogs.com/graphics/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
  • 相关阅读:
    POJ
    POJ
    操作系统
    POJ
    POJ
    codeforces Educational Round 89
    codeforces Round 647(div. 2)
    codeforces Educational Round 88
    后缀自动机简单总结
    dsu on tree 简单总结
  • 原文地址:https://www.cnblogs.com/graphics/p/1591683.html
Copyright © 2011-2022 走看看