zoukankan      html  css  js  c++  java
  • dx11 入门 Tutorial 04: DX、HLSL中矩阵的内存存储和数学计算方式 DirectXSampleBrowser(June 2010)

    主要是两方面:

    1.shader数据和dx的通信,使用constant Buffer

    2.矩阵的数学计算方式和内存存储方式再DX和HLSL中的异同

    先说第一个: dx中的常量数据matrix等传入shader中流程:

    The first thing that we need to do is declare three constant buffer variables. Constant buffers are used to store data that the application needs to pass to shaders. Before rendering, the application usually writes important data to constant buffers, and then during rendering the data can be read from within the shaders.           

                      第一步:在shader中 声明constantBuffer变量,constantBuffer存储application中传入shader的数据,在渲染时,shader可以读入这些数据                          

        cbuffer ConstantBuffer : register( b0 )
        {
            matrix World;
            matrix View;
            matrix Projection;
        }

    Before rendering, we copy the values of these matrices to the shader constant buffer.                 

                      第二步:在dx中,使用device创建buffer,这个buffer定义的数据结构和shader内constantBuffer  struct相同         

    	hr = g_pd3dDevice->CreateBuffer( &bd, NULL, &g_pConstantBuffer );
    

                 第三第四步:context来设置、更新constantBuffer,用来每帧更新数据,传入shader中

    笔记二:矩阵数学操作方式、内存存储方式再dx和hlsl中的异同

    疑问来源:because matrices are arranged differently in memory in C++ and HLSL, we must transpose the matrices before updating them.

    需要进行矩阵转置,再copy到shader里,但dx9中,使用constantTable来setMatrix时,并没有转置啊?

    参考:http://www.cnblogs.com/kex1n/archive/2013/10/29/3395023.html

                       

  • 相关阅读:
    SpringBoot到底run了什么
    Activity生命周期
    Activities and Tasks
    Android开发指南中文版(二)Application Fundamentals
    Android开发指南中文版(三)Intents and Intent Filters
    Android开发指南中文版(一)What is Android?
    Activity的启动模式
    skydrive 中 文件夹以zip格式下载,含有中文的文件将会被改名
    装了7个虚拟机
    google reader 居然要关闭了?
  • 原文地址:https://www.cnblogs.com/dust-fly/p/4230881.html
Copyright © 2011-2022 走看看