一天干掉一只Monkey計划(四)——卡通着色,描邊


一天干掉一只Monkey計划(四)--卡通着色,描邊

--Zephyroal

楔子:

實在無奈,Unreal的世界浩如煙海,在里面一點一點地爬動,很充實,但也很無奈,加之最近加入自行車驢行俱樂部,幾乎都沒有什么時間出來搞些自己的小小興趣愛好了,老大說的好“每一個年輕程序員都有一顆渲染的心”,正好有相關方面的應用,寫下此篇,總結一下卡通渲染方面的知識,摘錄不少,這里不一一謝過了,最后用RM做了相關的實現,工程文件就懶地放了,最怕害了一樣手懶的童鞋,下個東西就當學習結束了,以我自己的深刻教訓,理論與實際永遠隔着一條銀河,牢記,自勉:

實踐是檢驗真理的唯一標准!

一、 技術背景

非真實感繪制(Non-photorealistic rendering)

(NPR)是計算機圖形學的一類,主要模擬藝術式的繪制風格,也用於發展新繪制風格。和傳統的追求真實感的計算機圖形學不同,NPR受到油畫,素描,技術圖紙,和動畫卡通的影響。NPR已經以"卡通造影"的形式出現在電影和電子游戲中,它也已出現在設計圖紙和試驗動畫中

卡通渲染便是一種典型的常用非真實感繪制技術,它要求帖圖由不明顯的漸變色塊夾雜一些不復雜的紋理組成。它強調粗細線條(Silhouette,輪廓勾邊)和簡單色塊(ToonShading,塊狀色調着色),忽略細節。利用這些很簡單很純粹的線條和色塊,就能渲染出設計師所要求的質感很強的卡通效果,從而營造出互動的二維動畫世界。


wps_clip_image-15358

典型的卡通渲染


如上示例,茶壺上的色調是通過角度的余弦值選擇的,這個角度是指光線和面的法線之間的夾角角度。如果法線和光的夾角比較小,我們使用較亮的色調,隨着夾角變大,逐步使用更暗的色調。換句話說,角度余弦值將決定色調的強度。

wps_clip_image-21776

17.2:(a)使用卡通着色法着色的對象(注意着色間的尖銳過渡)。(b)增強卡通效果,輪廓邊(silhouette edge)被勾出。(c)使用標准散射光照着色的對象--摘自《龍書》

勾邊效果采用的是比較通行的做法,將模型的頂點沿法線方向外移一定距離得到一個比原模型稍大的模型,繪制時采用剔除正面繪制背面的方式,將模型繪制為黑色,再按正常方式繪制原來的模型,結果就產生了一定寬度的黑邊,黑邊的寬度可以通過將頂點沿法線外移的距離來控制。

色階效果采用了Diffuse Cubemap的方法實現。將模型法線作為第二套UV,根據光源方向設置適當的UV坐標變換矩陣,通過這套UV來索引一個保存了光照環境Diffuse光照信息的Cubemap貼圖。普通的Diffuse Cubemap貼圖上的光照信息是平滑過渡的,為了實現色階效果,將普通的Diffuse Cubemap貼圖在PhotoShop中進行色調分離,將連續的灰度變化變成4級灰度。

       當然實際的最終效果,不僅需要程序渲染的支持,美工的技術功底和經驗也是非常重要。


wps_clip_image-3734

著名的SF4


PSOpenGPUTrace大大翻譯的幾篇使用卡通渲染的典型日游,這里順便膜拜下,可以看看商業中是如何使用的~

NBGI 2011年大作《偶像大師2》技術大揭秘!

為了3D游戲粉絲的[(超級)街頭霸王4]圖形講座(后篇) 

【翻譯】火影忍者鳴人 疾風傳 終級風暴2 制作介紹

二、 實現原理

前面提到了,卡通渲染的主要技術就是“Outlining”和“ToonShading”兩個技術,首先色階渲染,可以用一張1D紋理讀取實現,其次是描邊,做法很多,龍書上有取邊列表的方法(比較耗),還可以通過邊緣檢測,或者法線方向放大實現。

1,描邊,邊緣檢測

實現原理:

1.  把模型渲染到一張紋理圖上;

2.  對這張圖進行Sobel邊緣檢測,找出邊界並把渲染到屏幕空間中。

邊緣檢測參照如下,如看着怕怕,首先翻出你塵封已久的數字圖像處理吧.

Sobel邊緣檢測算法

索貝爾算子(Sobel operator)主要用作邊緣檢測,在技術上,它是一離散性差分算子,用來運算圖像亮度函數的灰度之近似值。在圖像的任何一點使用此算子,將會產生對應的灰度矢量或是其法矢量

Sobel卷積因子為:

wps_clip_image-15120

 

該算子包含兩組3x3的矩陣,分別為橫向及縱向,將之與圖像作平面卷積,即可分別得出橫向及縱向的亮度差分近似值。如果以A代表原始圖像,Gx及Gy分別代表經橫向及縱向邊緣檢測的圖像灰度值,其公式如下:

wps_clip_image-32525 

 

具體計算如下:

Gx = (-1)*f(x-1, y-1) + 0*f(x,y-1) + 1*f(x+1,y-1)

      +(-2)*f(x-1,y) + 0*f(x,y)+2*f(x+1,y)

      +(-1)*f(x-1,y+1) + 0*f(x,y+1) + 1*f(x+1,y+1)

=[f(x+1,y-1)+2*f(x+1,y)+f(x+1,y+1)]-[f(x-1,y-1)+2*f(x-1,y)+f(x-1,y+1)]

 

Gy =1* f(x-1, y-1) + 2*f(x,y-1)+ 1*f(x+1,y-1)

      +0*f(x-1,y) 0*f(x,y) + 0*f(x+1,y)

      +(-1)*f(x-1,y+1) + (-2)*f(x,y+1) + (-1)*f(x+1, y+1)

=[f(x-1,y-1)+2f(x,y-1)+f(x+1,y-1)]-[f(x-1,y+1)+2*f(x,y+1)+f(x+1,y+1)]

 

其中f(a,b), 表示圖像(a,b)點的灰度值;

 

圖像的每一個像素的橫向及縱向灰度值通過以下公式結合,來計算該點灰度的大小:

wps_clip_image-21598

 

通常,為了提高效率 使用不開平方的近似值:

wps_clip_image-3585

 

如果梯度G大於某一閥值 則認為該點(x,y)為邊緣點。

 

然后可用以下公式計算梯度方向:

 

wps_clip_image-7174

 

Sobel算子根據像素點上下、左右鄰點灰度加權差,在邊緣處達到極值這一現象檢測邊緣。對噪聲具有平滑作用,提供較為精確的邊緣方向信息,邊緣定位精度不夠高。當對精度要求不是很高時,是一種較為常用的邊緣檢測方法。

用閾值化的方法勾勒卡通渲染需要的輪廓。該算子包含兩組3x3的矩陣(一個水平的,一個是垂直的),每一個逼近一個偏導數,分別為橫向及縱向,將之與圖像作平面卷積,即可分別得出橫向及縱向的亮度差分近似值。

計算出深度圖中的像素梯度值G,我們預設一個閥值(Threshold)值T,G值大於T值時,認為該像素為深度變化較大的邊緣,由此我們得到一張屏幕空間描邊圖(Edge Texture)。這種閾值化輪廓提取算法,已在數學上證明當像素點滿足正態分布時所求解是最優的。

    這種方法的Demo我就不貼了,需要的參見RenderMonkey自帶例子中NPR例子。

簡而言之,Sobel算子就是如何使用一個算子重新計算一個像素,看代碼說話:

Pixel Shader:

//RT尺寸 off值即為相鄰像素(想像一下九宮格)的距離

sampler RT: register(s0);

float4 myColor;

float fViewportWidth;

float fViewportHeight;

float4 ps_main(float2 texCoord: TEXCOORD0):COLOR

{  

float4 newColor;

newColor=tex2D(RT,texCoord);

float offx=1.0f/fViewportWidth;

float offy=1.0f/fViewportHeight;

float p00 = tex2D( RT, texCoord + float2(-offx, -offy)).r;

float p01 = tex2D( RT, texCoord + float2( 0, -offy)).r;

float p02 = tex2D( RT, texCoord + float2( offx, -offy)).r;

float p10 = tex2D( RT, texCoord + float2(-offx, 0)).r;

float p12 = tex2D( RT, texCoord + float2( offx, 0)).r;

float p20 = tex2D( RT, texCoord + float2(-offx, offy)).r;

float p21 = tex2D( RT, texCoord + float2( 0, offy)).r;

float p22 = tex2D( RT, texCoord + float2( 1, offy)).r;

// sobel算子的橫縱灰度值

float gx = (p00 + 2*p10 + p20) - (p02 + 2*p12 + p22);

float gy = (p00 + 2*p01 + p02) - (p20 + 2*p21 + p22);

float edgeSqr = gx*gx + gy*gy;

float final=1.0f - (edgeSqr < 0.07f*0.07f );

newColor.a = final;

return newColor;

}

2,描邊,法線放大

可以從一遍又一遍的采樣看出,Sobel算法在PixelShader中進行逐像素的效率並不高,而且也並不完全准確。

另一種描邊方法既是傳說中的法線放大,渲染兩次,先關閉Z-Write,對模型按法線方向微微進行一次放大,並在PS中將其處理為需要的描邊顏色,然后在第二遍渲染中,正常渲染出模型(當然了,這只是demo演示時的做法,真正應用中,比如點選人物效果,還需要對描邊進行一定的高斯模糊,具體方法后面再提)。

VSShader:

float4x4 matViewProjection;

struct VS_INPUT

{

   float4 Position : POSITION0;

   float3 Normal   : NORMAL0;

};

struct VS_OUTPUT

{

   float4 Position : POSITION0;

};

VS_OUTPUT vs_main( VS_INPUT Input )

{

   VS_OUTPUT Output;

   Output.Position = float4(Input.Position.xyz + Input.Normal*f1BiggerFactor1);

   Output.Position = mul( Output.Position, matViewProjection );

   return( Output );

}

PSShader:

sampler2D BaseMap;

float4 ps_main() : COLOR0

{

   return float4(0, 1, 0, 1);

}

3,邊列表方法

首先需要做的是找出模型中的邊來,其方法是首先在載入模型的時候,生成邊列表,保存每條邊連接的兩個頂點,每條邊相鄰的兩個面的編號。然后每一幀遍利所有邊,找出邊的兩個面的法線和攝像機鏡頭夾角的乘積為負的邊(大於90度為正,小於90度為負),找到這些邊之后,然后把每條邊的頂點復制一個,往法線方向位移一定的距離,獲得一個頂點,然后據此來生成mesh的頂點索引。 

若兩個三角面face0face1在視圖方向上與兩個不同方向的面共享同一條邊,則該邊為輪廓邊。也就是說,如果一個面是前面(front facing)而另一個面是后面(back facing),那么這條邊就是一條輪廓邊。圖17.8給出了一個輪廓邊和一個非輪廓邊的例子。

wps_clip_image-18972

17.8:在(a)中,由v0 v1定義的共享邊的一個面是前面,而共享邊另一個面是背面,因此該邊是輪廓邊。在(b)中,由v0 v1定義的這兩個共享邊面都是前面,因此該邊不是輪廓邊。

具體可以參照龍書17章,這里不采用,就不再贅述。

4,卡通着色(摘自龍書)

要實現卡通着色,我們采用Lander20003月發表在Game Developer Magazine的文章“Shades of Disney: Opaquing a 3D World”中所描述的方法。它像這樣工作:我們創建一個帶強度級別的灰度紋理,它包含我們需要的不同的着色強度。圖17.3顯示了我們在樣例程序中使用的這個紋理。

wps_clip_image-23700

17.3:用來保存着色強度的着色紋理。注意觀察不連續的着色間過渡和紋理着色強度必須從左到右增加。

然后在頂點着色器中,我們執行標准散射點積運算(standard diffuse calculation dot product)來確定頂點法線N和光線向量L之間角度的余弦,用以確定頂點接收到多少光線:s=L·N

如果s0,就表示光線向量和頂點法線之間的角度大於90度,也就表示該表面接收不到光線。因此,如果s0,我們就讓s0。所以s [0, 1]

現在,在通常的散射光照模型中,我們使用s來標記顏色向量。這樣,頂點顏色的明暗取決於接收到的光照的數量:diffuseColor = s(r, g, b, a)

但是,這將會導致從亮到暗之間平滑的着色。這是與我們期望的卡通着色相反的。我們想要一種在幾個不同着色器間突然轉換顏色的效果(對卡通渲染來說,在24種着色器工作起來還是挺不錯的)。

不使用s來標記顏色向量,我們將使用s作為早先提到的強度紋理的u紋理坐標——如圖17.3

注意:標量(scalars必定是一個有效的紋理坐標,因為s [0, 1],這是通常的紋理坐標區間。

按這種方式,頂點不會被平滑着色,而是間斷的。例如,強度紋理可能被分成3種着色,如圖17.4所示:

wps_clip_image-8048

17.4:那么,s [0, 0.33]的值使用shader0着色,s [ 0.330.66]的值使用shader1着色,s [0.66,1]的值使用shader2着色。當然,從這些着色的一種到另一種的過渡是不平滑的,這就賦予了我們期望的效果。

注意:我們還為卡通着色關閉了紋理過濾,因為這種過濾會試圖使着色過渡變平滑。這對於我們要求的不連續過渡是多余的。

為了實現卡通着色, 我們需要創建一個帶強度級別的灰度紋理, 來達到卡通繪畫中的陰影過度效果。

然后在頂點着色器中,我們執行基本的散射運算,通過 光向量L與法向量N的點積,以確定頂點接受到了多少光線:

S= L.N

如果s<0;表明光線和頂點法線間的夾角大於90度,頂點接受不到任何光線,所以如果s<0,則讓s=0; 以便讓s位於[0,1]之間,方便在紋理坐標空間取值。

像素處理器中,我們從亮度紋理中取值, 由於亮度紋理只有3中顏色,所以着色的結果是一種顏色到另一種顏色的生硬過度,這正是我們所期望的。

VS代碼片段:

VS_OUTPUT vs_main( VS_INPUT Input )

{

VS_OUTPUT Output;

Output.Position = mul( Input.Position, matViewProjection );

float3 posW    = mul( matView, Input.Position );

float3 normalW = mul( Input.Normal, matView);

float diffuse = max(0, dot(vecLightDir, normalW));

Output.Texcoord.x = diffuse;

Output.Texcoord.y = 0.0f;

return( Output );

}

PS代碼:

sampler cartoonMap;

float4 ps_main( float2 tex:TEXCOORD0) : COLOR0

return tex2D( cartoonMap, tex); 

}

 

三、 RenderMonkey實踐

Now.It's action time:

首先建立RM工程,初步,我們只需要兩步:

1,法線放大背景(背景);

2,渲染原始模型(前景);

話不多說,直接看圖:

wps_clip_image-14017

RM工程

wps_clip_image-9490

RimBack-VS

wps_clip_image-389

RimBack-PS

wps_clip_image-26986

ToonShading-VS

wps_clip_image-8114

ToonShading-PS

wps_clip_image-16867

額,結果,還行

四、 高斯模糊,隨機顏色

一開的效果,明顯過於單調,讓我們進入彩色的世界吧:

其中報了個錯,error X3025: global variables are implicitly constant, enable compatibility mode to allow modification,需要注意下這是因為當前編譯的shader基於一個較老的shader版本,必須指定兼容模式D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY才能 編譯通過也就是在調用D3DXCompileShaderFromFile編譯shader時,第6個參數必須包含此值。在RM中所以不要動態地改變全局變量值,直接中間賦值給一個局部變量吧~

wps_clip_image-8032

其次是高斯模糊問題,典型如最近的暗黑3中,鼠標移過人物背后會顯示“毛邊”,雖然沒有去分析過渲染,但大體可以猜測出原理應該是一樣的,渲染出人物背景后再進行高斯模糊(預存邊列表太費,且會在人物身上描出線條,大多見於日式卡通游戲)。

wps_clip_image-16684

坑爹吶,找不到圖,只好自己截了個

wps_clip_image-22957

再放一張,期待國內快點出

wps_clip_image-20586

偷偷地告訴你一句,其實RM里有,自己拖個過來吧,可別小瞧了RM的節點功能

wps_clip_image-15782

結果可以看到,這凶妹子是個精英怪哇,怕怕

五、 實際應用,RT處理

1Sobel二次勾邊

wps_clip_image-2823

無心試了下Sobel算子,特別提下,發現網上有的代碼使用Sobel的最終計算是錯誤的,如float final=1.0f - (edgeSqr > 0.07f*0.07f ); ,實際應為顏色值變化大的情況下,為false,返回1.0f,如下float final=1.0f - (edgeSqr < 0.07f*0.07f ); 

 

Gif圖,可能會看不到,用Chrome

特殊效果,加大Bigger法線參數,可以做出人物周圍電圈效果;,

 

Gif圖,同上

2,與場景結合

RT渲染的實際應用,如何貼上?你很快會發現這個問題;

首先是Clear相關RT的時候,記得設Alpha0

其次,將RT貼到MainBackBuffer上時,RM的半透明混合ms是沒設置的,需要建立RenderState節點,手動設置Alpha混合參數;

wps_clip_image-27708

最后,大功告成,結果如下:

 

最終效果,用了3張RT,模糊后背景變瘦,都還有待改進

六、 其它相關內容

PS

附錄《RenderMonkey Predefined Variables》,省的總是把參數忘了~

--摘自RenderMonkey Documentation.pdf

http://www.cppblog.com/lai3d/archive/2008/12/09/68975.html


Predefined Variables

RenderMonkey provides a set of predefined variables for added shader development
convenience. Such variables will display an appropriate tool tip (Predefined Variable) if
the mouse hovers over them. Predefined variables are shader constants whose values get
filled in at run-time by the viewer module directly at every frame. You cannot modify the
values directly through the same user interface that you can use to edit other variables of
similar types. A properly flagged predefined variable will be denoted in the workspace
tree view with a symbol over the nodes icon. For example: wps_clip_image-20692
RenderMonkey provides this set of predefined variables for your convenience:

Time

"Time0_X"
Provides a floating point time value (in seconds) which repeats itself based on the
“Cycle time” set in the RenderMonkey Preferences dialog. By default this “Cycle
time” is set to 120 seconds. This means that the value of this variable cycles from
0 to 120 in 120 seconds and then goes back to 0 again.
"CosTime0_X"
This variable will provide the cosine of Time0_X.
"SinTime0_X"
This variable will provide the sine of Time0_X.
"TanTime0_X"
This variable will provide the tangent of Time0_X.
"Time0_X_Packed"
This variable will pack the above xxxTime0_X variables into a 4 component
floating point vector.
Example: float4(Time0_X,CosTime0_X,SinTime0_X,TanTime0_X).
"Time0_1"
This variable provides a scaled floating point time value [0..1] which repeats itself
based on the “Cycle time” set in the RenderMonkey Preferences dialog. By
default this “Cycle time” is set to 120 seconds. This means that the value of this
variable cycles from 0 to 1 in 120 seconds and then goes back to 0 again.
"CosTime0_1"
This variable will provide the cosine of Time0_1.
"SinTime0_1"
This variable will provide the sine of Time0_1.
"TanTime0_1"
This variable will provide the tangent of Time0_1.
"Time0_1_Packed"
This variable will pack the above xxxTime0_1 variables into a 4 component
floating point vector.
Example: float4(Time0_1,CosTime0_1,SinTime0_1,TanTime0_1).
"Time0_2PI"
This variable provides a scaled floating point time value [0..2PI] which repeats
itself based on the “Cycle time” set in the RenderMonkey Preferences dialog. By
default this “Cycle time” is set to 120 seconds. This means that the value of this
variable cycles from 0 to 2PI in 120 seconds and then goes back to 0 again.
"CosTime0_2PI"
This variable will provide the cosine of Time0_2PI.
"SinTime0_2PI"
This variable will provide the sine of Time0_2PI.
"TanTime0_2PI"
This variable will provide the tangent of Time0_2PI .
"Time0_2PI_Packed"
This variable will pack the above xxxTime0_2PI variables into a 4 component
floating point vector.
Example: float4(Time0_2PI,CosTime0_2PI,SinTime0_2PI,TanTime0_2PI).
"TimeCyclePeriod"
This variable provides the “Cycle time” floating point value, as set in the
RenderMonkey Preferences dialog. By default this “Cycle time” is set to 120
seconds.
"FPS"
This variable provides the calculated frames per second, returned as a floating
point value.
"TimeElapsed"
This variable provides the elapsed time (in seconds) from the last frame to the
current frame, returned as a floating point value.


Viewport

"ViewportWidth"
This variable provides the preview window width (in pixels), returned as a
floating point value.
"ViewportHeight"
This variable provides the preview window height (in pixels), returned as a
floating point value.
"ViewportDimensions"
   This variable provides the preview window width and height (in pixels), returned
as a float2 value.
"ViewportWidthInverse"
   This variable will return 1.0 / ViewportWidth. 重劍注:NND!就是倒數啊!--囧,估計這位仁兄在此栽過跟頭
"ViewportHeightInverse"
   This variable will return 1.0 / ViewportHeight.
"InverseViewportDimensions"
This variable provides the inverse of the “ViewportDimensions”, returned as a
float2 value.
Random Values
"RandomFraction1PerPass"
"RandomFraction2PerPass"
"RandomFraction3PerPass"
"RandomFraction4PerPass"
Each of these variables provide a random floating point value in the range of
[0..1]. These values are updated each pass.
"RandomFraction1PerEffect"
"RandomFraction2PerEffect"
"RandomFraction3PerEffect"
"RandomFraction4PerEffect"
Each of these variables provide a random floating point value in the range of
[0..1]. These values are updated each effect.

Pass

"PassIndex"
This variable will provide the pass index, returned as a floating point value.

Mouse Parameters

"LeftMouseButton"
This variable will return a floating point value of 1.0 if the left mouse button is
currently pressed, or 0.0 if it is not currently pressed.
"MiddleMouseButton"
This variable will return a floating point value of 1.0 if the middle mouse button is
currently pressed, or 0.0 if it is not currently pressed.
"RightMouseButton"
This variable will return a floating point value of 1.0 if the right mouse button is
currently pressed, or 0.0 if it is not currently pressed.
"MouseButtonsPacked"
This variable will pack the above xxxMouseButton variables into a 4 component
floating point vector.
Example: float4(LeftMouseButton,MiddleMouseButton,RightMouseButton ,0.0).
"MouseCoordinateX"
This variable will return the horizontal mouse position (in pixels), relative to the
client area of the preview window, returned as a floating point value.
"MouseCoordinateY"
This variable will return the vertical mouse position (in pixels), relative to the
client area of the preview window, returned as a floating point value.
"MouseCoordinateXNDC"
This variable will return "MouseCoordinateX" / "ViewportWidth".
"MouseCoordinateYNDC"
This variable will return "MouseCoordinateY" / "ViewportHeight".
"MouseCoordsPacked"
This variable will pack the above MouseCoordinatexxx variables into a 4
component floating point vector.
Example: float4(MouseCoordinateX,MouseCoordinateY,XNDC,YNDC).
"MouseCoordinateXY"
This variable will return the "MouseCoordinateX" and "MouseCoordinateY"
coordinates into a 2 component floating point vector.
Example: float2(MouseCoordinateX,MouseCoordinateY).
"MouseCoordinateXYNDC"
This variable will return the "MouseCoordinateXNDC" and
"MouseCoordinateYNDC" coordinates into a 2 component floating point vector.
Example: float2(MouseCoordinateXNDC,MouseCoordinateYNDC).

Model Parameters

"ModelMoundingBoxTopLeftCorner"
This variable provides the top left coordinate of the model as a 3 component
floating point vector (world space).
"ModelMoundingBoxBottomRightCorner"
This variable provides the bottom right coordinate of the model as a 3 component
floating point vector (world space).
"ModelMoundingBoxCenter"
This variable provides the bounding box center of the model as a 3 component
floating point vector (world space).
"ModelCentroid"
This variable provides the centroid of the model as a 3 component floating point
vector (world space).
"ModelBoundingSphereCenter"
This variable provides the bounding sphere center of the model as a 3 component
floating point vector (world space).
"ModelBoundingSphereRadius"
This variable provides the bounding sphere radius of the model as a single
component floating point value (world space).

View Parameters

"ViewDirection"
This variable provides the view direction vector (world space).
"ViewPosition"
This variable provides the view position (world space).
"ViewSideVector"
This variable provides the view size vector (world space).
"ViewUpVector"
This variable provides the view up vector (world space).
"FOV"
This variable provides the field of view as a floating point value.
"NearClipPlane”
This variable provides the near clip distance as a floating point value.
"FarClipPlane”
This variable provides the far clip distance as a floating point value.

View Matrices

"View"
"ViewTranspose"
"ViewInverse"
"ViewInverseTranspose"
These 4x4 matrix variables provide the view matrix, its transpose, its inverse, and
the inverse transpose.
"Projection"
"ProjectionTranspose"
"ProjectionInverse"
"ProjectionInverseTranspose"
These 4x4 matrix variables provide the projection matrix, its transpose, its
inverse, and the inverse transpose.

"ViewProjection"
"ViewProjectionTranspose"
"ViewProjectionInverse"
"ViewProjectionInverseTranspose"
These 4x4 matrix variables provide the view * projection matrix, its transpose, its
inverse, and the inverse transpose.
"World"
"WorldTranspose"
"WorldInverse"
"WorldInverseTranspose"
These 4x4 matrix variables provide the world matrix, its transpose, its inverse,
and the inverse transpose. Note that since this version of RenderMonkey does not
support implementation of a scene graph, we have decided to keep the world
matrix as identity, but provide this predefined variable for your development
convenience. The user may apply this variable in their shader and when imported
into their engine, they may provide appropriate value of the world view projection
matrix through the engine’s calculations.
"WorldView"
"WorldViewTranspose"
"WorldViewInverse"
"WorldViewInverseTranspose"
These 4x4 matrix variables provide the world * view matrix, its transpose, its
inverse, and the inverse transpose.
"WorldViewProjection"
"WorldViewProjectionTranspose"
"WorldViewProjectionInverse"
"WorldViewProjectionInverseTranspose"
These 4x4 matrix variables provide the World * View * Projection matrix, its
transpose, its inverse, and the inverse transpose.

Customizing Predefined Variable Names

All predefined variable names are customizable through editing the
“.\UserData\RmPredefinedVariabled.txt” file. The data file is organized into four
columns. The first column contains the name that the variable will be created with by
default. This column is editable by the user. No other column data should be modified.
The second column specifies the variable type; the third column specifies the rendering
update frequency, and the fourth column species the predefined variable semantic. When
items in the first column have been modified, RenderMonkey should be restarted for the
changes to take effect.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM