doom3渲染器部分1


DOOM3
    map部分讲地图数据,粒子数据,模型等是放到了渲染器。
比quake3的渲染器进行了分离了,
模型上面与quake3不同的是模型上面的材质图像更多。
 一大半渲染时候要做的事情,在渲染器工作之前,
已经使用预渲染来进行对于静态阴影体的生成了,

windows阶段

 根据机器配置opengl,设置渲染的状态(例如渲染3D?2D?),线程等等,

Opengl的这个

配置d3d驱动,对于音频,sound等等这个是用d3d来处理的
配置opengl驱动的函数
比如 设置像素的格式,支持opengl。
windows32驱动函数 

检查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函数

颜色位数等等

模版位数等等

深度位数

模式、

是否全屏 ,自定义的宽高等等

宽度,高度等等

明亮度,

动态光 ,纹理模式,动态太阳等等

检查opengl的arb扩展了者也
渲染部分
渲染初始化
例如这个系统是否支持遮挡查询
openglarb的查询了者也
渲染器的很多   代码其实并不是引擎中用到的,而是工具用到的,
例如  magetexture mapname  生成megetexture文件,doom3中应该是没有使用,
后来雷神战争中使用,再到狂怒 ,应该是把megetexture转换成了 虚拟纹理......
rendbumps函数很多用于凹凸图像的处理 ,
gui在doom3游戏中经常的有这个,比如触发电梯的,开门的按钮,鼠标点到了那里,
就会变成了鼠标的样子了者也
碰撞检测的处理
渲染时候的处理
dxt文件包,乃是指的dxt1,dxt2,3,4,5等等算法的处理
shadow乃是指的这个静态阴影,动态阴影,等等的处理了者也
  • Mute Sound System        // 静音 音响 系统
  • Run Wipe                     //运行 Wipe
  • Capture screen to "_scratch"   //  将屏幕捕获到“_scratch”
  • Display "wipeMaterial" for "com_wipeSeconds" seconds.
  • /*----显示" wipemmaterial "为" com_wipesseconds "秒。----*/
扑捉屏幕到这个scratch
  • 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模型文件

  对于模型的数据来进行分析,文件是否有错误,检测等等

(2)还有这个液体模型和粒子模型的处理

对于md5模型,doom3中对于ma文件(maya生成的)加载的,

ase文件(3D max产生的),

lwo文件(lightwave)等等文件

转化为md5文件的网格

 据md5Mesh,这是静态的,

 对于静态的物体,就不生成动画数据md5 Anim了.

Deforms
tube
sprite
flare <size>
expand <amount>
move <amount>
turbulent <table> <range>
<timeoffset> <domain>
eyeBall
particle <particleDecl>
particle2 <particleDecl>

大致的流程跟这个quake3的类似了
加载所有的这个后置的数据
加载所有的实体
加载所有的这个图像文件
加载所有的这个贴花文件
家在所有的这个gui文件的处理
调集game的幁数,10ms
创建一个静态的光的interactions
运行这个wipe
拉伸屏幕
  • 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的这个来处理的 
  1. Renders all selfShadow objects shadows to the stencil buffer
  2. Renders all noSelfShadow objects with lighting
  3. Renders all noSelfShadow objects shadows to the stencil buffer
  4. Renders all selfShadow objects with lighting
  5. 渲染所有的半影对象对于模板缓存
  6. 渲染所有的半影与这个灯
  7. 渲染所有的不属于半影的对象,相对于模板缓存
  8. 渲染所有的这个半影对象伴随着灯 
  9. doom3不同于Quake3, 脚本定义了很多,比如weapon,door,map等等
调集 idGame::SpawnPlayer
玩家出生

<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模型也可以来进行增加多边形

对于md5模型,doom3中对于ma文件(maya生成的)加载的,

ase文件(3D max产生的),

lwo文件(lightwave)等等文件

转化为md5文件的网格

 据md5Mesh,这是静态的,

 对于静态的物体,就不生成动画数据md5 Anim了.

Deforms
tube
sprite
flare <size>
expand <amount>
move <amount>
turbulent <table> <range>
<timeoffset> <domain>
eyeBall
particle <particleDecl>
particle2 <particleDecl>

大致的流程跟这个quake3的类似了
加载所有的这个后置的数据
加载所有的实体
加载所有的这个图像文件
加载所有的这个贴花文件
家在所有的这个gui文件的处理
调集game的幁数,10ms
创建一个静态的光的interactions
运行这个wipe
拉伸屏幕

在渲染的时候
在渲染的时候加上了这个prt文件的处理
还有md3, ma文件的处理转化为了md5模型
对于这个这个灯还有灯光照到了这个物体上来处理了

 跟quake3的 前后 端 相类似

( 前端,主要是判断要渲染的多边形的数目)

(1)如果是bsp文件的格式处理的场景,根据pvs计算来

选出玩家所能看见的场景,

场景物体的渲染,先根据bsp树的pvs节点,来判断玩家所在的bsp area场景的数据,

模型的处理

再根据这个玩家的视锥进行裁剪,判断玩家所能看到的场景的多边形数目,再加上

玩家所能看见的物体,及所能看见的场景的多边形加在一起,

就是渲染的多边形总数者也,把它们发送到这个显卡的顶点缓存中去

对于这个内存中的幁缓存和顶点缓存的处理

初始化顶点缓存,然后对于这个缓存数据的处理了者也

将纹理数据最后发送到了这个显卡的幁缓存中去,

使用的opengl扩展来做光照。shader脚本部分的处理

对于NVIDIA的硬件,对于amd的使用amd的硬件扩展,对于其他的硬件,

则使用OpenGL的GL_VERTEX_PROGRAM_ARB扩展,因为这个是OpenGL通用的扩展,

通用

这个渲染器根据配置文件的中的显卡的渲染,
doom3 (2004) 是arb,arb2,nv,nv2,ati的显卡,来进行这个光照和这个纹理的映射的处理了
doom bfg则是使用的 cg、glsl等实现的

deform
这个乃是
还有ovelay的处理
idRenderModel * model = NULL;
if ( ( extension.Icmp( "ase" ) == 0 ) || ( extension.Icmp( "lwo" ) == 0 ) || ( extension.Icmp( "flt" ) == 0 ) || ( extension.Icmp( "ma" ) == 0 ) ) {
model = new (TAG_MODEL) idRenderModelStatic;
} else if ( extension.Icmp( MD5_MESH_EXT ) == 0 ) {
model = new (TAG_MODEL) idRenderModelMD5;
} else if ( extension.Icmp( "md3" ) == 0 ) {
model = new (TAG_MODEL) idRenderModelMD3;
} else if ( extension.Icmp( "prt" ) == 0  ) {
model = new (TAG_MODEL) idRenderModelPrt;
} else if ( extension.Icmp( "liquid" ) == 0  ) {
model = new (TAG_MODEL) idRenderModelLiquid;
模型一共可以分为了五种,
液体,还有这个粒子等等模型的分类的处理
typedef enum {
OP_TYPE_ADD,
OP_TYPE_SUBTRACT,
OP_TYPE_MULTIPLY,
OP_TYPE_DIVIDE,
OP_TYPE_MOD,
OP_TYPE_TABLE,
OP_TYPE_GT,
OP_TYPE_GE,
OP_TYPE_LT,
OP_TYPE_LE,
OP_TYPE_EQ,
OP_TYPE_NE,
OP_TYPE_AND,
OP_TYPE_OR,
OP_TYPE_SOUND
} expOpType_t;
typedef enum {
SS_SUBVIEW = -3, // mirrors, viewscreens, etc  镜子、视屏等
SS_GUI = -2, // guis
SS_BAD = -1,
SS_OPAQUE, // opaque
SS_PORTAL_SKY,
SS_DECAL, // scorch marks, etc.
SS_FAR,
SS_MEDIUM, // normal translucent 
SS_CLOSE,
SS_ALMOST_NEAREST, // gun smoke puffs
SS_NEAREST, // screen blood blobs
SS_POST_PROCESS = 100 // after a screen copy to texture 后 屏幕 复制 到 纹理
} materialSort_t;
材质的一个排序的处理了者也
typedef enum {
SURFTYPE_NONE, // default type
    SURFTYPE_METAL,
SURFTYPE_STONE,
SURFTYPE_FLESH,
SURFTYPE_WOOD,
SURFTYPE_CARDBOARD,
SURFTYPE_LIQUID,
SURFTYPE_GLASS,
SURFTYPE_PLASTIC,
SURFTYPE_RICOCHET,
SURFTYPE_10,
SURFTYPE_11,
SURFTYPE_12,
SURFTYPE_13,
SURFTYPE_14,
SURFTYPE_15
} surfTypes_t;
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:

TypeSrcDst
blendgl_src_alphagl_one_minus_src_alpha
addgl_onegl_one
filtergl_dst_colorgl_zero
modulategl_dst_colorgl_zero
nonegl_zerogl_one
bumpmapNormal map
diffusemapDiffuse map
specularmapSpecular map

Source blend modes:

gl_oneConstant 1
gl_zeroConstant 0
gl_dst_colorThe color currently on the screen
gl_one_minus_dst_colorOne minus the color currently on the screen
gl_src_alphaThe alpha channel of the source image
gl_one_minus_src_alphaOne minus the alpha channel of the source image
gl_dst_alphaThe alpha channel of the screen image
gl_one_minus_dst_alphaOne minus the alpha channel of the screen image
gl_src_alpha_saturateMinimum of the source alpha and one minus screen alpha

Destination blend modes:

gl_oneConstant 1
gl_zeroConstant 0
gl_src_colorThe color of the source image
gl_one_minus_src_colorOne minus the color of the source image
gl_src_alphaThe alpha channel of the source image
gl_one_minus_src_alphaOne minus the alpha channel of the source image
gl_dst_alphaThe alpha channel of the screen image
gl_one_minus_dst_alphaOne minus the alpha channel of the screen image


 
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
ignoreAlphaTestAlways use DEPTHFUNC_LEQUAL rather than DEPTHFUNC_EQUAL which is normally used for opaque and alpha tested surfaces
nearestUse nearest texture filtering
linearUse linear texture filtering
clampSame as the global keywords. Use to override a global clamp for a specific stage.
zeroclamp
alphazeroclamp
noclampUse 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
nopicmipIgnore 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
maskGreenDon't write to the blue channel
maskBlueDon't write to the green channel
maskAlphaDon't write to the alpha channel
maskColorShortcut for
maskRed
maskGreen
maskBlue
maskDepthDon'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
red <exp>
green <exp>
blue <exp>
rgba <exp>Shortcut for
red <exp>
green <exp>
blue <exp>
alpha <exp>
color <exp0>, <exp1>, <exp2>, <exp3>Shortcut for
red exp0
green exp1
blue exp2
alpha exp3
coloredShortcut for
color parm0, parm1, parm2, parm3
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
fragmentProgram <prog>
vertexProgram <prog>
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这个状态的处理了者也
这个megetexture的处理了者也

加载mgr材质文件

来表示材质属性的文件了

加载这个freetype库文件等等

用来渲染这个字体的处理者也!

Registerskins

其实就是加载这个纹理文件,

jpg,bmp,tga文件调用了这个bmp文件,jpg,tga等等文件加载的图像函数....

加载地图文件map,proc等等文件者也

InitRenderCommand

初始化这个渲染列表的命令者也!

typedef enum {

RC_END_OF_LIST,

RC_SET_COLOR,

RC_STRETCH_PIC,
RC_DRAW_SURFS,
RC_DRAW_BUFFER,
RC_SWAP_BUFFERS,
RC_SCREENSHOT
} renderCommand_t;

停止渲染列表

线程的状态

{

渲染场景,

设置颜色

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文件的这个加载以及处理方案,

对于bsp文件中得到了这个光源,entity来抽取出来进行显示了者也
R_ColorShiftLightingBytes( &buf_p[j*3], &image[j*4] );
这个说什么都想象不到的者也
// we are about to upload textures
R_SyncRenderThread();
R_LoadShaders( &header->lumps[LUMP_SHADERS] );
R_LoadLightmaps( &header->lumps[LUMP_LIGHTMAPS] );、
加载光照贴图的处理了者也!
R_LoadShaders( &header->lumps[LUMP_SHADERS] );
R_LoadLightmaps( &header->lumps[LUMP_LIGHTMAPS] );
R_LoadPlanes (&header->lumps[LUMP_PLANES]);
R_LoadFogs( &header->lumps[LUMP_FOGS], &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES] );
R_LoadSurfaces( &header->lumps[LUMP_SURFACES], &header->lumps[LUMP_DRAWVERTS], &header-
>lumps[LUMP_DRAWINDEXES] );
R_LoadMarksurfaces (&header->lumps[LUMP_LEAFSURFACES]);

R_LoadNodesAndLeafs (&header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]);
R_LoadSubmodels (&header->lumps[LUMP_MODELS]);
R_LoadVisibility( &header->lumps[LUMP_VISIBILITY] );
R_LoadEntities( &header->lumps[LUMP_ENTITIES] );
R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] );
加载整个quake3整个的这个流程的处理等等了者也
对于这个分析face,分析光照贴图的分析等等
case MST_PATCH:
ParseMesh ( in, dv, out );
numMeshes++;
break;
case MST_TRIANGLE_SOUP:
ParseTriSurf( in, dv, out, indexes );
numTriSurfs++;
break;
case MST_PLANAR:
ParseFace( in, dv, out, indexes );
numFaces++;
break;
case MST_FLARE:
ParseFlare( in, dv, out, indexes );
numFlares++;
break;
out->colorInt = ColorBytes4 ( shader->fogParms.color[0] * tr.identityLight, 
                          shader->fogParms.color[1] * tr.identityLight, 
                          shader->fogParms.color[2] * tr.identityLight, 1.0 );
R_ColorShiftLightingBytes( &w->lightGridData[i*8], &w->lightGridData[i*8] );
R_ColorShiftLightingBytes( &w->lightGridData[i*8+3], &w->lightGridData[i*8+3] );

对于光照这个偏移了

根据视口的高度,宽度等等来生成

2根据bsp文件中存储的玩家的位置,

来决定玩家的照相机的位置,根据配置文件的存储的这个view视口的

长,宽,远,近平面来生成这个平截头体,来判断这个与

bsp树中的这个
视锥体的六个平面与这个照相机的处理了这个,然后这个六个平面和这个pvs的处理者也

照相机的,这个六个视锥平面,来判断这个与bsp文件的相交处理,

然后相交来进行判断,

来裁剪了这个叶子节点,看不见的model了者也

对于照相机与平面的判定,如果在平面之前,那么渲染前面平面,
在渲染当前的平面
在渲染后面的平面
如果照相机在平面的后面,那么闲渲染这个后面的节点,在渲染中间的节点了,
再渲染前面的节点了,

5、  按从后到前的顺序渲染透明的面列表

点于这个六个平面的相交来进行判断
渲染器前端
R_LoadEntities
加载了这个entity物体了者也
quake3的bsp这个文件里面里面的这个解析出来了这个灯光的处理,灯光的类型,是不是进行这个
然后对于这个灯在渲染时,来进行这个光照
其他的静态的模型乃是使用这个bsp文件里面存储的这个model者也!
对于静态模型的这个处理怎么回事者也!
对于这个模型等等的这个处理怎么来处理的呢?
对于更新的这个entity,游戏逻辑部分发过来的这个粒子系统这个的更新的处理等等
然后bsp file->winding
model->mesh
flare->addflare者也
然后历经这个view的各项裁剪,例如box裁剪,sphere裁剪,等等各项裁剪者也

 render->根据配置文件的来配置opengl->设置视口大小->加载bsp文件

->根据 玩家位置,计算pvs潜在可视集->来找到这个brush的处理等等

+md3 model所有的这个多边形者也!

这里还可以加上了这个玩家武器发出的这个粒子系统者也!

找到玩家所在的房间及邻居房间+敌人模型或表示物体的模型->

  (1)表示房间多边形 数目(2)表示物体的多  边 形,(3)光源数目等等->

(1)将表示房间的多边形与表示物体或人物模型的多边形组合到一起

(2)在确定完玩家潜在能看到的多边形后->

 对于玩家生成平截头体,根据平截头体,再进一步裁剪pvs中看不见的多边形,

  剩下的多边形其实就是一幁所要处理的东西了->

     将多边形进行排序,对不透明的多边形从前往后渲染,从后往前对透明的多边形先渲染->

   当对于多边形阶段完了后,对多边形进行细分->

然后对于这一部分的顶点,进行细分者也
winding细分,mesh细分,网格的细分者也

后端阶段
这个裁剪的处理了,对于在平面的处理
裁剪的curve的处理,对于brush的处理了
R_AddMarkFragments
把这些子弹的痕迹做成了这个段的处理了
 R_BoxSurfaces_r
R_ColorShiftLightingBytes
这个颜色挪移的位了者也
渲染器后端
// all of the information needed by the back end must be
// contained in a backEndData_t.  This entire structure is
// duplicated so the front and back end can run in parallel
// on an SMP machine
typedef struct {
drawSurf_t drawSurfs[MAX_DRAWSURFS];
dlight_t dlights[MAX_DLIGHTS];
trRefEntity_t entities[MAX_ENTITIES];
srfPoly_t *polys;//[MAX_POLYS];
polyVert_t *polyVerts;//[MAX_POLYVERTS];
renderCommandList_t commands;
} backEndData_t;
后置处理的这个多边形数量,
还有这个动态灯的数量
还有这个实体的数量等等
这个渲染命令列表者也
RE_AddDynamicLightToScene
增加动态灯光给场景中
RE_AddLightToScene
RE_AddAdditiveLightToScene
渲染场景的处理了
RE_RenderScene
然后渲染了场景
主要是更新的这个brush model

还有这个md3 model模型

还有光源部分的更新处理等等

我明白了这个后置阶段以后,把模型还有场景的信息全部加载进来之后
然后再进行这个细分的处理,细分到了一定的程度
最后到达这个后端阶段者也
多边形数目
光源数目
实体数目、多边形顶点数目
这就是每一幁所能看见的数目者也
每一次都要更新这个三者,最后消除时,直接把构成这个三个数量清0即可者也

在更新的过程中,

对于动态的灯光的更新和对于运动物体的更新等等的处理

模型如果是水的波浪的话

对于水波浪的移动,根据法线来计算水波的颜色,从而来显示这个水面的颜色者也

波浪阶段wave的形式有几种

sin,三角形,四边形,还有其他的形,来处理者也,

渲染器后端的处理

决定下了这个视口内部要渲染的多边形数目以后

光照的处理

渲染时,光源只有平移,缩放,旋转等状态,

从bsp这个地图的文件中找到了这个light,提取了出来了者也,

然后对于这个light的处理了这样

灯的闪烁,

环境光照

doom3源码中使用的这个环境贴图来进行环境光的处理

游戏中的光照

基本几何体的光照,

更新动态的光源,静态的光源不必要进行更新的处理了者也

主要是brush上面的光照

分为两种情况,

doom3中已经变成了这个逐像素的光照了

灯光
有两种类型的灯,在doom3关卡的编辑器按这个j来处理这个
这个点光源
Projected lights投影的灯
和  点光源
// uplight the entire screen to crutch up not having better blending range
RB_STD_LightScale();
// now draw any non-light dependent shading passes
int processed = RB_STD_DrawShaderPasses( drawSurfs, numDrawSurfs );
// fob and blend lights
RB_STD_FogAllLights();
// now draw any post-processing effects using _currentRender
if ( processed < numDrawSurfs ) {
RB_STD_DrawShaderPasses( drawSurfs+processed, numDrawSurfs-processed );
}
RB_RenderDebugTools( drawSurfs, numDrawSurfs 
对于这个雾的处理和这个混合光的处理了等等

光源上使用一个包围体进行对光源的距离进行遮挡,

阴影,的处理,阴影

光照,

光照的处理了

 根据灯到这个entity的这个网格的距离,来计算这个normal的处理,是否大于小于0,怎么来处理

静态的灯光,和这个静态的网格

动态的灯光

(后端:主要是这个是渲染了)

3 对于光源渲染,预渲染的与实时渲染的相结合。给光源也生成一个平截头体,

给实体也生成一个平截头体,用来判断光源能照到那些实体entity,预渲染与实时渲染都是这么办的。

能照到的物体,使用这个光照方程进行光照的,前向光照的。

把光源照射到物体的反射光,镜面光的值传入到纹理,

从entity的高度图里抽取出法线来,进行渲染的,

对于场景的这个每个face面,判断这个与法线的这个叉积的结果是不是0,从而来判断这个结果,
是不是向上,来判断这个face的面的方向的处理
然后对着进行这个光线与之的判断,
最后,五层贴图的处理,
漫反射,镜面反射,法线等等的一个处理了者也
各种纹理贴图的一个处理了者也
互相组合的一个过程了者也

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

光线追踪的处理
// create two planes orthogonal to each other that intersect along the trace
startDir = end - start;
startDir.Normalize();
startDir.NormalVectors( planes[0].Normal(), planes[1].Normal() );
planes[0][3] = - start * planes[0].Normal();
planes[1][3] = - start * planes[1].Normal();
创建两个平面正视投影,来对于各自插入了光追了者也
开始平面
// create front and end planes so the trace is on the positive sides of both
planes[2] = startDir;
planes[2][3] = - start * planes[2].Normal();
planes[3] = -startDir;
planes[3][3] = - end * planes[3].Normal();

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>

对于这个图像的升采样和这个降采样的处理
dxt压缩的一个处理
遮挡查询的处理了
对于这个opengl的这个错误的各种的信息的输出等等
dds图像的处理了者也
dxt1,dxt5的处理

// If the line from localLight to localView intersects the geometry

// bounding box then the view is inside the infinite shadow projection.

局部的光照了啊?
难道还有这个全局的光照了?

在局部坐标系,和这个全局的坐标系

阴影部分

对于纹理,阴影,混合等等全部的使用了阴影来进行这个的处理了者也

(卡马克反转 阴影体算法.....)

对于阴影椎算法,有两种算法的,z-pass,z-fail算法的,z-fail算法适用于各种情况,而z-fail算法则在某些情况下不通用了者也
在照相机位于这个阴影体外面的时候,这个算法将会产生了这个错误的结果了者也,
我们如果将这个如果深度测试失败的话,则将其写入了模板缓存,同时将这个计数的增加和减少相互替换的话,
那么这种方法就叫做这个z-fail(或者是camack倒置法),这个方法在任何情况下通同的,
但是,z-fail方法必须处理这个在阴影体的前端和这个后端进行闭合,而且对于粒子,公告板等等东西都不顶用的,必须填充这个阴影体的处理了者也
对于所有的物体无限远处,把物体
生成阴影体,
渲染前端面
渲染后端面
渲染对象的轮廓了者也

对于静态的物体,预先计算阴影,动态的生成一个阴影体来生成阴影。

对于动态的阴影

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来进行绘制

动态的这个阴影体的生成部分
由于这个阴影体的这个机器消耗了cpu的处理了,所有必须进行这个优化的
是用sse simd指令集来计算这个三角形是不是朝向了光源
CalculateTriangleFacingCulledStatic
计算灯光的起点,终点,来生成了一条光线
来计算有多少个三角形在灯光的前面,
有多少个三角形在这个灯光的后面了者也
计算三角形是不是是被裁剪了者也
/*
=====================
DynamicShadowVolumeJob
Creates shadow volume indices for a surface that intersects a light.
Optionally also creates new surface indices with just the triangles
inside the light volume. These indices will be unique for a given
light / surface combination.
创建一个阴影体索引,从一个surface灯光,优化,创建
The shadow volume indices are created using the original surface vertices.
However, the indices are setup to be used with a shadow volume vertex buffer
with all vertices duplicated where the even vertices have the same positions
as the surface vertices (at the near cap) and each odd vertex has the
same position as the previous even vertex but is projected to infinity
(the far cap) in the vertex program.
// Calculate the shadow depth bounds.
计算这个阴影的深度盒子
int numLightIndices = 0;
R_ViewPotentiallyInsideInfiniteShadowVolume
If we know that we are "off to the side" of an infinite shadow volume,
we can draw it without caps in Z-pass mode.
判断这个在阴影体的内部还是外部
如果在这个阴影体的外部,我们使用这个z-pass模式来进行这个阴影体的渲染了者也

使用多重jetter来使得阴影模糊

(这个代码的分析包括了这个doom3和doom3bfg的代码分析了者也)

加入了 bloom,抖动等等技术,对于图像的模糊者也

5 对于屏幕的2D部分,也就是屏幕下方的生命值,弹药数目。

武器值等进行渲染。

切换渲染命令为渲染2D。

转换投影方式为正投影,来渲染文字,图片等信息

doom3bfg
是用的这个glsl这个,来进行编程,写的这个shader语句来进行的者也
将cg转化了glsl语句了
将所有的这个参数,矩阵等等的准备工作了者也
加载所有的这个shader文件,然后在进行这个关于shader文件的编译了者也
对于render log文件的处理了者也
这个turque这个对于粉刷道路,种植树木等等这个太好了者也

 doom3中的这个guimodel的处理了

对于图像的处理了,
加上了这个直方图,还有这个
Interaction between static entityDef surfaces and a static lightDef.
Interactions with no lightTris and no shadowTris are still
valid, because they show that a given entityDef / lightDef
do not interact, even though they share one or more areas.
这个裁剪位的处理了
// For each vertex a byte with the bits [0-5] set if the
// vertex is at the back side of the corresponding clip plane.
// If the 'cullBits' pointer equals LIGHT_CULL_ALL_FRONT all
// vertices are at the front of all the clip planes.
// Clip planes in surface space used to calculate the cull bits.
idPlane localClipPlanes[6];
裁剪平面来计算这个裁剪位的处理了
// Pre-generated shadow volumes from dmap are not present in surfaceInteraction_t,
// they are added separately.
// shadow volume triangle surface
如果已经有了阴影的话
如果做空的处理
静态的这个Interaction
// get space from here, if NULL, it is a pre-generated shadow volume from dmap
Determines which triangles of the surface are facing towards the light origin.
The facing array should be allocated with one extra index than
the number of surface triangles, which will be used to handle dangling
edge silhouettes.
决定这个三角形的面是不是朝向了这个灯的起点了,朝向,
如果不朝向光照,那么无需计算这个的光照了者也
如果朝向,那么需要计算这个网格点的光照了者也
全局阴影,局部的阴影的处理了
R_GlobalPointToLocal
const float d = plane.Distance( localLightOrigin );
cullInfo.facing[face] = ( d >= 0.0f );
R_CalcInteractionCullBits
We want to cull a little on the sloppy side, because the pre-clipping
of geometry to the lights in dmap will give many cases that are right
at the border. We throw things out on the border, because if any one
vertex is clearly inside, the entire triangle will be accepted.
=====================
裁剪这个三角形曲面的包围盒
// cull the triangle surface bounding box
R_CreateInteractionLightTris
This is only used for the static interaction case, dynamic interactions
just draw everything and let the GPU deal with it.
The resulting surface will be a subset of the original triangles,
it will never clip triangles, but it may cull on a per-triangle basis.
// if any surface is a shadow-casting perforated or translucent surface, or the
// base surface is suppressed in the view (world weapon shadows) we can't use
// the external shadow optimizations because we can see through 
=====================
R_CreateInteractionShadowVolume
Note that dangling edges outside the light frustum don't make silhouette planes because
a triangle outside the light frustum is considered facing and the "fake triangle" on
the outside of the dangling edge is also set to facing: cullInfo.facing[numFaces] = 1;
预处理
增加阴影
这家伙对于entity来进行排序,判断是不是这个entity,还是这个area,
还是这个动态的东西了者也

// Move the draw surfs to the view.

// Kick off jobs to setup static and dynamic shadow volumes.
让这个job来决定这个是不是静态的阴影或者是动态的阴影椎了
// surface light interactions
// check for a static interaction
检查一个静态的
原来光照这个也是分为静态,动态,还有预处理的啊
// try to do a more precise cull of this model surface to the light
if ( R_CullModelBoundsToLight( lightDef, tri->bounds, entityDef->modelRenderMatrix ) ) {
continue;
}
// Find which of the visible lights contact this entity
//
// If the entity doesn't accept light or cast shadows from any surface,
// this can be skipped.
//
// OPTIMIZE: world areas can assume all referenced lights are used
R_AddSingleModel
May be run in parallel.
Here is where dynamic models actually get instantiated, and necessary
interaction surfaces get created. This is all done on a sort-by-model
basis to keep source data in cache (most likely L2) as any interactions
and shadows are generated, since dynamic models will typically be lit by
two or more lights.
// process the shader expressions for conditionals / color / texcoords
RB_DrawBounds
RB_SimpleSurfaceSetup
// light interaction overdraw
Debugging tool to see how much dynamic range a scene is using.
The greatest of the rgb values at each pixel will be used, withthe resulting color
shading from red at 0 to green at 128 to blue at 255
RB_ShowLightCount
This is a debugging tool that will draw each surface with a color
based on how many lights are effecting it
===============
RB_EnterWeaponDepthHack
RB_TestImage();
RB_ShowPortals();
RB_ShowSilhouette();
RB_ShowDepthBuffer();
RB_ShowIntensity();
RB_ShowCenterOfProjection();
RB_ShowLines();
RB_ShowDebugLines();
RB_ShowDebugText();
RB_ShowDebugPolygons();
RB_ShowTrace( drawSurfs, numDrawSurfs );
RB_ShowLightCount();
RB_ShowTexturePolarity( drawSurfs, numDrawSurfs );
RB_ShowTangentSpace( drawSurfs, numDrawSurfs );
RB_ShowVertexColor( drawSurfs, numDrawSurfs );
RB_ShowTris( drawSurfs, numDrawSurfs );
RB_ShowUnsmoothedTangents( drawSurfs, numDrawSurfs );
RB_ShowSurfaceInfo( drawSurfs, numDrawSurfs );
RB_ShowEdges( drawSurfs, numDrawSurfs );
RB_ShowNormals( drawSurfs, numDrawSurfs );
RB_ShowViewEntitys( backEnd.viewDef->viewEntitys );
RB_ShowLights();
RB_ShowTextureVectors( drawSurfs, numDrawSurfs );
RB_ShowDominantTris( drawSurfs, numDrawSurfs );
TRIANGLE MESH PROCESSING
The functions in this file have no vertex / index count limits.
Truly identical vertexes that match in position, normal, and texcoord can
be merged away.
Vertexes that match in position and texcoord, but have distinct normals will
remain distinct for all purposes.  This is usually a poor choice for models,
as adding a bevel face will not add any more vertexes, and will tend to
look better.
Match in position and normal, but differ in texcoords are referenced together
for calculating tangent vectors for bump mapping.
Artists should take care to have identical texels in all maps (bump/diffuse/specular)
in this case
Vertexes that only match in position are merged for shadow edge finding.
Degenerate triangles.
Overlapped triangles, even if normals or texcoords differ, must be removed.
for the silhoette based stencil shadow algorithm to function properly.
Is this true???
Is the overlapped triangle problem just an example of the trippled edge problem?
Interpenetrating triangles are not currently clipped to surfaces.
Do they effect the shadows?
if vertexes are intended to deform apart, make sure that no vertexes
are on top of each other in the base frame, or the sil edges may be
calculated incorrectly.
We might be able to identify this from topology.
Dangling edges are acceptable, but three way edges are not.
Are any combinations of two way edges unacceptable, like one facing
the backside of the other?
Topology is determined by a collection of triangle indexes.
The edge list can be built up from this, and stays valid even under
deformations.
Somewhat non-intuitively, concave edges cannot be optimized away, or the
stencil shadow algorithm miscounts.
Face normals are needed for generating shadow volumes and for calculating
the silhouette, but they will change with any deformation.
Vertex normals and vertex tangents will change with each deformation,
but they may be able to be transformed instead of recalculated.
bounding volume, both box and sphere will change with deformation.
silhouette indexes
shade indexes
texture indexes
  shade indexes will only be > silhouette indexes if there is facet shading present
lookups from texture to sil and texture to shade?
The normal and tangent vector smoothing is simple averaging, no attempt is
made to better handle the cases where the distribution around the shared vertex
is highly uneven.
  we may get degenerate triangles even with the uniquing and removal
if the vertexes have different texcoords.
/*
=================
R_ReverseTriangles
Lit two sided surfaces need to have the triangles actually duplicated,
they can't just turn on two sided lighting, because the normal and tangents
are wrong on the other sides.
This should be called before R_CleanupTriangles

(机器翻译“

 发光的双面面需要有三角形的复制,

 他们不能只打开双面照明,因为法线和切线都是错的。

 这应该在r_cleanuptriangle之前调用”

=================
反转多边形的处理,
===================
R_InitDrawSurfFromTri
DEFORMED SURFACES
R_CreateVertexNormals
void R_DeriveUnsmoothedNormalsAndTangents( srfTriangles_t * tri ) 
R_DeriveNormalsAndTangents
Derives the normal and orthogonal tangent vectors for the triangle vertices.
For each vertex the normal and tangent vectors are derived from all triangles
using the vertex which results in smooth tangents across the mesh.

( 机器翻译“

  导出三角形顶点的法切向量和正交切向量。

 对于每个顶点,法向量 和 切向量 都是从所有三角形中导出的,

使用顶点,在网格上产生光滑的切线。

     ” )
============
// polygonOffset
// {
// map invertColor( textures/splat )
// blend GL_ZERO GL_ONE_MINUS_SRC
// vertexColor
// clamp
// }
Overlays are used for adding decals on top of dynamic models.
Projects an overlay onto deformable geometry and can be added to
a render entity to allow decals on top of dynamic models.
This does not generate tangent vectors, so it can't be used with
light interaction shaders. Materials for overlays should always
be clamped, because the projected texcoords can run well off the
texture since no new clip vertexes are generated.
Overlays with common materials will be merged together, but additional
overlays will be allocated as needed. The material should not be
one that receives lighting, because no interactions are generated
for these lightweight surfaces.
(机器翻译“”

叠加用于在动态模型的顶部添加贴花。

将覆盖投影到可变形的几何体上,并可以添加到一个渲染实体,

允许在动态模型上贴花。这不会生成切向量,所以不能用光交互着色器。

材料的叠加应该始终夹紧,

因为投影的文本可以很好地运行纹理,

因为没有生成新的剪辑顶点。与普通材料叠加将合并在一起,

但额外将根据需要分配覆盖层。材料不应该是一个接收光照,

因为没有相互作用产生对于这些轻质表面。” )

overlays的这个处理方法了者也

全局坐标系和这个本地的坐标系的处理

阴影椎的裁剪位

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)

对于所有的surface来进行排序
深度
索引的处理
渲染视图了者也
R_RenderView
A view may be either the actual camera view,
a mirror / remote location, or a 3D view on a gui surface.
Parms will typically be allocated with R_FrameAlloc
// make sure that interactions exist for all light / entity combinations that are visible
// add any pre-generated light shadows, and calculate the light shader values
R_AddLights();
// adds ambient surfaces and create any necessary interaction surfaces to add to the light lists
R_AddModels();
// build up the GUIs on world surfaces
R_AddInGameGuis( tr.viewDef->drawSurfs, tr.viewDef->numDrawSurfs );
// any viewLight that didn't have visible surfaces can have it's shadows removed
R_OptimizeViewLightsList();
// sort all the ambient surfaces for translucency ordering
R_SortDrawSurfs( tr.viewDef->drawSurfs, tr.viewDef->numDrawSurfs );
增加了模型,增加灯,增加了这个gui,增加了
排序的处理了
// add the rendering commands for this viewDef
R_AddDrawViewCmd( parms, false );
R_AddDrawPostProcess( parms );
enum cacheType_t {
CACHE_VERTEX,
CACHE_INDEX,
CACHE_JOINT
};
对于幁数据的处理
idFrameData smpFrameData[NUM_FRAME_DATA];
case DI_REMOTE_RENDER:
 R_RemoteRender( drawSurf, const_cast<textureStage_t *>(&stage->texture) );
break;
case DI_MIRROR_RENDER:
 R_MirrorRender( drawSurf, const_cast<textureStage_t *>(&stage->texture), scissor );
break;
case DI_XRAY_RENDER:
  R_XrayRender( drawSurf, const_cast<textureStage_t *>(&stage->texture), scissor );
break;
这个东西真的是不好搞了者也,太难了者也
idCVar r_drawEyeColor( "r_drawEyeColor", "0", CVAR_RENDERER | CVAR_BOOL, "Draw a colored box, red = left eye, blue = right eye, grey = non-stereo" );
idCVar r_motionBlur( "r_motionBlur", "0", CVAR_RENDERER | CVAR_INTEGER | CVAR_ARCHIVE, "1 - 5, log2 of the number of motion blur samples" );
idCVar r_forceZPassStencilShadows( "r_forceZPassStencilShadows", "0", CVAR_RENDERER | CVAR_BOOL, "force Z-pass rendering for performance testing" );
idCVar r_useStencilShadowPreload( "r_useStencilShadowPreload", "1", CVAR_RENDERER | CVAR_BOOL, "use stencil shadow preload algorithm instead of Z-fail" );
idCVar r_skipShaderPasses( "r_skipShaderPasses", "0", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_skipInteractionFastPath( "r_skipInteractionFastPath", "1", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_useLightStencilSelect( "r_useLightStencilSelect", "0", CVAR_RENDERER | CVAR_BOOL, "use stencil select pass" );
这个太复杂了真的是,
idCVar r_drawEyeColor( "r_drawEyeColor", "0", CVAR_RENDERER | CVAR_BOOL, "Draw a colored box, red = left eye, blue = right eye, grey = non-stereo" );
idCVar r_motionBlur( "r_motionBlur", "0", CVAR_RENDERER | CVAR_INTEGER | CVAR_ARCHIVE, "1 - 5, log2 of the number of motion blur samples" );
idCVar r_forceZPassStencilShadows( "r_forceZPassStencilShadows", "0", CVAR_RENDERER | CVAR_BOOL, "force Z-pass rendering for performance testing" );
idCVar r_useStencilShadowPreload( "r_useStencilShadowPreload", "1", CVAR_RENDERER | CVAR_BOOL, "use stencil shadow preload algorithm instead of Z-fail" );
idCVar r_skipShaderPasses( "r_skipShaderPasses", "0", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_skipInteractionFastPath( "r_skipInteractionFastPath", "1", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_useLightStencilSelect( "r_useLightStencilSelect", "0", CVAR_RENDERER | CVAR_BOOL, "use stencil select pass" );
这个怎么来处理了者也,怎么来处理了者也
到我现在看来,
这个真的是必须内功深厚,理解不好处理的者也
必须内功相当的深厚了者也
生成了材质material的这个处理
typedef enum {
TF_LINEAR,
TF_NEAREST,
TF_DEFAULT // use the user-specified r_textureFilter
} textureFilter_t;
typedef enum {
TR_REPEAT,
TR_CLAMP,
TR_CLAMP_TO_ZERO, // guarantee 0,0,0,255 edge for projected textures
TR_CLAMP_TO_ZERO_ALPHA // guarantee 0 alpha edge for projected textures
} textureRepeat_t;
typedef struct {
int stayTime; // msec for no change
int fadeTime; // msec to fade vertex colors over
float start[4]; // vertex color at spawn (possibly out of 0.0 - 1.0 range, will clamp after calc)
float end[4]; // vertex color at fade-out (possibly out of 0.0 - 1.0 range, will clamp after calc)
} decalInfo_t;
对于先是图像,然后再做成了这个material的这个材质的处理了啊
通过过滤,裁剪,替换等等方式来做成了这个方式的处理了啊
enum hdmi3DState_t {
HDMI3D_NOT_SUPPORTED, // The TV doesn't support it
HDMI3D_NOT_ENABLED, // The TV supports it, but the user disabled it
HDMI3D_NOT_ACTIVE, // The TV supports it, and the user enabled it, but it's not active
HDMI3D_ACTIVE
};
enum textureType_t {
TT_DISABLED,
TT_2D,
TT_CUBIC
};
纹理的处理了者也
enum textureFormat_t {
FMT_NONE,
//------------------------
// Standard color image formats
//------------------------
FMT_RGBA8, // 32 bpp
FMT_XRGB8, // 32 bpp
//------------------------
// Alpha channel only
//------------------------
// Alpha ends up being the same as L8A8 in our current implementation, because straight 
// alpha gives 0 for color, but we want 1.
FMT_ALPHA,
//------------------------
// Luminance replicates the value across RGB with a constant A of 255
// Intensity replicates the value across RGBA
//------------------------
FMT_L8A8, // 16 bpp
FMT_LUM8, //  8 bpp
FMT_INT8, //  8 bpp
//------------------------
// Compressed texture formats
//------------------------
FMT_DXT1, // 4 bpp
FMT_DXT5, // 8 bpp
//------------------------
// Depth buffer formats
//------------------------
FMT_DEPTH, // 24 bpp
//------------------------
//
//------------------------
FMT_X16, // 16 bpp
FMT_Y16_X16, // 32 bpp
FMT_RGB565, // 16 bpp
};
int BitsForFormat( textureFormat_t format );
纹理居然有这么多的处理了啊
真的没有想的到的啊!
enum textureColor_t {
CFM_DEFAULT, // RGBA
CFM_NORMAL_DXT5, // XY format and use the fast DXT5 compressor
CFM_YCOCG_DXT5, // convert RGBA to CoCg_Y format
CFM_GREEN_ALPHA // Copy the alpha channel to green
};
typedef struct {
idImage *image;
int size;
int index;
} sortedImage_t;
这个对于材质来进行这个的排序处理了者也
尺寸的处理,
R_ListImages_f
uncompressed
对于这个图像的处理了者也

对于纹理部分

renderStream的处理

无论动静,对于纹理部分,doom3最多包含有有五层纹理,specular,bump,falloff,Diffuse

等等五层的纹理,进入五个顶点编程渲染的状态 GL_VERTEX_PROGRAM_ARB ,

对于NVIDIA的硬件,对于amd的使用amd的硬件扩展,对于其他的硬件,

则使用OpenGL的GL_VERTEX_PROGRAM_ARB扩展,因为这个是OpenGL通用的扩展,通用的

ARB (minimum extensions, no specular highlights, no vertex programs), 
R200 (full featured, almost always single pass interaction rendering), 
ARB2 (floating point fragment shaders, minor quality improvements, always single pass).

对于纹理的状态,具有两层,三层,五层等等纹理状态,

来分别来进行渲染的处理了者也

这个材质图片的处理,

材质居然有如此多的东西啊
加载的mgr材质的文件
将quake3的shader文件转化为了这个材质文件的mgr文件了者也
材质的属性的处理


Image Program Functions

图像的编程函数
 

These can be used anywhere that accepts <map> and can be nested

heightmap(<map>, <float>)Turns a grayscale height map into a normal map. <float> varies the bumpiness
addnormals(<map>, <map>)Adds two normal maps together. Result is normalized.
smoothnormals(<map>)Does a box filter on the normal map, and normalizes the result.
add(<map>, <map>)Adds two images without normalizing the result
scale(<map>, <float> [,float] [,float] [,float])Scales the RGBA by the specified factors. Defaults to 0.
invertAlpha(<map>)Inverts the alpha channel (0 becomes 1, 1 becomes 0)
invertColor(<map>)Inverts the R, G, and B channels
makeIntensity(<map>)Copies the red channel to the G, B, and A channels
makeAlpha(<map>)Sets the alpha channel to an average of the RGB channels. Sets the RGB channels to white.
图像的各项的一个参数了
对于材质的属性的解析
对于图像方程系数的解析,根据这个来对于图像来进行这个反转,旋转,mipmap的处理
缩放等等的处理
半透明的阴影的处理
noFog
mirror
guisurf 
这个材质居然有镜面和阴影的处理怎么来处理呢?
sort <type>
对于材质的这个排序的处理, 
subview, opaque, decal, far, medium, close, almostNearest, nearest, postProcess、
对于这个贴花,透明的处理,中等,远处,关闭
最近的
例如透明的处理
材质居然要进行这个的处理了者也
材质的shader文件有这么多的东西了者也
diffusemap <map>
specularmap <map>
deform <type>
bumpmap <map>
DECAL_MACRO
doom3的 这个太强大了者也!
对于这个doom3的这个阴影的处理,怎么处理的呢?

对于纹理图像的操作方面,卡马克同志直接对图像的值进行了插值,使用镜面光方程,

使得 亮度越高,则表示为一个镜面 ,而不再是使用了光照贴图来表示光照了。

对于图像的处理,doom3中写了直方图处理,伽马等。 

原来doom3对bmp,pcx等图形文件都是直接从调色板中直接寻找到对应的像素,

存放到pic指针指向的内存中去。

加载了bmp,dds,jpg,tga等等文件等,做成了纹理的处理

将图像的数据发送到了幁缓存区,

从而做成纹理缓存者也

,对于游戏中的所有图像,进行图像的检查过滤,对于纹理图像文件,判断是

什么格式例如bmp,jpg,tga,dds,来调用相对应的加载函数。

binaryImage的这个图像的处理了者也
遮挡查询的处理
如果纹理时2d的纹理,那么绑定2d的纹理
如果是3d的纹理,那么绑定3d的纹理
如果是cube纹理,那么绑定cube的纹理
如果纹理经过压缩,那么解压缩这个纹理的处理
然后把这个纹理变成像素格式来存储了
设置纹理的参数的处理了
对于纹理的这个设置的处理了
根据这个纹理的压缩格式来做这个的处理了者也
最后把这个纹理发送到了这个缓存中去,
渲染凹凸映射,宽度,高度,尺寸
映射值在0.01到1.0之间
法线贴图的 处理图像 和
高多边形模型的处理?
这个doom3的命令居然有了这么多的东西了

G

bump映射,凹凸映射
这个乃是高度图的凹凸映射,和法线映射

Two types of images can be used for bump mapping:

 height maps and normal maps. 

这个doom3中的这个全局光照和局部光照的处理等等
( ( R-128 ) / 128, ( G-128 ) / 128, ( B-128 ) / 128 )
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屏幕上玩家的武器数据,以及对于玩家的生命值等等的输出到了屏幕之中了

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值