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

天行健 君子當(dāng)自強(qiáng)而不息

光照與材質(zhì)(2)

光源

光照計(jì)算模型說明圖形系統(tǒng)以什么樣的方法計(jì)算燈光照射在物體上的顏色值,它是一種計(jì)算方法,而不是具體的燈光。光源則定義了三維場景中具體的燈光,包括位置、方向、強(qiáng)度等信息。相同的光源可以根據(jù)物體表面材質(zhì)的不同,通過不同的光照模型顯示。比如,在臥室中的一盞臺燈,照射在布質(zhì)床單上時(shí),應(yīng)使用漫反射模型;而照射在玻璃表面的桌子上時(shí),則應(yīng)使用鏡面反射模型計(jì)算光照效果。

 

光源類型

在Direct3D中支持三種光源類型:方向光(directional light)、點(diǎn)光源(point light)和聚光燈(spot light)。它們在Direct3D中以枚舉類型D3DLIGHTTYPE表示,枚舉類型D3DLIGHTTYPE定義如下:

typedef enum _D3DLIGHTTYPE {
D3DLIGHT_POINT = 1,
D3DLIGHT_SPOT = 2,
D3DLIGHT_DIRECTIONAL = 3,
D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DLIGHTTYPE;

Constants

D3DLIGHT_POINT
Light is a point source. The light has a position in space and radiates light in all directions.
D3DLIGHT_SPOT
Light is a spotlight source. This light is like a point light, except that the illumination is limited to a cone. This light type has a direction and several other parameters that determine the shape of the cone it produces. For information about these parameters, see the D3DLIGHT9 structure.
D3DLIGHT_DIRECTIONAL
Light is a directional light source. This is equivalent to using a point light source at an infinite distance.
D3DLIGHT_FORCE_DWORD
Forces this enumeration to compile to 32 bits in size. Without this value, some compilers would allow this enumeration to compile to a size other than 32 bits. This value is not used.

Remarks

Directional lights are slightly faster than point light sources, but point lights look a little better. Spotlights offer interesting visual effects but are computationally time-consuming.

 

1、點(diǎn)光源

點(diǎn)光源有顏色和位置,但沒有方向,它向所有方向發(fā)射的光都一樣。

電燈泡是點(diǎn)光源的一個(gè)例子,這種光的強(qiáng)度隨著距離物體的遠(yuǎn)近而衰減,在程序中需要提供點(diǎn)光源的位置、顏色和衰減系數(shù)等參數(shù)。在進(jìn)行光照計(jì)算時(shí),根據(jù)點(diǎn)光源在世界空間中的位置和物體頂點(diǎn)坐標(biāo)計(jì)算出燈光的方向和燈光傳播的距離(用于計(jì)算燈光的衰減),然后再同頂點(diǎn)法向量一起,根據(jù)燈光和物體表面材質(zhì)屬性計(jì)算物體表面每個(gè)頂點(diǎn)的顏色值。

 

2、方向光

方向光有顏色和方向,沒有位置。它們發(fā)出的是平行光,這意味著由方向光生成的燈光以同一個(gè)方向照向場景。可以把方向光想象成無窮遠(yuǎn)處的一個(gè)光源,如太陽光發(fā)出的光。方向光不會衰竭,當(dāng)Direct3D用這種光源計(jì)算頂點(diǎn)顏色時(shí),只考慮指定的方向和顏色。因?yàn)椴恍枰紤]照亮范圍和位置的影響,所以這種光的計(jì)算量最少。有策略的應(yīng)用方向光能夠提高程序的執(zhí)行速度。

 

3、聚光燈

聚光燈有顏色、位置和方向,類似于現(xiàn)實(shí)世界中的探照燈。聚光燈發(fā)出的光線由一個(gè)明亮的內(nèi)錐體(inner cone)和大一點(diǎn)的外錐體(outer cone)組成。光線強(qiáng)度從內(nèi)椎體到外椎體逐漸衰減,通過聚光燈的falloff、theta和phi這三個(gè)屬性共同來控制其衰減規(guī)律,其中theta為內(nèi)錐角,phi為外錐角。

一個(gè)頂點(diǎn)受到的聚光燈光照總量以該頂點(diǎn)在內(nèi)椎體或外椎體中的位置為基礎(chǔ)。Direct3D計(jì)算聚光燈方向向量L與從光源到頂點(diǎn)的向量D的點(diǎn)積,這個(gè)點(diǎn)積的值等于兩個(gè)向量夾角alpha的余弦。Direct3D將該值與角度theta和phi的余弦作比較。如果向量的點(diǎn)積小于或等于外椎體的余弦,該頂點(diǎn)超出了外椎體,不受光照;若這個(gè)點(diǎn)積大于內(nèi)椎體角的余弦,則該頂點(diǎn)在內(nèi)椎體內(nèi),受到的光照總量較多,仍需考慮在距離上的衰減。如果頂點(diǎn)在兩個(gè)區(qū)域之間,用下面的公式計(jì)算衰減后的光照系數(shù)。

If = ((cos(alpha) - cos(phi/2)) / (cos(theta/2) - cos(phi/2)))p

其中,If為衰減后的光強(qiáng)系數(shù),alpha表示向量L和D間的夾角,theta表示內(nèi)錐角,phi表示外錐角,p表示衰減系數(shù)falloff。

該計(jì)算公式得到的If值在0.0~1.0之間,用來縮放光線強(qiáng)度以實(shí)現(xiàn)衰減。當(dāng)然還要考慮從具體每個(gè)頂點(diǎn)到光源的距離衰減(attenuation)。在Direct3D中,聚光燈是所有光源類型中最耗時(shí)的光源,因此在系統(tǒng)性能不高的情況下應(yīng)該謹(jǐn)慎采用聚光燈。

 

光源屬性

三維場景的一個(gè)光源通過其各種屬性來描述,光源屬性包括光的發(fā)光位置、方向、顏色和衰減范圍等,這些屬性可控制光線對物體的照明程度,各種類型光源的屬性由結(jié)構(gòu)D3DLIGHT9定義。

Defines a set of lighting properties.

typedef struct D3DLIGHT9 {
D3DLIGHTTYPE Type;
D3DCOLORVALUE Diffuse;
D3DCOLORVALUE Specular;
D3DCOLORVALUE Ambient;
D3DVECTOR Position;
D3DVECTOR Direction;
float Range;
float Falloff;
float Attenuation0;
float Attenuation1;
float Attenuation2;
float Theta;
float Phi;
} D3DLIGHT9, *LPD3DLIGHT;

Members

Type
Type of the light source. This value is one of the members of the D3DLIGHTTYPE enumerated type.
Diffuse
Diffuse color emitted by the light. This member is a D3DCOLORVALUE structure.
Specular
Specular color emitted by the light. This member is a D3DCOLORVALUE structure.
Ambient
Ambient color emitted by the light. This member is a D3DCOLORVALUE structure.
Position
Position of the light in world space, specified by a D3DVECTOR structure. This member has no meaning for directional lights and is ignored in that case.
Direction
Direction that the light is pointing in world space, specified by a D3DVECTOR structure. This member has meaning only for directional and spotlights. This vector need not be normalized, but it should have a nonzero length.
Range
Distance beyond which the light has no effect. The maximum allowable value for this member is the square root of FLT_MAX. This member does not affect directional lights.
Falloff

Decrease in illumination between a spotlight's inner cone (the angle specified by Theta) and the outer edge of the outer cone (the angle specified by Phi).

The effect of falloff on the lighting is subtle. Furthermore, a small performance penalty is incurred by shaping the falloff curve. For these reasons, most developers set this value to 1.0.

 

Attenuation0
Value specifying how the light intensity changes over distance. Attenuation values are ignored for directional lights. This member represents an attenuation constant. For information about attenuation, see Light Properties (Direct3D 9). Valid values for this member range from 0.0 to infinity. For non-directional lights, all three attenuation values should not be set to 0.0 at the same time.
Attenuation1
Value specifying how the light intensity changes over distance. Attenuation values are ignored for directional lights. This member represents an attenuation constant. For information about attenuation, see Light Properties (Direct3D 9). Valid values for this member range from 0.0 to infinity. For non-directional lights, all three attenuation values should not be set to 0.0 at the same time.
Attenuation2
Value specifying how the light intensity changes over distance. Attenuation values are ignored for directional lights. This member represents an attenuation constant. For information about attenuation, see Light Properties (Direct3D 9). Valid values for this member range from 0.0 to infinity. For non-directional lights, all three attenuation values should not be set to 0.0 at the same time.
Theta
Angle, in radians, of a spotlight's inner cone - that is, the fully illuminated spotlight cone. This value must be in the range from 0 through the value specified by Phi.
Phi
Angle, in radians, defining the outer edge of the spotlight's outer cone. Points outside this cone are not lit by the spotlight. This value must be between 0 and pi.

Ambient、Diffuse、Specular分別表示光以不同的光照計(jì)算模型計(jì)算時(shí)的光源顏色,例如Diffuse就表示光源的漫反射顏色。因?yàn)橐粋€(gè)光源會照亮場景中的多個(gè)物體,而這些物體可能會使用不同的光照計(jì)算模型進(jìn)行光照計(jì)算,所以這就需要為燈光分別設(shè)置用于不同光照計(jì)算模型的燈光顏色。

光源發(fā)出光的三種顏色,與當(dāng)前材質(zhì)的相應(yīng)部分相作用,生成最終用于渲染的顏色。光源漫反射顏色與當(dāng)前材質(zhì)的漫反射屬性作用,光源鏡面反射顏色與當(dāng)前材質(zhì)的鏡面反射屬性作用等。

這三個(gè)顏色成員都是D3DCOLORVALUE結(jié)構(gòu)體類型的變量,其中R、G、B這三個(gè)分量的取值區(qū)間為0.0f~1.0f。最常見的漫反射顏色是白色(R:1.0 G:1.0 B:1.0),但可根據(jù)需要實(shí)現(xiàn)的效果創(chuàng)建所需的顏色。例如,為一個(gè)壁爐采用紅光。

Describes color values.

typedef struct D3DCOLORVALUE {
float r;
float g;
float b;
float a;
} D3DCOLORVALUE, *LPD3DCOLORVALUE;

Members

r
Floating-point value specifying the red component of a color. This value generally is in the range from 0.0 through 1.0, with 0.0 being black.
g
Floating-point value specifying the green component of a color. This value generally is in the range from 0.0 through 1.0, with 0.0 being black.
b
Floating-point value specifying the blue component of a color. This value generally is in the range from 0.0 through 1.0, with 0.0 being black.
a
Floating-point value specifying the alpha component of a color. This value generally is in the range from 0.0 through 1.0, with 0.0 being black.

Remarks

You can set the members of this structure to values outside the range of 0 through 1 to implement some unusual effects. Values greater than 1 produce strong lights that tend to wash out a scene. Negative values produce dark lights that actually remove light from a scene.

距離衰減系數(shù)Attenuation0、Attenuation1、Attenuation2控制一個(gè)光源的光強(qiáng)如何向著最遠(yuǎn)距離減弱,最遠(yuǎn)距離是由屬性Range指定的照射范圍。這三個(gè)成員都是浮點(diǎn)型、取值范圍是從0.0到無窮大。Attenuation0、Attenuation1、Attenuation2分別表示光的常量、線性、二次距離衰減系數(shù)。衰減公式為:

Atten = 1 / (Attenuation0 + Attenuation1 * d + Attenuation2 * d2)

其中d為物體頂點(diǎn)和光源之間的距離。物體距離光源越遠(yuǎn),它的亮度越小。距離衰減系數(shù)僅對點(diǎn)光源和聚光燈有效。一些應(yīng)用程序可將Attenuation1設(shè)為1.0,其他的設(shè)為0.0,從而使光強(qiáng)按1/d的比例改變。在光源處光強(qiáng)最大,在光源的照射范圍邊界處減少到1/Range。也可以分別設(shè)置3個(gè)衰減系數(shù)為不同的數(shù)值,得到更復(fù)雜的衰減效果,這些值可以任意設(shè)置,但是不能為負(fù)數(shù)。

結(jié)構(gòu)類型D3DLIGHT9包含三個(gè)僅有聚光燈使用的成員:內(nèi)外錐體衰減系數(shù)falloff、內(nèi)椎體角度theta、外椎體角度phi,共同控制著一個(gè)聚光燈的內(nèi)外椎體各有多大,以及在它們中間的光線如何減弱。


posted on 2008-05-03 18:58 lovedday 閱讀(1583) 評論(0)  編輯 收藏 引用


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


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            午夜日韩激情| 亚洲视频一区在线观看| 蜜月aⅴ免费一区二区三区| 亚洲三级性片| 欧美xart系列在线观看| 狼人天天伊人久久| 欧美激情网友自拍| 亚洲日本va在线观看| 91久久国产综合久久| 一本色道久久88精品综合| 99国产精品自拍| 亚洲欧美国产精品专区久久| 先锋亚洲精品| 欧美在线高清| 免费成人性网站| 欧美久久久久久久久久| 欧美日韩一区二区三区视频| 欧美色中文字幕| 国产乱码精品一区二区三区忘忧草| 久久成人免费电影| 欧美一区二区精美| 欧美成年人网站| 免费观看久久久4p| 国产精品家教| 在线观看不卡| 亚洲视频综合| 久久女同互慰一区二区三区| 久热成人在线视频| 亚洲天天影视| 欧美电影美腿模特1979在线看 | 亚洲精一区二区三区| 一区二区三区欧美成人| 午夜精品成人在线| 欧美成人精品高清在线播放| 亚洲精品欧美极品| 亚洲小说春色综合另类电影| 久久亚洲综合色一区二区三区| 久久综合亚州| 国产精品av一区二区| 91久久嫩草影院一区二区| 正在播放亚洲一区| 久久亚洲综合| 亚洲精品乱码视频| 午夜久久影院| 亚洲看片免费| 免费亚洲一区二区| 国内成人在线| 欧美一区二区三区在| 99riav久久精品riav| 性欧美大战久久久久久久久| 麻豆国产精品va在线观看不卡| 国产精品99久久不卡二区 | 久久成人免费| 国产精品永久在线| 亚洲免费中文字幕| 一本高清dvd不卡在线观看| 欧美1级日本1级| 亚洲激情在线激情| 欧美国产高潮xxxx1819| 久久久久久成人| 精品动漫av| 久久视频在线看| 久久精品一二三| 在线观看欧美成人| 欧美mv日韩mv国产网站app| 久久久www成人免费精品| 黑人巨大精品欧美黑白配亚洲| 欧美资源在线观看| 欧美在线观看你懂的| 在线观看国产精品淫| 免费久久99精品国产| 久久女同精品一区二区| 亚洲成色www8888| 亚洲大胆人体视频| 欧美精品精品一区| 亚洲一区二区三区激情| 亚洲一区二区视频在线| 国产亚洲精品福利| 欧美激情偷拍| 国产精品国产自产拍高清av| 午夜精品亚洲| 久久九九久精品国产免费直播| 在线观看视频欧美| 亚洲精品一二三| 国产欧美 在线欧美| 免费久久精品视频| 欧美日韩一区不卡| 久久久www成人免费无遮挡大片 | 国产欧美在线| 另类国产ts人妖高潮视频| 老司机aⅴ在线精品导航| 日韩视频精品在线| 亚洲欧美在线视频观看| 亚洲高清成人| 亚洲视频免费在线| 1000精品久久久久久久久| 亚洲精品国产精品乱码不99 | 99国产精品99久久久久久| 亚洲视频一区| 欧美特黄一区| 久久精品国产96久久久香蕉| 免费观看欧美在线视频的网站| 一区二区三区四区国产| 欧美亚洲日本国产| 99精品99| 久久精品人人做人人爽电影蜜月| 日韩天天综合| 久久久99免费视频| 亚洲尤物在线视频观看| 久久综合图片| 久久国产直播| 国产精品第一页第二页第三页| 久久人人爽人人爽爽久久| 欧美日韩成人一区二区三区| 久久久久久久综合日本| 欧美日韩三级在线| 欧美激情一区二区久久久| 国产日韩在线不卡| 亚洲少妇在线| 一区二区三区高清| 女仆av观看一区| 久久影院午夜论| 国产伦精品一区二区三区高清 | 欧美国产精品久久| 国产一区二区成人| 亚洲一区二区三区四区五区午夜| 91久久精品国产91久久性色| 欧美一级专区| 午夜久久tv| 国产精品久久久久影院色老大| 亚洲激情自拍| 亚洲另类春色国产| 欧美成人免费va影院高清| 免费观看不卡av| 在线观看视频一区| 久久久久国产一区二区三区四区| 欧美在线free| 国产一区二区久久精品| 午夜精品久久久久久久蜜桃app| 亚洲午夜性刺激影院| 欧美久久久久久久久久| 99精品视频免费观看视频| 亚洲午夜精品国产| 国产精品久久久久久影院8一贰佰| 亚洲免费精品| 亚洲欧美影院| 国产一区二区在线观看免费| 欧美在线视频a| 免费黄网站欧美| 亚洲人体影院| 欧美揉bbbbb揉bbbbb| 99综合精品| 久久精品1区| 伊人天天综合| 欧美激情五月| 激情一区二区三区| 嫩草伊人久久精品少妇av杨幂| 乱人伦精品视频在线观看| 国产一区在线观看视频| 久久久噜噜噜久久狠狠50岁| 欧美国产专区| 一区二区av| 国产精品超碰97尤物18| 亚洲一区日韩在线| 经典三级久久| 欧美电影美腿模特1979在线看 | 亚洲图片在线| 久久精品一级爱片| 亚洲精品亚洲人成人网| 国产精品xxxxx| 久久天堂av综合合色| 最新精品在线| 欧美在线播放| 亚洲精品久久久久久久久久久 | 国产网站欧美日韩免费精品在线观看 | 欧美三级乱码| 亚洲综合不卡| 免费观看在线综合| 午夜精品视频一区| 亚洲人成人一区二区三区| 国产精品多人| 蘑菇福利视频一区播放| 亚洲制服少妇| 亚洲国产成人午夜在线一区| 一区二区日韩伦理片| 激情久久五月| 欧美视频一区二区三区…| 午夜在线一区| 亚洲美女在线看| 欧美在线黄色| 一区二区欧美日韩视频| 黄色国产精品| 国产精品看片资源| 另类图片国产| 久久精品91久久香蕉加勒比| 一区二区三区欧美| 亚洲精品视频二区| 亚洲国产成人精品女人久久久 | 欧美在线一二三区| 99精品久久久|