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

天行健 君子當(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>
            亚洲精品综合久久中文字幕| 欧美在线视频免费播放| 亚洲免费在线精品一区| 一区二区三区高清在线 | av成人国产| 亚洲视频在线观看网站| 亚洲在线播放电影| 久久成人综合网| 欧美成年人视频网站欧美| 欧美日韩精品一区二区天天拍小说| 欧美日韩视频第一区| 国产精品视频自拍| 亚洲国产精品一区制服丝袜| 亚洲麻豆av| 午夜视频在线观看一区二区三区| 欧美精品粉嫩高潮一区二区 | 亚洲一二三四久久| 久久狠狠婷婷| 欧美日韩在线一二三| 狠狠色综合播放一区二区| 99国产精品久久| 久久久久九九视频| 亚洲乱码日产精品bd| 欧美一区二区日韩| 欧美日韩美女一区二区| 激情综合视频| 翔田千里一区二区| 亚洲精品久久视频| 欧美亚洲一级片| 亚洲精品国产系列| 久久精品毛片| 国产精品毛片a∨一区二区三区|国 | 亚洲特色特黄| 欧美国产日韩精品免费观看| 亚洲伊人网站| 欧美日韩国产在线播放网站| 精品福利免费观看| 久久电影一区| 亚洲一品av免费观看| 欧美另类在线播放| 亚洲欧洲美洲综合色网| 亚洲精品久久久一区二区三区| 亚洲欧美日韩高清| 亚洲电影在线| 久久久欧美精品| 国产日韩欧美a| 亚洲一区精品在线| 99国产精品久久久久久久久久 | 亚洲激情在线激情| 久久久久久网| 欧美一区2区三区4区公司二百| 国产精品va在线| av不卡在线看| 亚洲精品欧美一区二区三区| 蜜桃av噜噜一区| 亚洲黄色成人| 免费不卡视频| 免费成人美女女| 亚洲国产成人精品视频| 男女视频一区二区| 乱人伦精品视频在线观看| 在线精品视频一区二区三四| 久久亚洲影音av资源网| 久久久久综合网| 亚洲国产99| 亚洲片区在线| 国产精品久久久久99| 午夜精品久久久久久久白皮肤| 中文在线资源观看网站视频免费不卡 | 欧美暴力喷水在线| 久久中文在线| 亚洲黄色免费电影| 亚洲精品免费观看| 国产精品s色| 久久久av毛片精品| 老司机精品视频网站| 亚洲美女视频网| 中文精品视频一区二区在线观看| 国产乱码精品一区二区三区不卡| 久久精品一区| 欧美黄在线观看| 亚洲一级免费视频| 性欧美大战久久久久久久久| 国产亚洲欧美激情| 欧美韩日一区二区三区| 欧美午夜电影一区| 久久亚洲欧美| 欧美日韩免费高清一区色橹橹| 亚洲欧美一区二区激情| 久久久青草青青国产亚洲免观| 国内一区二区三区在线视频| 亚洲永久免费精品| 国外视频精品毛片| 最新中文字幕亚洲| 国产欧美日韩另类一区| 亚洲电影免费观看高清完整版在线| 欧美日韩国产在线观看| 久久久久国产免费免费| 欧美日韩黄色大片| 久久综合给合久久狠狠色 | 亚洲视频欧洲视频| 亚洲国产成人在线播放| 中文网丁香综合网| 亚洲激情视频在线观看| 亚洲免费视频网站| 日韩视频在线一区二区三区| 欧美中文字幕不卡| 亚洲欧美国产日韩中文字幕| 欧美a级一区二区| 久久久999精品| 国产精品福利片| 亚洲精品影院在线观看| 在线日韩中文字幕| 欧美一级视频精品观看| 亚洲午夜一二三区视频| 欧美激情一区二区三区不卡| 葵司免费一区二区三区四区五区| 国产精品久久久久久久久久久久久久| 欧美激情区在线播放| 韩日精品视频| 欧美在线91| 久久精品99国产精品日本| 国产精品久久久999| 亚洲精品美女在线观看| 亚洲人久久久| 欧美.日韩.国产.一区.二区| 美女国内精品自产拍在线播放| 国产日本欧美一区二区三区| 亚洲午夜激情免费视频| 亚洲香蕉成视频在线观看| 欧美日韩成人在线观看| 亚洲精品孕妇| 亚洲先锋成人| 国产精品欧美日韩久久| 亚洲夜间福利| 欧美一区二区三区免费在线看| 国产精品久久久久久久久久妞妞| 99www免费人成精品| 亚洲图片欧美午夜| 国产精品高清免费在线观看| 亚洲调教视频在线观看| 亚洲免费婷婷| 国产一区二区福利| 久久一区视频| 亚洲精品一区二区三区四区高清| 正在播放日韩| 国产精品久久久久一区二区三区| 亚洲天堂网站在线观看视频| 久久久久成人网| 亚洲国产成人不卡| 欧美日韩亚洲一区二区三区| 亚洲一二三四久久| 久久午夜视频| 一本色道精品久久一区二区三区| 欧美三级在线| 亚洲大胆人体在线| 免费不卡在线观看av| 亚洲国产一区二区三区高清| 99成人精品| 国产精品入口夜色视频大尺度 | 亚洲自拍16p| 久久久久久亚洲综合影院红桃 | 国产精品欧美精品| 欧美有码在线视频| 亚洲高清久久久| 亚洲影视在线播放| 伊人色综合久久天天五月婷| 欧美激情片在线观看| 亚洲视频网站在线观看| 久久网站免费| 亚洲一区二区不卡免费| 国内偷自视频区视频综合| 欧美激情综合色综合啪啪| 亚洲欧美在线磁力| 亚洲国产精品成人综合色在线婷婷| 亚洲午夜三级在线| 亚洲激情在线观看| 国产午夜精品麻豆| 欧美视频一区在线| 蜜臀久久久99精品久久久久久 | 亚洲缚视频在线观看| 国产精品久久久久久久久久免费看| 久久在线视频| 欧美亚洲在线观看| 夜夜爽av福利精品导航 | 国产精品一区二区在线观看| 免费在线观看精品| 久久久国产精品一区| 亚洲免费在线观看视频| 亚洲精品精选| 亚洲电影av在线| 久久全球大尺度高清视频| 亚洲一区免费观看| 在线视频你懂得一区二区三区| 亚洲高清自拍| 亚洲国产精品成人一区二区| 国产在线精品二区| 国产亚洲欧洲997久久综合| 国产精品美女久久福利网站| 欧美日韩精品国产|