DOOM3
windows阶段
根据机器配置opengl,设置渲染的状态(例如渲染3D?2D?),线程等等,
Opengl的这个
检查opengl可能出现的错误,设置opengl的状态,
诸如缓存溢出,未能初始值等等
堆栈溢出等等
得到显示的模式,例如320*240, 1024*768,800*600等等分辨率等等的问题
使用glide初始化opengl
windows也要初始化midi音频,
模式列表 等等截屏的处理,
函数 比如截屏函数, 应该是f12,把屏幕上的图像保存为一个jpeg图像
(3)
得到了默认的状态,例如初始化cullface为 裁剪前面
开启多重纹理,清除深度缓存,开启纹理模式
,设置opengl画图为 平滑模式
开启顶点数组
禁用混合
开启 多边形模式为
开启视口裁剪
禁用gl_face_cull
比如 游戏中 打游戏时候,鼠标的箭头变成一个枪口的样子的函数
(4)输出机器上的opengl类型,例如opengl版本为多少,opengl支持的扩展等等
如果驱动支持gamma则输出这个硬件
否则软件支持这个位数的处理
输出纹理模式,开启纹理字符串模式
如果硬件类型为nvidia显卡
如果smpactive这个活跃的话,那么显示出来者也
如果完成了,输出完成呢个了gl的检查
比如 根据1024*768,或者800*600等等模式来配置 opengl 了者也
记录,得到了这个机器上的配置,cvar变量,从保存的机器配置上
检查opengl是不是支持多重纹理等等api函数
颜色位数等等
模版位数等等
深度位数
模式、
是否全屏 ,自定义的宽高等等
宽度,高度等等
明亮度,
动态光 ,纹理模式,动态太阳等等
- Mute Sound System // 静音 音响 系统
- Run Wipe //运行 Wipe
- Capture screen to "_scratch" // 将屏幕捕获到“_scratch”
- Display "wipeMaterial" for "com_wipeSeconds" seconds.
- /*----显示" wipemmaterial "为" com_wipesseconds "秒。----*/
- Unload Previous Map (Call idGame::MapShutdown)
- //卸载之前的地图(调用idGame::MapShutdown)
- Show the loading gui for the next map (guis/map/____.gui)
- //显示下一个地图的加载gui (gui /map/____.gui)
- 显示加载gui
- 初始化渲染世界
- 分析地图文件
- 清除了这个输入缓存的处理
- Initialize Render World //初始化渲染世界
- Parse Map File 解析地图 文件
- Build lists of portals and models 构建门户和模型的列表
- Populate areas with models (but don't load them yet)//用 模型 填充区域(但不要加载它们)
- Clear user input buffers //清除用户输入缓冲区
- Set user info (idGame::SetUserInfo and idGame::SetPersistentPlayerInfo)
- // 设置用户信息(idGame::SetUserInfo和idGame::SetPersistentPlayerInfo)
- Call idGame::InitFromSaveGame or idGame::InitFromNewMap
- Call idGame::SpawnPlayer
- 玩家生成
- 加载所有的声音
- 加载所有的decls
- 加载所有的gui数据了者也
- Load all deferred data
- Load all models
- Load all images
- Load all sounds
- Load all decls
- Load all guis
- 调集了10次,
乃是要加载加载一个关卡里面的模型文件,
比如 md3模型文件了比如 lwo文件,ase模型文件等等
doom3中的武器,弹药,实体等等很多都是使用的lightwave文件制造的,
再转化为了这个md5模型文件
对于模型的数据来进行分析,文件是否有错误,检测等等
对于md5模型,doom3中对于ma文件(maya生成的)加载的,
ase文件(3D max产生的),
lwo文件(lightwave)等等文件
转化为md5文件的网格
据md5Mesh,这是静态的,
对于静态的物体,就不生成动画数据md5 Anim了.
<timeoffset> <domain>
- Call idGame::RunFrame 10 times to let things settle
- Create static light interactions
- 创建了静态灯的这个interactions
- Run Wipe
- Capture screen to "_scratch"
- Display "wipe2Material" for "com_wipeSeconds" seconds.
- Un-Mute Sound System
- 这个doom3的这个来处理的
- Renders all selfShadow objects shadows to the stencil buffer
- Renders all noSelfShadow objects with lighting
- Renders all noSelfShadow objects shadows to the stencil buffer
- Renders all selfShadow objects with lighting
- 渲染所有的半影对象对于模板缓存
- 渲染所有的半影与这个灯
- 渲染所有的不属于半影的对象,相对于模板缓存
- 渲染所有的这个半影对象伴随着灯
- doom3不同于Quake3, 脚本定义了很多,比如weapon,door,map等等
<strong>Parameters Key</strong>
<float> | Any number |
<int> | Any number without a fractional part |
<stri ng> | Any value enclosed in quotes |
<index> | An integer number that is an index into an array |
<map> | An image map, which may include image programs (below) |
<prog> | A vertex / frament program. Written using the GL ARB shader language. These files are stored in the glprogs directory |
<exp> | An expression that is evaluated every frame. |
对于md5模型,doom3中对于ma文件(maya生成的)加载的,
ase文件(3D max产生的),
lwo文件(lightwave)等等文件
转化为md5文件的网格
据md5Mesh,这是静态的,
对于静态的物体,就不生成动画数据md5 Anim了.
<timeoffset> <domain>
跟quake3的 前后 端 相类似
( 前端,主要是判断要渲染的多边形的数目)
(1)如果是bsp文件的格式处理的场景,根据pvs计算来
选出玩家所能看见的场景,
场景物体的渲染,先根据bsp树的pvs节点,来判断玩家所在的bsp area场景的数据,
再根据这个玩家的视锥进行裁剪,判断玩家所能看到的场景的多边形数目,再加上
玩家所能看见的物体,及所能看见的场景的多边形加在一起,
就是渲染的多边形总数者也,把它们发送到这个显卡的顶点缓存中去
对于这个内存中的幁缓存和顶点缓存的处理
初始化顶点缓存,然后对于这个缓存数据的处理了者也
将纹理数据最后发送到了这个显卡的幁缓存中去,
3
使用的opengl扩展来做光照。shader脚本部分的处理
对于NVIDIA的硬件,对于amd的使用amd的硬件扩展,对于其他的硬件,
则使用OpenGL的GL_VERTEX_PROGRAM_ARB扩展,因为这个是OpenGL通用的扩展,
通用
1 渲染所有的这个半影的阴影对象
2 渲染所有的这个不在阴影内部的对象
3 渲染所有的模板缓存里的对象物体
4渲染所有的光照的半影物体的出路
<strong>材质</strong>
textures/alphalabs/a_lfwall21b
{
qer_editorimage textures/alphalabs/a_lfwall21b
bumpmap textures/base_wall/lfwall21_local 凹凸贴图的处理了者也
diffusemap textures/alphalabs/a_lfwall21b 漫反射图像的处理
specularmap textures/alphalabs/a_lfwall21b_s 反射光的处理了者也
}
第一行是这个材质的图像的名字
第二行是这个凹凸图像的名字
对于这个材质的处理,
显示加载上了这个材质,然后再转化为了这个材质的处理了者也
图像编程的这个函数者也
这个使用的五六层材质的图片了者也
heightmap(<map>, <float>)
高度图的参数者也
add(<map>, <map>)
scale(<map>, <float> [,float] [,float] [,float])
invertAlpha(<map>)
invertColor(<map>)
makeIntensity(<map>)
makeAlpha(<map>)
makeIntensity(<map>)
mefragmentProgram <prog>这个乃是
gaTexture <mega>
这个纹理的这个处理了者也
把图像这个转化为了这个
室外的这个草的问题了者也处理了
者也
对于地形使用这个bsp来处理这个,怎么来处理的呢?
textures/glass/outdoor_glass1
{
noSelfShadow
noshadows
twosided
translucent
glass
forceoverlays
sort decal
qer_editorimage textures/glass/glass1
{
vertexProgram heatHaze.vfp
vertexParm 0 0 , 0 // texture scrolling
vertexParm 1 .5 // magnitude of the distortion
fragmentProgram heatHaze.vfp
fragmentMap 0 _currentRender
fragmentMap 1 textures/sfx/vp1 // the normal map for distortion
}
{
maskcolor
map makealpha(textures/glass/glass1)
}
{
blend gl_dst_alpha, gl_one
maskalpha
cubeMap env/gen2
red Parm0
green Parm1
blue Parm2
texgen reflect
}
{
blend filter
map textures/glass/outdoor_glass1fx
}
}
这个家伙难道是这个是用的cg的fx文件来进行这个对于材质的处理的?
id使用的自身定义的这个顶点着色器文件等来处理这个
- idCommon::Frame - idSession::UpdateScreen - idSession::Draw - idGame::Draw - idPlayerView::RenderPlayerView - idPlayerView::SingleView - idRenderWorld::RenderScene | - build params | - ::R_RenderView(params) | { | R_SetViewMatrix | R_SetupViewFrustum | R_SetupProjection 设置投影 | static_cast<idRenderWorldLocal *>(parms->renderWorld)->FindViewLightsAndEntities(); | R_ConstrainViewFrustum | R_AddLightSurfaces 增加光照的面 | R_AddModelSurfaces 增加模型 | R_RemoveUnecessaryViewLights | R_SortDrawSurfs | R_GenerateSubViews | R_AddDrawViewCmd | } | - idPlayer::DrawHUD FindViewLightsAndEntities: PointInArea: Uses tr.viewDef->initialViewAreaOrigin and search for the area the origin is located in. This is a non-recursive BSP traversal At the end of the first step, RC_DRAW_VIEW commands are issued. Each command contains a viewDef which contains among other things the list of surfaces to render. Note: R_SortDrawSurfs uses libc qsort, C++ sort with template would have been so much faster Note: The end of the process (R_AddDrawViewCmd) adds rendering commands to the command buffer. RB_ExecuteBackEndCommands picks up those commands types (RC_DRAW_VIEW)
The naming convention is a bit misleading. Even though there are "Render" and "Draw" everywhere, the CPU is not communicating with the GPU at all. The sole goal of the FrontEnd is to gather informations, pack them in a viewDef
and let the backend pick it up.
Doom3 Renderer Backend
idRenderSystemLocal::EndFrame R_IssueRenderCommands RB_ExecuteBackEndCommands RB_DrawView RB_ShowOverdraw RB_STD_DrawView { RB_BeginDrawingView // clear the z buffer, set the projection matrix, etc RB_DetermineLightScale
RB_STD_FillDepthBuffer // fill the depth buffer and clear color buffer to black except on _DrawInteractions { 5 GPU specific path R10 (GeForce256) R20 (geForce3) R200 (Radeon 8500) ARB ARB2 } 决定了这个阴影体的这个渲染了者也
// disable stencil shadow test qglStencilFunc( GL_ALWAYS, 128, 255 ); RB_STD_LightScale RB_STD_DrawShaderPasses //draw any non-light dependent shading passes RB_STD_FogAllLights RB_STD_DrawShaderPasses
The Backend starts by rendering all geometry provided by the frontend but only writing to the depth Stage Keywords
blend <type> blend <src>, <dst> | Blend types:
Source blend modes:
Destination blend modes:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
map <map> | The image program to use for this stage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
remoteRenderMap <int> <int> | Width and Height of the buffer to render a remote image in to (for cameras). The entity this material is applied to has to support remote render views. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mirrorRenderMap <int> <int> | Width and Height of the buffer to render a mirror in to. This of course makes this stage a mirror stage, which is different from using the 'mirror' global keyword because that makes the entire material a mirror, rather than just one stage. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
videomap [loop] <file> | This stage uses a video stream as an image map | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
soundmap [waveform] | This stage uses a sound meter from the sound system as an image map. Specify 'waveform' to get a scope rather than bars. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cubeMap <map> | This stage uses a cube map as the image map. Looks for _px, _py, _pz, _nx, _ny, _nz for the positive x, y, z, and negative x, y, z sides | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cameraCubeMap <map> | This stage uses a cube map in camera space. Looks for _forward, _back, _left, _right, _up, and _down | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ignoreAlphaTest | Always use DEPTHFUNC_LEQUAL rather than DEPTHFUNC_EQUAL which is normally used for opaque and alpha tested surfaces | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nearest | Use nearest texture filtering | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
linear | Use linear texture filtering | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
clamp | Same as the global keywords. Use to override a global clamp for a specific stage. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
zeroclamp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
alphazeroclamp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
noclamp | Use to set texture repeat for a stage when global clamp is set | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uncompressed | Do not compress this image in medium quality mode | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
highquality | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
forceHighQu ality | Do not compress this image in low quality mode | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nopicmip | Ignore the image_downSize cvar | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
vertexColor | Multiply the pixel color by the vertex color | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
inverseVertexColor | Multiply the pixel color by one minus the vertex color | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
privatePolygonOffset <float> | Explict larger (or negative) polygon offset for this stage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
texGen <type> | Type is one of: normal, reflect, skybox, wobbleSky <exp> <exp> <exp> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
scroll <exp>, <exp> | Scroll the texture coordinates | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
translate < exp>, <exp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
scale <exp>, <exp> | Just scales without a centering | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
centerScale <exp>, <exp> | Subtracts 0.5, then scales, then adds 0.5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shear <exp>, <exp> | Subtracts 0.5, then shears, then adds 0.5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rotate <exp> | Subtracts 0.5, then rotates, then adds 0.5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
maskRed | Don't write to the red channel | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
maskGreen | Don't write to the blue channel | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
maskBlue | Don't write to the green channel | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
maskAlpha | Don't write to the alpha channel | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
maskColor | Shortcut for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
maskDepth | Don't write to the depth buffer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
alphaTest <exp> | Only write if the alpha value is greater than <exp> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
red <exp> | Set the red vertex color | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
green <exp> | Set the green vertex color | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
blue <exp> | Set the blue vertex color | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
alpha <exp> | Set the alpha vertex value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rgb <exp> | Shortcut for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rgba <exp> | Shortcut for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
color <exp0>, <exp1>, <exp2>, <exp3> | Shortcut for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
colored | Shortcut for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if <exp> | Conditionally disable stages | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fragmentProgram <prog> | Use an ARB fragment program with this stage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
vertexProgram <prog> | Use an ARB vertex program with this stage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
program <prog> | Shortcut for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
vertexParm <index> <exp0> [,exp1] [,exp2] [,exp3] | Values to pass to the vertex program. One expression gets repeated across all 4 values. Two expressions put 0, 1 in z, w. Three expressions put 1 in w. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fragmentMap <index> [options] <map> | The image map to use for texture unit <index> [options] can be cubeMap, cameraCubeMap, nearest, linear, clamp, noclamp, zeroclamp, alphazeroclamp, forceHighQuality, uncompressed, highquality, or nopicmip | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
megaTexture <mega> | This stage uses a mega texture (super secret) |
这个megetexture的处理了者也
加载mgr材质文件
来表示材质属性的文件了
加载这个freetype库文件等等
用来渲染这个字体的处理者也!
Registerskins
其实就是加载这个纹理文件,
jpg,bmp,tga文件调用了这个bmp文件,jpg,tga等等文件加载的图像函数....
加载地图文件map,proc等等文件者也
InitRenderCommand
初始化这个渲染列表的命令者也!
typedef enum {
RC_END_OF_LIST,
RC_SET_COLOR,
停止渲染列表
线程的状态
{
渲染场景,
设置颜色
DrawBuffer
Draw2D
Draw3d
}
对于线程的互斥锁,mutex,线程的切换,同步的处理了
线程的状态等等,例如交换缓存,提交数据,一个线程把数据准备好了,另一个进行渲染者也
不断的运行线程者也,切换线程的状态者也
渲染
渲染buffer
对于子弹的痕迹,还有粒子系统的处理等等
对于beginFrame之前,进行前端的处理
在一幁处理完了后,
每次不断的交换缓存,来进行渲染
RenderFrame,来渲染后置数据了
renderView,视口从配置文件里面得到的这个的
对于配置文件中找到了这个各种功能了
md3模型的顶点数目,这个纹理坐标的处理了
渲染3d
noise噪声的处理
初始化这个命令列表,
各种命令的处理
在这个最后,消除了命令列表了者也
backEndData[tr.smpFrame]->commands.used = 0;
r_firstSceneDrawSurf = 0;
r_numdlights = 0;
r_firstSceneDlight = 0;
r_numentities = 0;
r_firstSceneEntity = 0;
r_numpolys = 0;
r_firstScenePoly = 0;
r_numpolyverts = 0;
}
每一帧,清除了这个一幁之内的多边形数目
和所有的entity的数据了
渲染队列
Brush model和这个md3模型了者也
原来这个quake3这个还有一个关于运行期间的这个glstate设置的结构者也
这个乃是设置这个运行时刻的这个状态的东西者也
data = GLimp_RendererSleep();
if ( !data ) {
return; // all done, renderer is shutting down
}
renderThreadActive = qtrue;
画这个多边形者也!
在渲染时,来交换这个线程的数据者也!
交换这个线程的数据者也
不断的更换这个线程里面的这个数据者也
渲染视图内的多边形
渲染这个
(1)渲染器
(其实这一部分乃是在这个cgame里面定义的者也)
初始化渲染状态,渲染2d,渲染3d,渲染缓存,
关卡截屏,对于每一关生成了截屏的图片了者也
渲染过程中
渲染命令列表
不断的切换渲染线程者也,
例如设置颜色,
对于渲染器方面,使用控制命令来控制这个渲染状态者也,渲染2d,设置颜色者也
渲染3d
这几个状态,分别在ui界面时,渲染器切换到2D渲染,
进入游戏后,切换到3D渲染,
前端,
初始化命令行者也 记录总数者也
如渲染线程的状态分为场景电影,2D,3D,Buffer,画surface,画缓冲区等等
在播放游戏开始的画面视频时,在切换到视频的状态,每个状态对应的执行过程不同,例如3D的渲染3D空间的物体,2D渲染的平面的物体,场景的电影,我们把它剪成一幁一幁地画上去,
交换缓存,来进行渲染者也
画缓存,
画多边形等等的处理者也
后置阶段的所有的多边形者也
线程的处理等等
2d部分的显示者也
渲染2d
字体
渲染2d的处理,,
要渲染了字体和图像了者也
freetype这个opengl的显示纹理乃是使用的这个纹理的2次方了者也,
这个乃是调用的这个把字体保存为了纹理图片,然后来显示纹理的
拉伸纹理,拉伸这个字体的处理等等
载入了这个字体的轮廓,把轮廓保存为了位图,然后来进行处理了者也!
调用显示列表来处理
保存位图,把这个转化为了这个opengl能够使用的这个纹理东西了者也
8位的亮度表示这个alpha?
绑定了字体的纹理
计算位图中字符图像的宽度
绘制一个正方形,显示字符
然后绑定了这个纹理的宽度和这个长度,来显示的这个字体的处理了者也
// 创建FreeType库
创建一个freetype这个字体的库?
在FreeType库中保存字体信息的类叫做face
在FreeType中使用1/64作为一个像素的高度所以我们需要缩放h来满足这个要求
设置这个face这个的尺寸了者也
然后再来创建了这个显示列表,
释放了这个freetype类,
释放了这个face
最后释放显示列表
最后显示这个字体的处理
字体的使用者也,使用的freetype来绘制
图像
StretchPic();//拉宽页面
显示一幅图像者也
设置颜色
设置2d式的状态等等
在显示这个文字时候,拉宽图像,文字在制定的地方渲染
对于2d的东西,例如生命值,中心的交叉点,还有弹药值等等2d的东西要不断的切换线程的状态,
从而来进行渲染者也
1
加载了dmap文件了者也
dmap文件的格式
对于bsp文件的这个加载以及处理方案,
R_LoadNodesAndLeafs (&header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]);
对于光照这个偏移了
根据视口的高度,宽度等等来生成
2根据bsp文件中存储的玩家的位置,
来决定玩家的照相机的位置,根据配置文件的存储的这个view视口的
长,宽,远,近平面来生成这个平截头体,来判断这个与
照相机的,这个六个视锥平面,来判断这个与bsp文件的相交处理,
然后相交来进行判断,
来裁剪了这个叶子节点,看不见的model了者也
5、 按从后到前的顺序渲染透明的面列表
model->mesh
flare->addflare者也
然后历经这个view的各项裁剪,例如box裁剪,sphere裁剪,等等各项裁剪者也
render->根据配置文件的来配置opengl->设置视口大小->加载bsp文件
->根据 玩家位置,计算pvs潜在可视集->来找到这个brush的处理等等
+md3 model所有的这个多边形者也!
这里还可以加上了这个玩家武器发出的这个粒子系统者也!
找到玩家所在的房间及邻居房间+敌人模型或表示物体的模型->
(1)表示房间多边形 数目(2)表示物体的多 边 形,(3)光源数目等等->
(1)将表示房间的多边形与表示物体或人物模型的多边形组合到一起
(2)在确定完玩家潜在能看到的多边形后->
对于玩家生成平截头体,根据平截头体,再进一步裁剪pvs中看不见的多边形,
剩下的多边形其实就是一幁所要处理的东西了->
将多边形进行排序,对不透明的多边形从前往后渲染,从后往前对透明的多边形先渲染->
当对于多边形阶段完了后,对多边形进行细分->
然后对于这一部分的顶点,进行细分者也
winding细分,mesh细分,网格的细分者也
还有这个md3 model模型
还有光源部分的更新处理等等
多边形数目
光源数目
实体数目、多边形顶点数目
这就是每一幁所能看见的数目者也
在更新的过程中,
对于动态的灯光的更新和对于运动物体的更新等等的处理
模型如果是水的波浪的话
对于水波浪的移动,根据法线来计算水波的颜色,从而来显示这个水面的颜色者也
波浪阶段wave的形式有几种
sin,三角形,四边形,还有其他的形,来处理者也,
渲染器后端的处理
决定下了这个视口内部要渲染的多边形数目以后
光照的处理
渲染时,光源只有平移,缩放,旋转等状态,
从bsp这个地图的文件中找到了这个light,提取了出来了者也,
然后对于这个light的处理了这样
灯的闪烁,
环境光照
游戏中的光照
基本几何体的光照,
更新动态的光源,静态的光源不必要进行更新的处理了者也
主要是brush上面的光照
分为两种情况,
doom3中已经变成了这个逐像素的光照了
光源上使用一个包围体进行对光源的距离进行遮挡,
阴影,的处理,阴影
光照的处理了
根据灯到这个entity的这个网格的距离,来计算这个normal的处理,是否大于小于0,怎么来处理
静态的灯光,和这个静态的网格
动态的灯光
(后端:主要是这个是渲染了)
3 对于光源渲染,预渲染的与实时渲染的相结合。给光源也生成一个平截头体,
给实体也生成一个平截头体,用来判断光源能照到那些实体entity,预渲染与实时渲染都是这么办的。
能照到的物体,使用这个光照方程进行光照的,前向光照的。
把光源照射到物体的反射光,镜面光的值传入到纹理,
从entity的高度图里抽取出法线来,进行渲染的,
const float n = dotDir0Dir2 * dotDir1Dir2 - dotDir0Dir1 * dotDir2Dir2;
const float t1 = n / d;
const float t1c = idMath::ClampFloat( 0.0f, 1.0f, t1 );
const float t2 = ( dotDir0Dir2 + dotDir1Dir2 * t1 ) / dotDir2Dir2;
const float t2c = idMath::ClampFloat( 0.0f, 1.0f, t2 );
const idVec3 closest1 = start1 + ( dir1 * t1c );
const idVec3 closest2 = start2 + ( dir2 * t2c );
const float distSqr = ( closest2 - closest1 ).LengthSqr();
return distSqr;
// test if the line passes through the triangle
测试光线能否穿过三角形
// if determinant is near zero then the ray lies in the triangle plane
决定这个光线是不是在这个三角形平面的上下?
#define TEMP_ROUND4( x ) ( ( x + 3 ) & ~3 ) // round up to a multiple of 4 for SIMD
lobal Keywords for light materials
全局的这个键值对于灯光的材质的处理等等
noShadows这个上面没有阴影的有没有
forceShadows
fog, blend, and ambient lights don't cast shadows by default. This forces them to cast shadows
noPortalFog
fogLight雾里面有没有灯光了
blendLight混合的灯光了者也
ambientLight
lightFalloffImage <map>
// If the line from localLight to localView intersects the geometry
// bounding box then the view is inside the infinite shadow projection.
在局部坐标系,和这个全局的坐标系
阴影部分
对于纹理,阴影,混合等等全部的使用了阴影来进行这个的处理了者也
(卡马克反转 阴影体算法.....)
对于静态的物体,预先计算阴影,动态的生成一个阴影体来生成阴影。
对于动态的阴影
Doom3 阴影部分使用idBound这个包围体对物体,模型进行一次包围,
使得进入到模版缓冲区的数据减少,然后再进行模板测试,
对于物体来说,所有能照着物体的光源逐个的进行阴影处理
对于阴影面的轮廓的绘制的处理了
阴影处理
分为三种阴影,预处理阴影,静态阴影,动态阴影三种情况的处理了
对于area的这个bsp树的这个 node节点的这个包围盒的处理
我怀疑这个来判断
时刻要判断玩家位置和构成这个物体的包围盒的比较了者也
先生成了这个阴影体的最大值和这个最小值,如果与照相机的位置来进行比较
,判断是不是需要使用这个z-fail方法来渲染,照相机位置在包围盒外部的话,那么使用的z-pass来进行绘制
如果在包围盒内部的话,使用z-fail来进行绘制
如果
// The shadow volume may be depth culled if either the shadow volume was culled to the view frustum or if the
// depth range of the visible part of the shadow volume is outside the depth range of the light volume.
如果阴影体需要z-fail的话,那么写入了这个阴影索引
// write out the shadow volume state
Pre-Light Shadow Volume Setup
A pre-light shadow is cast from static world geometry touching a static light.
A pre-light shadow volume does not extend to infinity but is capped at the light
boundaries which means the end caps always need to be rendered.
A pre-light shadow volume is created at map compile time and this job determines whether or
not the shadow volume needs to be rendered with Z-Fail.
一个预处理的阴影体应该是在地图编译时候,来进行阴影的处理的,
并且job来决定这个那部分需要这个是用z-fail来进行渲染的处理的
静态生成了阴影体
对于游戏中的这个静态的灯 生成了阴影
,也是用这个方法来判断是不是要生成了这个阴影了者也
Static Shadow Volume Setup
A static shadow is cast from a static model touching a static light.
A static shadow volume extends to infinity which allows the end caps to be omitted
when the view is outside and far enough away from the shadow volume.
A static shadow volume is created at map load time and this job determines whether or
not the end caps need to be rendered, whether or not the shadow volume needs to be
rendered with Z-Fail, and optionally calculates the shadow volume depth bounds.
先生成了这个阴影体的最大值和这个最小值,如果与照相机的位置来进行比较
,判断是不是需要使用这个z-fail方法来渲染,照相机位置在包围盒外部的话,那么使用的z-pass来进行绘制
如果在包围盒内部的话,使用z-fail来进行绘制
使用多重jetter来使得阴影模糊
(这个代码的分析包括了这个doom3和doom3bfg的代码分析了者也)
加入了 bloom,抖动等等技术,对于图像的模糊者也
5 对于屏幕的2D部分,也就是屏幕下方的生命值,弹药数目。
武器值等进行渲染。
切换渲染命令为渲染2D。
转换投影方式为正投影,来渲染文字,图片等信息
doom3中的这个guimodel的处理了
// Move the draw surfs to the view.
(机器翻译“
发光的双面面需要有三角形的复制,
他们不能只打开双面照明,因为法线和切线都是错的。
这应该在r_cleanuptriangle之前调用”
)
( 机器翻译“
导出三角形顶点的法切向量和正交切向量。
对于每个顶点,法向量 和 切向量 都是从所有三角形中导出的,
使用顶点,在网格上产生光滑的切线。
” )叠加用于在动态模型的顶部添加贴花。
将覆盖投影到可变形的几何体上,并可以添加到一个渲染实体,
允许在动态模型上贴花。这不会生成切向量,所以不能用光交互着色器。
材料的叠加应该始终夹紧,
因为投影的文本可以很好地运行纹理,
因为没有生成新的剪辑顶点。与普通材料叠加将合并在一起,
但额外将根据需要分配覆盖层。材料不应该是一个接收光照,
因为没有相互作用产生对于这些轻质表面。” )
全局坐标系和这个本地的坐标系的处理
阴影椎的裁剪位
R_SegmentToSegmentDistanceSquare
段距离的平方的处理
This deals with column-major (OpenGL style) matrices where transforms are
applied with right-multiplication.
This is the old DOOM3 matrix code that should really to be replaced with idRenderMatrix.
==========================================================================================
*/
矩阵的处理了者也
全局矩阵转化了这个局部矩阵的处理
多重矩阵的处理了者也
void R_AxisToModelMatrix( const idMat3 &axis, const idVec3 &origin, float modelMatrix[16] );
void R_MatrixTranspose( const float in[16], float out[16] );
void R_MatrixMultiply( const float *a, const float *b, float *out );
void R_TransformModelToClip( const idVec3 &src, const float *modelMatrix, const float *projectionMatrix, idPlane &eye, idPlane &dst );
void R_TransformClipToDevice( const idPlane &clip, idVec3 &ndc );
void R_GlobalToNormalizedDeviceCoordinates( const idVec3 &global, idVec3 &ndc );
// note that these assume a normalized matrix, and will not work with scaled axis
void R_GlobalPointToLocal( const float modelMatrix[16], const idVec3 &in, idVec3 &out );
void R_LocalPointToGlobal( const float modelMatrix[16], const idVec3 &in, idVec3 &out );
void R_GlobalVectorToLocal( const float modelMatrix[16], const idVec3 &in, idVec3 &out );
void R_LocalVectorToGlobal( const float modelMatrix[16], const idVec3 &in, idVec3 &out );
void R_GlobalPlaneToLocal( const float modelMatrix[16], const idPlane &in, idPlane &out );
void R_LocalPlaneToGlobal( const float modelMatrix[16], const idPlane &in, idPlane &out );
void R_SetupViewMatrix( viewDef_t *viewDef );
void R_SetupProjectionMatrix( viewDef_t *viewDef );
对于的cg的加载的处理
shader文件部分的处理了
顶点矩阵,参数的处理了者也
图像的program的处理,例如旋转图像,mipmaps等等的处理了
R_InitFrameData
对于这个幁缓存的处理了者也
// sort the draw surfs based on:
// 1. sort value (largest first)
// 2. depth (smallest first)
// 3. index (largest first)
4
对于纹理部分
renderStream的处理
无论动静,对于纹理部分,doom3最多包含有有五层纹理,specular,bump,falloff,Diffuse
等等五层的纹理,进入五个顶点编程渲染的状态 GL_VERTEX_PROGRAM_ARB ,
对于NVIDIA的硬件,对于amd的使用amd的硬件扩展,对于其他的硬件,
则使用OpenGL的GL_VERTEX_PROGRAM_ARB扩展,因为这个是OpenGL通用的扩展,通用的
对于纹理的状态,具有两层,三层,五层等等纹理状态,
来分别来进行渲染的处理了者也
这个材质图片的处理,
Image Program Functions 图像的编程函数 These can be used anywhere that accepts <map> and can be nested
| ||||||||||||||||||
对于纹理图像的操作方面,卡马克同志直接对图像的值进行了插值,使用镜面光方程,
使得 亮度越高,则表示为一个镜面 ,而不再是使用了光照贴图来表示光照了。
对于图像的处理,doom3中写了直方图处理,伽马等。
原来doom3对bmp,pcx等图形文件都是直接从调色板中直接寻找到对应的像素,
存放到pic指针指向的内存中去。
加载了bmp,dds,jpg,tga等等文件等,做成了纹理的处理
将图像的数据发送到了幁缓存区,
从而做成纹理缓存者也
,对于游戏中的所有图像,进行图像的检查过滤,对于纹理图像文件,判断是
什么格式例如bmp,jpg,tga,dds,来调用相对应的加载函数。
G
Two types of images can be used for bump mapping:
height maps and normal maps.
textures/doom/techpanel
{
qer_editorimage ase/techpanel.tga
diffusemap ase/techpanel_diffuse.tga
specularmap ase/techpanel_specular.tga
bumpmap ase/techpanel_local.tga
}
renderBump [-size <width> <height>] [-aa <0/1/2>]
[-trace <0.01 - 1.0>] <normalMapImage> <highPolyModel>
Size defaults to 256 by 256 if not specified.
AA defaults to 1 if not specified.
Trace defaults to 0.05 if not specified
尺寸应该是在了256之间
对于最后的结果gammma修正,和gui 2d屏幕上玩家的武器数据,以及对于玩家的生命值等等的输出到了屏幕之中了