Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_38597003
opencv_contrib
提交
234bf196
O
opencv_contrib
项目概览
qq_38597003
/
opencv_contrib
与 Fork 源项目一致
Fork自
OpenCV / opencv_contrib
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv_contrib
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
234bf196
编写于
12月 26, 2020
作者:
P
Pavel Rojtberg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ovis: implement real-time shadows
上级
24be5b85
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
2 deletion
+31
-2
modules/ovis/include/opencv2/ovis.hpp
modules/ovis/include/opencv2/ovis.hpp
+5
-2
modules/ovis/src/ovis.cpp
modules/ovis/src/ovis.cpp
+26
-0
未找到文件。
modules/ovis/include/opencv2/ovis.hpp
浏览文件 @
234bf196
...
@@ -52,7 +52,9 @@ enum SceneSettings
...
@@ -52,7 +52,9 @@ enum SceneSettings
/// Apply anti-aliasing. The first window determines the setting for all windows.
/// Apply anti-aliasing. The first window determines the setting for all windows.
SCENE_AA
=
8
,
SCENE_AA
=
8
,
/// Render off-screen without a window. Allows separate AA setting. Requires manual update via @ref WindowScene::update
/// Render off-screen without a window. Allows separate AA setting. Requires manual update via @ref WindowScene::update
SCENE_OFFSCREEN
=
16
SCENE_OFFSCREEN
=
16
,
/// Enable real-time shadows in the scene. All entities cast shadows by default. Control via @ref ENTITY_CAST_SHADOWS
SCENE_SHADOWS
=
32
};
};
enum
MaterialProperty
enum
MaterialProperty
...
@@ -74,7 +76,8 @@ enum EntityProperty
...
@@ -74,7 +76,8 @@ enum EntityProperty
ENTITY_MATERIAL
,
ENTITY_MATERIAL
,
ENTITY_SCALE
,
ENTITY_SCALE
,
ENTITY_AABB_WORLD
,
ENTITY_AABB_WORLD
,
ENTITY_ANIMBLEND_MODE
ENTITY_ANIMBLEND_MODE
,
ENTITY_CAST_SHADOWS
};
};
/**
/**
...
...
modules/ovis/src/ovis.cpp
浏览文件 @
234bf196
...
@@ -187,6 +187,7 @@ struct Application : public OgreBites::ApplicationContext, public OgreBites::Inp
...
@@ -187,6 +187,7 @@ struct Application : public OgreBites::ApplicationContext, public OgreBites::Inp
uint32_t
h
;
uint32_t
h
;
int
key_pressed
;
int
key_pressed
;
int
flags
;
int
flags
;
Ogre
::
MaterialPtr
casterMat
;
Application
(
const
Ogre
::
String
&
_title
,
const
Size
&
sz
,
int
_flags
)
Application
(
const
Ogre
::
String
&
_title
,
const
Size
&
sz
,
int
_flags
)
:
OgreBites
::
ApplicationContext
(
"ovis"
),
mainWin
(
NULL
),
title
(
_title
),
w
(
sz
.
width
),
:
OgreBites
::
ApplicationContext
(
"ovis"
),
mainWin
(
NULL
),
title
(
_title
),
w
(
sz
.
width
),
...
@@ -287,6 +288,9 @@ struct Application : public OgreBites::ApplicationContext, public OgreBites::Inp
...
@@ -287,6 +288,9 @@ struct Application : public OgreBites::ApplicationContext, public OgreBites::Inp
MaterialManager
&
matMgr
=
MaterialManager
::
getSingleton
();
MaterialManager
&
matMgr
=
MaterialManager
::
getSingleton
();
matMgr
.
setDefaultTextureFiltering
(
TFO_ANISOTROPIC
);
matMgr
.
setDefaultTextureFiltering
(
TFO_ANISOTROPIC
);
matMgr
.
setDefaultAnisotropy
(
16
);
matMgr
.
setDefaultAnisotropy
(
16
);
casterMat
=
matMgr
.
create
(
"DepthCaster"
,
Ogre
::
RGN_INTERNAL
);
casterMat
->
setLightingEnabled
(
false
);
casterMat
->
setDepthBias
(
-
1
,
-
1
);
}
}
};
};
...
@@ -318,6 +322,21 @@ public:
...
@@ -318,6 +322,21 @@ public:
RTShader
::
ShaderGenerator
&
shadergen
=
RTShader
::
ShaderGenerator
::
getSingleton
();
RTShader
::
ShaderGenerator
&
shadergen
=
RTShader
::
ShaderGenerator
::
getSingleton
();
shadergen
.
addSceneManager
(
sceneMgr
);
// must be done before we do anything with the scene
shadergen
.
addSceneManager
(
sceneMgr
);
// must be done before we do anything with the scene
if
(
flags
&
SCENE_SHADOWS
)
{
sceneMgr
->
setShadowTechnique
(
SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED
);
sceneMgr
->
setShadowTexturePixelFormat
(
PF_DEPTH32
);
// arbitrary heuristic for shadowmap size
sceneMgr
->
setShadowTextureSize
(
std
::
max
(
sz
.
width
,
sz
.
height
)
*
2
);
sceneMgr
->
setShadowCameraSetup
(
FocusedShadowCameraSetup
::
create
());
sceneMgr
->
setShadowTextureCasterMaterial
(
app
->
casterMat
);
// inject shadowmap into materials
const
auto
&
schemeName
=
RTShader
::
ShaderGenerator
::
DEFAULT_SCHEME_NAME
;
auto
rs
=
shadergen
.
getRenderState
(
schemeName
);
rs
->
addTemplateSubRenderState
(
shadergen
.
createSubRenderState
(
"SGX_IntegratedPSSM3"
));
}
sceneMgr
->
setAmbientLight
(
ColourValue
(
.1
,
.1
,
.1
));
sceneMgr
->
setAmbientLight
(
ColourValue
(
.1
,
.1
,
.1
));
_createBackground
();
_createBackground
();
}
}
...
@@ -716,6 +735,13 @@ public:
...
@@ -716,6 +735,13 @@ public:
SceneNode
&
node
=
_getSceneNode
(
sceneMgr
,
name
);
SceneNode
&
node
=
_getSceneNode
(
sceneMgr
,
name
);
switch
(
prop
)
switch
(
prop
)
{
{
case
ENTITY_CAST_SHADOWS
:
{
Entity
*
ent
=
dynamic_cast
<
Entity
*>
(
node
.
getAttachedObject
(
name
));
CV_Assert
(
ent
&&
"invalid entity"
);
ent
->
setCastShadows
(
bool
(
value
[
0
]));
break
;
}
case
ENTITY_SCALE
:
case
ENTITY_SCALE
:
{
{
node
.
setScale
(
value
[
0
],
value
[
1
],
value
[
2
]);
node
.
setScale
(
value
[
0
],
value
[
1
],
value
[
2
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录