The most important part need to be change is about our struct of vertex
D3DDECLUSAGE_TEXCOORD part need to be add into our vertexElements.
We also talk about lighting.For now we just ignore the reflecting light.
We use the cosine value between the norbal and the light to control the light
The screen cut
in Pix
The code
The process of our graphics work
I want to do this because every time we talk about this will make us embarrassed. I just want to answer the question easier.
The process of our graphics work
First we send the vertex data and the how they connect together to be several triangles (the index data) to the vertex shade
There are two main purposes of vertex shader, and the vertex shader will do what we want(as we program),it will output in two part: 1.the position data to the graphics board. 2 the second part is the data we want (anything).This part we will deal it with the fragment shader. For assignment 2 we output the data of color want the fragment shader do the interpolation for us
The fragment is some potential pixels. The graphics board will deal with the position data to decide which fragment to be shaded.
The data output from the vertex shader(the part what we want)will be send into the fragment shader. The graphics hardware does interpolates the output of the vertex shader, and the values we get as input to the fragment shader are already interpolated.
Image is 2D array pixels.
varying data is different in one draw call
Uniform data is the same in one draw call
Now we have two kind of data send to the fragment shader the varying and the uniforms.
Varying and uniform data is available to both the vertex and fragment shaders. Uniform data is set the same way (we actually do this in our code: seconds elapsed is set in both the vertex and the fragment shader). Varying data in the vertex shader is sent by us in our vertex and index buffers, and varying data in the fragment shader comes from the interpolated output of the vertex shader.
The texture is one kind of special uniforms. Texture is 2D dimension array data.We send it into device.
The reason why we use the texture.
When we only have a single triangle, we only now it is a individual fragment.If we want some visual thing on it, we have to do texture coordinate to know where to sample the texture. We do this in vertex shader using the varying data which gives us the specifics coordinates to put our texture.
P.S Light is another kind of uniforms
The transformation
To know the position to output to the graphics board we need to do the transformation in the vertex shader.
We have different kinds of spaces
The first space is the model space where we pass our varying data in.
Model space is origin position of the model and facing forward.
Then we do the transformation
model space to the world space
World space: the models can be anywhere of the world and can face anywhere.
world space to view space
View space: the camera is at the origin position and facing forward.
At this step we move the whole world let the camera is at the origin position.
view space to Projection space
Projection space: It is a 2D space which we take a 3D view of camera and project it to 2D. It is like we holding a paper and say this is what we want to captrue.
2D coordinates is the projection position.


没有评论:
发表评论