Direct3D (DirectX 9.0) Code Samples&nbsp














Direct3D (DirectX 9.0) Code Samples 的图1 Direct3D (DirectX 9.0) Code Samples 的图2 Direct3D (DirectX 9.0) Code Samples 的图3
Direct3D (DirectX 9.0) Code Samples 的图4





Simple Vertex Shader (Cg)

Demonstrates how to write a simple vertex shader, or vertex program using Cg. Check out the OpenGL source code page for the OpenGL equivalent of this sample.


Relevant Keywords: CGcontext, CGprogram, CGparameter, cgCreateContext, cgD3D9GetLatestVertexProfile, cgCreateProgramFromFile, cgD3D9ValidateVertexDeclaration, cgD3D9LoadProgram, cgGetNamedParameter, cgGetParameterType, cgD3D9TypeToSize, cgD3D9SetDevice, cgDestroyProgram, cgDestroyContext, cgD3D9SetUniformMatrix, cgD3D9SetUniform, cgD3D9BindProgram, CreateVertexDeclaration, LPDIRECT3DVERTEXDECLARATION9, LPDIRECT3DVERTEXDECLARATION9, POSITION, COLOR0, uniform, float4x4, float4, mul, and return.


Direct3D (DirectX 9.0) Code Samples 的图5


Direct3D (DirectX 9.0) Code Samples 的图7
Direct3D (DirectX 9.0) Code Samples 的图8 Direct3D (DirectX 9.0) Code Samples 的图9 Direct3D (DirectX 9.0) Code Samples 的图10
















Direct3D (DirectX 9.0) Code Samples 的图11 Direct3D (DirectX 9.0) Code Samples 的图12 Direct3D (DirectX 9.0) Code Samples 的图13
Direct3D (DirectX 9.0) Code Samples 的图14





Simple Vertex & Pixel Shader (Cg)

Demonstrates how to write both a simple vertex and pixel shader using Cg. The two shaders have matching connectors and can be used simultaneously on the same piece of geometry. The shaders in this sample don't really do anything useful or neat, it's meant to be used as a framework or starting place for experimenting with shaders. Check out the OpenGL source code page for the OpenGL equivalent of this sample.


Relevant Keywords: cgD3D9GetLatestPixelProfile, cgD3D9GetOptimalOptions, cgD3D9SetTextureWrapMode, cgD3D9SetSamplerState, cgD3D9BindProgram, D3DXMatrixTranspose, D3DXMatrixRotationYawPitchRoll, D3DVERTEXELEMENT9, D3DDECLTYPE_FLOAT3, D3DDECLUSAGE_POSITION, D3DDECLTYPE_D3DCOLOR, D3DDECLUSAGE_COLOR, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, D3DSAMP_ADDRESSUD3DSAMP_ADDRESSV, D3DTADDRESS_WRAP, D3DTEXF_POINT, D3DTEXF_NONE, D3DSAMP_MINFILTER, D3DSAMP_MAGFILTER, D3DSAMP_MIPFILTER, float2, float3, float4, uniform, float4x4, sampler2D, and tex2D.


Direct3D (DirectX 9.0) Code Samples 的图15


Direct3D (DirectX 9.0) Code Samples 的图17
Direct3D (DirectX 9.0) Code Samples 的图18 Direct3D (DirectX 9.0) Code Samples 的图19 Direct3D (DirectX 9.0) Code Samples 的图20
















Direct3D (DirectX 9.0) Code Samples 的图21 Direct3D (DirectX 9.0) Code Samples 的图22 Direct3D (DirectX 9.0) Code Samples 的图23
Direct3D (DirectX 9.0) Code Samples 的图24





Lighting Shader (Cg)

Demonstrates how to write a vertex shader using Cg, which calculates simple diffuse lighting for a single light source. Check out the OpenGL source code page for the OpenGL equivalent of this sample.


Relevant Keywords: cgD3D9SetUniformMatrix, cgD3D9SetUniform, SetLight, SetRenderState, LightEnable, SetMaterial, D3DLIGHT9, D3DMATERIAL9, D3DRS_LIGHTING, LPDIRECT3DVERTEXDECLARATION9, POSITION, NORMAL, COLOR0, float4, float4x4, uniform, mul, normalize, dot, and pow.


Direct3D (DirectX 9.0) Code Samples 的图25


Direct3D (DirectX 9.0) Code Samples 的图27
Direct3D (DirectX 9.0) Code Samples 的图28 Direct3D (DirectX 9.0) Code Samples 的图29 Direct3D (DirectX 9.0) Code Samples 的图30
















Direct3D (DirectX 9.0) Code Samples 的图31 Direct3D (DirectX 9.0) Code Samples 的图32 Direct3D (DirectX 9.0) Code Samples 的图33
Direct3D (DirectX 9.0) Code Samples 的图34





Anisotropic Lighting Shader (Cg)

Demonstrates how to write a vertex shader using Cg, which calculates Anisotropic Lighting for a single light source. The shader uses a texture as a look-up table for the correct Anisotropic Lighting values by storing the pre-calculated diffuse values in the texture's RGB components and specular values in its alpha component. This style of lighting is very useful for rendering surfaces like brushed steel where the surface is composed of micro facets or microscopic scratches that tend to lay parallel or run in the same direction. Check out the OpenGL source code page for the OpenGL equivalent of this sample.


Relevant Keywords: D3DXLoadMeshFromX, GetVertexBuffer, GetIndexBuffer, CloneMeshFVF, Optimize, GetAttributeTable, LPDIRECT3DVERTEXDECLARATION9, LPDIRECT3DINDEXBUFFER9, D3DXATTRIBUTERANGE, D3DXMESH_SYSTEMMEM, D3DXMESHOPT_ATTRSORT, D3DXMESH_WRITEONLY, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR, D3DTOP_MODULATE4X, D3DTA_ALPHAREPLICATE, D3DTSS_COLOROP, D3DTSS_COLORARG1, D3DTSS_COLORARG2, D3DTA_TEXTURE, POSITION, NORMAL, TEXCOORD0, float3x3, float3x4, normalize, mul, and max.


Direct3D (DirectX 9.0) Code Samples 的图35


Direct3D (DirectX 9.0) Code Samples 的图38
Direct3D (DirectX 9.0) Code Samples 的图39 Direct3D (DirectX 9.0) Code Samples 的图40 Direct3D (DirectX 9.0) Code Samples 的图41
















Direct3D (DirectX 9.0) Code Samples 的图42 Direct3D (DirectX 9.0) Code Samples 的图43 Direct3D (DirectX 9.0) Code Samples 的图44
Direct3D (DirectX 9.0) Code Samples 的图45





Vertex Displacement or Mesh Deformation Shader (Cg)

Demonstrates how to performs vertex displacement on a simple mesh to create a flag waving animation. Check out the OpenGL source code page for the OpenGL equivalent of this sample.


Relevant Keywords: CGcontext, CGprogram, CGparameter, cgCreateContext, cgD3D9GetLatestVertexProfile, cgCreateProgramFromFile, cgD3D9ValidateVertexDeclaration, cgD3D9LoadProgram, cgGetNamedParameter, cgGetParameterType, cgD3D9TypeToSize, cgD3D9SetDevice, cgDestroyProgram, cgDestroyContext, cgD3D9SetUniformMatrix, cgD3D9SetUniform, cgD3D9BindProgram, CreateVertexDeclaration, SetRenderState, D3DRS_FILLMODE, D3DFILL_WIREFRAME, D3DFILL_SOLID, LPDIRECT3DVERTEXDECLARATION9, LPDIRECT3DVERTEXDECLARATION9, POSITION, COLOR0, uniform, float4x4, float4, mul, sin, and return.


Direct3D (DirectX 9.0) Code Samples 的图46


Direct3D (DirectX 9.0) Code Samples 的图48
Direct3D (DirectX 9.0) Code Samples 的图49 Direct3D (DirectX 9.0) Code Samples 的图50 Direct3D (DirectX 9.0) Code Samples 的图51
登录后免费查看全文
立即登录
App下载
技术邻APP
工程师必备
  • 项目客服
  • 培训客服
  • 平台客服

TOP

1