• Cg:访问OpenGL的状态


    From http://stackoverflow.com/questions/14358/accessing-opengl-state-variables-in-cg

    If you are on any fairly recent Cg profile (arbvp1 and later), your Cg shader programs can in fact access the OpenGL state (MVP matrices, material and light settings) directly. This makes writing those programs less painful.

    Here are some of the state variables which can be accessed:

    MVP matrices of all types:

    state.matrix.mvp
    state.matrix.inverse.mvp
    state.matrix.modelview
    state.matrix.inverse.modelview
    state.matrix.modelview.invtrans
    state.matrix.projection
    state.matrix.inverse.projection
    Light and material properties:

    state.material.ambient
    state.material.diffuse
    state.material.specular
    state.light[0].ambient
    For the full list of state variables, refer to the section Accessing OpenGL State, OpenGL ARB Vertex Program Profile (arbvp1) in the Cg Users Manual[P.256 Accessing OpenGL State].

    Note:

    All the OpenGL state variables are of uniform type when accessed in Cg.
    For light variables, the index is mandatory. (Eg: 1 in state.light[1].ambient)
    Lighting or light(s) need not be enabled to use those corresponding light values inside Cg. But, they need to be set using glLight() functions.

    From http://developer.nvidia.com/forums/index.php?showtopic=2146&hl=ModelViewProjection

    Wow, what a waste of time on my part.
    ModelViewProjection really isn't a semantic, it's an alias! How damn sneaky!
    I found out that in the C++ code, they do a lookup for ModelViewProjection and set the model view projection manually, just like a regular uniform. To get what I actually wanted, I had to use the "state.matrix.mvp" semantic.
    Why this was so hard to figure out, I'll never know. Maybe bad documentation.

    From http://www.gamedev.net/community/forums/topic.asp?topic_id=480004

    These params always should be uniform:
    uniform float4x4 ModelViewProj : state.matrix.mvp
    You don't need to use cgGLSetStateMatrixParameter if you use ARB-based profile (arbvp1, vp40, etc.)

  • 相关阅读:
    操作系统与进程.md
    解决粘包现象
    Python3网络爬虫开发实战
    Django学习目录
    前端学习目录
    MySQL数据库学习目录
    第一章 开发环境配置
    15.3 Scrapyd 对接 Docker
    13.4 Spider 的用法
    9.1 代理的设置
  • 原文地址:https://www.cnblogs.com/lilei9110/p/1888558.html
Copyright © 2020-2023  润新知