[英]Ogre3d / Compositor related issue
我殺了一整天試圖找出,為什么下面的代碼不起作用:
我有這個.compositor腳本:
compositor BW
{
technique
{
texture rt0 target_width target_height PF_A8R8G8B8
target rt0
{
input previous
}
target_output
{
input none
pass render_quad
{
material BlackAndWhite
input 0 scene
}
}
}
}
.material腳本:
vertex_program BW_VP cg
{
source MyShader.cg
entry_point BW_VP
profiles vs_4_0 vs_2_0 vs_1_1 arbvp1
default_params
{
param_named_auto worldViewProj worldviewproj_matrix
}
}
fragment_program BW_FP cg
{
source MyShader.cg
entry_point BW_FP
profiles ps_4_0 ps_2_0 arbfp1
}
material BlackAndWhite
{
technique
{
vertex_program_ref BW_VP{}
fragment_program_ref BW_FP{}
texture_unit
{
texture rt0
tex_coord_set 0
tex_address_mode clamp
filtering none
}
}
}
和.cg程序:
sampler2D RT : register(s0);
void BW_VP(in float4 inPos : POSITION, out float4 pos : POSITION, out float2 uv0 : TEXCOORD0, uniform float4x4 worldViewProj)
{
pos = mul(worldViewProj, inPos);
inPos.xy = sign(inPos.xy);
uv0 = (float2(inPos.x, -inPos.y) + 1.0f) * 0.5f;
}
float4 BW_FP(float4 pos : POSITION, float2 iTexCoord : TEXCOORD0) : COLOR
{
float3 greyscale = dot(tex2D(RT, iTexCoord).rgb, float3(0.3, 0.59, 0.11));
return float4(greyscale, 1.0);
}
我使用下面的語句來初始化compositor:
Ogre::CompositorManager::getSingleton().addCompositor(mViewport, "BW");
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, "BW", true);
而且我看不到任何結果。 我的場景中有幾個燈光和cg着色器 - 它們工作得很好。 此外,所有資源都正確加載,資源組查看每個所需的文件,但是我在日志文件中得到此異常:
OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource rt0 in resource group Mission 1 : Deliver Tom or any other group. in ResourceGroupManager::openResource at D:\ARCHIVES\DEPENDENCIES\OGRE_REPOSITORY\OgreMain\src\OgreResourceGroupManager.cpp (line 756)
由於食人魔“在飛行中”自動生成,AFAIK rt0不應該是一種資源。 我錯過了什么嗎?
任何幫助表示贊賞! 謝謝!
異常錯誤是正確的 :您沒有具有該名稱的紋理文件資源,但OGRE將為您創建空白紋理。
但是我看到兩個問題:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.