青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

concentrate on c/c++ related technology

plan,refactor,daily-build, self-discipline,

  C++博客 :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
  37 Posts :: 1 Stories :: 12 Comments :: 0 Trackbacks

常用鏈接

留言簿(9)

我參與的團(tuán)隊(duì)

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

only one vertex shader can be active at one time.
every vertex shader- driven program must run the following steps:
1) check for vertex shader support by checking the D3DCAPS8:VertexShaderVersion field.
D3DVS_VERSION(X,Y) shader x.y.
if(pCaps->VertexShaderVersion < D3DVS_VERSION(1,1))
{
return E_FAIL;
}
here to judge whether the vertex shader is suited for shader1.1.
the vertex shader version is in the D3DCAPS8 structure.
2) declaration of the vertex shader with D3DVSD_* macros, to map vertex buffers streams to input registers.
you must declare a vertex shader before using it,
SetStreamSource: bind a vertex buffer to a device data stream. D3DVSD_STREAM.
D3DVSD_REG:bind a single vertex register to a vertex element/property from vertex stream.
3) setting the vertex constant register with SetVertexShaderConstant.
you fill the vertex shader constant registers with SetVertexShaderConstant, and  get the vertex shader constant registers with GetVertexShaderConstant.
D3DVSD_CONSTANT: used in vertex shader declaration, and it can only be used once.
SetVertexShaderConstant: it can be used in every DrawPrimitive* calls.
4) compile previously written vertex shader with D3DXAssembleShader*.
different instructions include:
add  dest src1 src2  add src1 and src2 together.
dp3  dest src1 src2 dest.x = dest.y = dest.z = dest.w = (src1.x * src2.x ) + (src1.y * src2.y) + (src1.z* src2.z)
dp4  dest src1 src2 dest.w =  (src1.x * src2.x ) + (src1.y * src2.y) + (src1.z* src2.z) +(src1.w* src2.w) and dest.x dest.y, dest.z is not used.
dst dest src1 src2  dest.x = 1; dest.y = src1.y * src2.y;dest.z = src1.z;dest.w = src2.w; it is useful to calculate standard attentuation.
expp dest, src.w float tmp = (float)pow(2, w); WORD tmpd = *(DWORD*)&tmp & 0xffffff00; dest.z = *(float*)&tmpd;
lit dest, src

Calculates lighting coefficients from two dot products and a power.
---------------------------------------------
To calculate the lighting coefficients, set up the registers as shown:

src.x = N*L ; The dot product between normal and direction to light
src.y = N*H ; The dot product between normal and half vector
src.z = ignored ; This value is ignored
src.w = specular power ; The value must be between ?28.0 and 128.0
logp dest src.w 
 float tmp = (float)(log(v)/log(2)); 
 DWORD tmpd = *(DWORD*)&tmp & 0xffffff00; 
 dest.z = *(float*)&tmpd;
mad dest src1 src2 src3 dest = (src1 * src2) + src3
max dest src1 src2 dest = (src1 >= src2)?src1:src2
min dest src1 src2 dest = (src1 < src2)?src1:src2
mov dest, src move
mul dest, src1, src2  set dest to the component by component product of src1 and src2
nop nothing
rcp dest, src.w
if(src.w == 1.0f)
{
  dest.x = dest.y = dest.z = dest.w = 1.0f;
}
else if(src.w == 0)
{
  dest.x = dest.y = dest.z = dest.w = PLUS_INFINITY();
}
else
{
  dest.x = dest.y = dest.z = m_dest.w = 1.0f/src.w;
}
rsq dest, src

reciprocal square root of src
(much more useful than straight 'square root'):

float v = ABSF(src.w);
if(v == 1.0f)
{
  dest.x = dest.y = dest.z = dest.w = 1.0f;
}
else if(v == 0)
{
  dest.x = dest.y = dest.z = dest.w = PLUS_INFINITY();
}
else
{
  v = (float)(1.0f / sqrt(v));
  dest.x = dest.y = dest.z = dest.w = v;
}
sge dest, src1, src2 dest = (src1 >=src2) ? 1 : 0
slt dest, src1, src2 dest = (src1 <src2) ? 1 : 0

The Vertex Shader ALU is a multi-threaded vector processor that operates on quad-float data. It consists of two functional units. The SIMD Vector Unit is responsible for the mov, mul, add, mad, dp3, dp4, dst, min, max, slt and sge instructions. The Special Function Unit is responsible for the rcp, rsq, log, exp and lit instructions.

rsq is used in normalizing vectors to be used in lighting equations.
The exponential instruction expp can be used for fog effects, procedural noise generation.
A log function can be the inverse of a exponential function, means it undoes the operation of the exponential function.

The lit instruction deals by default with directional lights. It calculates the diffuse & specular factors with clamping based on N * L and N * H and the specular power. There is no attenuation involved, but you can use an attenuation level separately with the result of lit by using the dst instruction. This is useful for constructing attenuation factors for point and spot lights.

The min and max instructions allow for clamping and absolute value computation.
Using the Input Registers

The 16 input registers can be accessed by using their names v0 to v15. Typical values provided to the input vertex registers are:

  • Position(x,y,z,w)
  • Diffuse color (r,g,b,a) -> 0.0 to +1.0
  • Specular color (r,g,b,a) -> 0.0 to +1.0
  • Up to 8 Texture coordinates (each as s, t, r, q or u, v , w, q) but normally 4 or 6, dependent on hardware support
  • Fog (f,*,*,*) -> value used in fog equation
  • Point size (p,*,*,*)

The input registers are read-only. Each instruction may access only one vertex input register. unspecified components of the input registers default to 0.0 for the .x, .y, .z and 1.0 for the components w.

all data in an input register remains persistent throughout the vertex shader execution and even longer. that means they retain their data longer than the life-time of a vertex shader, so it is possible to re-use the data of the input registers in the next vertex shader.

Using the Constant Registers

Typical uses for the constant registers include:

  • Matrix data: quad-floats are typically one row of a 4x4 matrix
  • Light characteristics, (position, attenuation etc)
  • Current time
  • Vertex interpolation data
  • Procedural data

the constant registers are read-only from the perspective of the vertex shader, whereas the application can read and write into the constant registers.they can be reused just as input registers.
this allows an application to avoid making redundant SetVertexShaderConstant() calls.
Using the Address Register
you access the address registers with a0 to an(more than one address register should be available in vertex shader versions higher than 1.1)
Using the Temporary Registers
you can access 12 temporary registers using r0 to r11.
each temporary register has single write and triple read access. therefore an instruction could have the same temporary register as a source three times, vertex shaders can not read a value from a temporary register before writing to it. if you try to read a temporary register that was not filled with a value, the API will give you an error messge while creating the vertex shader(CreateVertexShader)
Using the Output Registers
there are up to 13 write-only output registers that can be accessed using the following register names. they are defined as the inputs to the rasterizer and the name of each registers is preceded by a lower case 'o'. the output registers are named to suggest their use by pixel shaders.
every vertex shader must write at least to one component of oPos, or you will get an error message by the assembler.
swizzling and masking
if you use the input, constant and temporary registers as source registers, you can swizzle the .x, .y, .z and .w values independently of each other.
if you use the output and temporary registers as destination registers you can use the .x, .y, .z and .w values as write-masks.
component modifier description
R.[x].[y].[z].[w]     Destination mask
R.xwzy                  source swizzle
- R                        source negation 
Guidelines for writing the vertex shaders
the most important restrictions you should remember when writing vertex shaders are the following:
they must write to at least one component of the output register oPos.
there is a 128 instruction limit
every instruction may souce no more than one constant register,e.g, add r0, c4,c3 will fail.
every instruction may souce no more than one input register, e.g. add r0,v1,v2 will fail.
there are no c-like conditional statements, but you can mimic an instruction of the form r0 = (r1 >= r2) ? r3 : r4 with the sge instruction.
all iterated values transferred out of the vertex shader are clamped to [0..1]
several ways to optimize vertex shaders:
when setting vertex shader constant data, try to set all data in one SetVertexShaderConstant call.
pause and think about using a mov instruction, you may be able to avoid it.
choose instructions that perform multiple operations over instructions that perform single operations.
collapse(remove complex instructions like m4x4 or m3x3 instructions)vertex shaders before thinking about optimizations.
a rule of thumb for load-balancing between the cpu/gpu: many calculations in shaders can be pulled outside and reformulated per-object instead of per-vertex and put into constant    registers. if you are doing some calculation which is per object rather than per vertex, then do it on the cpu and upload it on the vertex shader as a constant, rather than doing it on the GPU.
one of the most interesting methods to optimize methods to optimize your applications bandwidth usage, is the usage of the compressed vertex data.
Compiling a Vertex Shader
Direct3D uses byte-codes, whereas OpenGL implementations parses a string. therefore the Direct3D developer needs to assemble the vertex shader source with an assembler.this might help you find bugs earlier in your development cycle and it also reduces load-time.
three different ways to compile a vertex shader:
write the vertex shader source into a separate ASCII file for example test.vsh and compile it with vertex shader assembler into a binary file, for example test.vso. this file will be opened and read at game start up. this way, not every person will be able to read and modify your vertex shader source.
write the vertex shader source into a separate ASCII file or as a char string into you *.cpp file and compile it "on the fly" while the application starts up with the D3DXAssembleShader*() functions.
write the vertex shader source in an effects file and open this effect file when the application starts up.the vertex shader can be compiled by reading the effect files with D3DXCreateEffectFromFile. it is also possible to pre-compile an effects file. this way, most of the handling of vertex shaders is simplified and handled by the effect file functions.
 
5) Creating a vertex shader handle with CreateVertexShader.
the CreateVertexShader function is used to create and validate a vertex shader.
6) setting a vertex shader with SetVertexShader for a specific object.
you set a vertex shader for a specific object by using SetVertexShader before the DrawPrimitive() call of this object.
vertex shaders are executed with SetVertexShader as many times as there are vertices,.
7) delete a vertex shader with DeleteVertexShader().
when the game shuts down or when the device is changed, the resources taken by the vertex shader must be released. this must be done by calling DeleteVertexShader with the vertex shader handle.

Point light source.
a point light source has color and position within a scene, but no single direction. all light rays originate from one point and illuminate equally in all directions. the intensity of the rays will remain constant regardless of their distance from the point source unless a falloff value is explicitly stated. a point light is useful to simulate light bulb.

to get a wider range of effects a decent attenuation equation is used:
funcAttenuation = 1/A0 + A1 * dL + A2 * dL * dL

posted on 2008-12-09 11:18 jolley 閱讀(544) 評論(0)  編輯 收藏 引用

只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            韩国三级电影久久久久久| 久久狠狠婷婷| 欧美日韩免费观看一区=区三区| 亚洲国产高清视频| 亚洲国产精品久久人人爱蜜臀| 久久一区二区三区超碰国产精品| 亚洲国产欧美日韩精品| 亚洲欧洲日产国产综合网| 欧美日韩国产一区精品一区| 亚洲免费小视频| 欧美一级理论片| 91久久极品少妇xxxxⅹ软件| 亚洲美女精品成人在线视频| 国产精品一区二区三区成人| 久久综合给合久久狠狠狠97色69| 欧美不卡视频一区发布| 亚洲专区在线| 久久亚洲二区| 亚洲一二三区在线观看| 久久成人免费日本黄色| 亚洲激情小视频| 午夜精品av| 99精品视频免费观看视频| 亚洲欧美日韩中文播放| 亚洲人成网站777色婷婷| 一区二区91| 91久久极品少妇xxxxⅹ软件| 亚洲淫片在线视频| 亚洲乱码久久| 久久精品91久久久久久再现| 一区二区三区视频在线看 | 日韩视频在线一区二区三区| 亚洲一区精品视频| 亚洲精品乱码久久久久久黑人| 亚洲一区在线免费| 日韩午夜在线电影| 久久久久国产精品一区| 亚洲欧美影院| 欧美日韩一区在线| 亚洲国产高清视频| 在线电影国产精品| 亚洲欧美一区二区三区久久 | 欧美一级一区| 欧美日韩午夜| 亚洲欧洲一区二区在线观看| 激情久久久久久| 亚洲欧美三级在线| 亚洲你懂的在线视频| 久久国产精品久久w女人spa| 中文精品视频| 亚洲美女性视频| 麻豆精品视频| 免费亚洲一区| 在线观看成人小视频| 久久国产精品久久久久久| 亚洲欧美日韩高清| 国产精品久久久99| 亚洲午夜精品一区二区| 一区二区三区视频在线看| 米奇777在线欧美播放| 久久综合九色综合网站| 好吊成人免视频| 欧美一区观看| 久久在精品线影院精品国产| 国语自产偷拍精品视频偷| 欧美亚洲日本网站| 久久夜色精品| 亚洲国产精品一区二区久| 久色婷婷小香蕉久久| 欧美福利视频一区| 亚洲精选大片| 欧美日韩一区二区在线视频| 一区二区三区精品久久久| 亚洲综合国产激情另类一区| 国产精品视频yy9099| 小处雏高清一区二区三区| 久久久久久久性| 亚洲国产精品一区二区www在线| 欧美xxx在线观看| 一本色道久久综合狠狠躁篇怎么玩| 亚洲免费中文| 狠狠入ady亚洲精品经典电影| 玖玖在线精品| 日韩视频在线观看免费| 午夜在线一区| 亚洲黄页视频免费观看| 欧美日韩1区2区3区| 亚洲一区二区三区午夜| 老色批av在线精品| 一本综合久久| 国产一区二区三区在线观看免费视频| 久久精品视频在线| 亚洲另类一区二区| 久久成人精品视频| 亚洲美女诱惑| 国产综合久久久久久| 欧美激情综合五月色丁香小说| 一区二区三区色| 久久综合激情| 亚洲一区精品视频| 亚洲国产精品成人va在线观看| 欧美日韩免费观看中文| 久久国产视频网| 在线视频日韩| 亚洲第一区中文99精品| 欧美一区二区免费视频| 亚洲日本免费| 精品999日本| 国产精品大片wwwwww| 免费观看欧美在线视频的网站| 中文欧美在线视频| 亚洲国产一区二区三区在线播| 亚洲欧美视频一区二区三区| 亚洲精品无人区| 一区二区在线免费观看| 国产精品久久久久久影院8一贰佰| 六月天综合网| 久久国产黑丝| 亚洲女同精品视频| 一本久久青青| 91久久午夜| 在线精品观看| 久久精品国产999大香线蕉| 日韩亚洲国产欧美| 欧美激情视频在线免费观看 欧美视频免费一 | 免费一区二区三区| 欧美中文在线观看国产| 亚洲婷婷综合色高清在线 | 你懂的视频欧美| 欧美亚洲综合网| 午夜精品久久久久久久| 中日韩美女免费视频网址在线观看 | 欧美日韩成人综合| 免费观看日韩| 久久尤物视频| 久久亚洲精品一区二区| 久久人人爽国产| 狂野欧美激情性xxxx欧美| 久久九九电影| 久热精品视频在线| 欧美v日韩v国产v| 欧美精品一区二| 欧美日韩成人精品| 欧美色一级片| 国产精品视频精品| 国产精品主播| 国产日韩一区二区| 国产资源精品在线观看| 狠狠色狠狠色综合日日tαg| 精品999日本| 亚洲精品乱码久久久久久久久| 亚洲精品久久嫩草网站秘色| 亚洲精品免费在线| 亚洲午夜精品国产| 性欧美精品高清| 久久久噜久噜久久综合| 麻豆精品精华液| 亚洲国产二区| 亚洲午夜一区二区| 午夜精品久久久| 久久人人97超碰精品888| 欧美电影免费观看高清| 欧美日韩一区二区三区四区五区| 国产精品高潮呻吟| 国语自产精品视频在线看抢先版结局 | 欧美在线黄色| 麻豆成人91精品二区三区| 欧美激情一区二区三区在线视频观看 | 老**午夜毛片一区二区三区| 亚洲国产精品久久久久| 中国成人黄色视屏| 欧美专区在线播放| 欧美激情国产日韩| 国产精品亚洲综合| 亚洲国产精品悠悠久久琪琪| 亚洲一级高清| 欧美岛国激情| 亚洲欧美不卡| 欧美精品播放| 国产一区视频网站| 在线亚洲成人| 免费在线成人| 亚洲一区二区少妇| 国产一区二区三区久久悠悠色av| 欧美在线视频一区二区三区| 欧美激情一区二区在线| 亚洲精品影院| 久久国产手机看片| 欧美三级在线| 亚洲国产一区二区视频| 欧美一区激情视频在线观看| 亚洲欧洲日产国产综合网| 欧美在线综合视频| 国产精品美女久久| 亚洲日本精品国产第一区| 久久精品国产在热久久| 一区二区三区日韩在线观看| 欧美成人一区二区三区| 狠狠色伊人亚洲综合成人| 亚洲欧美视频在线观看|