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

天行健 君子當(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>
            国产精品theporn88| 久久裸体艺术| 国产精品久久久久久久久久妞妞 | 亚洲人成人一区二区三区| 欧美国产先锋| 欧美日韩免费观看中文| 亚洲制服欧美中文字幕中文字幕| 一区二区欧美在线| 国产欧美日韩免费看aⅴ视频| 久久久国产午夜精品| 久久一日本道色综合久久| 99re热精品| 亚洲欧美日韩精品久久久久| 黄色av日韩| 亚洲精品国产精品久久清纯直播| 欧美日产一区二区三区在线观看 | 免费观看久久久4p| 欧美激情一区二区三区高清视频| 亚洲男人影院| 久久久人成影片一区二区三区| 亚洲美女黄网| 欧美一区二区三区四区高清| 亚洲精品国产精品乱码不99| 亚洲综合欧美日韩| 亚洲精品国产精品国产自| 亚洲一区二区av电影| 亚洲成色999久久网站| 日韩午夜视频在线观看| 黑人中文字幕一区二区三区| 亚洲免费观看视频| 在线电影国产精品| 亚洲一区免费在线观看| 亚洲国产精品女人久久久| 亚洲一区二区三区影院| 亚洲另类自拍| 久久久水蜜桃| 欧美一激情一区二区三区| 欧美成人一品| 美女视频黄a大片欧美| 国产精品久久久久久福利一牛影视| 欧美11—12娇小xxxx| 国产精品视频yy9099| 亚洲欧洲一区二区在线播放| 黄色av成人| 先锋影音网一区二区| 亚洲一区视频在线观看视频| 欧美sm重口味系列视频在线观看| 欧美一区二区三区四区在线观看地址 | 亚洲午夜精品久久| 欧美国产视频在线观看| 久久九九电影| 国产午夜精品一区二区三区欧美| 一区二区三区欧美日韩| 99av国产精品欲麻豆| 午夜精品久久久久99热蜜桃导演| 欧美激情一区二区三区成人| 欧美黄免费看| 亚洲茄子视频| 欧美福利电影网| 亚洲大胆女人| 很黄很黄激情成人| 亚洲午夜日本在线观看| 亚洲欧美日韩一区二区在线 | 久久久久久香蕉网| 久久先锋影音av| 在线观看91精品国产麻豆| 欧美专区第一页| 久久综合给合| 在线日韩电影| 欧美高清不卡| 亚洲精品一区二区三区av| 一本一本久久a久久精品综合妖精| 欧美刺激午夜性久久久久久久| 亚洲大胆女人| 一区二区三区 在线观看视频 | 久久激情视频免费观看| 美女黄网久久| 亚洲理伦在线| 国产精品久久久一区二区| 性欧美video另类hd性玩具| 久久久青草婷婷精品综合日韩| 黄网站免费久久| 欧美大片在线看| 一区二区三区四区五区在线| 久久国产精品99久久久久久老狼| 国产一区二区在线免费观看| 久久久久国产精品一区二区| 亚洲精品国产视频| 校园激情久久| 亚洲激情另类| 国产精品一区二区你懂的| 久久精品综合| 一区二区三区不卡视频在线观看 | 中文一区二区在线观看| 国产乱人伦精品一区二区 | 亚洲欧洲一级| 久久成人综合视频| 日韩视频亚洲视频| 国产一区二区欧美| 欧美日韩亚洲另类| 久久精品国产亚洲5555| 亚洲美女黄色| 美女福利精品视频| 亚洲欧美资源在线| 亚洲日韩欧美视频一区| 国产婷婷色一区二区三区四区| 蜜臀久久99精品久久久画质超高清 | 亚洲精品之草原avav久久| 久久精品免费电影| 99精品欧美一区二区蜜桃免费| 国产日韩亚洲欧美精品| 欧美人与性动交a欧美精品| 久久国产日本精品| 亚洲午夜av| 亚洲精品免费网站| 欧美激情1区| 久久久久.com| 欧美成人在线网站| 久久精品国产亚洲aⅴ| 亚洲一区国产一区| 一区二区三区久久久| 亚洲国产精品久久| 免费欧美日韩| 看欧美日韩国产| 久久久久国产精品午夜一区| 亚洲欧美综合v| 在线亚洲美日韩| 亚洲人成在线播放网站岛国| 樱花yy私人影院亚洲| 国产一区视频网站| 国产揄拍国内精品对白| 国产欧美日韩在线视频| 国产精品亚洲欧美| 国产伦精品一区二区三区高清版| 欧美视频中文一区二区三区在线观看 | 免费日韩av| 欧美不卡视频| 欧美国产精品中文字幕| 欧美成人国产va精品日本一级| 久久久国产亚洲精品| 久久天堂国产精品| 美女国内精品自产拍在线播放| 久久久久久久成人| 久久综合国产精品| 欧美成人国产| 亚洲欧洲日夜超级视频| 日韩一区二区免费看| 亚洲乱码一区二区| 亚洲一区二区三区四区视频| 午夜精彩视频在线观看不卡| 亚洲欧美日韩中文在线制服| 先锋影音网一区二区| 亚洲欧美日韩精品综合在线观看| 午夜精品www| 久久精品中文| 欧美国产综合视频| 亚洲日本视频| 亚洲欧美日韩在线综合| 久久国产精品久久久| 媚黑女一区二区| 欧美三级午夜理伦三级中文幕| 国产精品婷婷午夜在线观看| 国产一区二区日韩| 亚洲精品久久久一区二区三区| 一区二区三区|亚洲午夜| 午夜免费日韩视频| 巨乳诱惑日韩免费av| 亚洲国产成人午夜在线一区 | 牛牛国产精品| av成人黄色| 久久精品免费电影| 欧美日韩一区二区三区| 国产亚洲一区二区三区在线观看| 亚洲国产精品va在线看黑人| 亚洲视频在线观看视频| 久久久水蜜桃av免费网站| 亚洲国产精品久久久久婷婷884 | 韩国女主播一区| 在线一区二区三区做爰视频网站| 久久激情综合| 99精品视频网| 免费看亚洲片| 国产三级欧美三级| 一区二区日韩| 欧美国产日韩在线观看| 亚洲男人第一av网站| 欧美国产一区二区| 国产在线观看91精品一区| 亚洲视频一区二区| 亚洲国产乱码最新视频| 欧美一区二区三区视频免费播放 | 精品福利免费观看| 亚洲综合好骚| 亚洲精选91| 欧美96在线丨欧| 狠狠色狠狠色综合日日五| 亚洲免费视频网站| 亚洲开发第一视频在线播放| 欧美一区二区成人6969| 亚洲精品视频免费观看|