D3D Vertex Shader & Pixel Shader
2012-08-24 08:34
375 查看
The demo how to use D3D vertex shader and pixel shaders. The difference between GPU API rendering and shaders one is not so hurge. While using shaders, you need to create vertex declaration instead FVF(flexible Vertex format). And before call DrawIndexedPrimitives, set the vertex shader & pixel shader to GPU. Those shaders are just very short lines of code that could be run on the GPU.
With D3D, we could privide shader source code directly, and D3D API will compile those shaders at running time. Those shader are text, C-like code. So you could provide D3D with text file or a string hold the whole content of the shader code that could be hard coded in the project. A better way to using shader code is compile shader source code into byte code(Precompiled offline), that will save us a bit time cause we do not to compile it any more.
Here some bugs that need to be mentioned here when I write this demo. 1) The correct way to use mul is mul(vector, matrix). If you write like mul(matrix, vector), there was no errors or warning reported during compiling process, but obviously the result is not correct. 2) About CULL_MODE ! What I get from this demo it seems like that: D3DCULL_CCW means you should provide the D3D with counterclockwise vertices, and D3DCULL_CW means you should provide the D3D with clockwise vertices. Otherwise they will be culled as back surfaces. This does not make scene at all. I will check this later.
The full source code could be downloaded from here.
相关文章推荐
- Vertex Shader & Pixel Shader
- Vertex Shader&Pixel Shader介绍
- Vertex & Fragment Shader入门
- Shader 基础使用(三) ----- vertex & fragment
- Learn Vertex & Pixel Shader Programming with DirectX 9
- Shader第三讲 Vertex&Fragment Shader
- 【猫猫的Unity Shader之旅】之Vertex&Fragment Shader下的透明
- Unity 中用 Vertex & Fragment Shader 实现 surface shader 中的 Diffuse 和 Decal
- Vertex Shader & Pixel Shader 介绍
- UNITY3D shader学习心得<三> Vertex and Fragment Shader
- 在基于shader的D3D程序中实现2D面板
- OpenGL&D3D State Machine
- LIGHTING IN VERTEX AND FRAGMENT SHADER
- 【浅墨Unity3D Shader编程】之十 深入理解Unity5中的Standard Shader(二)&屏幕油画特效的实现
- Lamber算法 & SurfaceShader自定义光照
- OpenGL ES 2.0——顶点着色器Vertex Shader
- 解决Unity Vertex Shader 渲染丢失的问题