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

                       

  • 相关阅读:
    软件设计7个原则
    vue.js 样式绑定 font-size 问题
    实例理解scala 隐式转换(隐式值,隐式方法,隐式类)
    著名端口整理(常用服务的默认端总结)
    .NET Core Web API 实现大文件分片上传
    ngnix反向代理tomcat,ssl证书配置及自定义错误页面
    微信登录闪退
    gradle如何配置阿里云的中央仓库
    HashMap底层实现和原理
    关于Java中String类的hashCode方法
  • 原文地址:https://www.cnblogs.com/dust-fly/p/4230881.html
Copyright © 2011-2022 走看看