食人魔3d /合成器相关问题
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
}
}
}
}
.材料脚本:
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:ARCHIVESDEPENDENCIESOGRE_REPOSITORYOgreMainsrcOgreResourceGroupManager.cpp (line 756)
AFAIK rt0不应该是一种资源,因为它是由食人魔"飞行"自动生成的。我错过了什么吗?
任何帮助不胜感激!谢谢!
异常错误是正确的:您没有具有该名称的纹理文件资源,但是 OGRE 将为您创建一个空白纹理。
但是我看到两个问题:
- 在合成器文件中,什么是场景?您必须使用 rt0 而不是场景,这是渲染场景的渲染目标,也是您应用材质的位置。
- 材料脚本中缺少传递语句。
相关文章:
- 警告处理为错误这里有什么问题
- 最小硬币更换问题(自上而下方法)
- 为"adjacent"变量赋值时出现问题
- 我的神经网络不起作用 [XOR 问题]
- 在Ubuntu 16.04上安装Cilk时出现问题
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 编译包含字符串的代码时遇到问题
- Project Euler问题4的错误解决方案
- 问题:什么是QAbstractItemView::NoEditTriggers的反面
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 在进程中对同一管道进行读取和写入时C++管道出现问题
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++ 雷神库 - 使用资源加载器类时出现问题(不命名类型)
- 一个关于在C++中重载布尔运算符的问题
- 首要问题的答案让值班员搞错了
- setlocale的C++土耳其字符串问题
- 如何重构类层次结构以避免菱形问题
- 基于boost的程序的静态链接——zlib问题
- C++格式化输出问题
- 食人魔3d /合成器相关问题