forked from abcdls0905/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi_scene_view.h
210 lines (178 loc) · 6.46 KB
/
i_scene_view.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//--------------------------------------------------------------------
// 文件名: i_scene_view.h
// 内 容:
// 说 明:
// 创建日期: 2013年6月24日
// 创建人: 张俊胜
// 版权所有: 苏州蜗牛电子有限公司
//--------------------------------------------------------------------
#ifndef _I_SCENE_VIEW_H
#define _I_SCENE_VIEW_H
#include "../public/Macros.h"
#include "i_resource.h"
#include "i_context.h"
class ISceneView
{
public:
//视图类型
enum SCENE_VIEW_TYPE
{
TYPE_NORMAL,
TYPE_REFLECTION,
TYPE_PROJECTION,
TYPE_TEXTURE,
};
public:
// 渲染函数原型
typedef void (*render_func_t)(void* pdata);
public:
// 渲染器参数
virtual void SetContext(IRenderContext* value) = 0;
virtual IRenderContext* GetContext() const = 0;
virtual void SetBackColor(const FmVec4 backcolor ) = 0;
// 获取当前背景颜色
virtual const FmVec4& GetBackColor()const = 0;
// 获取视图类型
virtual ISceneView::SCENE_VIEW_TYPE GetSceneViewType() = 0;
// 释放
virtual void Release() = 0;
// 清除所有批次
virtual void ClearBatchs() = 0;
// 新增EarlyZ批次 渲染回调 渲染函数 到屏幕空间距离 bRestoreRenderState是否需要进行状态恢复
virtual void AddEarlyZBatch(render_func_t only_z_pass_func, void* pdata,float distance,const char* ident = NULL,render_func_t only_color_pass_func = NULL,bool bRestoreRenderState = true) = 0;
// 增加实心批次
virtual void AddSolidBatch(render_func_t func, void* pdata,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 新加地表渲染批次
virtual void AddGroundBatch(render_func_t func, void* pdata,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 增加带Alpha测试一类的实体批次渲染
virtual void AddSolidAlphaTestBatch(render_func_t func, void* pdata,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 新增绘制草体批次
virtual void AddGrassBatch(render_func_t func, void* pdata,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 增加水体批次
virtual void AddWaterBatch(render_func_t func, void* pdata,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 新增绘制所有实体批次后的一个批次内容
virtual void AddAfterSolidBatch(render_func_t func, void* pdata,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 增加半透明提前批次
virtual void AddPriorBlendBatch(render_func_t func, void* pdata, float distance,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 增加半透明批次
virtual void AddBlendBatch(render_func_t func, void* pdata, float distance,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 增加天空批次
virtual void AddSkyBatch(render_func_t func, void* pdata,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 增加后处理批次
virtual void AddPostBatch(render_func_t func, void* pdata,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 添加屏幕叠加渲染批次
virtual void AddTopmostBatch(render_func_t func, void* pdata,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 增加全屏阴影生成批次
virtual void AddShadowPostBatch(render_func_t func, void* pdata,const char* ident = NULL,bool bRestoreRenderState = true) = 0;
// 渲染场景
virtual void DrawScene() = 0;
// 渲染器相关参数
virtual void SetColorRT(IColorRT* pRT) = 0;
virtual void SetColorTex(IColorTex* pTex) = 0;
// 收集深度信息
virtual void SetDepthRT(IDepthRT* pRT) = 0;
virtual void SetDepthTex(IDepthTex* pTex) = 0;
// 收集模板信息
virtual void SetStencilTex(IStencilTex* pTex) = 0;
virtual void SetDepthStencilTex(IDepthStencilTex* pTex) = 0;
//渲染辅助参数
virtual void SetUnderWater(bool value) = 0;
virtual void SetSkyVisible(bool value) = 0;
virtual void SetBlendVisible(bool value) = 0;
};
#endif
/*
这里注解一下关于批次的公共批次(以下底层全局状态批次管理状态,对于批次内部的公共状态下面代码有状态情况,不需要批次内部再重复设置,如果批次内部需要特殊处理,那么在改批次渲染结束后需要恢复到批次组的全局状态)
void CSceneView::BeginOnlyZPassBatch()
{
m_pRenderStateOp->EnableColorWrite(false);
m_pRenderStateOp->EnableDepthWrite(true);
}
void CSceneView::BeginOnlyColorPassBatch()
{
m_pRenderStateOp->EnableColorWrite(true);
m_pRenderStateOp->EnableDepthWrite(false);
m_pRenderStateOp->SetDepthTestFunc( IRenderStateOp::DEPTH_TEST_EQUAL);
}
//批次渲染的全局状态变换
void CSceneView::BeginSolidBatch()
{
// 设置批次相关状态
m_pRenderStateOp->EnableCullFace(true);
m_pRenderStateOp->EnableDepthWrite(true);
m_pRenderStateOp->SetDepthTestFunc(IRenderStateOp::DEPTH_TEST_LEQUAL);
// 关闭阿法混合
m_pRenderStateOp->EnableBlend(false);
}
void CSceneView::BeginGroundBatch()
{
// 设置批次相关状态
m_pRenderStateOp->EnableCullFace(true);
m_pRenderStateOp->EnableDepthWrite(true);
m_pRenderStateOp->SetDepthTestFunc(IRenderStateOp::DEPTH_TEST_LEQUAL);
// 关闭阿法混合
m_pRenderStateOp->EnableBlend(false);
}
void CSceneView::BeginGroundBatch()
{
// 设置批次相关状态
m_pRenderStateOp->EnableCullFace(true);
m_pRenderStateOp->EnableDepthWrite(true);
m_pRenderStateOp->SetDepthTestFunc(IRenderStateOp::DEPTH_TEST_LEQUAL);
// 关闭阿法混合
m_pRenderStateOp->EnableBlend(false);
}
void CSceneView::BeginSolidAlphaTestBatch()
{
// 设置批次相关状态
m_pRenderStateOp->EnableCullFace(true);
m_pRenderStateOp->EnableDepthWrite(true);
m_pRenderStateOp->SetDepthTestFunc(IRenderStateOp::DEPTH_TEST_LEQUAL);
// 关闭阿法混合
m_pRenderStateOp->EnableBlend(false);
}
void CSceneView::BeginGrassBatch()
{
// 设置批次相关状态
m_pRenderStateOp->EnableCullFace(true);
m_pRenderStateOp->EnableDepthWrite(true);
m_pRenderStateOp->SetDepthTestFunc(IRenderStateOp::DEPTH_TEST_LEQUAL);
// 关闭阿法混合
m_pRenderStateOp->EnableBlend(false);
}
void CSceneView::BeginWaterBatch()
{
// 设置批次相关状态
m_pRenderStateOp->EnableCullFace(true);
m_pRenderStateOp->EnableDepthWrite(true);
m_pRenderStateOp->SetDepthTestFunc(IRenderStateOp::DEPTH_TEST_LEQUAL);
}
void CSceneView::BeginPriorBlendBatch()
{
m_pRenderStateOp->EnableBlend(true);
m_pRenderStateOp->EnableDepthWrite(false);
// 设置批次相关状态
m_pRenderStateOp->EnableCullFace(true);
}
void CSceneView::BeginBlendBatch()
{
m_pRenderStateOp->EnableBlend(true);
m_pRenderStateOp->EnableDepthWrite(false);
// 设置批次相关状态
m_pRenderStateOp->EnableCullFace(true);
}
void CSceneView::BeginSkyBatch()
{
m_pRenderStateOp->EnableDepthWrite(false);
}
void CSceneView::BeginPostBatch()
{
m_pRenderStateOp->EnableDepthTest(false);
}
void CSceneView::BeginTopmostBatch()
{
m_pRenderStateOp->EnableBlend(true);
m_pRenderStateOp->EnableDepthWrite(false);
m_pRenderStateOp->EnableDepthTest(false);
}
*/