0
我杀了我整天想弄清楚,为什么下面的代码不工作:OGRE3D /合成器相关的问题
我有这样的.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
}
}
}
}
。材料脚本:
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);
}
我用下面的语句来初始化合成:
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不应该是一种资源,因为它自动生成“飞行”,由食人魔。我错过了什么吗?
任何帮助表示赞赏!谢谢!
你说得对!但不知何故,即使在这种改变之后,排字工具仍然无法使用! –
另外,我将'texture rt0'改为'content_type compositor BW rt0'但是这没有什么区别!它仍然不起作用 –
我刚刚注意到材料脚本中的一个疏忽:_pass_语句在哪里?我试过你的代码(添加pass语句)并且它正常工作。 – enigma