DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
render.h File Reference
#include "svbsp.h"
#include "r_stats.h"
#include "r_modules.h"
#include "meshqueue.h"
#include "gl_backend.h"
Include dependency graph for render.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  r_framebufferstate_t
struct  r_refdef_scene_t
struct  r_refdef_t
struct  r_refdef_view_t
struct  r_refdef_viewcache_t
struct  r_rendertarget_t
struct  r_viewport_t
struct  r_waterstate_t
struct  r_waterstate_waterplane_t
struct  rmesh_t
struct  rsurfacestate_t

Macros

#define BATCHNEED_ALLOWMULTIDRAW   (1<<10)
#define BATCHNEED_ALWAYSCOPY   (1<< 9)
#define BATCHNEED_ARRAY_LIGHTMAP   (1<< 6)
#define BATCHNEED_ARRAY_NORMAL   (1<< 1)
#define BATCHNEED_ARRAY_SKELETAL   (1<< 7)
#define BATCHNEED_ARRAY_TEXCOORD   (1<< 5)
#define BATCHNEED_ARRAY_VECTOR   (1<< 2)
#define BATCHNEED_ARRAY_VERTEX   (1<< 0)
#define BATCHNEED_ARRAY_VERTEXCOLOR   (1<< 4)
#define BATCHNEED_ARRAY_VERTEXTINTCOLOR   (1<< 3)
#define BATCHNEED_NOGAPS   (1<< 8)
#define BOTTOM_RANGE   96
#define FOGMASKTABLEWIDTH   1024
#define gl_alpha_format   4
#define gl_solid_format   3
#define SHADERPERMUTATION_ALPHAGEN_VERTEX   (1u<<29)
 alphaGen vertex
#define SHADERPERMUTATION_ALPHAKILL   (1u<<22)
 (deferredgeometry) discard pixel if diffuse texture alpha below 0.5, (generic) apply global alpha
#define SHADERPERMUTATION_BLOOM   (1u<<12)
 bloom (postprocessing only)
#define SHADERPERMUTATION_BOUNCEGRID   (1u<<25)
 (lightmap) use Texture_BounceGrid as an additional source of ambient light
#define SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL   (1u<<26)
 (lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standard 4-component
#define SHADERPERMUTATION_COLORMAPPING   (1u<<3)
 indicates this is a colormapped skin
#define SHADERPERMUTATION_COUNT   32u
 size of shaderpermutationinfo array
#define SHADERPERMUTATION_CUBEFILTER   (1u<<10)
 (lightsource) use cubemap light filter
#define SHADERPERMUTATION_DEFERREDLIGHTMAP   (1u<<21)
 (lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping
#define SHADERPERMUTATION_DEPTHRGB   (1u<<28)
 read/write depth values in RGB color coded format for older hardware without depth samplers
#define SHADERPERMUTATION_DIFFUSE   (1u<<0)
 (lightsource) whether to use directional shading
#define SHADERPERMUTATION_FOGALPHAHACK   (1u<<8)
 fog color and density determined by texture mapped on vertical axis
#define SHADERPERMUTATION_FOGHEIGHTTEXTURE   (1u<<7)
 fog color and density determined by texture mapped on vertical axis
#define SHADERPERMUTATION_FOGINSIDE   (1u<<5)
 tint the color by fog color or black if using additive blend mode
#define SHADERPERMUTATION_FOGOUTSIDE   (1u<<6)
 tint the color by fog color or black if using additive blend mode
#define SHADERPERMUTATION_GAMMARAMPS   (1u<<9)
 gamma (postprocessing only)
#define SHADERPERMUTATION_GLOW   (1u<<11)
 (lightmap) blend in an additive glow texture
#define SHADERPERMUTATION_NORMALMAPSCROLLBLEND   (1u<<24)
 (water) counter-direction normalmaps scrolling
#define SHADERPERMUTATION_OCCLUDE   (1u<<31)
 use occlusion buffer for corona
#define SHADERPERMUTATION_OFFSETMAPPING   (1u<<16)
 adjust texcoords to roughly simulate a displacement mapped surface
#define SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING   (1u<<17)
 adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also be set!)
#define SHADERPERMUTATION_POSTPROCESSING   (1u<<14)
 user defined postprocessing (postprocessing only)
#define SHADERPERMUTATION_REFLECTCUBE   (1u<<23)
 fake reflections using global cubemap (not HDRI light probe)
#define SHADERPERMUTATION_REFLECTION   (1u<<15)
 normalmap-perturbed reflection of the scene infront of the surface, preformed as an overlay on the surface
#define SHADERPERMUTATION_SATURATION   (1u<<4)
 saturation (postprocessing only)
#define SHADERPERMUTATION_SHADOWMAP2D   (1u<<18)
 (lightsource) use shadowmap texture as light filter
#define SHADERPERMUTATION_SHADOWMAPORTHO   (1u<<20)
 (lightsource) use orthographic shadowmap projection
#define SHADERPERMUTATION_SHADOWMAPVSDCT   (1u<<19)
 (lightsource) use virtual shadow depth cube texture for shadowmap indexing
#define SHADERPERMUTATION_SKELETAL   (1u<<30)
 (skeletal models) use skeletal matrices to deform vertices (gpu-skinning)
#define SHADERPERMUTATION_SPECULAR   (1u<<13)
 (lightsource or deluxemapping) render specular effects
#define SHADERPERMUTATION_TRIPPY   (1u<<27)
 use trippy vertex shader effect
#define SHADERPERMUTATION_VERTEXTEXTUREBLEND   (1u<<1)
 indicates this is a two-layer material blend based on vertex alpha (q3bsp)
#define SHADERPERMUTATION_VIEWTINT   (1u<<2)
 view tint (postprocessing only), use vertex colors (generic only)
#define TOP_RANGE   16

Enumerations

enum  glsl_attrib {
  GLSLATTRIB_POSITION = 0 , GLSLATTRIB_COLOR = 1 , GLSLATTRIB_TEXCOORD0 = 2 , GLSLATTRIB_TEXCOORD1 = 3 ,
  GLSLATTRIB_TEXCOORD2 = 4 , GLSLATTRIB_TEXCOORD3 = 5 , GLSLATTRIB_TEXCOORD4 = 6 , GLSLATTRIB_TEXCOORD5 = 7 ,
  GLSLATTRIB_TEXCOORD6 = 8 , GLSLATTRIB_TEXCOORD7 = 9
}
enum  r_bufferdata_type_t {
  R_BUFFERDATA_VERTEX , R_BUFFERDATA_INDEX16 , R_BUFFERDATA_INDEX32 , R_BUFFERDATA_UNIFORM ,
  R_BUFFERDATA_COUNT
}
 enum of the various types of hardware buffer object used in rendering note that the r_buffermegs[] array must be maintained to match this More...
enum  r_refdef_scene_type_t { RST_CLIENT , RST_MENU , RST_COUNT }
enum  r_viewport_type_t {
  R_VIEWPORTTYPE_ORTHO , R_VIEWPORTTYPE_PERSPECTIVE , R_VIEWPORTTYPE_PERSPECTIVE_INFINITEFARCLIP , R_VIEWPORTTYPE_PERSPECTIVECUBESIDE ,
  R_VIEWPORTTYPE_TOTAL
}
enum  rsurfacepass_t { RSURFPASS_BASE , RSURFPASS_BACKGROUND , RSURFPASS_RTLIGHT , RSURFPASS_DEFERREDGEOMETRY }
enum  shaderlanguage_t { SHADERLANGUAGE_GLSL , SHADERLANGUAGE_COUNT }
enum  shadermode_t {
  SHADERMODE_GENERIC , SHADERMODE_POSTPROCESS , SHADERMODE_DEPTH_OR_SHADOW , SHADERMODE_FLATCOLOR ,
  SHADERMODE_VERTEXCOLOR , SHADERMODE_LIGHTMAP , SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE , SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE ,
  SHADERMODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP , SHADERMODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR , SHADERMODE_LIGHTGRID , SHADERMODE_LIGHTDIRECTION ,
  SHADERMODE_LIGHTSOURCE , SHADERMODE_REFRACTION , SHADERMODE_WATER , SHADERMODE_DEFERREDGEOMETRY ,
  SHADERMODE_DEFERREDLIGHTSOURCE , SHADERMODE_COUNT
}
 this enum selects which of the glslshadermodeinfo entries should be used More...

Functions

void CL_VM_DrawHud (double frametime)
qbool CL_VM_UpdateView (double frametime)
dp_font_tFindFont (const char *title, qbool allocate_new)
void FOG_clear (void)
void Font_Init (void)
void gl_backend_init (void)
void GL_Draw_Init (void)
void GL_Main_Init (void)
void GL_Surf_Init (void)
void LoadFont (qbool override, const char *name, dp_font_t *fnt, float scale, float voffset)
void Mod_RenderInit (void)
void R_AnimCache_CacheVisibleEntities (void)
 generate animcache data for all entities marked visible
void R_AnimCache_ClearCache (void)
 clear the animcache pointers on all known render entities
void R_AnimCache_Free (void)
 free all R_AnimCache memory
qbool R_AnimCache_GetEntity (entity_render_t *ent, qbool wantnormals, qbool wanttangents)
 get the skeletal data or cached animated mesh data for an entity (optionally with normals and tangents)
void R_BufferData_NewFrame (void)
 begin a new frame (recycle old buffers)
void R_BufferData_Reset (void)
 free all dynamic vertex/index/uniform buffers
r_meshbuffer_tR_BufferData_Store (size_t size, const void *data, r_bufferdata_type_t type, int *returnbufferoffset)
 request space in a vertex/index/uniform buffer for the chosen data, returns the buffer pointer and offset, always successful
void R_BuildLightMap (const entity_render_t *ent, msurface_t *surface, int combine)
void R_CalcBeam_Vertex3f (float *vert, const float *org1, const float *org2, float width)
void R_CalcSprite_Vertex3f (float *vertex3f, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2)
qbool R_CanSeeBox (int numsamples, vec_t eyejitter, vec_t entboxenlarge, vec_t entboxexpand, vec_t pad, vec3_t eye, vec3_t entboxmins, vec3_t entboxmaxs)
qbool R_CompileShader_CheckStaticParms (void)
qbool R_CullBox (const vec3_t mins, const vec3_t maxs, int numplanes, const mplane_t *planes)
qbool R_CullFrustum (const vec3_t mins, const vec3_t maxs)
void R_DebugLine (vec3_t start, vec3_t end)
void R_DecalSystem_Reset (decalsystem_t *decalsystem)
void R_DecalSystem_SplatEntities (const vec3_t org, const vec3_t normal, float r, float g, float b, float a, float s1, float t1, float s2, float t2, float size)
void R_DrawCustomSurface (skinframe_t *skinframe, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qbool writedepth, qbool prepass, qbool ui)
void R_DrawCustomSurface_Texture (texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qbool writedepth, qbool prepass, qbool ui)
void R_DrawExplosions (void)
void R_DrawModelSurfaces (entity_render_t *ent, qbool skysurfaces, qbool writedepth, qbool depthonly, qbool debug, qbool prepass, qbool ui)
void R_DrawParticles (void)
void R_DrawPortals (void)
void R_Explosion_Init (void)
void R_FillColors (float *out, int verts, float r, float g, float b, float a)
voidR_FrameData_Alloc (size_t size)
 allocate some temporary memory for your purposes
void R_FrameData_NewFrame (void)
 prepare for a new frame, recycles old buffers if a resize occurred previously
void R_FrameData_Reset (void)
 free all R_FrameData memory
void R_FrameData_ReturnToMark (void)
 discard recent memory allocations (rewind to marker)
void R_FrameData_SetMark (void)
 set a marker that allows you to discard the following temporary memory allocations
voidR_FrameData_Store (size_t size, void *data)
 allocate some temporary memory and copy this data into it
rtexture_tR_GetCubemap (const char *basename)
texture_tR_GetCurrentTexture (texture_t *t)
r_refdef_scene_tR_GetScenePointer (r_refdef_scene_type_t scenetype)
void R_GLSL_Restart_f (cmd_state_t *cmd)
void R_HDR_UpdateIrisAdaptation (const vec3_t point)
void R_LightningBeams_Init (void)
void R_Mesh_AddBrushMeshFromPlanes (rmesh_t *mesh, int numplanes, mplane_t *planes)
void R_Mesh_AddPolygon3f (rmesh_t *mesh, int numvertices, float *vertex3f)
void R_Model_Sprite_Draw (entity_render_t *ent)
void R_ModulateColors (float *in, float *out, int verts, float r, float g, float b)
void R_NewExplosion (const vec3_t org)
void R_Particles_Init (void)
void R_RenderScene (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
void R_RenderTarget_FreeUnused (qbool force)
r_rendertarget_tR_RenderTarget_Get (int texturewidth, int textureheight, textype_t depthtextype, qbool depthisrenderbuffer, textype_t colortextype0, textype_t colortextype1, textype_t colortextype2, textype_t colortextype3)
void R_RenderView (int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int x, int y, int width, int height)
void R_RenderView_UpdateViewVectors (void)
void R_RenderWaterPlanes (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
void R_ResetSkyBox (void)
void R_ResetViewRendering2D (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
void R_ResetViewRendering2D_Common (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight, float x2, float y2)
void R_ResetViewRendering3D (int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
void R_SelectScene (r_refdef_scene_type_t scenetype)
int R_SetSkyBox (const char *sky)
void R_SetupShader_DeferredLight (const rtlight_t *rtlight)
void R_SetupShader_DepthOrShadow (qbool notrippy, qbool depthrgb, qbool skeletal)
void R_SetupShader_Generic (rtexture_t *t, qbool usegamma, qbool notrippy, qbool suppresstexalpha)
void R_SetupShader_Generic_NoTexture (qbool usegamma, qbool notrippy)
void R_SetupShader_Surface (const float ambientcolor[3], const float diffusecolor[3], const float specularcolor[3], rsurfacepass_t rsurfacepass, int texturenumsurfaces, const msurface_t **texturesurfacelist, void *waterplane, qbool notrippy, qbool ui)
void R_SetupView (qbool allowwaterclippingplane, int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
void R_Shadow_EditLights_DrawSelectedLightProperties (void)
int R_Shadow_GetRTLightInfo (unsigned int lightindex, float *origin, float *radius, float *color)
void R_Shadow_Init (void)
void R_Shadow_UpdateBounceGridTexture (void)
skinframe_tR_SkinFrame_Find (const char *name, int textureflags, int comparewidth, int compareheight, int comparecrc, qbool add)
skinframe_tR_SkinFrame_FindNextByName (skinframe_t *last, const char *name)
skinframe_tR_SkinFrame_LoadExternal (const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
skinframe_tR_SkinFrame_LoadExternal_SkinFrame (skinframe_t *skinframe, const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
skinframe_tR_SkinFrame_LoadInternal8bit (const char *name, int textureflags, const unsigned char *skindata, int width, int height, const unsigned int *palette, const unsigned int *alphapalette)
skinframe_tR_SkinFrame_LoadInternalBGRA (const char *name, int textureflags, const unsigned char *skindata, int width, int height, int comparewidth, int compareheight, int comparecrc, qbool sRGB)
skinframe_tR_SkinFrame_LoadInternalQuake (const char *name, int textureflags, int loadpantsandshirt, int loadglowtexture, const unsigned char *skindata, int width, int height)
skinframe_tR_SkinFrame_LoadInternalUsingTexture (const char *name, int textureflags, rtexture_t *tex, int width, int height, qbool sRGB)
skinframe_tR_SkinFrame_LoadMissing (void)
skinframe_tR_SkinFrame_LoadNoTexture (void)
void R_SkinFrame_MarkUsed (skinframe_t *skinframe)
void R_SkinFrame_PrepareForPurge (void)
void R_SkinFrame_Purge (void)
void R_SkinFrame_PurgeSkinFrame (skinframe_t *skinframe)
void R_Sky (void)
void R_Sky_Init (void)
void R_SkyStartFrame (void)
void R_Stain (const vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, int cr2, int cg2, int cb2, int ca2)
void R_Textures_Init (void)
void R_TimeReport (const char *name)
void R_UpdateFog (void)
void R_UpdateVariables (void)
void R_View_WorldVisibility (qbool forcenovis)
void R_Water_AddWaterPlane (msurface_t *surface, int entno)
void Render_Init (void)
void RSurf_ActiveCustomEntity (const matrix4x4_t *matrix, const matrix4x4_t *inversematrix, int entflags, double shadertime, float r, float g, float b, float a, int numvertices, const float *vertex3f, const float *texcoord2f, const float *normal3f, const float *svector3f, const float *tvector3f, const float *color4f, int numtriangles, const int *element3i, const unsigned short *element3s, qbool wantnormals, qbool wanttangents)
void RSurf_ActiveModelEntity (const entity_render_t *ent, qbool wantnormals, qbool wanttangents, qbool prepass)
void RSurf_DrawBatch (void)
float RSurf_FogPoint (const float *v)
float RSurf_FogVertex (const float *v)
void RSurf_PrepareVerticesForBatch (int batchneed, int texturenumsurfaces, const msurface_t **texturesurfacelist)
void RSurf_SetupDepthAndCulling (bool ui)
void RSurf_UploadBuffersForBatch (void)
void Sbar_Init (void)
void SCR_DrawConsole (void)
void SHOWLMP_decodehide (void)
void SHOWLMP_decodeshow (void)
void SHOWLMP_drawall (void)

Variables

cvar_t cl_deathfade
cvar_t developer_texturelogging
cvar_t gl_flashblend
cvar_t gl_polyblend
float ixtable [4096]
cvar_t r_ambient
cvar_t r_draw2d
qbool r_draw2d_force
cvar_t r_drawentities
cvar_t r_drawviewmodel
cvar_t r_drawworld
cvar_t r_dynamic
r_framebufferstate_t r_fb
cvar_t r_fullbright
cvar_t r_fxaa
cvar_t r_glsl_deluxemapping
cvar_t r_glsl_offsetmapping
cvar_t r_glsl_offsetmapping_lod
cvar_t r_glsl_offsetmapping_lod_distance
cvar_t r_glsl_offsetmapping_reliefmapping
cvar_t r_glsl_offsetmapping_scale
cvar_t r_lerplightstyles
cvar_t r_lerpmodels
cvar_t r_lerpsprites
mempool_tr_main_mempool
unsigned int r_maxqueries
cvar_t r_nearclip
cvar_t r_novis
unsigned int r_numqueries
cvar_t r_q1bsp_lightmap_updates_combine
cvar_t r_q1bsp_lightmap_updates_combine_full_texture
cvar_t r_q1bsp_lightmap_updates_enabled
cvar_t r_q1bsp_lightmap_updates_hidden_surfaces
cvar_t r_q3bsp_renderskydepth
unsigned int r_queries [MAX_OCCLUSION_QUERIES]
r_refdef_t r_refdef
cvar_t r_render
cvar_t r_renderview
const float r_screenvertex3f [12]
 vertex coordinates for a quad that covers the screen exactly
rtexture_tr_shadow_attenuation2dtexture
rtexture_tr_shadow_attenuation3dtexture
rtexture_tr_shadow_attenuationgradienttexture
float r_shadow_lightshadowmap_parameters [4]
float r_shadow_lightshadowmap_texturescale [4]
float r_shadow_modelshadowmap_parameters [4]
float r_shadow_modelshadowmap_texturescale [4]
int r_shadow_prepass_height
int r_shadow_prepass_width
rtexture_tr_shadow_prepassgeometrydepthbuffer
rtexture_tr_shadow_prepassgeometrynormalmaptexture
rtexture_tr_shadow_prepasslightingdiffusetexture
rtexture_tr_shadow_prepasslightingspeculartexture
rtexture_tr_shadow_shadowmap2ddepthbuffer
rtexture_tr_shadow_shadowmap2ddepthtexture
matrix4x4_t r_shadow_shadowmapmatrix
qbool r_shadow_shadowmapvsdct
rtexture_tr_shadow_shadowmapvsdcttexture
qbool r_shadow_usingdeferredprepass
qbool r_shadow_usingshadowmap2d
qbool r_shadow_usingshadowmaportho
rtexture_tr_shadow_viewcolortexture
rtexture_tr_shadow_viewdepthtexture
int r_shadow_viewfbo
int r_shadow_viewheight
int r_shadow_viewwidth
int r_shadow_viewx
int r_shadow_viewy
cvar_t r_shadows
cvar_t r_shadows_castfrombmodels
cvar_t r_shadows_darken
cvar_t r_shadows_drawafterrtlighting
cvar_t r_shadows_focus
cvar_t r_shadows_shadowmapbias
cvar_t r_shadows_shadowmapscale
cvar_t r_shadows_throwdirection
cvar_t r_shadows_throwdistance
cvar_t r_showcollisionbrushes
cvar_t r_showcollisionbrushes_polygonfactor
cvar_t r_showcollisionbrushes_polygonoffset
cvar_t r_showdisabledepthtest
cvar_t r_showlighting
cvar_t r_shownormals
cvar_t r_showoverdraw
cvar_t r_showparticleedges
cvar_t r_showspriteedges
cvar_t r_showtris
cvar_t r_sky
cvar_t r_sky_scissor
cvar_t r_skyscroll1
cvar_t r_skyscroll2
cvar_t r_smoothnormals_areaweighting
cvar_t r_speeds
svbsp_t r_svbsp
 shadow volume bsp struct with automatically growing nodes buffer
cvar_t r_test
rtexture_tr_texture_black
rtexture_tr_texture_blanknormalmap
rtexture_tr_texture_fogattenuation
rtexture_tr_texture_fogheighttexture
rtexture_tr_texture_grey128
rtexture_tr_texture_normalizationcube
rtexture_tr_texture_notexture
rtexture_tr_texture_white
rtexture_tr_texture_whitecube
int r_textureframe
 used only by R_GetCurrentTexture, incremented per view and per UI render
int r_timereport_active
cvar_t r_transparent_alphatocoverage
cvar_t r_transparent_sortarraysize
cvar_t r_transparent_sortmaxdist
cvar_t r_transparent_sortmindist
cvar_t r_transparent_sortsurfacesbynearest
cvar_t r_transparent_useplanardistance
cvar_t r_trippy
cvar_t r_viewfbo
cvar_t r_wateralpha
cvar_t r_waterscroll
cvar_t r_waterwarp
rsurfacestate_t rsurface
int skyrenderlater
int skyrendermasked
int skyscissor [4]

Macro Definition Documentation

◆ BATCHNEED_ALLOWMULTIDRAW

◆ BATCHNEED_ALWAYSCOPY

#define BATCHNEED_ALWAYSCOPY   (1<< 9)

◆ BATCHNEED_ARRAY_LIGHTMAP

#define BATCHNEED_ARRAY_LIGHTMAP   (1<< 6)

Definition at line 791 of file render.h.

Referenced by R_SetupShader_Surface(), and RSurf_PrepareVerticesForBatch().

◆ BATCHNEED_ARRAY_NORMAL

#define BATCHNEED_ARRAY_NORMAL   (1<< 1)

◆ BATCHNEED_ARRAY_SKELETAL

#define BATCHNEED_ARRAY_SKELETAL   (1<< 7)

Definition at line 792 of file render.h.

Referenced by RSurf_PrepareVerticesForBatch().

◆ BATCHNEED_ARRAY_TEXCOORD

#define BATCHNEED_ARRAY_TEXCOORD   (1<< 5)

Definition at line 790 of file render.h.

Referenced by R_SetupShader_Surface(), and RSurf_PrepareVerticesForBatch().

◆ BATCHNEED_ARRAY_VECTOR

#define BATCHNEED_ARRAY_VECTOR   (1<< 2)

◆ BATCHNEED_ARRAY_VERTEX

◆ BATCHNEED_ARRAY_VERTEXCOLOR

#define BATCHNEED_ARRAY_VERTEXCOLOR   (1<< 4)

◆ BATCHNEED_ARRAY_VERTEXTINTCOLOR

#define BATCHNEED_ARRAY_VERTEXTINTCOLOR   (1<< 3)

Definition at line 788 of file render.h.

◆ BATCHNEED_NOGAPS

◆ BOTTOM_RANGE

#define BOTTOM_RANGE   96

Definition at line 183 of file render.h.

Referenced by M_Setup_Draw().

◆ FOGMASKTABLEWIDTH

#define FOGMASKTABLEWIDTH   1024

◆ gl_alpha_format

#define gl_alpha_format   4

Definition at line 498 of file render.h.

◆ gl_solid_format

#define gl_solid_format   3

Definition at line 497 of file render.h.

◆ SHADERPERMUTATION_ALPHAGEN_VERTEX

#define SHADERPERMUTATION_ALPHAGEN_VERTEX   (1u<<29)

alphaGen vertex

Definition at line 102 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_ALPHAKILL

#define SHADERPERMUTATION_ALPHAKILL   (1u<<22)

(deferredgeometry) discard pixel if diffuse texture alpha below 0.5, (generic) apply global alpha

Definition at line 95 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_BLOOM

#define SHADERPERMUTATION_BLOOM   (1u<<12)

bloom (postprocessing only)

Definition at line 85 of file render.h.

Referenced by R_BlendView().

◆ SHADERPERMUTATION_BOUNCEGRID

#define SHADERPERMUTATION_BOUNCEGRID   (1u<<25)

(lightmap) use Texture_BounceGrid as an additional source of ambient light

Definition at line 98 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL

#define SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL   (1u<<26)

(lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standard 4-component

Definition at line 99 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_COLORMAPPING

#define SHADERPERMUTATION_COLORMAPPING   (1u<<3)

indicates this is a colormapped skin

Definition at line 76 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_COUNT

#define SHADERPERMUTATION_COUNT   32u

size of shaderpermutationinfo array

Definition at line 105 of file render.h.

Referenced by R_GLSL_CompilePermutation(), R_GLSL_DumpShader_f(), and R_SetupShader_SetPermutationGLSL().

◆ SHADERPERMUTATION_CUBEFILTER

#define SHADERPERMUTATION_CUBEFILTER   (1u<<10)

(lightsource) use cubemap light filter

Definition at line 83 of file render.h.

Referenced by R_SetupShader_DeferredLight(), and R_SetupShader_Surface().

◆ SHADERPERMUTATION_DEFERREDLIGHTMAP

#define SHADERPERMUTATION_DEFERREDLIGHTMAP   (1u<<21)

(lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping

Definition at line 94 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_DEPTHRGB

#define SHADERPERMUTATION_DEPTHRGB   (1u<<28)

read/write depth values in RGB color coded format for older hardware without depth samplers

Definition at line 101 of file render.h.

Referenced by R_SetupShader_DeferredLight(), R_SetupShader_DepthOrShadow(), and R_SetupShader_Surface().

◆ SHADERPERMUTATION_DIFFUSE

#define SHADERPERMUTATION_DIFFUSE   (1u<<0)

(lightsource) whether to use directional shading

Definition at line 73 of file render.h.

Referenced by R_SetupShader_DeferredLight(), R_SetupShader_Generic(), and R_SetupShader_Surface().

◆ SHADERPERMUTATION_FOGALPHAHACK

#define SHADERPERMUTATION_FOGALPHAHACK   (1u<<8)

fog color and density determined by texture mapped on vertical axis

Definition at line 81 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_FOGHEIGHTTEXTURE

#define SHADERPERMUTATION_FOGHEIGHTTEXTURE   (1u<<7)

fog color and density determined by texture mapped on vertical axis

Definition at line 80 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_FOGINSIDE

#define SHADERPERMUTATION_FOGINSIDE   (1u<<5)

tint the color by fog color or black if using additive blend mode

Definition at line 78 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_FOGOUTSIDE

#define SHADERPERMUTATION_FOGOUTSIDE   (1u<<6)

tint the color by fog color or black if using additive blend mode

Definition at line 79 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_GAMMARAMPS

#define SHADERPERMUTATION_GAMMARAMPS   (1u<<9)

gamma (postprocessing only)

Definition at line 82 of file render.h.

Referenced by R_BlendView(), and R_SetupShader_Generic().

◆ SHADERPERMUTATION_GLOW

#define SHADERPERMUTATION_GLOW   (1u<<11)

(lightmap) blend in an additive glow texture

Definition at line 84 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_NORMALMAPSCROLLBLEND

#define SHADERPERMUTATION_NORMALMAPSCROLLBLEND   (1u<<24)

(water) counter-direction normalmaps scrolling

Definition at line 97 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_OCCLUDE

#define SHADERPERMUTATION_OCCLUDE   (1u<<31)

use occlusion buffer for corona

Definition at line 104 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_OFFSETMAPPING

#define SHADERPERMUTATION_OFFSETMAPPING   (1u<<16)

adjust texcoords to roughly simulate a displacement mapped surface

Definition at line 89 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING

#define SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING   (1u<<17)

adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also be set!)

Definition at line 90 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_POSTPROCESSING

#define SHADERPERMUTATION_POSTPROCESSING   (1u<<14)

user defined postprocessing (postprocessing only)

Definition at line 87 of file render.h.

Referenced by R_BlendView().

◆ SHADERPERMUTATION_REFLECTCUBE

#define SHADERPERMUTATION_REFLECTCUBE   (1u<<23)

fake reflections using global cubemap (not HDRI light probe)

Definition at line 96 of file render.h.

Referenced by R_SetupShader_Generic(), and R_SetupShader_Surface().

◆ SHADERPERMUTATION_REFLECTION

#define SHADERPERMUTATION_REFLECTION   (1u<<15)

normalmap-perturbed reflection of the scene infront of the surface, preformed as an overlay on the surface

Definition at line 88 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_SATURATION

#define SHADERPERMUTATION_SATURATION   (1u<<4)

saturation (postprocessing only)

Definition at line 77 of file render.h.

Referenced by R_BlendView().

◆ SHADERPERMUTATION_SHADOWMAP2D

#define SHADERPERMUTATION_SHADOWMAP2D   (1u<<18)

(lightsource) use shadowmap texture as light filter

Definition at line 91 of file render.h.

Referenced by R_SetupShader_DeferredLight(), and R_SetupShader_Surface().

◆ SHADERPERMUTATION_SHADOWMAPORTHO

#define SHADERPERMUTATION_SHADOWMAPORTHO   (1u<<20)

(lightsource) use orthographic shadowmap projection

Definition at line 93 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_SHADOWMAPVSDCT

#define SHADERPERMUTATION_SHADOWMAPVSDCT   (1u<<19)

(lightsource) use virtual shadow depth cube texture for shadowmap indexing

Definition at line 92 of file render.h.

Referenced by R_SetupShader_DeferredLight(), and R_SetupShader_Surface().

◆ SHADERPERMUTATION_SKELETAL

#define SHADERPERMUTATION_SKELETAL   (1u<<30)

(skeletal models) use skeletal matrices to deform vertices (gpu-skinning)

Definition at line 103 of file render.h.

Referenced by R_SetupShader_DepthOrShadow(), and R_SetupShader_Surface().

◆ SHADERPERMUTATION_SPECULAR

#define SHADERPERMUTATION_SPECULAR   (1u<<13)

(lightsource or deluxemapping) render specular effects

Definition at line 86 of file render.h.

Referenced by R_SetupShader_DeferredLight(), and R_SetupShader_Surface().

◆ SHADERPERMUTATION_TRIPPY

#define SHADERPERMUTATION_TRIPPY   (1u<<27)

use trippy vertex shader effect

Definition at line 100 of file render.h.

Referenced by R_SetupShader_DepthOrShadow(), R_SetupShader_Generic(), and R_SetupShader_Surface().

◆ SHADERPERMUTATION_VERTEXTEXTUREBLEND

#define SHADERPERMUTATION_VERTEXTEXTUREBLEND   (1u<<1)

indicates this is a two-layer material blend based on vertex alpha (q3bsp)

Definition at line 74 of file render.h.

Referenced by R_SetupShader_Surface().

◆ SHADERPERMUTATION_VIEWTINT

#define SHADERPERMUTATION_VIEWTINT   (1u<<2)

view tint (postprocessing only), use vertex colors (generic only)

Definition at line 75 of file render.h.

Referenced by R_BlendView(), and R_SetupShader_Generic().

◆ TOP_RANGE

#define TOP_RANGE   16

Definition at line 182 of file render.h.

Referenced by M_Setup_Draw().

Enumeration Type Documentation

◆ glsl_attrib

Enumerator
GLSLATTRIB_POSITION 
GLSLATTRIB_COLOR 
GLSLATTRIB_TEXCOORD0 
GLSLATTRIB_TEXCOORD1 
GLSLATTRIB_TEXCOORD2 
GLSLATTRIB_TEXCOORD3 
GLSLATTRIB_TEXCOORD4 
GLSLATTRIB_TEXCOORD5 
GLSLATTRIB_TEXCOORD6 
GLSLATTRIB_TEXCOORD7 

Definition at line 27 of file render.h.

28{
39}
@ GLSLATTRIB_TEXCOORD4
Definition render.h:35
@ GLSLATTRIB_TEXCOORD3
Definition render.h:34
@ GLSLATTRIB_TEXCOORD7
Definition render.h:38
@ GLSLATTRIB_COLOR
Definition render.h:30
@ GLSLATTRIB_TEXCOORD6
Definition render.h:37
@ GLSLATTRIB_TEXCOORD1
Definition render.h:32
@ GLSLATTRIB_TEXCOORD5
Definition render.h:36
@ GLSLATTRIB_TEXCOORD0
Definition render.h:31
@ GLSLATTRIB_POSITION
Definition render.h:29
@ GLSLATTRIB_TEXCOORD2
Definition render.h:33

◆ r_bufferdata_type_t

enum of the various types of hardware buffer object used in rendering note that the r_buffermegs[] array must be maintained to match this

Enumerator
R_BUFFERDATA_VERTEX 
R_BUFFERDATA_INDEX16 

vertex buffer

R_BUFFERDATA_INDEX32 

index buffer - 16bit (because D3D cares)

R_BUFFERDATA_UNIFORM 

index buffer - 32bit (because D3D cares)

R_BUFFERDATA_COUNT 

uniform buffer

how many kinds of buffer we have

Definition at line 523 of file render.h.

524{
530}
@ R_BUFFERDATA_VERTEX
Definition render.h:525
@ R_BUFFERDATA_COUNT
uniform buffer
Definition render.h:529
@ R_BUFFERDATA_UNIFORM
index buffer - 32bit (because D3D cares)
Definition render.h:528
@ R_BUFFERDATA_INDEX32
index buffer - 16bit (because D3D cares)
Definition render.h:527
@ R_BUFFERDATA_INDEX16
vertex buffer
Definition render.h:526

◆ r_refdef_scene_type_t

Enumerator
RST_CLIENT 
RST_MENU 
RST_COUNT 

Definition at line 222 of file render.h.

222 {
224 RST_MENU,
r_refdef_scene_type_t
Definition render.h:222
@ RST_CLIENT
Definition render.h:223
@ RST_COUNT
Definition render.h:225
@ RST_MENU
Definition render.h:224

◆ r_viewport_type_t

Enumerator
R_VIEWPORTTYPE_ORTHO 
R_VIEWPORTTYPE_PERSPECTIVE 
R_VIEWPORTTYPE_PERSPECTIVE_INFINITEFARCLIP 
R_VIEWPORTTYPE_PERSPECTIVECUBESIDE 
R_VIEWPORTTYPE_TOTAL 

Definition at line 228 of file render.h.

229{
235}
@ R_VIEWPORTTYPE_PERSPECTIVE_INFINITEFARCLIP
Definition render.h:232
@ R_VIEWPORTTYPE_ORTHO
Definition render.h:230
@ R_VIEWPORTTYPE_TOTAL
Definition render.h:234
@ R_VIEWPORTTYPE_PERSPECTIVECUBESIDE
Definition render.h:233
@ R_VIEWPORTTYPE_PERSPECTIVE
Definition render.h:231

◆ rsurfacepass_t

Enumerator
RSURFPASS_BASE 
RSURFPASS_BACKGROUND 
RSURFPASS_RTLIGHT 
RSURFPASS_DEFERREDGEOMETRY 

Definition at line 802 of file render.h.

803{
808}
@ RSURFPASS_BACKGROUND
Definition render.h:805
@ RSURFPASS_BASE
Definition render.h:804
@ RSURFPASS_DEFERREDGEOMETRY
Definition render.h:807
@ RSURFPASS_RTLIGHT
Definition render.h:806

◆ shaderlanguage_t

Enumerator
SHADERLANGUAGE_GLSL 
SHADERLANGUAGE_COUNT 

Definition at line 42 of file render.h.

43{
46}
@ SHADERLANGUAGE_COUNT
Definition render.h:45
@ SHADERLANGUAGE_GLSL
Definition render.h:44

◆ shadermode_t

this enum selects which of the glslshadermodeinfo entries should be used

Enumerator
SHADERMODE_GENERIC 

(particles/HUD/etc) vertex color, optionally multiplied by one texture

SHADERMODE_POSTPROCESS 

postprocessing shader (r_glsl_postprocess)

SHADERMODE_DEPTH_OR_SHADOW 

(depthfirst/shadows) vertex shader only

SHADERMODE_FLATCOLOR 

(lightmap) modulate texture by uniform color (q1bsp, q3bsp)

SHADERMODE_VERTEXCOLOR 

(lightmap) modulate texture by vertex colors (q3bsp)

SHADERMODE_LIGHTMAP 

(lightmap) modulate texture by lightmap texture (q1bsp, q3bsp)

SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE 

(lightmap) use directional pixel shading from texture containing modelspace light directions (q3bsp deluxemap)

SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE 

(lightmap) use directional pixel shading from texture containing tangentspace light directions (q1bsp deluxemap)

SHADERMODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP 
SHADERMODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR 
SHADERMODE_LIGHTGRID 

(lightmap) use directional pixel shading from lightgrid data (q3bsp)

SHADERMODE_LIGHTDIRECTION 

(lightmap) use directional pixel shading from fixed light direction (q3bsp)

SHADERMODE_LIGHTSOURCE 

(lightsource) use directional pixel shading from light source (rtlight)

SHADERMODE_REFRACTION 

refract background (the material is rendered normally after this pass)

SHADERMODE_WATER 

refract background and reflection (the material is rendered normally after this pass)

SHADERMODE_DEFERREDGEOMETRY 

(deferred) render material properties to screenspace geometry buffers

SHADERMODE_DEFERREDLIGHTSOURCE 

(deferred) use directional pixel shading from light source (rtlight) on screenspace geometry buffers

SHADERMODE_COUNT 

Definition at line 50 of file render.h.

51{
60 SHADERMODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP, // forced deluxemapping for lightmapped surfaces
61 SHADERMODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR, // forced deluxemapping for vertexlit surfaces
70}
@ SHADERMODE_DEFERREDGEOMETRY
(deferred) render material properties to screenspace geometry buffers
Definition render.h:67
@ SHADERMODE_FLATCOLOR
(lightmap) modulate texture by uniform color (q1bsp, q3bsp)
Definition render.h:55
@ SHADERMODE_LIGHTDIRECTION
(lightmap) use directional pixel shading from fixed light direction (q3bsp)
Definition render.h:63
@ SHADERMODE_VERTEXCOLOR
(lightmap) modulate texture by vertex colors (q3bsp)
Definition render.h:56
@ SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE
(lightmap) use directional pixel shading from texture containing modelspace light directions (q3bsp d...
Definition render.h:58
@ SHADERMODE_COUNT
Definition render.h:69
@ SHADERMODE_LIGHTMAP
(lightmap) modulate texture by lightmap texture (q1bsp, q3bsp)
Definition render.h:57
@ SHADERMODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP
Definition render.h:60
@ SHADERMODE_GENERIC
(particles/HUD/etc) vertex color, optionally multiplied by one texture
Definition render.h:52
@ SHADERMODE_POSTPROCESS
postprocessing shader (r_glsl_postprocess)
Definition render.h:53
@ SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE
(lightmap) use directional pixel shading from texture containing tangentspace light directions (q1bsp...
Definition render.h:59
@ SHADERMODE_DEFERREDLIGHTSOURCE
(deferred) use directional pixel shading from light source (rtlight) on screenspace geometry buffers
Definition render.h:68
@ SHADERMODE_WATER
refract background and reflection (the material is rendered normally after this pass)
Definition render.h:66
@ SHADERMODE_DEPTH_OR_SHADOW
(depthfirst/shadows) vertex shader only
Definition render.h:54
@ SHADERMODE_LIGHTSOURCE
(lightsource) use directional pixel shading from light source (rtlight)
Definition render.h:64
@ SHADERMODE_LIGHTGRID
(lightmap) use directional pixel shading from lightgrid data (q3bsp)
Definition render.h:62
@ SHADERMODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR
Definition render.h:61
@ SHADERMODE_REFRACTION
refract background (the material is rendered normally after this pass)
Definition render.h:65

Function Documentation

◆ CL_VM_DrawHud()

void CL_VM_DrawHud ( double frametime)

Definition at line 541 of file csprogs.c.

542{
543 prvm_prog_t *prog = CLVM_prog;
544
545 R_TimeReport("pre-DrawHud");
546
548 PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
550
552
553 // width and height parameters are virtual in CSQC_SIMPLE engines
556 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_DrawHud), "QC function CSQC_DrawHud is missing");
557
558 if (PRVM_clientfunction(CSQC_DrawScores))
559 {
562 if (key_dest != key_menu)
563 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_DrawScores), "QC function CSQC_DrawScores is missing");
564 }
565 else if (sb_showscores || (cl.stats[STAT_HEALTH] <= 0 && cl_deathscoreboard.integer))
566 if (!cl.islocalgame) // LadyHavoc: changed to draw the deathmatch overlays in any multiplayer mode
568
569 R_TimeReport("DrawHud");
570}
client_state_t cl
Definition cl_main.c:117
cvar_t vid_conheight
Definition cl_screen.c:57
cvar_t vid_conwidth
Definition cl_screen.c:56
qbool sb_showscores
Definition sbar.c:56
static void CSQC_SetGlobals(double frametime)
Definition csprogs.c:247
entity self
float frametime
float time
keydest_t key_dest
Definition keys.c:37
@ key_menu
Definition keys.h:372
#define VectorSet(vec, x, y, z)
Definition mathlib.h:96
#define OFS_PARM0
Definition pr_comp.h:34
#define OFS_PARM1
Definition pr_comp.h:35
#define PRVM_clientfunction(funcname)
Definition progsvm.h:194
#define CLVM_prog
Definition progsvm.h:767
#define PRVM_clientglobaledict(fieldname)
Definition progsvm.h:192
#define PRVM_clientglobalfloat(fieldname)
Definition progsvm.h:189
void PRVM_GarbageCollection(prvm_prog_t *prog)
#define PRVM_G_FLOAT(o)
Definition progsvm.h:882
#define PRVM_G_VECTOR(o)
Definition progsvm.h:886
#define STAT_HEALTH
Definition qstats.h:8
void R_TimeReport(const char *desc)
Definition r_stats.c:193
cvar_t cl_deathscoreboard
Definition sbar.c:110
void Sbar_DeathmatchOverlay(void)
Definition sbar.c:1866
void(* ExecuteProgram)(struct prvm_prog_s *prog, func_t fnum, const char *errormessage)
pointer to one of the *VM_ExecuteProgram functions
Definition progsvm.h:749

References cl, cl_deathscoreboard, CLVM_prog, CSQC_SetGlobals(), prvm_prog_t::ExecuteProgram, frametime, key_dest, key_menu, OFS_PARM0, OFS_PARM1, PRVM_clientfunction, PRVM_clientglobaledict, PRVM_clientglobalfloat, PRVM_G_FLOAT, PRVM_G_VECTOR, PRVM_GarbageCollection(), R_TimeReport(), sb_showscores, Sbar_DeathmatchOverlay(), self, STAT_HEALTH, time, VectorSet, vid_conheight, and vid_conwidth.

Referenced by SCR_DrawScreen().

◆ CL_VM_UpdateView()

qbool CL_VM_UpdateView ( double frametime)

Definition at line 484 of file csprogs.c.

485{
486 prvm_prog_t *prog = CLVM_prog;
487 vec3_t emptyvector;
488 emptyvector[0] = 0;
489 emptyvector[1] = 0;
490 emptyvector[2] = 0;
491// vec3_t oldangles;
492
493 if(!prog->loaded)
494 return false;
495
496 R_TimeReport("pre-UpdateView");
497
500 //VectorCopy(cl.viewangles, oldangles);
502 PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
504 // clear renderable entity and light lists to prevent crashes if the
505 // CSQC_UpdateView function does not call R_ClearScene as it should
506 r_refdef.scene.numentities = 0;
507 r_refdef.scene.numlights = 0;
508 // polygonbegin without draw2d arg has to guess
509 prog->polygonbegin_guess2d = false;
510 // free memory for resources that are no longer referenced
512 // pass in width and height and menu/focus state as parameters (EXT_CSQC_1)
513 if (csqc_lowres.integer)
514 {
517 }
518 else
519 {
520 PRVM_G_FLOAT(OFS_PARM0) = vid.mode.width;
521 PRVM_G_FLOAT(OFS_PARM1) = vid.mode.height;
522 }
523 /*
524 * This should be fine for now but FTEQW uses flags for keydest
525 * and checks that an array called "eyeoffset" is 0
526 *
527 * Just a note in case there's compatibility problems later
528 */
530 prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_UpdateView), "QC function CSQC_UpdateView is missing");
531 //VectorCopy(oldangles, cl.viewangles);
532 // Dresk : Reset Dmg Globals Here
533 CL_VM_UpdateDmgGlobals(0, 0, emptyvector);
535 R_RenderView_UpdateViewVectors(); // we have to do this, as we undid the scene render doing this for us
536
537 R_TimeReport("UpdateView");
538 return true;
539}
cvar_t csqc_lowres
Definition cl_main.c:40
r_refdef_view_t csqc_main_r_refdef_view
Definition clvm_cmds.c:26
r_refdef_view_t csqc_original_r_refdef_view
Definition clvm_cmds.c:25
void CL_VM_UpdateDmgGlobals(int dmg_take, int dmg_save, vec3_t dmg_origin)
Definition csprogs.c:222
void CSQC_UpdateView(float vid_width, float vid_height, float notmenu)
void R_RenderView_UpdateViewVectors(void)
Definition gl_rmain.c:4512
r_refdef_t r_refdef
Definition gl_rmain.c:57
@ key_game
Definition keys.h:372
#define OFS_PARM2
Definition pr_comp.h:36
vec_t vec3_t[3]
Definition qtypes.h:71
qbool loaded
used to indicate whether a prog is loaded
Definition progsvm.h:710
qbool polygonbegin_guess2d
indicates if polygonbegin should be interpreted as 2d (clearscene sets this to false,...
Definition progsvm.h:661
viddef_t vid
global video state
Definition vid_shared.c:64

References cl, CL_VM_UpdateDmgGlobals(), CLVM_prog, csqc_lowres, csqc_main_r_refdef_view, csqc_original_r_refdef_view, CSQC_SetGlobals(), CSQC_UpdateView(), prvm_prog_t::ExecuteProgram, frametime, key_dest, key_game, prvm_prog_t::loaded, OFS_PARM0, OFS_PARM1, OFS_PARM2, prvm_prog_t::polygonbegin_guess2d, PRVM_clientfunction, PRVM_clientglobaledict, PRVM_clientglobalfloat, PRVM_G_FLOAT, PRVM_GarbageCollection(), r_refdef, R_RenderView_UpdateViewVectors(), R_TimeReport(), self, time, vid, vid_conheight, and vid_conwidth.

Referenced by SCR_DrawScreen().

◆ FindFont()

dp_font_t * FindFont ( const char * title,
qbool allocate_new )

Definition at line 481 of file gl_draw.c.

482{
483 int i, oldsize;
484
485 // find font
486 for(i = 0; i < dp_fonts.maxsize; ++i)
487 if(!strcmp(dp_fonts.f[i].title, title))
488 return &dp_fonts.f[i];
489 // if not found - try allocate
490 if (allocate_new)
491 {
492 // find any font with empty title
493 for(i = 0; i < dp_fonts.maxsize; ++i)
494 {
495 if(!strcmp(dp_fonts.f[i].title, ""))
496 {
497 dp_strlcpy(dp_fonts.f[i].title, title, sizeof(dp_fonts.f[i].title));
498 return &dp_fonts.f[i];
499 }
500 }
501 // if no any 'free' fonts - expand buffer
502 oldsize = dp_fonts.maxsize;
503 dp_fonts.maxsize = dp_fonts.maxsize + FONTS_EXPAND;
504 if (developer_font.integer)
505 Con_Printf("FindFont: enlarging fonts buffer (%i -> %i)\n", oldsize, dp_fonts.maxsize);
507 // relink ft2 structures
508 for(i = 0; i < oldsize; ++i)
509 if (dp_fonts.f[i].ft2)
510 dp_fonts.f[i].ft2->settings = &dp_fonts.f[i].settings;
511 // register a font in first expanded slot
512 dp_strlcpy(dp_fonts.f[oldsize].title, title, sizeof(dp_fonts.f[oldsize].title));
513 return &dp_fonts.f[oldsize];
514 }
515 return NULL;
516}
#define dp_strlcpy(dst, src, dsize)
Definition common.h:303
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
#define FONTS_EXPAND
Definition draw.h:127
dp_fonts_t dp_fonts
Definition gl_draw.c:50
cvar_t developer_font
Definition ft2.c:61
static mempool_t * fonts_mempool
Definition gl_draw.c:51
#define NULL
Definition qtypes.h:12
#define Mem_Realloc(pool, data, size)
Definition zone.h:94

References Con_Printf(), developer_font, dp_fonts, dp_strlcpy, FONTS_EXPAND, fonts_mempool, Mem_Realloc, and NULL.

Referenced by LoadFont_f(), and VM_loadfont().

◆ FOG_clear()

void FOG_clear ( void )

Definition at line 349 of file gl_rmain.c.

350{
351 if (gamemode == GAME_NEHAHRA)
352 {
355 Cvar_SetQuick(&gl_fogred, "0.3");
356 Cvar_SetQuick(&gl_foggreen, "0.3");
357 Cvar_SetQuick(&gl_fogblue, "0.3");
358 }
359 r_refdef.fog_density = 0;
360 r_refdef.fog_red = 0;
361 r_refdef.fog_green = 0;
362 r_refdef.fog_blue = 0;
363 r_refdef.fog_alpha = 1;
364 r_refdef.fog_start = 0;
365 r_refdef.fog_end = 16384;
366 r_refdef.fog_height = 1<<30;
367 r_refdef.fog_fadedepth = 128;
368 memset(r_refdef.fog_height_texturename, 0, sizeof(r_refdef.fog_height_texturename));
369}
gamemode_t gamemode
Definition com_game.c:26
@ GAME_NEHAHRA
Definition com_game.h:32
void Cvar_SetQuick(cvar_t *var, const char *value)
Definition cvar.c:436
cvar_t gl_fogdensity
Definition gl_rmain.c:148
cvar_t gl_fogblue
Definition gl_rmain.c:151
cvar_t gl_fogenable
Definition gl_rmain.c:147
cvar_t gl_fogred
Definition gl_rmain.c:149
cvar_t gl_foggreen
Definition gl_rmain.c:150

References Cvar_SetQuick(), GAME_NEHAHRA, gamemode, gl_fogblue, gl_fogdensity, gl_fogenable, gl_foggreen, gl_fogred, and r_refdef.

Referenced by CL_Fog_f(), CL_Fog_HeightTexture_f(), and CL_ParseEntityLump().

◆ Font_Init()

void Font_Init ( void )

Definition at line 443 of file ft2.c.

444{
452
454
455 // let's open it at startup already
457}
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
cvar_t r_font_size_snapping
Definition ft2.c:56
cvar_t r_font_disable_incmaps
Definition ft2.c:63
cvar_t r_font_nonpoweroftwo
Definition ft2.c:60
qbool Font_OpenLibrary(void)
Definition ft2.c:362
cvar_t r_font_disable_freetype
Definition ft2.c:55
cvar_t r_font_compress
Definition ft2.c:59
cvar_t r_font_kerning
Definition ft2.c:57
cvar_t r_font_diskcache
Definition ft2.c:58

References Cvar_RegisterVariable(), developer_font, Font_OpenLibrary(), r_font_compress, r_font_disable_freetype, r_font_disable_incmaps, r_font_diskcache, r_font_kerning, r_font_nonpoweroftwo, and r_font_size_snapping.

Referenced by Render_Init().

◆ gl_backend_init()

void gl_backend_init ( void )

Definition at line 339 of file gl_backend.c.

340{
341 int i;
342
343 for (i = 0;i < POLYGONELEMENTS_MAXPOINTS - 2;i++)
344 {
345 polygonelement3s[i * 3 + 0] = 0;
346 polygonelement3s[i * 3 + 1] = i + 1;
347 polygonelement3s[i * 3 + 2] = i + 2;
348 }
349 // elements for rendering a series of quads as triangles
350 for (i = 0;i < QUADELEMENTS_MAXQUADS;i++)
351 {
352 quadelement3s[i * 6 + 0] = i * 4;
353 quadelement3s[i * 6 + 1] = i * 4 + 1;
354 quadelement3s[i * 6 + 2] = i * 4 + 2;
355 quadelement3s[i * 6 + 3] = i * 4;
356 quadelement3s[i * 6 + 4] = i * 4 + 2;
357 quadelement3s[i * 6 + 5] = i * 4 + 3;
358 }
359
360 for (i = 0;i < (POLYGONELEMENTS_MAXPOINTS - 2)*3;i++)
362 for (i = 0;i < QUADELEMENTS_MAXQUADS*6;i++)
364
372#ifdef DEBUGGL // gl_printcheckerror does nothing in normal builds
374#endif
375
376 Cmd_AddCommand(CF_CLIENT, "gl_vbostats", GL_VBOStats_f, "prints a list of all buffer objects (vertex data and triangle elements) and total video memory used by them");
377
379}
cvar_t v_flipped
Definition gl_backend.c:20
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.c:1661
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
unsigned short quadelement3s[QUADELEMENTS_MAXQUADS *6]
Definition gl_backend.c:243
static void gl_backend_devicelost(void)
Definition gl_backend.c:304
cvar_t r_renderview
Definition gl_backend.c:12
unsigned short polygonelement3s[(POLYGONELEMENTS_MAXPOINTS-2) *3]
Definition gl_backend.c:241
cvar_t r_render
Definition gl_backend.c:11
static void GL_VBOStats_f(cmd_state_t *cmd)
Definition gl_backend.c:245
static void gl_backend_shutdown(void)
Definition gl_backend.c:281
int polygonelement3i[(POLYGONELEMENTS_MAXPOINTS-2) *3]
Definition gl_backend.c:240
static void gl_backend_start(void)
Definition gl_backend.c:252
cvar_t gl_printcheckerror
Definition gl_backend.c:9
int quadelement3i[QUADELEMENTS_MAXQUADS *6]
Definition gl_backend.c:242
static void gl_backend_devicerestored(void)
Definition gl_backend.c:329
cvar_t gl_polyblend
Definition gl_backend.c:17
cvar_t gl_debug
Definition gl_backend.c:7
cvar_t r_waterwarp
Definition gl_backend.c:13
static void gl_backend_newmap(void)
Definition gl_backend.c:300
cvar_t gl_paranoid
Definition gl_backend.c:8
#define QUADELEMENTS_MAXQUADS
Definition gl_backend.h:18
#define POLYGONELEMENTS_MAXPOINTS
Definition gl_backend.h:15
void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void))
Definition r_modules.c:25

References CF_CLIENT, Cmd_AddCommand(), Cvar_RegisterVariable(), gl_backend_devicelost(), gl_backend_devicerestored(), gl_backend_newmap(), gl_backend_shutdown(), gl_backend_start(), gl_debug, gl_paranoid, gl_polyblend, gl_printcheckerror, GL_VBOStats_f(), polygonelement3i, polygonelement3s, POLYGONELEMENTS_MAXPOINTS, quadelement3i, quadelement3s, QUADELEMENTS_MAXQUADS, R_RegisterModule(), r_render, r_renderview, r_waterwarp, and v_flipped.

Referenced by Render_Init().

◆ GL_Draw_Init()

void GL_Draw_Init ( void )

Definition at line 747 of file gl_draw.c.

748{
749 int i, j;
750
764
765 // allocate fonts storage
766 fonts_mempool = Mem_AllocPool("FONTS", 0, NULL);
767 dp_fonts.maxsize = MAX_FONTS;
768 dp_fonts.f = (dp_font_t *)Mem_Alloc(fonts_mempool, sizeof(dp_font_t) * dp_fonts.maxsize);
769 memset(dp_fonts.f, 0, sizeof(dp_font_t) * dp_fonts.maxsize);
770
771 // assign starting font names
772 dp_strlcpy(FONT_DEFAULT->title, "default", sizeof(FONT_DEFAULT->title));
773 dp_strlcpy(FONT_DEFAULT->texpath, "gfx/conchars", sizeof(FONT_DEFAULT->texpath));
774 dp_strlcpy(FONT_CONSOLE->title, "console", sizeof(FONT_CONSOLE->title));
775 dp_strlcpy(FONT_SBAR->title, "sbar", sizeof(FONT_SBAR->title));
776 dp_strlcpy(FONT_NOTIFY->title, "notify", sizeof(FONT_NOTIFY->title));
777 dp_strlcpy(FONT_CHAT->title, "chat", sizeof(FONT_CHAT->title));
778 dp_strlcpy(FONT_CENTERPRINT->title, "centerprint", sizeof(FONT_CENTERPRINT->title));
779 dp_strlcpy(FONT_INFOBAR->title, "infobar", sizeof(FONT_INFOBAR->title));
780 dp_strlcpy(FONT_MENU->title, "menu", sizeof(FONT_MENU->title));
781 for(i = 0, j = 0; i < MAX_USERFONTS; ++i)
782 if(!FONT_USER(i)->title[0])
783 dpsnprintf(FONT_USER(i)->title, sizeof(FONT_USER(i)->title), "user%d", j++);
784
785 Cmd_AddCommand(CF_CLIENT, "loadfont", LoadFont_f, "loadfont function tganame loads a font; example: loadfont console gfx/veramono; loadfont without arguments lists the available functions");
787}
int dpsnprintf(char *buffer, size_t buffersize, const char *format,...)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
Definition common.c:997
cvar_t r_textbrightness
Definition gl_draw.c:55
cvar_t r_textcontrast
Definition gl_draw.c:56
#define MAX_USERFONTS
Definition draw.h:137
#define FONT_DEFAULT
Definition draw.h:128
#define FONT_CHAT
Definition draw.h:132
#define FONT_CONSOLE
Definition draw.h:129
#define MAX_FONTS
Definition draw.h:126
#define FONT_INFOBAR
Definition draw.h:134
#define FONT_NOTIFY
Definition draw.h:131
#define FONT_USER(i)
Definition draw.h:136
#define FONT_MENU
Definition draw.h:135
#define FONT_SBAR
Definition draw.h:130
#define FONT_CENTERPRINT
Definition draw.h:133
static void LoadFont_f(cmd_state_t *cmd)
Definition gl_draw.c:544
cvar_t r_font_postprocess_shadow_x
Definition gl_draw.c:60
cvar_t r_font_postprocess_outline
Definition gl_draw.c:59
static void gl_draw_start(void)
Definition gl_draw.c:706
cvar_t r_font_postprocess_shadow_z
Definition gl_draw.c:62
static void gl_draw_shutdown(void)
Definition gl_draw.c:723
cvar_t r_textshadow
Definition gl_draw.c:53
static void gl_draw_newmap(void)
Definition gl_draw.c:733
cvar_t r_font_antialias
Definition gl_draw.c:64
cvar_t r_font_postprocess_shadow_y
Definition gl_draw.c:61
cvar_t r_font_hinting
Definition gl_draw.c:63
cvar_t r_font_postprocess_blur
Definition gl_draw.c:58
cvar_t r_font_always_reload
Definition gl_draw.c:65
cvar_t r_nearest_2d
Definition gl_draw.c:66
cvar_t r_nearest_conchars
Definition gl_draw.c:67
#define Mem_Alloc(pool, size)
Definition zone.h:92
#define Mem_AllocPool(name, flags, parent)
Definition zone.h:104

References CF_CLIENT, Cmd_AddCommand(), Cvar_RegisterVariable(), dp_fonts, dp_strlcpy, dpsnprintf(), FONT_CENTERPRINT, FONT_CHAT, FONT_CONSOLE, FONT_DEFAULT, FONT_INFOBAR, FONT_MENU, FONT_NOTIFY, FONT_SBAR, FONT_USER, fonts_mempool, gl_draw_newmap(), gl_draw_shutdown(), gl_draw_start(), LoadFont_f(), MAX_FONTS, MAX_USERFONTS, Mem_Alloc, Mem_AllocPool, NULL, r_font_always_reload, r_font_antialias, r_font_hinting, r_font_postprocess_blur, r_font_postprocess_outline, r_font_postprocess_shadow_x, r_font_postprocess_shadow_y, r_font_postprocess_shadow_z, r_nearest_2d, r_nearest_conchars, R_RegisterModule(), r_textbrightness, r_textcontrast, and r_textshadow.

Referenced by Render_Init().

◆ GL_Main_Init()

void GL_Main_Init ( void )

Definition at line 3220 of file gl_rmain.c.

3221{
3222 int i;
3223 r_main_mempool = Mem_AllocPool("Renderer", 0, NULL);
3225
3226 Cmd_AddCommand(CF_CLIENT, "r_glsl_restart", R_GLSL_Restart_f, "unloads GLSL shaders, they will then be reloaded as needed");
3227 Cmd_AddCommand(CF_CLIENT, "r_glsl_dumpshader", R_GLSL_DumpShader_f, "dumps the engine internal default.glsl shader into glsl/default.glsl");
3228 // FIXME: the client should set up r_refdef.fog stuff including the fogmasktable
3229 if (gamemode == GAME_NEHAHRA)
3230 {
3239 }
3355
3365
3402 for (i = 0;i < R_BUFFERDATA_COUNT;i++)
3410#ifdef DP_MOBILETOUCH
3411 // GLES devices have terrible depth precision in general, so...
3416#endif
3418}
cvar_t r_fullbright_directed_pitch_relative
Definition gl_rmain.c:118
cvar_t r_fullbright_directed_diffuse
Definition gl_rmain.c:116
cvar_t r_fullbright_directed
Definition gl_rmain.c:114
cvar_t r_fullbright_directed_ambient
Definition gl_rmain.c:115
cvar_t r_fullbright_directed_pitch
Definition gl_rmain.c:117
cvar_t r_hdr_glowintensity
Definition gl_rmain.c:219
cvar_t r_fog_clear
Definition gl_rmain.c:138
@ GAME_TENEBRAE
full of evil hackery
Definition com_game.h:41
void Cvar_SetValueQuick(cvar_t *var, float value)
Definition cvar.c:473
cvar_t r_shadows_castfrombmodels
Definition gl_rmain.c:128
cvar_t r_buffermegs[R_BUFFERDATA_COUNT]
Definition gl_rmain.c:249
cvar_t r_showlighting
Definition gl_rmain.c:88
cvar_t r_shadows_shadowmapbias
Definition gl_rmain.c:131
void R_GLSL_Restart_f(cmd_state_t *cmd)
Definition gl_rmain.c:1394
cvar_t r_motionblur_velocityfactor
Definition gl_rmain.c:65
cvar_t r_motionblur_minblur
Definition gl_rmain.c:63
cvar_t r_shadows_drawafterrtlighting
Definition gl_rmain.c:127
cvar_t r_showspriteedges
Definition gl_rmain.c:93
cvar_t r_water_hideplayer
Definition gl_rmain.c:200
cvar_t r_hdr_irisadaptation_fade_up
Definition gl_rmain.c:225
cvar_t r_glsl_offsetmapping_reliefmapping_steps
Definition gl_rmain.c:175
cvar_t r_q1bsp_lightmap_updates_enabled
Definition gl_rmain.c:257
cvar_t r_batch_dynamicbuffer
Definition gl_rmain.c:240
cvar_t r_hdr_irisadaptation_value
Definition gl_rmain.c:224
cvar_t r_hdr_irisadaptation_minvalue
Definition gl_rmain.c:222
cvar_t r_hdr_irisadaptation_fade_down
Definition gl_rmain.c:226
cvar_t r_drawfog
Definition gl_rmain.c:139
cvar_t r_motionblur
Definition gl_rmain.c:59
cvar_t r_bloom_colorsubtract
Definition gl_rmain.c:215
cvar_t r_shadows_focus
Definition gl_rmain.c:129
cvar_t r_fullbrights
Definition gl_rmain.c:122
cvar_t r_viewscale_fpsscaling_stepsize
Definition gl_rmain.c:166
cvar_t r_nolerp_list
Definition gl_rmain.c:204
cvar_t r_usedepthtextures
Definition gl_rmain.c:159
cvar_t r_bloom_colorexponent
Definition gl_rmain.c:214
cvar_t r_shadows_darken
Definition gl_rmain.c:124
cvar_t r_glsl_postprocess_uservec1_enable
Definition gl_rmain.c:185
cvar_t r_water_clippingplanebias
Definition gl_rmain.c:194
cvar_t r_q1bsp_skymasking
Definition gl_rmain.c:132
cvar_t r_draw2d
Definition gl_rmain.c:97
cvar_t r_transparent_sortmaxdist
Definition gl_rmain.c:142
cvar_t r_smoothnormals_areaweighting
Definition gl_rmain.c:229
cvar_t r_test
Definition gl_rmain.c:235
cvar_t r_bloom
Definition gl_rmain.c:208
cvar_t r_shadows_throwdirection
Definition gl_rmain.c:126
cvar_t r_transparent_useplanardistance
Definition gl_rmain.c:81
cvar_t r_motionblur_velocityfactor_minspeed
Definition gl_rmain.c:66
cvar_t r_celoutlines
Definition gl_rmain.c:145
cvar_t r_glsl_deluxemapping
Definition gl_rmain.c:171
static void gl_main_start(void)
Definition gl_rmain.c:3041
cvar_t r_q1bsp_lightmap_updates_hidden_surfaces
Definition gl_rmain.c:259
cvar_t r_showtris
Definition gl_rmain.c:86
cvar_t r_viewscale_fpsscaling_stepmax
Definition gl_rmain.c:167
cvar_t r_viewscale
Definition gl_rmain.c:162
cvar_t r_shadows
Definition gl_rmain.c:123
cvar_t r_showcollisionbrushes_polygonfactor
Definition gl_rmain.c:90
cvar_t r_motionblur_velocityfactor_maxspeed
Definition gl_rmain.c:67
cvar_t r_cullentities_trace
Definition gl_rmain.c:101
cvar_t r_colorfringe
Definition gl_rmain.c:189
cvar_t r_water_scissormode
Definition gl_rmain.c:198
cvar_t r_polygonoffset_decals_factor
Definition gl_rmain.c:135
cvar_t r_hdr_irisadaptation_maxvalue
Definition gl_rmain.c:223
cvar_t r_viewscale_fpsscaling_target
Definition gl_rmain.c:168
cvar_t r_viewscale_fpsscaling_min
Definition gl_rmain.c:164
cvar_t r_water_resolutionmultiplier
Definition gl_rmain.c:195
cvar_t r_glsl_offsetmapping_reliefmapping_refinesteps
Definition gl_rmain.c:176
cvar_t r_water_refractdistort
Definition gl_rmain.c:196
cvar_t r_glsl_vertextextureblend_usebothalphas
Definition gl_rmain.c:245
cvar_t r_farclip_world
Definition gl_rmain.c:75
cvar_t r_drawportals
Definition gl_rmain.c:95
cvar_t r_waterscroll
Definition gl_rmain.c:206
cvar_t r_cullentities_trace_eyejitter
Definition gl_rmain.c:109
cvar_t r_glsl_postprocess_uservec3_enable
Definition gl_rmain.c:187
cvar_t r_polygonoffset_decals_offset
Definition gl_rmain.c:136
static void gl_main_newmap(void)
Definition gl_rmain.c:3194
cvar_t r_bloom_scenebrightness
Definition gl_rmain.c:216
cvar_t r_celshading
Definition gl_rmain.c:144
mempool_t * r_main_mempool
Definition gl_rmain.c:42
cvar_t r_fullbright
Definition gl_rmain.c:112
cvar_t r_bloom_colorscale
Definition gl_rmain.c:209
cvar_t r_motionblur_mousefactor
Definition gl_rmain.c:68
cvar_t r_transparent_sortsurfacesbynearest
Definition gl_rmain.c:80
cvar_t r_showoverdraw
Definition gl_rmain.c:82
cvar_t r_glsl_offsetmapping
Definition gl_rmain.c:172
cvar_t r_batch_multidraw_mintriangles
Definition gl_rmain.c:238
cvar_t r_water_lowquality
Definition gl_rmain.c:199
cvar_t r_cullentities_trace_tempentitysamples
Definition gl_rmain.c:104
cvar_t r_cullentities_trace_delay
Definition gl_rmain.c:108
cvar_t r_bloom_resolution
Definition gl_rmain.c:213
cvar_t r_hdr_irisadaptation
Definition gl_rmain.c:220
cvar_t r_drawentities
Definition gl_rmain.c:96
cvar_t r_dynamic
Definition gl_rmain.c:121
cvar_t r_useinfinitefarclip
Definition gl_rmain.c:73
cvar_t r_bloom_brighten
Definition gl_rmain.c:211
cvar_t r_shadows_shadowmapscale
Definition gl_rmain.c:130
cvar_t r_batch_multidraw
Definition gl_rmain.c:237
cvar_t r_hdr_scenebrightness
Definition gl_rmain.c:218
cvar_t r_motionblur_maxblur
Definition gl_rmain.c:64
cvar_t r_motionblur_averaging
Definition gl_rmain.c:61
cvar_t r_fxaa
Definition gl_rmain.c:190
cvar_t r_transparent_sortarraysize
Definition gl_rmain.c:143
cvar_t r_motionblur_mousefactor_maxspeed
Definition gl_rmain.c:70
cvar_t r_showparticleedges
Definition gl_rmain.c:94
cvar_t r_water_reflectdistort
Definition gl_rmain.c:197
cvar_t r_showsurfaces
Definition gl_rmain.c:85
cvar_t r_motionblur_mousefactor_minspeed
Definition gl_rmain.c:69
cvar_t gl_fogstart
Definition gl_rmain.c:152
cvar_t r_hdr_irisadaptation_radius
Definition gl_rmain.c:227
cvar_t r_polygonoffset_submodel_factor
Definition gl_rmain.c:133
cvar_t r_drawexteriormodel
Definition gl_rmain.c:100
cvar_t developer_texturelogging
Definition gl_rmain.c:231
cvar_t r_viewscale_fpsscaling_multiply
Definition gl_rmain.c:165
cvar_t r_water
Definition gl_rmain.c:192
cvar_t r_glsl_offsetmapping_lod
Definition gl_rmain.c:178
cvar_t r_glsl_offsetmapping_scale
Definition gl_rmain.c:177
cvar_t r_showbboxes
Definition gl_rmain.c:83
cvar_t r_batch_debugdynamicvertexpath
Definition gl_rmain.c:239
static void R_InitShaderModeInfo(void)
Definition gl_rmain.c:987
cvar_t r_shadows_throwdistance
Definition gl_rmain.c:125
cvar_t gl_lightmaps
Definition gl_rmain.c:233
cvar_t r_transparent_sortmindist
Definition gl_rmain.c:141
cvar_t r_cullentities_trace_samples
Definition gl_rmain.c:103
cvar_t r_showbboxes_client
Definition gl_rmain.c:84
cvar_t r_framedatasize
Definition gl_rmain.c:248
cvar_t r_wateralpha
Definition gl_rmain.c:120
cvar_t r_glsl_postprocess_uservec2_enable
Definition gl_rmain.c:186
cvar_t r_showcollisionbrushes
Definition gl_rmain.c:89
cvar_t r_damageblur
Definition gl_rmain.c:60
cvar_t r_fog_exp2
Definition gl_rmain.c:137
cvar_t r_glsl_postprocess_uservec4
Definition gl_rmain.c:184
cvar_t r_cullentities_trace_expand
Definition gl_rmain.c:106
cvar_t r_shownormals
Definition gl_rmain.c:87
cvar_t r_transparent
Definition gl_rmain.c:78
cvar_t r_bloom_blur
Definition gl_rmain.c:212
cvar_t r_sortentities
Definition gl_rmain.c:110
cvar_t r_transparent_alphatocoverage
Definition gl_rmain.c:79
cvar_t r_glsl_saturation_redcompensate
Definition gl_rmain.c:243
cvar_t r_glsl_offsetmapping_reliefmapping
Definition gl_rmain.c:174
cvar_t r_speeds
Definition gl_rmain.c:111
cvar_t r_polygonoffset_submodel_offset
Definition gl_rmain.c:134
static void gl_main_shutdown(void)
Definition gl_rmain.c:3138
cvar_t r_showcollisionbrushes_polygonoffset
Definition gl_rmain.c:91
cvar_t r_showdisabledepthtest
Definition gl_rmain.c:92
cvar_t r_drawworld
Definition gl_rmain.c:98
cvar_t r_motionblur_randomize
Definition gl_rmain.c:62
cvar_t r_drawviewmodel
Definition gl_rmain.c:99
cvar_t r_nearclip
Definition gl_rmain.c:76
cvar_t r_cullentities_trace_pad
Definition gl_rmain.c:107
cvar_t gl_fogend
Definition gl_rmain.c:153
cvar_t r_cullentities_trace_enlarge
Definition gl_rmain.c:105
cvar_t r_glsl_postprocess_uservec4_enable
Definition gl_rmain.c:188
cvar_t r_hdr_irisadaptation_multiplier
Definition gl_rmain.c:221
cvar_t r_glsl_postprocess_uservec1
Definition gl_rmain.c:181
cvar_t r_lerpsprites
Definition gl_rmain.c:202
cvar_t r_water_cameraentitiesonly
Definition gl_rmain.c:193
cvar_t r_rendertarget_debug
Definition gl_rmain.c:161
cvar_t r_glsl_offsetmapping_steps
Definition gl_rmain.c:173
cvar_t r_q1bsp_lightmap_updates_combine
Definition gl_rmain.c:258
cvar_t r_texture_dds_load
Definition gl_rmain.c:156
cvar_t r_lerplightstyles
Definition gl_rmain.c:205
cvar_t r_depthfirst
Definition gl_rmain.c:72
cvar_t r_deformvertexes
Definition gl_rmain.c:77
cvar_t r_glsl_saturation
Definition gl_rmain.c:242
cvar_t gl_skyclip
Definition gl_rmain.c:154
cvar_t r_viewfbo
Definition gl_rmain.c:160
cvar_t r_lerpmodels
Definition gl_rmain.c:203
static void R_GLSL_DumpShader_f(cmd_state_t *cmd)
Definition gl_rmain.c:1419
cvar_t r_farclip_base
Definition gl_rmain.c:74
cvar_t r_glsl_postprocess_uservec2
Definition gl_rmain.c:182
cvar_t r_glsl_postprocess
Definition gl_rmain.c:180
cvar_t r_cullentities_trace_entityocclusion
Definition gl_rmain.c:102
cvar_t r_transparentdepthmasking
Definition gl_rmain.c:140
cvar_t r_glsl_postprocess_uservec3
Definition gl_rmain.c:183
cvar_t r_glsl_offsetmapping_lod_distance
Definition gl_rmain.c:179
cvar_t r_glsl_skeletal
Definition gl_rmain.c:170
cvar_t r_viewscale_fpsscaling
Definition gl_rmain.c:163
cvar_t r_texture_dds_save
Definition gl_rmain.c:157

References CF_CLIENT, Cmd_AddCommand(), Cvar_RegisterVariable(), Cvar_SetQuick(), Cvar_SetValueQuick(), developer_texturelogging, GAME_NEHAHRA, GAME_TENEBRAE, gamemode, gl_fogblue, gl_fogdensity, gl_fogenable, gl_fogend, gl_foggreen, gl_fogred, gl_fogstart, gl_lightmaps, gl_main_newmap(), gl_main_shutdown(), gl_main_start(), gl_skyclip, Mem_AllocPool, NULL, r_batch_debugdynamicvertexpath, r_batch_dynamicbuffer, r_batch_multidraw, r_batch_multidraw_mintriangles, r_bloom, r_bloom_blur, r_bloom_brighten, r_bloom_colorexponent, r_bloom_colorscale, r_bloom_colorsubtract, r_bloom_resolution, r_bloom_scenebrightness, R_BUFFERDATA_COUNT, r_buffermegs, r_celoutlines, r_celshading, r_colorfringe, r_cullentities_trace, r_cullentities_trace_delay, r_cullentities_trace_enlarge, r_cullentities_trace_entityocclusion, r_cullentities_trace_expand, r_cullentities_trace_eyejitter, r_cullentities_trace_pad, r_cullentities_trace_samples, r_cullentities_trace_tempentitysamples, r_damageblur, r_deformvertexes, r_depthfirst, r_draw2d, r_drawentities, r_drawexteriormodel, r_drawfog, r_drawportals, r_drawviewmodel, r_drawworld, r_dynamic, r_farclip_base, r_farclip_world, r_fog_clear, r_fog_exp2, r_framedatasize, r_fullbright, r_fullbright_directed, r_fullbright_directed_ambient, r_fullbright_directed_diffuse, r_fullbright_directed_pitch, r_fullbright_directed_pitch_relative, r_fullbrights, r_fxaa, r_glsl_deluxemapping, R_GLSL_DumpShader_f(), r_glsl_offsetmapping, r_glsl_offsetmapping_lod, r_glsl_offsetmapping_lod_distance, r_glsl_offsetmapping_reliefmapping, r_glsl_offsetmapping_reliefmapping_refinesteps, r_glsl_offsetmapping_reliefmapping_steps, r_glsl_offsetmapping_scale, r_glsl_offsetmapping_steps, r_glsl_postprocess, r_glsl_postprocess_uservec1, r_glsl_postprocess_uservec1_enable, r_glsl_postprocess_uservec2, r_glsl_postprocess_uservec2_enable, r_glsl_postprocess_uservec3, r_glsl_postprocess_uservec3_enable, r_glsl_postprocess_uservec4, r_glsl_postprocess_uservec4_enable, R_GLSL_Restart_f(), r_glsl_saturation, r_glsl_saturation_redcompensate, r_glsl_skeletal, r_glsl_vertextextureblend_usebothalphas, r_hdr_glowintensity, r_hdr_irisadaptation, r_hdr_irisadaptation_fade_down, r_hdr_irisadaptation_fade_up, r_hdr_irisadaptation_maxvalue, r_hdr_irisadaptation_minvalue, r_hdr_irisadaptation_multiplier, r_hdr_irisadaptation_radius, r_hdr_irisadaptation_value, r_hdr_scenebrightness, R_InitShaderModeInfo(), r_lerplightstyles, r_lerpmodels, r_lerpsprites, r_main_mempool, r_motionblur, r_motionblur_averaging, r_motionblur_maxblur, r_motionblur_minblur, r_motionblur_mousefactor, r_motionblur_mousefactor_maxspeed, r_motionblur_mousefactor_minspeed, r_motionblur_randomize, r_motionblur_velocityfactor, r_motionblur_velocityfactor_maxspeed, r_motionblur_velocityfactor_minspeed, r_nearclip, r_nolerp_list, r_polygonoffset_decals_factor, r_polygonoffset_decals_offset, r_polygonoffset_submodel_factor, r_polygonoffset_submodel_offset, r_q1bsp_lightmap_updates_combine, r_q1bsp_lightmap_updates_enabled, r_q1bsp_lightmap_updates_hidden_surfaces, r_q1bsp_skymasking, R_RegisterModule(), r_rendertarget_debug, r_shadows, r_shadows_castfrombmodels, r_shadows_darken, r_shadows_drawafterrtlighting, r_shadows_focus, r_shadows_shadowmapbias, r_shadows_shadowmapscale, r_shadows_throwdirection, r_shadows_throwdistance, r_showbboxes, r_showbboxes_client, r_showcollisionbrushes, r_showcollisionbrushes_polygonfactor, r_showcollisionbrushes_polygonoffset, r_showdisabledepthtest, r_showlighting, r_shownormals, r_showoverdraw, r_showparticleedges, r_showspriteedges, r_showsurfaces, r_showtris, r_smoothnormals_areaweighting, r_sortentities, r_speeds, r_test, r_texture_dds_load, r_texture_dds_save, r_transparent, r_transparent_alphatocoverage, r_transparent_sortarraysize, r_transparent_sortmaxdist, r_transparent_sortmindist, r_transparent_sortsurfacesbynearest, r_transparent_useplanardistance, r_transparentdepthmasking, r_usedepthtextures, r_useinfinitefarclip, r_viewfbo, r_viewscale, r_viewscale_fpsscaling, r_viewscale_fpsscaling_min, r_viewscale_fpsscaling_multiply, r_viewscale_fpsscaling_stepmax, r_viewscale_fpsscaling_stepsize, r_viewscale_fpsscaling_target, r_water, r_water_cameraentitiesonly, r_water_clippingplanebias, r_water_hideplayer, r_water_lowquality, r_water_reflectdistort, r_water_refractdistort, r_water_resolutionmultiplier, r_water_scissormode, r_wateralpha, and r_waterscroll.

Referenced by Render_Init().

◆ GL_Surf_Init()

void GL_Surf_Init ( void )

Definition at line 1564 of file gl_rsurf.c.

1565{
1566
1581
1582 Cmd_AddCommand(CF_CLIENT, "r_replacemaptexture", R_ReplaceWorldTexture_f, "override a map texture for testing purposes");
1583 Cmd_AddCommand(CF_CLIENT, "r_listmaptextures", R_ListWorldTextures_f, "list all textures used by the current map");
1584
1585 //R_RegisterModule("GL_Surf", gl_surf_start, gl_surf_shutdown, gl_surf_newmap);
1586}
cvar_t r_lockvisibility
Definition gl_rsurf.c:30
cvar_t r_lockpvs
Definition gl_rsurf.c:29
cvar_t r_vis_trace_eyejitter
Definition gl_rsurf.c:36
cvar_t r_ambient
Definition gl_rsurf.c:28
cvar_t r_usesurfaceculling
Definition gl_rsurf.c:32
cvar_t r_vis_trace_surfaces
Definition gl_rsurf.c:40
cvar_t r_useportalculling
Definition gl_rsurf.c:31
cvar_t r_vis_trace_delay
Definition gl_rsurf.c:35
cvar_t r_vis_trace_enlarge
Definition gl_rsurf.c:37
cvar_t r_vis_trace
Definition gl_rsurf.c:33
cvar_t r_vis_trace_samples
Definition gl_rsurf.c:34
cvar_t r_vis_trace_expand
Definition gl_rsurf.c:38
cvar_t r_vis_trace_pad
Definition gl_rsurf.c:39
cvar_t r_q3bsp_renderskydepth
Definition gl_rsurf.c:41
static void R_ListWorldTextures_f(cmd_state_t *cmd)
Definition gl_rsurf.c:1532
static void R_ReplaceWorldTexture_f(cmd_state_t *cmd)
Definition gl_rsurf.c:1483

References CF_CLIENT, Cmd_AddCommand(), Cvar_RegisterVariable(), r_ambient, R_ListWorldTextures_f(), r_lockpvs, r_lockvisibility, r_q3bsp_renderskydepth, R_ReplaceWorldTexture_f(), r_useportalculling, r_usesurfaceculling, r_vis_trace, r_vis_trace_delay, r_vis_trace_enlarge, r_vis_trace_expand, r_vis_trace_eyejitter, r_vis_trace_pad, r_vis_trace_samples, and r_vis_trace_surfaces.

Referenced by Render_Init().

◆ LoadFont()

void LoadFont ( qbool override,
const char * name,
dp_font_t * fnt,
float scale,
float voffset )

Definition at line 330 of file gl_draw.c.

331{
332 int i, ch;
333 float maxwidth;
334 char widthfile[MAX_QPATH];
335 char *widthbuf;
336 fs_offset_t widthbufsize;
337
338 if(override || !fnt->texpath[0])
339 {
340 dp_strlcpy(fnt->texpath, name, sizeof(fnt->texpath));
341 // load the cvars when the font is FIRST loader
342 fnt->settings.scale = scale;
343 fnt->settings.voffset = voffset;
344 fnt->settings.antialias = r_font_antialias.integer;
345 fnt->settings.hinting = r_font_hinting.integer;
351 }
352
353 // fix bad scale
354 if (fnt->settings.scale <= 0)
355 fnt->settings.scale = 1;
356
357 if(drawtexturepool == NULL)
358 return; // before gl_draw_start, so will be loaded later
359
360 if(fnt->ft2)
361 {
362 // we are going to reload. clear old ft2 data
363 Font_UnloadFont(fnt->ft2);
364 Mem_Free(fnt->ft2);
365 fnt->ft2 = NULL;
366 }
367
368 if(fnt->req_face != -1)
369 {
370 if(!Font_LoadFont(fnt->texpath, fnt))
371 Con_DPrintf("Failed to load font-file for '%s', it will not support as many characters.\n", fnt->texpath);
372 }
373
375 if(!Draw_IsPicLoaded(fnt->pic))
376 {
377 for (i = 0; i < MAX_FONT_FALLBACKS; ++i)
378 {
379 if (!fnt->fallbacks[i][0])
380 break;
382 if(Draw_IsPicLoaded(fnt->pic))
383 break;
384 }
385 if(!Draw_IsPicLoaded(fnt->pic))
386 {
388 dp_strlcpy(widthfile, "gfx/conchars.width", sizeof(widthfile));
389 }
390 else
391 dpsnprintf(widthfile, sizeof(widthfile), "%s.width", fnt->fallbacks[i]);
392 }
393 else
394 dpsnprintf(widthfile, sizeof(widthfile), "%s.width", fnt->texpath);
395
396 // unspecified width == 1 (base width)
397 for(ch = 0; ch < 256; ++ch)
398 fnt->width_of[ch] = 1;
399
400 // FIXME load "name.width", if it fails, fill all with 1
401 if((widthbuf = (char *) FS_LoadFile(widthfile, tempmempool, true, &widthbufsize)))
402 {
403 float extraspacing = 0;
404 const char *p = widthbuf;
405
406 ch = 0;
407 while(ch < 256)
408 {
409 if(!COM_ParseToken_Simple(&p, false, false, true))
410 return;
411
412 switch(*com_token)
413 {
414 case '0':
415 case '1':
416 case '2':
417 case '3':
418 case '4':
419 case '5':
420 case '6':
421 case '7':
422 case '8':
423 case '9':
424 case '+':
425 case '-':
426 case '.':
427 fnt->width_of[ch] = atof(com_token) + extraspacing;
428 ch++;
429 break;
430 default:
431 if(!strcmp(com_token, "extraspacing"))
432 {
433 if(!COM_ParseToken_Simple(&p, false, false, true))
434 return;
435 extraspacing = atof(com_token);
436 }
437 else if(!strcmp(com_token, "scale"))
438 {
439 if(!COM_ParseToken_Simple(&p, false, false, true))
440 return;
441 fnt->settings.scale = atof(com_token);
442 }
443 else
444 {
445 Con_DPrintf("Warning: skipped unknown font property %s\n", com_token);
446 if(!COM_ParseToken_Simple(&p, false, false, true))
447 return;
448 }
449 break;
450 }
451 }
452
453 Mem_Free(widthbuf);
454 }
455
456 if(fnt->ft2)
457 {
458 for (i = 0; i < MAX_FONT_SIZES; ++i)
459 {
460 ft2_font_map_t *map = Font_MapForIndex(fnt->ft2, i);
461 if (!map)
462 break;
463 for(ch = 0; ch < 256; ++ch)
464 fnt->width_of_ft2[i][ch] = Font_SnapTo(fnt->width_of[ch], 1/map->size);
465 }
466 }
467
468 maxwidth = fnt->width_of[0];
469 for(i = 1; i < 256; ++i)
470 maxwidth = max(maxwidth, fnt->width_of[i]);
471 fnt->maxwidth = maxwidth;
472
473 // fix up maxwidth for overlap
474 fnt->maxwidth *= fnt->settings.scale;
475
476 if(fnt == FONT_CONSOLE)
477 con_linewidth = -1; // rewrap console in next frame
478}
char com_token[MAX_INPUTLINE]
Definition common.c:39
qbool COM_ParseToken_Simple(const char **datapointer, qbool returnnewline, qbool parsebackslash, qbool parsecomments)
Definition common.c:463
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1544
int con_linewidth
Definition console.c:94
float scale
@ CACHEPICFLAG_FAILONMISSING
Definition draw.h:44
@ CACHEPICFLAG_NEAREST
Definition draw.h:42
@ CACHEPICFLAG_QUIET
Definition draw.h:37
@ CACHEPICFLAG_NOCOMPRESSION
Definition draw.h:38
rtexturepool_t * drawtexturepool
Definition gl_draw.c:76
#define MAX_FONT_FALLBACKS
Definition draw.h:95
#define MAX_FONT_SIZES
Definition draw.h:94
unsigned char * FS_LoadFile(const char *path, mempool_t *pool, qbool quiet, fs_offset_t *filesizepointer)
Definition fs.c:3541
int64_t fs_offset_t
Definition fs.h:37
ft2_font_map_t * Font_MapForIndex(ft2_font_t *font, int index)
Definition ft2.c:1052
float Font_SnapTo(float val, float snapwidth)
Definition ft2.c:514
qbool Font_LoadFont(const char *name, dp_font_t *dpfnt)
Definition ft2.c:521
void Font_UnloadFont(ft2_font_t *font)
Definition ft2.c:1184
cachepic_t * Draw_CachePic_Flags(const char *path, unsigned int cachepicflags)
Definition gl_draw.c:86
qbool Draw_IsPicLoaded(cachepic_t *pic)
Definition gl_draw.c:211
const GLchar * name
Definition glquake.h:601
#define max(A, B)
Definition mathlib.h:38
#define MAX_QPATH
max length of a quake game pathname
Definition qdefs.h:169
struct ft2_font_s * ft2
Definition draw.h:110
int req_face
Definition draw.h:106
float maxwidth
Definition draw.h:102
char texpath[MAX_QPATH]
Definition draw.h:103
float width_of[256]
Definition draw.h:100
ft2_settings_t settings
Definition draw.h:112
float width_of_ft2[MAX_FONT_SIZES][256]
Definition draw.h:101
char fallbacks[MAX_FONT_FALLBACKS][MAX_QPATH]
Definition draw.h:108
cachepic_t * pic
Definition draw.h:99
float shadowy
Definition draw.h:91
float scale
Definition draw.h:88
float outline
Definition draw.h:91
int antialias
Definition draw.h:90
float voffset
Definition draw.h:88
float shadowz
Definition draw.h:91
int hinting
Definition draw.h:90
float shadowx
Definition draw.h:91
float blur
Definition draw.h:91
mempool_t * tempmempool
Definition zone.c:794
#define Mem_Free(mem)
Definition zone.h:96

References ft2_settings_t::antialias, ft2_settings_t::blur, CACHEPICFLAG_FAILONMISSING, CACHEPICFLAG_NEAREST, CACHEPICFLAG_NOCOMPRESSION, CACHEPICFLAG_QUIET, COM_ParseToken_Simple(), com_token, Con_DPrintf(), con_linewidth, dp_strlcpy, dpsnprintf(), Draw_CachePic_Flags(), Draw_IsPicLoaded(), drawtexturepool, dp_font_t::fallbacks, FONT_CONSOLE, Font_LoadFont(), Font_MapForIndex(), Font_SnapTo(), Font_UnloadFont(), FS_LoadFile(), dp_font_t::ft2, ft2_settings_t::hinting, max, MAX_FONT_FALLBACKS, MAX_FONT_SIZES, MAX_QPATH, dp_font_t::maxwidth, Mem_Free, name, NULL, ft2_settings_t::outline, dp_font_t::pic, r_font_antialias, r_font_hinting, r_font_postprocess_blur, r_font_postprocess_outline, r_font_postprocess_shadow_x, r_font_postprocess_shadow_y, r_font_postprocess_shadow_z, r_nearest_conchars, dp_font_t::req_face, ft2_settings_t::scale, scale, dp_font_t::settings, ft2_settings_t::shadowx, ft2_settings_t::shadowy, ft2_settings_t::shadowz, tempmempool, dp_font_t::texpath, ft2_settings_t::voffset, dp_font_t::width_of, and dp_font_t::width_of_ft2.

Referenced by gl_draw_start(), LoadFont_f(), and VM_loadfont().

◆ Mod_RenderInit()

void Mod_RenderInit ( void )

Definition at line 206 of file model_shared.c.

207{
209}
static void mod_newmap(void)
static void mod_start(void)
static void mod_shutdown(void)

References mod_newmap(), mod_shutdown(), mod_start(), NULL, and R_RegisterModule().

Referenced by Render_Init().

◆ R_AnimCache_CacheVisibleEntities()

void R_AnimCache_CacheVisibleEntities ( void )

generate animcache data for all entities marked visible

Definition at line 3874 of file gl_rmain.c.

3875{
3876 int i;
3877
3878 // TODO: thread this
3879 // NOTE: R_PrepareRTLights() also caches entities
3880
3881 for (i = 0;i < r_refdef.scene.numentities;i++)
3882 if (r_refdef.viewcache.entityvisible[i])
3883 R_AnimCache_GetEntity(r_refdef.scene.entities[i], true, true);
3884}
qbool R_AnimCache_GetEntity(entity_render_t *ent, qbool wantnormals, qbool wanttangents)
get the skeletal data or cached animated mesh data for an entity (optionally with normals and tangent...
Definition gl_rmain.c:3789

References R_AnimCache_GetEntity(), and r_refdef.

Referenced by R_RenderView(), and R_Water_ProcessPlanes().

◆ R_AnimCache_ClearCache()

void R_AnimCache_ClearCache ( void )

clear the animcache pointers on all known render entities

Definition at line 3762 of file gl_rmain.c.

3763{
3764 int i;
3765 entity_render_t *ent;
3766
3767 for (i = 0;i < r_refdef.scene.numentities;i++)
3768 {
3769 ent = r_refdef.scene.entities[i];
3770 ent->animcache_vertex3f = NULL;
3773 ent->animcache_normal3f = NULL;
3786 }
3787}
float * animcache_skeletaltransform3x4
Definition client.h:395
r_meshbuffer_t * animcache_vertex3f_vertexbuffer
Definition client.h:380
float * animcache_normal3f
Definition client.h:382
int animcache_skeletaltransform3x4size
Definition client.h:398
int animcache_vertex3f_bufferoffset
Definition client.h:381
r_meshbuffer_t * animcache_svector3f_vertexbuffer
Definition client.h:386
r_meshbuffer_t * animcache_tvector3f_vertexbuffer
Definition client.h:389
float * animcache_vertex3f
Definition client.h:379
int animcache_svector3f_bufferoffset
Definition client.h:387
r_meshbuffer_t * animcache_skeletaltransform3x4buffer
Definition client.h:396
r_meshbuffer_t * animcache_normal3f_vertexbuffer
Definition client.h:383
float * animcache_svector3f
Definition client.h:385
int animcache_tvector3f_bufferoffset
Definition client.h:390
float * animcache_tvector3f
Definition client.h:388
int animcache_skeletaltransform3x4offset
Definition client.h:397
int animcache_normal3f_bufferoffset
Definition client.h:384

References entity_render_t::animcache_normal3f, entity_render_t::animcache_normal3f_bufferoffset, entity_render_t::animcache_normal3f_vertexbuffer, entity_render_t::animcache_skeletaltransform3x4, entity_render_t::animcache_skeletaltransform3x4buffer, entity_render_t::animcache_skeletaltransform3x4offset, entity_render_t::animcache_skeletaltransform3x4size, entity_render_t::animcache_svector3f, entity_render_t::animcache_svector3f_bufferoffset, entity_render_t::animcache_svector3f_vertexbuffer, entity_render_t::animcache_tvector3f, entity_render_t::animcache_tvector3f_bufferoffset, entity_render_t::animcache_tvector3f_vertexbuffer, entity_render_t::animcache_vertex3f, entity_render_t::animcache_vertex3f_bufferoffset, entity_render_t::animcache_vertex3f_vertexbuffer, NULL, and r_refdef.

Referenced by R_RenderView().

◆ R_AnimCache_Free()

void R_AnimCache_Free ( void )

free all R_AnimCache memory

free all R_AnimCache memory

Definition at line 3758 of file gl_rmain.c.

3759{
3760}

Referenced by gl_main_shutdown(), and gl_main_start().

◆ R_AnimCache_GetEntity()

qbool R_AnimCache_GetEntity ( entity_render_t * ent,
qbool wantnormals,
qbool wanttangents )

get the skeletal data or cached animated mesh data for an entity (optionally with normals and tangents)

Definition at line 3789 of file gl_rmain.c.

3790{
3791 model_t *model = ent->model;
3792 int numvertices;
3793
3794 // see if this ent is worth caching
3795 if (!model || !model->Draw || !model->AnimateVertices)
3796 return false;
3797 // nothing to cache if it contains no animations and has no skeleton
3798 if (!model->surfmesh.isanimated && !(model->num_bones && ent->skeleton && ent->skeleton->relativetransforms))
3799 return false;
3800 // see if it is already cached for gpuskeletal
3802 return false;
3803 // see if it is already cached as a mesh
3804 if (ent->animcache_vertex3f)
3805 {
3806 // check if we need to add normals or tangents
3807 if (ent->animcache_normal3f)
3808 wantnormals = false;
3809 if (ent->animcache_svector3f)
3810 wanttangents = false;
3811 if (!wantnormals && !wanttangents)
3812 return false;
3813 }
3814
3815 // check which kind of cache we need to generate
3816 if (r_gpuskeletal && model->num_bones > 0 && model->surfmesh.data_skeletalindex4ub)
3817 {
3818 // cache the skeleton so the vertex shader can use it
3820 r_refdef.stats[r_stat_animcache_skeletal_bones] += model->num_bones;
3822 ent->animcache_skeletaltransform3x4 = (float *)R_FrameData_Alloc(sizeof(float[3][4]) * model->num_bones);
3824 // note: this can fail if the buffer is at the grow limit
3825 ent->animcache_skeletaltransform3x4size = sizeof(float[3][4]) * model->num_bones;
3827 }
3828 else if (ent->animcache_vertex3f)
3829 {
3830 // mesh was already cached but we may need to add normals/tangents
3831 // (this only happens with multiple views, reflections, cameras, etc)
3832 if (wantnormals || wanttangents)
3833 {
3834 numvertices = model->surfmesh.num_vertices;
3835 if (wantnormals)
3836 ent->animcache_normal3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3837 if (wanttangents)
3838 {
3839 ent->animcache_svector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3840 ent->animcache_tvector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3841 }
3842 model->AnimateVertices(model, ent->frameblend, ent->skeleton, NULL, wantnormals ? ent->animcache_normal3f : NULL, wanttangents ? ent->animcache_svector3f : NULL, wanttangents ? ent->animcache_tvector3f : NULL);
3844 r_refdef.stats[r_stat_animcache_shade_vertices] += numvertices;
3846 }
3847 }
3848 else
3849 {
3850 // generate mesh cache
3851 numvertices = model->surfmesh.num_vertices;
3852 ent->animcache_vertex3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3853 if (wantnormals)
3854 ent->animcache_normal3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3855 if (wanttangents)
3856 {
3857 ent->animcache_svector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3858 ent->animcache_tvector3f = (float *)R_FrameData_Alloc(sizeof(float[3])*numvertices);
3859 }
3860 model->AnimateVertices(model, ent->frameblend, ent->skeleton, ent->animcache_vertex3f, ent->animcache_normal3f, ent->animcache_svector3f, ent->animcache_tvector3f);
3861 if (wantnormals || wanttangents)
3862 {
3864 r_refdef.stats[r_stat_animcache_shade_vertices] += numvertices;
3866 }
3868 r_refdef.stats[r_stat_animcache_shape_vertices] += numvertices;
3870 }
3871 return true;
3872}
string model
static qbool r_gpuskeletal
Definition gl_rmain.c:52
void * R_FrameData_Alloc(size_t size)
allocate some temporary memory for your purposes
Definition gl_rmain.c:3539
r_meshbuffer_t * R_BufferData_Store(size_t datasize, const void *data, r_bufferdata_type_t type, int *returnbufferoffset)
request space in a vertex/index/uniform buffer for the chosen data, returns the buffer pointer and of...
Definition gl_rmain.c:3707
void Mod_Skeletal_BuildTransforms(const model_t *RESTRICT model, const frameblend_t *RESTRICT frameblend, const skeleton_t *skeleton, float *RESTRICT bonepose, float *RESTRICT boneposerelative)
Definition model_alias.c:65
@ r_stat_animcache_shape_count
Definition r_stats.h:67
@ r_stat_animcache_skeletal_bones
Definition r_stats.h:62
@ r_stat_animcache_shape_maxvertices
Definition r_stats.h:69
@ r_stat_animcache_skeletal_maxbones
Definition r_stats.h:63
@ r_stat_animcache_skeletal_count
Definition r_stats.h:61
@ r_stat_animcache_shade_count
Definition r_stats.h:64
@ r_stat_animcache_shape_vertices
Definition r_stats.h:68
@ r_stat_animcache_shade_vertices
Definition r_stats.h:65
@ r_stat_animcache_shade_maxvertices
Definition r_stats.h:66
frameblend_t frameblend[MAX_FRAMEBLENDS]
Definition client.h:373
model_t * model
Definition client.h:343
skeleton_t * skeleton
Definition client.h:375
struct matrix4x4_s * relativetransforms
Definition protocol.h:426

References entity_render_t::animcache_normal3f, entity_render_t::animcache_skeletaltransform3x4, entity_render_t::animcache_skeletaltransform3x4buffer, entity_render_t::animcache_skeletaltransform3x4offset, entity_render_t::animcache_skeletaltransform3x4size, entity_render_t::animcache_svector3f, entity_render_t::animcache_tvector3f, entity_render_t::animcache_vertex3f, entity_render_t::frameblend, max, Mod_Skeletal_BuildTransforms(), entity_render_t::model, model, NULL, R_BufferData_Store(), R_BUFFERDATA_UNIFORM, R_FrameData_Alloc(), r_gpuskeletal, r_refdef, r_stat_animcache_shade_count, r_stat_animcache_shade_maxvertices, r_stat_animcache_shade_vertices, r_stat_animcache_shape_count, r_stat_animcache_shape_maxvertices, r_stat_animcache_shape_vertices, r_stat_animcache_skeletal_bones, r_stat_animcache_skeletal_count, r_stat_animcache_skeletal_maxbones, skeleton_t::relativetransforms, and entity_render_t::skeleton.

Referenced by R_AnimCache_CacheVisibleEntities(), R_Shadow_PrepareLight(), and R_Shadow_PrepareModelShadows().

◆ R_BufferData_NewFrame()

void R_BufferData_NewFrame ( void )

begin a new frame (recycle old buffers)

Definition at line 3678 of file gl_rmain.c.

3679{
3680 int type;
3681 r_bufferdata_buffer_t **p, *mem;
3682 // cycle to the next frame's buffers
3684 // if we ran out of space on the last time we used these buffers, free the old memory now
3685 for (type = 0;type < R_BUFFERDATA_COUNT;type++)
3686 {
3688 {
3690 // free all but the head buffer, this is how we recycle obsolete
3691 // buffers after they are no longer in use
3693 while (*p)
3694 {
3695 mem = *p;
3696 *p = (*p)->purge;
3697 if (mem->buffer)
3699 Mem_Free(mem);
3700 }
3701 // reset the current offset
3703 }
3704 }
3705}
void R_Mesh_DestroyMeshBuffer(r_meshbuffer_t *buffer)
#define R_BUFFERDATA_CYCLE
Definition gl_rmain.c:3598
static r_bufferdata_buffer_t * r_bufferdata_buffer[R_BUFFERDATA_CYCLE][R_BUFFERDATA_COUNT]
Definition gl_rmain.c:3610
static void R_BufferData_Resize(r_bufferdata_type_t type, qbool mustgrow, size_t minsize)
Definition gl_rmain.c:3636
static int r_bufferdata_cycle
Definition gl_rmain.c:3609
GLenum type
Definition glquake.h:656
r_bufferdata_type_t
enum of the various types of hardware buffer object used in rendering note that the r_buffermegs[] ar...
Definition render.h:524
struct r_bufferdata_buffer_s * purge
Definition gl_rmain.c:3602
r_meshbuffer_t * buffer
Definition gl_rmain.c:3605

References r_bufferdata_buffer_t::buffer, Mem_Free, r_bufferdata_buffer_t::purge, r_bufferdata_buffer, R_BUFFERDATA_COUNT, R_BUFFERDATA_CYCLE, r_bufferdata_cycle, R_BufferData_Resize(), R_Mesh_DestroyMeshBuffer(), and type.

Referenced by CL_UpdateScreen().

◆ R_BufferData_Reset()

void R_BufferData_Reset ( void )

free all dynamic vertex/index/uniform buffers

free all dynamic vertex/index/uniform buffers

Definition at line 3613 of file gl_rmain.c.

3614{
3615 int cycle, type;
3616 r_bufferdata_buffer_t **p, *mem;
3617 for (cycle = 0;cycle < R_BUFFERDATA_CYCLE;cycle++)
3618 {
3619 for (type = 0;type < R_BUFFERDATA_COUNT;type++)
3620 {
3621 // free all buffers
3622 p = &r_bufferdata_buffer[cycle][type];
3623 while (*p)
3624 {
3625 mem = *p;
3626 *p = (*p)->purge;
3627 if (mem->buffer)
3629 Mem_Free(mem);
3630 }
3631 }
3632 }
3633}

References r_bufferdata_buffer_t::buffer, Mem_Free, r_bufferdata_buffer_t::purge, r_bufferdata_buffer, R_BUFFERDATA_COUNT, R_BUFFERDATA_CYCLE, R_Mesh_DestroyMeshBuffer(), and type.

Referenced by gl_main_newmap(), gl_main_shutdown(), and gl_main_start().

◆ R_BufferData_Store()

r_meshbuffer_t * R_BufferData_Store ( size_t size,
const void * data,
r_bufferdata_type_t type,
int * returnbufferoffset )

request space in a vertex/index/uniform buffer for the chosen data, returns the buffer pointer and offset, always successful

Definition at line 3707 of file gl_rmain.c.

3708{
3710 int offset = 0;
3711 int padsize;
3712
3713 *returnbufferoffset = 0;
3714
3715 // align size to a byte boundary appropriate for the buffer type, this
3716 // makes all allocations have aligned start offsets
3718 padsize = (datasize + r_uniformbufferalignment - 1) & ~(r_uniformbufferalignment - 1);
3719 else
3720 padsize = (datasize + 15) & ~15;
3721
3722 // if we ran out of space in this buffer we must allocate a new one
3724 R_BufferData_Resize(type, true, padsize);
3725
3726 // if the resize did not give us enough memory, fail
3728 Sys_Error("R_BufferData_Store: failed to create a new buffer of sufficient size\n");
3729
3731 offset = (int)mem->current;
3732 mem->current += padsize;
3733
3734 // upload the data to the buffer at the chosen offset
3735 if (offset == 0)
3736 R_Mesh_UpdateMeshBuffer(mem->buffer, NULL, mem->size, false, 0);
3737 R_Mesh_UpdateMeshBuffer(mem->buffer, data, datasize, true, offset);
3738
3739 // count the usage for stats
3742
3743 // return the buffer offset
3744 *returnbufferoffset = offset;
3745
3746 return mem->buffer;
3747}
vector size
static int(ZEXPORT *qz_inflate)(z_stream *strm
void R_Mesh_UpdateMeshBuffer(r_meshbuffer_t *buffer, const void *data, size_t size, qbool subdata, size_t offset)
int r_uniformbufferalignment
Definition gl_rmain.c:270
GLsizeiptr const GLvoid * data
Definition glquake.h:639
GLuint GLuint GLintptr offset
Definition glquake.h:632
@ r_stat_bufferdatasize_vertex
Definition r_stats.h:57
@ r_stat_bufferdatacurrent_vertex
Definition r_stats.h:53
void Sys_Error(const char *error,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
Causes the entire program to exit ASAP.
Definition sys_shared.c:724

References r_bufferdata_buffer_t::buffer, r_bufferdata_buffer_t::current, data, int(), max, NULL, offset, r_bufferdata_buffer, r_bufferdata_cycle, R_BufferData_Resize(), R_BUFFERDATA_UNIFORM, R_Mesh_UpdateMeshBuffer(), r_refdef, r_stat_bufferdatacurrent_vertex, r_stat_bufferdatasize_vertex, r_uniformbufferalignment, r_bufferdata_buffer_t::size, size, Sys_Error(), and type.

Referenced by Mod_Mesh_UploadDynamicBuffers(), R_AnimCache_GetEntity(), R_Mesh_Draw(), R_Mesh_PrepareVertices_Generic_Arrays(), R_Mesh_PrepareVertices_Mesh_Arrays(), R_Mesh_PrepareVertices_Vertex3f(), and RSurf_UploadBuffersForBatch().

◆ R_BuildLightMap()

void R_BuildLightMap ( const entity_render_t * ent,
msurface_t * surface,
int combine )

Definition at line 50 of file gl_rsurf.c.

51{
52 int smax, tmax, i, size, size3, maps, l;
53 int *bl, scale;
54 unsigned char *lightmap, *out, *stain;
55 model_t *model = ent->model;
56 int *intblocklights;
57 unsigned char *templight;
58
59 smax = (surface->lightmapinfo->extents[0]>>4)+1;
60 tmax = (surface->lightmapinfo->extents[1]>>4)+1;
61 size = smax*tmax;
62 size3 = size*3;
63
66
67 if (cl.buildlightmapmemorysize < size*sizeof(int[3]))
68 {
69 cl.buildlightmapmemorysize = size*sizeof(int[3]);
70 if (cl.buildlightmapmemory)
71 Mem_Free(cl.buildlightmapmemory);
72 cl.buildlightmapmemory = (unsigned char *) Mem_Alloc(cls.levelmempool, cl.buildlightmapmemorysize);
73 }
74
75 // these both point at the same buffer, templight is only used for final
76 // processing and can replace the intblocklights data as it goes
77 intblocklights = (int *)cl.buildlightmapmemory;
78 templight = (unsigned char *)cl.buildlightmapmemory;
79
80 // update cached lighting info
81 model->brushq1.lightmapupdateflags[surface - model->data_surfaces] = false;
82
83 lightmap = surface->lightmapinfo->samples;
84
85// set to full bright if no light data
86 bl = intblocklights;
87 if (!model->brushq1.lightdata)
88 {
89 for (i = 0;i < size3;i++)
90 bl[i] = 128*256;
91 }
92 else
93 {
94// clear to no light
95 memset(bl, 0, size3*sizeof(*bl));
96
97// add all the lightmaps
98 if (lightmap)
99 for (maps = 0;maps < MAXLIGHTMAPS && surface->lightmapinfo->styles[maps] != 255;maps++, lightmap += size3)
100 for (scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[maps]], i = 0;i < size3;i++)
101 bl[i] += lightmap[i] * scale;
102 }
103
104 stain = surface->lightmapinfo->stainsamples;
105 bl = intblocklights;
106 out = templight;
107 // the >> 16 shift adjusts down 8 bits to account for the stainmap
108 // scaling, and remaps the 0-65536 (2x overbright) to 0-256, it will
109 // be doubled during rendering to achieve 2x overbright
110 // (0 = 0.0, 128 = 1.0, 256 = 2.0)
111 if (stain)
112 {
113 for (i = 0;i < size;i++, bl += 3, stain += 3, out += 4)
114 {
115 l = (bl[0] * stain[0]) >> 16;out[2] = min(l, 255);
116 l = (bl[1] * stain[1]) >> 16;out[1] = min(l, 255);
117 l = (bl[2] * stain[2]) >> 16;out[0] = min(l, 255);
118 out[3] = 255;
119 }
120 }
121 else
122 {
123 for (i = 0;i < size;i++, bl += 3, out += 4)
124 {
125 l = bl[0] >> 8;out[2] = min(l, 255);
126 l = bl[1] >> 8;out[1] = min(l, 255);
127 l = bl[2] >> 8;out[0] = min(l, 255);
128 out[3] = 255;
129 }
130 }
131
132 if(vid_sRGB.integer && vid_sRGB_fallback.integer && !vid.sRGB3D)
133 Image_MakesRGBColorsFromLinear_Lightmap(templight, templight, size);
134 R_UpdateTexture(surface->lightmaptexture, templight, surface->lightmapinfo->lightmaporigin[0], surface->lightmapinfo->lightmaporigin[1], 0, smax, tmax, 1, combine);
135
136 // update the surface's deluxemap if it has one
138 {
139 vec3_t n;
140 unsigned char *normalmap = surface->lightmapinfo->nmapsamples;
141 lightmap = surface->lightmapinfo->samples;
142 // clear to no normalmap
143 bl = intblocklights;
144 memset(bl, 0, size3*sizeof(*bl));
145 // add all the normalmaps
146 if (lightmap && normalmap)
147 {
148 for (maps = 0;maps < MAXLIGHTMAPS && surface->lightmapinfo->styles[maps] != 255;maps++, lightmap += size3, normalmap += size3)
149 {
150 for (scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[maps]], i = 0;i < size;i++)
151 {
152 // add the normalmap with weighting proportional to the style's lightmap intensity
153 l = (int)(VectorLength(lightmap + i*3) * scale);
154 bl[i*3+0] += ((int)normalmap[i*3+0] - 128) * l;
155 bl[i*3+1] += ((int)normalmap[i*3+1] - 128) * l;
156 bl[i*3+2] += ((int)normalmap[i*3+2] - 128) * l;
157 }
158 }
159 }
160 bl = intblocklights;
161 out = templight;
162 // we simply renormalize the weighted normals to get a valid deluxemap
163 for (i = 0;i < size;i++, bl += 3, out += 4)
164 {
165 VectorCopy(bl, n);
167 l = (int)(n[0] * 128 + 128);out[2] = bound(0, l, 255);
168 l = (int)(n[1] * 128 + 128);out[1] = bound(0, l, 255);
169 l = (int)(n[2] * 128 + 128);out[0] = bound(0, l, 255);
170 out[3] = 255;
171 }
172 R_UpdateTexture(surface->deluxemaptexture, templight, surface->lightmapinfo->lightmaporigin[0], surface->lightmapinfo->lightmaporigin[1], 0, smax, tmax, 1, r_q1bsp_lightmap_updates_combine.integer);
173 }
174}
#define MAXLIGHTMAPS
Definition bspfile.h:282
client_static_t cls
Definition cl_main.c:116
#define n(x, y)
rtexture_t * r_texture_blanknormalmap
Definition gl_rmain.c:272
void R_UpdateTexture(rtexture_t *rt, const unsigned char *data, int x, int y, int z, int width, int height, int depth, int combine)
void Image_MakesRGBColorsFromLinear_Lightmap(unsigned char *pout, const unsigned char *pin, int numpixels)
Definition image.c:946
#define min(A, B)
Definition mathlib.h:37
#define VectorNormalize(v)
Definition mathlib.h:104
#define bound(min, num, max)
Definition mathlib.h:34
#define VectorLength(a)
Definition mathlib.h:109
#define VectorCopy(in, out)
Definition mathlib.h:101
@ r_stat_lightmapupdatepixels
Definition r_stats.h:20
@ r_stat_lightmapupdates
Definition r_stats.h:19
unsigned char * stainsamples
unsigned char styles[MAXLIGHTMAPS]
unsigned char * samples
unsigned char * nmapsamples
msurface_lightmapinfo_t * lightmapinfo
lightmaptexture rebuild information not used in q3bsp
struct rtexture_s * deluxemaptexture
the lighting direction texture fragment to use on the rendering mesh
struct rtexture_s * lightmaptexture
the lightmap texture fragment to use on the rendering mesh
cvar_t vid_sRGB_fallback
Definition vid_shared.c:158
cvar_t vid_sRGB
Definition vid_shared.c:157

References bound, cl, cls, msurface_t::deluxemaptexture, msurface_lightmapinfo_t::extents, Image_MakesRGBColorsFromLinear_Lightmap(), int(), msurface_t::lightmapinfo, msurface_lightmapinfo_t::lightmaporigin, msurface_t::lightmaptexture, MAXLIGHTMAPS, Mem_Alloc, Mem_Free, min, entity_render_t::model, model, n, msurface_lightmapinfo_t::nmapsamples, r_q1bsp_lightmap_updates_combine, r_refdef, r_stat_lightmapupdatepixels, r_stat_lightmapupdates, r_texture_blanknormalmap, R_UpdateTexture(), msurface_lightmapinfo_t::samples, scale, size, msurface_lightmapinfo_t::stainsamples, msurface_lightmapinfo_t::styles, VectorCopy, VectorLength, VectorNormalize, vid, vid_sRGB, and vid_sRGB_fallback.

Referenced by R_DrawModelSurfaces().

◆ R_CalcBeam_Vertex3f()

void R_CalcBeam_Vertex3f ( float * vert,
const float * org1,
const float * org2,
float width )

Definition at line 6253 of file gl_rmain.c.

6254{
6255 vec3_t right1, right2, diff, normal;
6256
6257 VectorSubtract (org2, org1, normal);
6258
6259 // calculate 'right' vector for start
6260 VectorSubtract (r_refdef.view.origin, org1, diff);
6261 CrossProduct (normal, diff, right1);
6262 VectorNormalize (right1);
6263
6264 // calculate 'right' vector for end
6265 VectorSubtract (r_refdef.view.origin, org2, diff);
6266 CrossProduct (normal, diff, right2);
6267 VectorNormalize (right2);
6268
6269 vert[ 0] = org1[0] + width * right1[0];
6270 vert[ 1] = org1[1] + width * right1[1];
6271 vert[ 2] = org1[2] + width * right1[2];
6272 vert[ 3] = org1[0] - width * right1[0];
6273 vert[ 4] = org1[1] - width * right1[1];
6274 vert[ 5] = org1[2] - width * right1[2];
6275 vert[ 6] = org2[0] - width * right2[0];
6276 vert[ 7] = org2[1] - width * right2[1];
6277 vert[ 8] = org2[2] - width * right2[2];
6278 vert[ 9] = org2[0] + width * right2[0];
6279 vert[10] = org2[1] + width * right2[1];
6280 vert[11] = org2[2] + width * right2[2];
6281}
GLenum GLsizei width
Definition glquake.h:622
#define VectorSubtract(a, b, out)
Definition mathlib.h:99
#define CrossProduct(a, b, out)
Definition mathlib.h:103
vec3 normal

References CrossProduct, normal, r_refdef, VectorNormalize, VectorSubtract, and width.

Referenced by R_DrawParticle_TransparentCallback().

◆ R_CalcSprite_Vertex3f()

void R_CalcSprite_Vertex3f ( float * vertex3f,
const vec3_t origin,
const vec3_t left,
const vec3_t up,
float scalex1,
float scalex2,
float scaley1,
float scaley2 )

Definition at line 6283 of file gl_rmain.c.

6284{
6285 vertex3f[ 0] = origin[0] + left[0] * scalex2 + up[0] * scaley1;
6286 vertex3f[ 1] = origin[1] + left[1] * scalex2 + up[1] * scaley1;
6287 vertex3f[ 2] = origin[2] + left[2] * scalex2 + up[2] * scaley1;
6288 vertex3f[ 3] = origin[0] + left[0] * scalex2 + up[0] * scaley2;
6289 vertex3f[ 4] = origin[1] + left[1] * scalex2 + up[1] * scaley2;
6290 vertex3f[ 5] = origin[2] + left[2] * scalex2 + up[2] * scaley2;
6291 vertex3f[ 6] = origin[0] + left[0] * scalex1 + up[0] * scaley2;
6292 vertex3f[ 7] = origin[1] + left[1] * scalex1 + up[1] * scaley2;
6293 vertex3f[ 8] = origin[2] + left[2] * scalex1 + up[2] * scaley2;
6294 vertex3f[ 9] = origin[0] + left[0] * scalex1 + up[0] * scaley1;
6295 vertex3f[10] = origin[1] + left[1] * scalex1 + up[1] * scaley1;
6296 vertex3f[11] = origin[2] + left[2] * scalex1 + up[2] * scaley1;
6297}
vector origin
static vec3_t up
Definition sv_user.c:305

References origin, and up.

Referenced by R_BeginCoronaQuery(), R_DrawCorona(), R_Model_Sprite_Draw_TransparentCallback(), R_Shadow_DrawCursor_TransparentCallback(), and R_Shadow_DrawLightSprite_TransparentCallback().

◆ R_CanSeeBox()

qbool R_CanSeeBox ( int numsamples,
vec_t eyejitter,
vec_t entboxenlarge,
vec_t entboxexpand,
vec_t pad,
vec3_t eye,
vec3_t entboxmins,
vec3_t entboxmaxs )

Definition at line 3888 of file gl_rmain.c.

3889{
3890 long unsigned int i;
3891 int j;
3892 vec3_t eyemins, eyemaxs;
3893 vec3_t boxmins, boxmaxs;
3894 vec3_t padmins, padmaxs;
3895 vec3_t start;
3896 vec3_t end;
3897 model_t *model = r_refdef.scene.worldmodel;
3898 static vec3_t positions[] = {
3899 { 0.5f, 0.5f, 0.5f },
3900 { 0.0f, 0.0f, 0.0f },
3901 { 0.0f, 0.0f, 1.0f },
3902 { 0.0f, 1.0f, 0.0f },
3903 { 0.0f, 1.0f, 1.0f },
3904 { 1.0f, 0.0f, 0.0f },
3905 { 1.0f, 0.0f, 1.0f },
3906 { 1.0f, 1.0f, 0.0f },
3907 { 1.0f, 1.0f, 1.0f },
3908 };
3909
3910 // sample count can be set to -1 to skip this logic, for flicker-prone objects
3911 if (numsamples < 0)
3912 return true;
3913
3914 // view origin is not used for culling in portal/reflection/refraction renders or isometric views
3915 if (!r_refdef.view.usevieworiginculling)
3916 return true;
3917
3918 if (!r_cullentities_trace_entityocclusion.integer && (!model || !model->brush.TraceLineOfSight))
3919 return true;
3920
3921 // expand the eye box a little
3922 eyemins[0] = eye[0] - eyejitter;
3923 eyemaxs[0] = eye[0] + eyejitter;
3924 eyemins[1] = eye[1] - eyejitter;
3925 eyemaxs[1] = eye[1] + eyejitter;
3926 eyemins[2] = eye[2] - eyejitter;
3927 eyemaxs[2] = eye[2] + eyejitter;
3928 // expand the box a little
3929 boxmins[0] = (entboxenlarge + 1) * entboxmins[0] - entboxenlarge * entboxmaxs[0] - entboxexpand;
3930 boxmaxs[0] = (entboxenlarge + 1) * entboxmaxs[0] - entboxenlarge * entboxmins[0] + entboxexpand;
3931 boxmins[1] = (entboxenlarge + 1) * entboxmins[1] - entboxenlarge * entboxmaxs[1] - entboxexpand;
3932 boxmaxs[1] = (entboxenlarge + 1) * entboxmaxs[1] - entboxenlarge * entboxmins[1] + entboxexpand;
3933 boxmins[2] = (entboxenlarge + 1) * entboxmins[2] - entboxenlarge * entboxmaxs[2] - entboxexpand;
3934 boxmaxs[2] = (entboxenlarge + 1) * entboxmaxs[2] - entboxenlarge * entboxmins[2] + entboxexpand;
3935 // make an even larger box for the acceptable area
3936 padmins[0] = boxmins[0] - pad;
3937 padmaxs[0] = boxmaxs[0] + pad;
3938 padmins[1] = boxmins[1] - pad;
3939 padmaxs[1] = boxmaxs[1] + pad;
3940 padmins[2] = boxmins[2] - pad;
3941 padmaxs[2] = boxmaxs[2] + pad;
3942
3943 // return true if eye overlaps enlarged box
3944 if (BoxesOverlap(boxmins, boxmaxs, eyemins, eyemaxs))
3945 return true;
3946
3947 VectorCopy(eye, start);
3948 // try specific positions in the box first - note that these can be cached
3950 {
3951 for (i = 0; i < sizeof(positions) / sizeof(positions[0]); i++)
3952 {
3953 trace_t trace;
3954 end[0] = boxmins[0] + (boxmaxs[0] - boxmins[0]) * positions[i][0];
3955 end[1] = boxmins[1] + (boxmaxs[1] - boxmins[1]) * positions[i][1];
3956 end[2] = boxmins[2] + (boxmaxs[2] - boxmins[2]) * positions[i][2];
3957 //trace_t trace = CL_TraceLine(start, end, MOVE_NORMAL, NULL, SUPERCONTENTS_SOLID, SUPERCONTENTS_SKY, MATERIALFLAGMASK_TRANSLUCENT, 0.0f, true, false, NULL, true, true);
3959 // not picky - if the trace ended anywhere in the box we're good
3960 if (BoxesOverlap(trace.endpos, trace.endpos, padmins, padmaxs))
3961 return true;
3962 }
3963 }
3964 else
3965 {
3966 // try center
3967 VectorMAM(0.5f, boxmins, 0.5f, boxmaxs, end);
3968 if (model->brush.TraceLineOfSight(model, start, end, padmins, padmaxs))
3969 return true;
3970 }
3971
3972 // try various random positions
3973 for (j = 0; j < numsamples; j++)
3974 {
3975 VectorSet(start, lhrandom(eyemins[0], eyemaxs[0]), lhrandom(eyemins[1], eyemaxs[1]), lhrandom(eyemins[2], eyemaxs[2]));
3976 VectorSet(end, lhrandom(boxmins[0], boxmaxs[0]), lhrandom(boxmins[1], boxmaxs[1]), lhrandom(boxmins[2], boxmaxs[2]));
3978 {
3979 trace_t trace = CL_TraceLine(start, end, MOVE_NORMAL, NULL, SUPERCONTENTS_SOLID, SUPERCONTENTS_SKY, MATERIALFLAGMASK_TRANSLUCENT, 0.0f, true, false, NULL, true, true);
3980 // not picky - if the trace ended anywhere in the box we're good
3981 if (BoxesOverlap(trace.endpos, trace.endpos, padmins, padmaxs))
3982 return true;
3983 }
3984 else if (model->brush.TraceLineOfSight(model, start, end, padmins, padmaxs))
3985 return true;
3986 }
3987
3988 return false;
3989}
#define SUPERCONTENTS_SKY
Definition bspfile.h:200
#define SUPERCONTENTS_SOLID
Definition bspfile.h:196
trace_t CL_TraceLine(const vec3_t start, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask, float extend, qbool hitnetworkbrushmodels, qbool hitnetworkplayers, int *hitnetworkentity, qbool hitcsqcentities, qbool hitsurfaces)
trace_t CL_Cache_TraceLineSurfaces(const vec3_t start, const vec3_t end, int type, int hitsupercontentsmask, int skipsupercontentsmask, int skipmaterialflagsmask)
#define BoxesOverlap(a, b, c, d)
Definition mathlib.h:122
#define lhrandom(MIN, MAX)
LadyHavoc: this function never returns exactly MIN or exactly MAX, because of a QuakeC bug in id1 whe...
Definition mathlib.h:48
#define VectorMAM(scale1, b1, scale2, b2, out)
Definition mathlib.h:116
#define MATERIALFLAGMASK_TRANSLUCENT
double endpos[3]
Definition collision.h:42
#define MOVE_NORMAL
Definition world.h:28

References BoxesOverlap, CL_Cache_TraceLineSurfaces(), CL_TraceLine(), trace_t::endpos, lhrandom, MATERIALFLAGMASK_TRANSLUCENT, model, MOVE_NORMAL, NULL, r_cullentities_trace_entityocclusion, r_refdef, SUPERCONTENTS_SKY, SUPERCONTENTS_SOLID, VectorCopy, VectorMAM, and VectorSet.

Referenced by R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_PrepareLight(), R_View_UpdateEntityVisible(), R_View_WorldVisibility(), and R_View_WorldVisibility_CullSurfaces().

◆ R_CompileShader_CheckStaticParms()

qbool R_CompileShader_CheckStaticParms ( void )

Definition at line 861 of file gl_rmain.c.

862{
863 static int r_compileshader_staticparms_save[(SHADERSTATICPARMS_COUNT + 0x1F) >> 5];
864 memcpy(r_compileshader_staticparms_save, r_compileshader_staticparms, sizeof(r_compileshader_staticparms));
866
867 // detect all
872 if (r_shadow_glossexact.integer)
874 if (r_glsl_postprocess.integer)
875 {
884 }
885 if (r_fxaa.integer)
889
892 if (r_shadow_shadowmappcf > 1)
894 else if (r_shadow_shadowmappcf)
896 if (r_celshading.integer)
898 if (r_celoutlines.integer)
900 if (r_colorfringe.value)
902
903 return memcmp(r_compileshader_staticparms, r_compileshader_staticparms_save, sizeof(r_compileshader_staticparms)) != 0;
904}
int r_shadow_shadowmappcf
Definition r_shadow.c:60
#define R_COMPILESHADER_STATICPARM_ENABLE(p)
Definition gl_rmain.c:857
@ SHADERSTATICPARM_POSTPROCESS_USERVEC4
postprocess uservec4 is enabled
Definition gl_rmain.c:840
@ SHADERSTATICPARM_SHADOWSAMPLER
sampler
Definition gl_rmain.c:845
@ SHADERSTATICPARM_EXACTSPECULARMATH
(lightsource or deluxemapping) use exact reflection map for specular effects, as opposed to the usual...
Definition gl_rmain.c:836
@ SHADERSTATICPARM_CELOUTLINES
celoutline (depth buffer analysis to produce outlines)
Definition gl_rmain.c:847
@ SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS
Definition gl_rmain.c:841
@ SHADERSTATICPARM_SHADOWMAPPCF_1
PCF 1.
Definition gl_rmain.c:843
@ SHADERSTATICPARM_CELSHADING
celshading (alternative diffuse and specular math)
Definition gl_rmain.c:846
@ SHADERSTATICPARM_COLORFRINGE
colorfringe (chromatic aberration)
Definition gl_rmain.c:849
@ SHADERSTATICPARM_POSTPROCESS_USERVEC2
postprocess uservec2 is enabled
Definition gl_rmain.c:838
@ SHADERSTATICPARM_OFFSETMAPPING_USELOD
LOD for offsetmapping.
Definition gl_rmain.c:842
@ SHADERSTATICPARM_FXAA
fast approximate anti aliasing
Definition gl_rmain.c:848
@ SHADERSTATICPARM_POSTPROCESS_USERVEC1
postprocess uservec1 is enabled
Definition gl_rmain.c:837
@ SHADERSTATICPARM_SATURATION_REDCOMPENSATE
red compensation filter for saturation
Definition gl_rmain.c:835
@ SHADERSTATICPARM_SHADOWMAPPCF_2
PCF 2.
Definition gl_rmain.c:844
@ SHADERSTATICPARM_POSTPROCESS_USERVEC3
postprocess uservec3 is enabled
Definition gl_rmain.c:839
qbool r_shadow_shadowmapsampler
Definition r_shadow.c:58
#define SHADERSTATICPARMS_COUNT
Definition gl_rmain.c:851
static unsigned int r_compileshader_staticparms[(SHADERSTATICPARMS_COUNT+0x1F) > > 5]
Definition gl_rmain.c:856
cvar_t r_shadow_glossexact
Definition r_shadow.c:152

References r_celoutlines, r_celshading, r_colorfringe, R_COMPILESHADER_STATICPARM_ENABLE, r_compileshader_staticparms, r_fxaa, r_glsl_offsetmapping_lod, r_glsl_offsetmapping_lod_distance, r_glsl_postprocess, r_glsl_postprocess_uservec1_enable, r_glsl_postprocess_uservec2_enable, r_glsl_postprocess_uservec3_enable, r_glsl_postprocess_uservec4_enable, r_glsl_saturation_redcompensate, r_glsl_vertextextureblend_usebothalphas, r_shadow_glossexact, r_shadow_shadowmappcf, r_shadow_shadowmapsampler, SHADERSTATICPARM_CELOUTLINES, SHADERSTATICPARM_CELSHADING, SHADERSTATICPARM_COLORFRINGE, SHADERSTATICPARM_EXACTSPECULARMATH, SHADERSTATICPARM_FXAA, SHADERSTATICPARM_OFFSETMAPPING_USELOD, SHADERSTATICPARM_POSTPROCESS_USERVEC1, SHADERSTATICPARM_POSTPROCESS_USERVEC2, SHADERSTATICPARM_POSTPROCESS_USERVEC3, SHADERSTATICPARM_POSTPROCESS_USERVEC4, SHADERSTATICPARM_SATURATION_REDCOMPENSATE, SHADERSTATICPARM_SHADOWMAPPCF_1, SHADERSTATICPARM_SHADOWMAPPCF_2, SHADERSTATICPARM_SHADOWSAMPLER, SHADERSTATICPARM_VERTEXTEXTUREBLEND_USEBOTHALPHAS, and SHADERSTATICPARMS_COUNT.

Referenced by R_RenderView(), and R_Shadow_SetShadowMode().

◆ R_CullBox()

qbool R_CullBox ( const vec3_t mins,
const vec3_t maxs,
int numplanes,
const mplane_t * planes )

Definition at line 3470 of file gl_rmain.c.

3471{
3472 // nothing to ignore
3473 return _R_CullBox(mins, maxs, numplanes, planes, -1);
3474}
vector mins
vector maxs
static qbool _R_CullBox(const vec3_t mins, const vec3_t maxs, int numplanes, const mplane_t *planes, int ignore)
Definition gl_rmain.c:3445

References _R_CullBox(), maxs, and mins.

Referenced by R_Q1BSP_RecursiveGetLightInfo_BIH(), R_Q1BSP_RecursiveGetLightInfo_BSP(), and R_Shadow_PrepareLight().

◆ R_CullFrustum()

qbool R_CullFrustum ( const vec3_t mins,
const vec3_t maxs )

Definition at line 3464 of file gl_rmain.c.

3465{
3466 // skip nearclip plane, it often culls portals when you are very close, and is almost never useful
3467 return _R_CullBox(mins, maxs, r_refdef.view.numfrustumplanes, r_refdef.view.frustum, 4);
3468}

References _R_CullBox(), maxs, mins, and r_refdef.

Referenced by R_DrawDebugModel(), R_DrawPortals(), R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_BounceGrid_TracePhotons_Shot(), R_Shadow_PrepareLight(), R_View_UpdateEntityVisible(), R_View_WorldVisibility(), and R_View_WorldVisibility_CullSurfaces().

◆ R_DebugLine()

void R_DebugLine ( vec3_t start,
vec3_t end )

Definition at line 10107 of file gl_rmain.c.

10108{
10109 model_t *mod = CL_Mesh_UI();
10110 msurface_t *surf;
10111 int e0, e1, e2, e3;
10112 float offsetx, offsety, x1, y1, x2, y2, width = 1.0f;
10113 float r1 = 1.0f, g1 = 0.0f, b1 = 0.0f, alpha1 = 0.25f;
10114 float r2 = 1.0f, g2 = 1.0f, b2 = 0.0f, alpha2 = 0.25f;
10115 vec4_t w[2], s[2];
10116
10117 // transform to screen coords first
10118 Vector4Set(w[0], start[0], start[1], start[2], 1);
10119 Vector4Set(w[1], end[0], end[1], end[2], 1);
10120 R_Viewport_TransformToScreen(&r_refdef.view.viewport, w[0], s[0]);
10121 R_Viewport_TransformToScreen(&r_refdef.view.viewport, w[1], s[1]);
10122 x1 = s[0][0] * vid_conwidth.value / vid.mode.width;
10123 y1 = (vid.mode.height - s[0][1]) * vid_conheight.value / vid.mode.height;
10124 x2 = s[1][0] * vid_conwidth.value / vid.mode.width;
10125 y2 = (vid.mode.height - s[1][1]) * vid_conheight.value / vid.mode.height;
10126 //Con_DPrintf("R_DebugLine: %.0f,%.0f to %.0f,%.0f\n", x1, y1, x2, y2);
10127
10128 // add the line to the UI mesh for drawing later
10129
10130 // width is measured in real pixels
10131 if (fabs(x2 - x1) > fabs(y2 - y1))
10132 {
10133 offsetx = 0;
10134 offsety = 0.5f * width * vid_conheight.value / vid.mode.height;
10135 }
10136 else
10137 {
10138 offsetx = 0.5f * width * vid_conwidth.value / vid.mode.width;
10139 offsety = 0;
10140 }
10142 e0 = Mod_Mesh_IndexForVertex(mod, surf, x1 - offsetx, y1 - offsety, 10, 0, 0, -1, 0, 0, 0, 0, r1, g1, b1, alpha1);
10143 e1 = Mod_Mesh_IndexForVertex(mod, surf, x2 - offsetx, y2 - offsety, 10, 0, 0, -1, 0, 0, 0, 0, r2, g2, b2, alpha2);
10144 e2 = Mod_Mesh_IndexForVertex(mod, surf, x2 + offsetx, y2 + offsety, 10, 0, 0, -1, 0, 0, 0, 0, r2, g2, b2, alpha2);
10145 e3 = Mod_Mesh_IndexForVertex(mod, surf, x1 + offsetx, y1 + offsety, 10, 0, 0, -1, 0, 0, 0, 0, r1, g1, b1, alpha1);
10146 Mod_Mesh_AddTriangle(mod, surf, e0, e1, e2);
10147 Mod_Mesh_AddTriangle(mod, surf, e0, e2, e3);
10148
10149}
#define CL_Mesh_UI()
Definition client.h:1372
float mod(float dividend, float divisor)
void R_Viewport_TransformToScreen(const r_viewport_t *v, const vec4_t in, vec4_t out)
Definition gl_backend.c:383
GLubyte GLubyte GLubyte GLubyte w
Definition glquake.h:782
#define Vector4Set(vec, r, g, b, a)
Definition mathlib.h:86
float fabs(float f)
#define MATERIALFLAG_VERTEXCOLOR
#define MATERIALFLAG_ALPHA
Definition model_brush.h:79
#define MATERIALFLAG_BLENDED
#define MATERIALFLAG_ALPHAGEN_VERTEX
#define MATERIALFLAG_WALL
Definition model_brush.h:89
#define MATERIALFLAG_NOSHADOW
msurface_t * Mod_Mesh_AddSurface(model_t *mod, texture_t *tex, qbool batchwithprevioussurface)
int Mod_Mesh_IndexForVertex(model_t *mod, msurface_t *surf, float x, float y, float z, float nx, float ny, float nz, float s, float t, float u, float v, float r, float g, float b, float a)
texture_t * Mod_Mesh_GetTexture(model_t *mod, const char *name, int defaultdrawflags, int defaulttexflags, int defaultmaterialflags)
void Mod_Mesh_AddTriangle(model_t *mod, msurface_t *surf, int e0, int e1, int e2)
vec_t vec4_t[4]
Definition qtypes.h:72
vec3 y2
vec3 x2
vec3 x1
describes the textures to use on a range of triangles in the model, and mins/maxs (AABB) for culling.

References CL_Mesh_UI, fabs(), MATERIALFLAG_ALPHA, MATERIALFLAG_ALPHAGEN_VERTEX, MATERIALFLAG_BLENDED, MATERIALFLAG_NOSHADOW, MATERIALFLAG_VERTEXCOLOR, MATERIALFLAG_WALL, mod(), Mod_Mesh_AddSurface(), Mod_Mesh_AddTriangle(), Mod_Mesh_GetTexture(), Mod_Mesh_IndexForVertex(), r_refdef, R_Viewport_TransformToScreen(), Vector4Set, vid, vid_conheight, vid_conwidth, w, width, x1, x2, and y2.

Referenced by R_DrawParticle_TransparentCallback(), and R_Model_Sprite_Draw_TransparentCallback().

◆ R_DecalSystem_Reset()

void R_DecalSystem_Reset ( decalsystem_t * decalsystem)

Definition at line 9134 of file gl_rmain.c.

9135{
9136 if (decalsystem->decals)
9137 Mem_Free(decalsystem->decals);
9138 memset(decalsystem, 0, sizeof(*decalsystem));
9139}
tridecal_t * decals
Definition client.h:61

References decalsystem_t::decals, and Mem_Free.

Referenced by CL_UpdateNetworkEntities(), CLVM_free_edict(), R_DecalSystem_SplatEntity(), R_DrawModelDecals_Entity(), and R_DrawModelDecals_FadeEntity().

◆ R_DecalSystem_SplatEntities()

void R_DecalSystem_SplatEntities ( const vec3_t org,
const vec3_t normal,
float r,
float g,
float b,
float a,
float s1,
float t1,
float s2,
float t2,
float size )

Definition at line 9506 of file gl_rmain.c.

9507{
9509
9511 return;
9512
9514 VectorCopy(worldorigin, queue->worldorigin);
9515 VectorCopy(worldnormal, queue->worldnormal);
9516 Vector4Set(queue->color, r, g, b, a);
9517 Vector4Set(queue->tcrange, s1, t1, s2, t2);
9518 queue->worldsize = worldsize;
9519 queue->decalsequence = cl.decalsequence++;
9520}
int r_decalsystem_numqueued
Definition gl_rmain.c:9503
r_decalsystem_splatqueue_t r_decalsystem_queue[MAX_DECALSYSTEM_QUEUE]
Definition gl_rmain.c:9504
#define MAX_DECALSYSTEM_QUEUE
Definition qdefs.h:150
dp_FragColor r
dp_FragColor g
dp_FragColor b
ret a

References a, b, cl, r_decalsystem_splatqueue_t::color, r_decalsystem_splatqueue_t::decalsequence, g, MAX_DECALSYSTEM_QUEUE, r, r_decalsystem_numqueued, r_decalsystem_queue, r_decalsystem_splatqueue_t::tcrange, Vector4Set, VectorCopy, r_decalsystem_splatqueue_t::worldnormal, r_decalsystem_splatqueue_t::worldorigin, and r_decalsystem_splatqueue_t::worldsize.

Referenced by CL_ImmediateBloodStain(), and CL_SpawnDecalParticleForSurface().

◆ R_DrawCustomSurface()

void R_DrawCustomSurface ( skinframe_t * skinframe,
const matrix4x4_t * texmatrix,
int materialflags,
int firstvertex,
int numvertices,
int firsttriangle,
int numtriangles,
qbool writedepth,
qbool prepass,
qbool ui )

Definition at line 10152 of file gl_rmain.c.

10153{
10154 static texture_t texture;
10155
10156 // fake enough texture and surface state to render this geometry
10157
10158 texture.update_lastrenderframe = -1; // regenerate this texture
10159 texture.basematerialflags = materialflags | MATERIALFLAG_CUSTOMSURFACE | MATERIALFLAG_WALL;
10160 texture.basealpha = 1.0f;
10161 texture.currentskinframe = skinframe;
10162 texture.currenttexmatrix = *texmatrix; // requires MATERIALFLAG_CUSTOMSURFACE
10163 texture.offsetmapping = OFFSETMAPPING_OFF;
10164 texture.offsetscale = 1;
10165 texture.specularscalemod = 1;
10166 texture.specularpowermod = 1;
10167 texture.transparentsort = TRANSPARENTSORT_DISTANCE;
10168
10169 R_DrawCustomSurface_Texture(&texture, texmatrix, materialflags, firstvertex, numvertices, firsttriangle, numtriangles, writedepth, prepass, ui);
10170}
void R_DrawCustomSurface_Texture(texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qbool writedepth, qbool prepass, qbool ui)
Definition gl_rmain.c:10172
GLenum GLenum GLuint texture
Definition glquake.h:613
#define MATERIALFLAG_CUSTOMSURFACE
@ TRANSPARENTSORT_DISTANCE
Definition r_qshader.h:194
@ OFFSETMAPPING_OFF
Definition r_qshader.h:185

References MATERIALFLAG_CUSTOMSURFACE, MATERIALFLAG_WALL, OFFSETMAPPING_OFF, R_DrawCustomSurface_Texture(), texture, and TRANSPARENTSORT_DISTANCE.

Referenced by R_DrawCorona(), R_Shadow_DrawCursor_TransparentCallback(), R_Shadow_DrawLightSprite_TransparentCallback(), R_SkyBox(), and R_SkySphere().

◆ R_DrawCustomSurface_Texture()

void R_DrawCustomSurface_Texture ( texture_t * texture,
const matrix4x4_t * texmatrix,
int materialflags,
int firstvertex,
int numvertices,
int firsttriangle,
int numtriangles,
qbool writedepth,
qbool prepass,
qbool ui )

Definition at line 10172 of file gl_rmain.c.

10173{
10174 static msurface_t surface;
10175 const msurface_t *surfacelist = &surface;
10176
10177 // fake enough texture and surface state to render this geometry
10178 surface.texture = texture;
10179 surface.num_triangles = numtriangles;
10180 surface.num_firsttriangle = firsttriangle;
10181 surface.num_vertices = numvertices;
10182 surface.num_firstvertex = firstvertex;
10183
10184 // now render it
10185 rsurface.texture = R_GetCurrentTexture(surface.texture);
10186 rsurface.lightmaptexture = NULL;
10187 rsurface.deluxemaptexture = NULL;
10188 rsurface.uselightmaptexture = false;
10189 R_DrawModelTextureSurfaceList(1, &surfacelist, writedepth, prepass, ui);
10190}
static void R_DrawModelTextureSurfaceList(int texturenumsurfaces, const msurface_t **texturesurfacelist, qbool writedepth, qbool prepass, qbool ui)
Definition gl_rmain.c:8832
rsurfacestate_t rsurface
Definition gl_rmain.c:6919
texture_t * R_GetCurrentTexture(texture_t *t)
Definition gl_rmain.c:6549
int num_firsttriangle
int num_triangles
range of triangles and vertices in model->surfmesh
texture_t * texture
the texture to use on the surface
int num_firstvertex

References NULL, msurface_t::num_firsttriangle, msurface_t::num_firstvertex, msurface_t::num_triangles, msurface_t::num_vertices, R_DrawModelTextureSurfaceList(), R_GetCurrentTexture(), rsurface, msurface_t::texture, and texture.

Referenced by R_DrawCustomSurface(), and R_Model_Sprite_Draw_TransparentCallback().

◆ R_DrawExplosions()

void R_DrawExplosions ( void )

Definition at line 264 of file r_explosion.c.

265{
266#ifdef MAX_EXPLOSIONS
267 int i;
268
269 if (!r_drawexplosions.integer)
270 return;
271
272 for (i = 0;i < numexplosions;i++)
273 {
274 if (explosion[i].alpha)
275 {
277 if (explosion[i].alpha)
279 }
280 }
281 while (numexplosions > 0 && explosion[i-1].alpha <= 0)
283#endif
284}
float alpha
void R_MeshQueue_AddTransparent(dptransparentsortcategory_t category, const vec3_t center, void(*callback)(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist), const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight)
Definition meshqueue.c:33
static void R_DrawExplosion_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
static int numexplosions
Definition r_explosion.c:29
static cvar_t r_drawexplosions
Definition r_explosion.c:60
static void R_MoveExplosion(explosion_t *e)
static explosion_t explosion[MAX_EXPLOSIONS]
Definition r_explosion.c:50

References alpha, explosion, NULL, numexplosions, origin, R_DrawExplosion_TransparentCallback(), r_drawexplosions, R_MeshQueue_AddTransparent(), R_MoveExplosion(), and TRANSPARENTSORT_DISTANCE.

Referenced by R_RenderScene().

◆ R_DrawModelSurfaces()

void R_DrawModelSurfaces ( entity_render_t * ent,
qbool skysurfaces,
qbool writedepth,
qbool depthonly,
qbool debug,
qbool prepass,
qbool ui )

Definition at line 9970 of file gl_rmain.c.

9971{
9972 int i, j, flagsmask;
9973 model_t *model = ent->model;
9974 msurface_t *surfaces;
9975 unsigned char *update;
9976 int numsurfacelist = 0;
9977 if (model == NULL)
9978 return;
9979
9980 if (r_maxsurfacelist < model->num_surfaces)
9981 {
9982 r_maxsurfacelist = model->num_surfaces;
9983 if (r_surfacelist)
9986 }
9987
9988 if (r_showsurfaces.integer && r_showsurfaces.integer != 3)
9989 RSurf_ActiveModelEntity(ent, false, false, false);
9990 else if (prepass)
9991 RSurf_ActiveModelEntity(ent, true, true, true);
9992 else if (depthonly)
9993 RSurf_ActiveModelEntity(ent, model->wantnormals, model->wanttangents, false);
9994 else
9995 RSurf_ActiveModelEntity(ent, true, true, false);
9996
9997 surfaces = model->data_surfaces;
9998 update = model->brushq1.lightmapupdateflags;
9999
10000 flagsmask = skysurfaces ? MATERIALFLAG_SKY : MATERIALFLAG_WALL;
10001
10002 if (debug)
10003 {
10005 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
10006 return;
10007 }
10008
10009 // check if this is an empty model
10010 if (model->submodelsurfaces_start >= model->submodelsurfaces_end)
10011 return;
10012
10013 rsurface.lightmaptexture = NULL;
10014 rsurface.deluxemaptexture = NULL;
10015 rsurface.uselightmaptexture = false;
10016 rsurface.texture = NULL;
10017 rsurface.rtlight = NULL;
10018 numsurfacelist = 0;
10019
10020 // add visible surfaces to draw list
10021 if (ent == r_refdef.scene.worldentity)
10022 {
10023 // for the world entity, check surfacevisible
10024 for (i = model->submodelsurfaces_start;i < model->submodelsurfaces_end;i++)
10025 {
10026 j = model->modelsurfaces_sorted[i];
10027 if (r_refdef.viewcache.world_surfacevisible[j])
10028 r_surfacelist[numsurfacelist++] = surfaces + j;
10029 }
10030
10031 // don't do anything if there were no surfaces added (none of the world entity is visible)
10032 if (!numsurfacelist)
10033 {
10034 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
10035 return;
10036 }
10037 }
10038 else if (ui)
10039 {
10040 // for ui we have to preserve the order of surfaces (not using modelsurfaces_sorted)
10041 for (i = model->submodelsurfaces_start; i < model->submodelsurfaces_end; i++)
10042 r_surfacelist[numsurfacelist++] = surfaces + i;
10043 }
10044 else
10045 {
10046 // add all surfaces
10047 for (i = model->submodelsurfaces_start; i < model->submodelsurfaces_end; i++)
10048 r_surfacelist[numsurfacelist++] = surfaces + model->modelsurfaces_sorted[i];
10049 }
10050
10051 /*
10052 * Mark lightmaps as dirty if their lightstyle's value changed. We do this by
10053 * using style chains because most styles do not change on most frames, and most
10054 * surfaces do not have styles on them. Mods like Arcane Dimensions (e.g. ad_necrokeep)
10055 * break this rule and animate most surfaces.
10056 */
10057 if (update && !skysurfaces && !depthonly && !prepass && model->brushq1.num_lightstyles && r_refdef.scene.lightmapintensity > 0 && r_q1bsp_lightmap_updates_enabled.integer)
10058 {
10060
10061 // For each lightstyle, check if its value changed and mark the lightmaps as dirty if so
10062 for (i = 0, style = model->brushq1.data_lightstyleinfo; i < model->brushq1.num_lightstyles; i++, style++)
10063 {
10064 if (style->value != r_refdef.scene.lightstylevalue[style->style])
10065 {
10066 int* list = style->surfacelist;
10067 style->value = r_refdef.scene.lightstylevalue[style->style];
10068 // Value changed - mark the surfaces belonging to this style chain as dirty
10069 for (j = 0; j < style->numsurfaces; j++)
10070 update[list[j]] = true;
10071 }
10072 }
10073 // Now check if update flags are set on any surfaces that are visible
10075 {
10076 /*
10077 * We can do less frequent texture uploads (approximately 10hz for animated
10078 * lightstyles) by rebuilding lightmaps on surfaces that are not currently visible.
10079 * For optimal efficiency, this includes the submodels of the worldmodel, so we
10080 * use model->num_surfaces, not nummodelsurfaces.
10081 */
10082 for (i = 0; i < model->num_surfaces;i++)
10083 if (update[i])
10084 R_BuildLightMap(ent, surfaces + i, r_q1bsp_lightmap_updates_combine.integer);
10085 }
10086 else
10087 {
10088 for (i = 0; i < numsurfacelist; i++)
10089 if (update[r_surfacelist[i] - surfaces])
10091 }
10092 }
10093
10094 R_QueueModelSurfaceList(ent, numsurfacelist, r_surfacelist, flagsmask, writedepth, depthonly, prepass, ui);
10095
10096 // add to stats if desired
10097 if (r_speeds.integer && !skysurfaces && !depthonly)
10098 {
10099 r_refdef.stats[r_stat_entities_surfaces] += numsurfacelist;
10100 for (j = 0;j < numsurfacelist;j++)
10101 r_refdef.stats[r_stat_entities_triangles] += r_surfacelist[j]->num_triangles;
10102 }
10103
10104 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
10105}
float style
int r_maxsurfacelist
Definition gl_rmain.c:9968
static void R_QueueModelSurfaceList(entity_render_t *ent, int numsurfaces, const msurface_t **surfacelist, int flagsmask, qbool writedepth, qbool depthonly, qbool prepass, qbool ui)
Definition gl_rmain.c:9012
const msurface_t ** r_surfacelist
Definition gl_rmain.c:9969
void RSurf_ActiveModelEntity(const entity_render_t *ent, qbool wantnormals, qbool wanttangents, qbool prepass)
Definition gl_rmain.c:6921
static void R_DrawDebugModel(void)
Definition gl_rmain.c:9747
void R_BuildLightMap(const entity_render_t *ent, msurface_t *surface, int combine)
Definition gl_rsurf.c:50
#define MATERIALFLAG_SKY
Definition model_brush.h:92
@ r_stat_entities_triangles
Definition r_stats.h:14
@ r_stat_entities_surfaces
Definition r_stats.h:13

References MATERIALFLAG_SKY, MATERIALFLAG_WALL, Mem_Alloc, Mem_Free, entity_render_t::model, model, NULL, R_BuildLightMap(), R_DrawDebugModel(), r_main_mempool, r_maxsurfacelist, r_q1bsp_lightmap_updates_combine, r_q1bsp_lightmap_updates_enabled, r_q1bsp_lightmap_updates_hidden_surfaces, R_QueueModelSurfaceList(), r_refdef, r_showsurfaces, r_speeds, r_stat_entities_surfaces, r_stat_entities_triangles, r_surfacelist, RSurf_ActiveModelEntity(), rsurface, and style.

Referenced by DrawQ_FlushUI(), R_Mod_Draw(), R_Mod_DrawDebug(), R_Mod_DrawDepth(), R_Mod_DrawPrepass(), and R_Mod_DrawSky().

◆ R_DrawParticles()

void R_DrawParticles ( void )

Definition at line 2907 of file cl_particles.c.

2908{
2909 int i, a;
2910 int drawparticles = r_drawparticles.integer;
2911 float minparticledist_start;
2912 particle_t *p;
2913 float gravity, frametime, f, dist, oldorg[3], decaldir[3];
2914 float drawdist2;
2915 int hitent;
2916 trace_t trace;
2917 qbool update;
2918 float pt_explode_frame_interval, pt_explode2_frame_interval;
2919 int color;
2920
2921 frametime = bound(0, cl.time - cl.particles_updatetime, 1);
2922 cl.particles_updatetime = bound(cl.time - 1, cl.particles_updatetime + frametime, cl.time + 1);
2923
2924 // LadyHavoc: early out conditions
2925 if (!cl.num_particles)
2926 return;
2927
2928 // Handling of the colour ramp for pt_explode and pt_explode2
2929 pt_explode_frame_interval = frametime * 10;
2930 pt_explode2_frame_interval = frametime * 15;
2931
2932 minparticledist_start = DotProduct(r_refdef.view.origin, r_refdef.view.forward) + r_drawparticles_nearclip_min.value;
2933 gravity = frametime * cl.movevars_gravity;
2934 update = frametime > 0;
2935 drawdist2 = r_drawparticles_drawdistance.value * r_refdef.view.quality;
2936 drawdist2 = drawdist2*drawdist2;
2937
2938 for (i = 0, p = cl.particles;i < cl.num_particles;i++, p++)
2939 {
2940 if (!p->typeindex)
2941 {
2942 if (cl.free_particle > i)
2943 cl.free_particle = i;
2944 continue;
2945 }
2946
2947 if (update)
2948 {
2949 if (p->delayedspawn > cl.time)
2950 continue;
2951
2952 p->size += p->sizeincrease * frametime;
2953 p->alpha -= p->alphafade * frametime;
2954
2955 if (p->alpha <= 0 || p->die <= cl.time)
2956 goto killparticle;
2957
2959 {
2961 {
2962 if (p->typeindex == pt_blood)
2963 p->size += frametime * 8;
2964 else
2965 p->vel[2] -= p->gravity * gravity;
2966 f = 1.0f - min(p->liquidfriction * frametime, 1);
2967 VectorScale(p->vel, f, p->vel);
2968 }
2969 else
2970 {
2971 p->vel[2] -= p->gravity * gravity;
2972 if (p->airfriction)
2973 {
2974 f = 1.0f - min(p->airfriction * frametime, 1);
2975 VectorScale(p->vel, f, p->vel);
2976 }
2977 }
2978
2979 VectorCopy(p->org, oldorg);
2980 VectorMA(p->org, frametime, p->vel, p->org);
2981// if (p->bounce && cl.time >= p->delayedcollisions)
2982 if (p->bounce && cl_particles_collisions.integer && VectorLength(p->vel))
2983 {
2984 trace = CL_TraceLine(oldorg, p->org, MOVE_NORMAL, NULL, SUPERCONTENTS_SOLID | ((p->typeindex == pt_rain || p->typeindex == pt_snow) ? SUPERCONTENTS_LIQUIDSMASK : 0), 0, 0, collision_extendmovelength.value, true, false, &hitent, false, false);
2985 // if the trace started in or hit something of SUPERCONTENTS_NODROP
2986 // or if the trace hit something flagged as NOIMPACT
2987 // then remove the particle
2989 goto killparticle;
2990 VectorCopy(trace.endpos, p->org);
2991 // react if the particle hit something
2992 if (trace.fraction < 1)
2993 {
2994 VectorCopy(trace.endpos, p->org);
2995
2996 if (p->staintexnum >= 0)
2997 {
2998 // blood - splash on solid
3000 {
3001 R_Stain(p->org, 16,
3002 p->staincolor[0], p->staincolor[1], p->staincolor[2], (int)(p->stainalpha * p->stainsize * (1.0f / 160.0f)),
3003 p->staincolor[0], p->staincolor[1], p->staincolor[2], (int)(p->stainalpha * p->stainsize * (1.0f / 160.0f)));
3004 if (cl_decals.integer)
3005 {
3006 // create a decal for the blood splat
3007 a = 0xFFFFFF ^ (p->staincolor[0]*65536+p->staincolor[1]*256+p->staincolor[2]);
3009 {
3010 VectorCopy(p->vel, decaldir);
3011 VectorNormalize(decaldir);
3012 }
3013 else
3014 VectorCopy(trace.plane.normal, decaldir);
3015 CL_SpawnDecalParticleForSurface(hitent, p->org, decaldir, a, a, p->staintexnum, p->stainsize, p->stainalpha); // staincolor needs to be inverted for decals!
3016 }
3017 }
3018 }
3019
3020 if (p->typeindex == pt_blood)
3021 {
3022 // blood - splash on solid
3024 goto killparticle;
3025 if(p->staintexnum == -1) // staintex < -1 means no stains at all
3026 {
3027 R_Stain(p->org, 16, 64, 16, 16, (int)(p->alpha * p->size * (1.0f / 80.0f)), 64, 32, 32, (int)(p->alpha * p->size * (1.0f / 80.0f)));
3028 if (cl_decals.integer)
3029 {
3030 // create a decal for the blood splat
3032 {
3033 VectorCopy(p->vel, decaldir);
3034 VectorNormalize(decaldir);
3035 }
3036 else
3037 VectorCopy(trace.plane.normal, decaldir);
3038 CL_SpawnDecalParticleForSurface(hitent, p->org, decaldir, p->color[0] * 65536 + p->color[1] * 256 + p->color[2], p->color[0] * 65536 + p->color[1] * 256 + p->color[2], tex_blooddecal[rand()&7], p->size * lhrandom(cl_particles_blood_decal_scalemin.value, cl_particles_blood_decal_scalemax.value), cl_particles_blood_decal_alpha.value * 768);
3039 }
3040 }
3041 goto killparticle;
3042 }
3043 else if (p->bounce < 0)
3044 {
3045 // bounce -1 means remove on impact
3046 goto killparticle;
3047 }
3048 else
3049 {
3050 // anything else - bounce off solid
3051 dist = DotProduct(p->vel, trace.plane.normal) * -p->bounce;
3052 VectorMA(p->vel, dist, trace.plane.normal, p->vel);
3053 }
3054 }
3055 }
3056
3057 if (VectorLength2(p->vel) < 0.03)
3058 {
3059 if(p->orientation == PARTICLE_SPARK) // sparks are virtually invisible if very slow, so rather let them go off
3060 goto killparticle;
3061 VectorClear(p->vel);
3062 }
3063 }
3064
3065 if (p->typeindex != pt_static)
3066 {
3067 switch (p->typeindex)
3068 {
3069 case pt_entityparticle:
3070 // particle that removes itself after one rendered frame
3071 if (p->time2)
3072 goto killparticle;
3073 else
3074 p->time2 = 1;
3075 break;
3076 case pt_blood:
3079 goto killparticle;
3080 break;
3081 case pt_bubble:
3084 goto killparticle;
3085 break;
3086 case pt_rain:
3089 goto killparticle;
3090 break;
3091 case pt_snow:
3092 if (cl.time > p->time2)
3093 {
3094 // snow flutter
3095 p->time2 = cl.time + (rand() & 3) * 0.1;
3096 p->vel[0] = p->vel[0] * 0.9f + lhrandom(-32, 32);
3097 p->vel[1] = p->vel[0] * 0.9f + lhrandom(-32, 32);
3098 }
3101 goto killparticle;
3102 break;
3103 case pt_explode:
3104 // Progress the particle colour up the ramp
3105 p->time2 += pt_explode_frame_interval;
3106 if (p->time2 >= 8)
3107 p->die = -1;
3108 else
3109 {
3111 p->color[0] = color >> 16;
3112 p->color[1] = color >> 8;
3113 p->color[2] = color >> 0;
3114 }
3115 break;
3116 case pt_explode2:
3117 // Progress the particle colour up the ramp
3118 p->time2 += pt_explode2_frame_interval;
3119 if (p->time2 >= 8)
3120 p->die = -1;
3121 else
3122 {
3124 p->color[0] = color >> 16;
3125 p->color[1] = color >> 8;
3126 p->color[2] = color >> 0;
3127 }
3128 break;
3129 default:
3130 break;
3131 }
3132 }
3133 }
3134 else if (p->delayedspawn > cl.time)
3135 continue;
3136 if (!drawparticles)
3137 continue;
3138 // don't render particles too close to the view (they chew fillrate)
3139 // also don't render particles behind the view (useless)
3140 // further checks to cull to the frustum would be too slow here
3141 switch(p->typeindex)
3142 {
3143 case pt_beam:
3144 // beams have no culling
3146 break;
3147 default:
3148 if(cl_particles_visculling.integer)
3149 if (!r_refdef.viewcache.world_novis)
3150 if(r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.PointInLeaf)
3151 {
3152 mleaf_t *leaf = r_refdef.scene.worldmodel->brush.PointInLeaf(r_refdef.scene.worldmodel, p->org);
3153 if(leaf)
3154 if(!CHECKPVSBIT(r_refdef.viewcache.world_pvsbits, leaf->clusterindex))
3155 continue;
3156 }
3157 // anything else just has to be in front of the viewer and visible at this distance
3158 if (!r_refdef.view.useperspective || (DotProduct(p->org, r_refdef.view.forward) >= minparticledist_start && VectorDistance2(p->org, r_refdef.view.origin) < drawdist2 * (p->size * p->size)))
3160 break;
3161 }
3162
3163 continue;
3164killparticle:
3165 p->typeindex = 0;
3166 if (cl.free_particle > i)
3167 cl.free_particle = i;
3168 }
3169
3170 // reduce cl.num_particles if possible
3171 while (cl.num_particles > 0 && cl.particles[cl.num_particles - 1].typeindex == 0)
3172 cl.num_particles--;
3173
3174 if (cl.num_particles == cl.max_particles && cl.max_particles < MAX_PARTICLES)
3175 {
3176 particle_t *oldparticles = cl.particles;
3177 cl.max_particles = min(cl.max_particles * 2, MAX_PARTICLES);
3178 cl.particles = (particle_t *) Mem_Alloc(cls.levelmempool, cl.max_particles * sizeof(particle_t));
3179 memcpy(cl.particles, oldparticles, cl.num_particles * sizeof(particle_t));
3180 Mem_Free(oldparticles);
3181 }
3182}
#define SUPERCONTENTS_LAVA
Definition bspfile.h:199
#define SUPERCONTENTS_SLIME
Definition bspfile.h:198
#define SUPERCONTENTS_LIQUIDSMASK
Definition bspfile.h:218
#define SUPERCONTENTS_NODROP
Definition bspfile.h:203
#define SUPERCONTENTS_WATER
Definition bspfile.h:197
#define CL_PointSuperContents(point)
static int particlepalette[256]
cvar_t cl_particles_visculling
cvar_t cl_particles_blood_decal_alpha
static cvar_t r_drawparticles_nearclip_min
static cvar_t r_drawparticles_drawdistance
int ramp1[8]
cvar_t cl_decals
cvar_t cl_decals_newsystem_bloodsmears
static void R_DrawParticle_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
cvar_t r_drawparticles
void CL_SpawnDecalParticleForSurface(int hitent, const vec3_t org, const vec3_t normal, int color1, int color2, int texnum, float size, float alpha)
static const int tex_blooddecal[8]
cvar_t cl_particles_blood_decal_scalemax
cvar_t cl_particles_collisions
cvar_t cl_particles_blood_decal_scalemin
int ramp2[8]
@ pt_snow
@ pt_blood
@ pt_explode2
@ pt_bubble
@ pt_static
@ pt_beam
@ pt_entityparticle
@ pt_rain
@ pt_explode
@ PARTICLE_SPARK
@ PARTICLE_HBEAM
@ PARTICLE_VBEAM
cvar_t collision_extendmovelength
Definition collision.c:14
vector color
void R_Stain(const vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, int cr2, int cg2, int cb2, int ca2)
Definition gl_rsurf.c:298
#define VectorClear(a)
Definition mathlib.h:97
#define VectorLength2(a)
Definition mathlib.h:110
#define VectorDistance2(a, b)
Definition mathlib.h:107
#define DotProduct(a, b)
Definition mathlib.h:98
#define VectorScale(in, scale, out)
Definition mathlib.h:111
#define VectorMA(a, scale, b, out)
Definition mathlib.h:114
#define CHECKPVSBIT(pvs, b)
#define Q3SURFACEFLAG_NOMARKS
#define Q3SURFACEFLAG_NOIMPACT
#define MAX_PARTICLES
upper limit on cl.particles size
Definition qdefs.h:154
bool qbool
Definition qtypes.h:9
float f
int clusterindex
unsigned char staincolor[3]
unsigned char typeindex
float alphafade
how much alpha reduces per second
float die
time when this particle should be removed, regardless of alpha
float bounce
how much bounce-back from a surface the particle hits (0 = no physics, 1 = stop and slide,...
float airfriction
how much air friction affects this object (objects with a low mass/size ratio tend to get more air fr...
unsigned char orientation
float gravity
how much gravity affects this particle (1.0 = normal gravity, 0.0 = none)
float stainsize
vec3_t vel
velocity of particle, or orientation of decal, or end point of beam
vec3_t sortorigin
sort by this group origin, not particle org
float alpha
0-255
float sizeincrease
rate of size change per second
signed char staintexnum
float liquidfriction
how much liquid friction affects this object (objects with a low mass/size ratio tend to get more liq...
float delayedspawn
time that particle appears and begins moving
unsigned char color[3]
float stainalpha
float time2
used for snow fluttering, decal fade, explosion colour ramp
double fraction
Definition collision.h:40
int hitq3surfaceflags
Definition collision.h:60
int startsupercontents
Definition collision.h:56
plane_t plane
Definition collision.h:44
int hitsupercontents
Definition collision.h:58
vec3_t normal
Definition collision.h:13

References a, particle_t::airfriction, particle_t::alpha, particle_t::alphafade, particle_t::bounce, bound, CHECKPVSBIT, cl, cl_decals, cl_decals_newsystem_bloodsmears, cl_particles_blood_decal_alpha, cl_particles_blood_decal_scalemax, cl_particles_blood_decal_scalemin, cl_particles_collisions, cl_particles_visculling, CL_PointSuperContents, CL_SpawnDecalParticleForSurface(), CL_TraceLine(), cls, mleaf_t::clusterindex, collision_extendmovelength, color, particle_t::color, particle_t::delayedspawn, particle_t::die, DotProduct, trace_t::endpos, f, trace_t::fraction, frametime, particle_t::gravity, trace_t::hitq3surfaceflags, trace_t::hitsupercontents, int(), lhrandom, particle_t::liquidfriction, MAX_PARTICLES, Mem_Alloc, Mem_Free, min, MOVE_NORMAL, plane_t::normal, NULL, particle_t::org, particle_t::orientation, PARTICLE_HBEAM, PARTICLE_SPARK, PARTICLE_VBEAM, particlepalette, trace_t::plane, pt_beam, pt_blood, pt_bubble, pt_entityparticle, pt_explode, pt_explode2, pt_rain, pt_snow, pt_static, Q3SURFACEFLAG_NOIMPACT, Q3SURFACEFLAG_NOMARKS, R_DrawParticle_TransparentCallback(), r_drawparticles, r_drawparticles_drawdistance, r_drawparticles_nearclip_min, R_MeshQueue_AddTransparent(), r_refdef, R_Stain(), ramp1, ramp2, particle_t::size, particle_t::sizeincrease, particle_t::sortorigin, particle_t::stainalpha, particle_t::staincolor, particle_t::stainsize, particle_t::staintexnum, trace_t::startsupercontents, SUPERCONTENTS_LAVA, SUPERCONTENTS_LIQUIDSMASK, SUPERCONTENTS_NODROP, SUPERCONTENTS_SLIME, SUPERCONTENTS_SOLID, SUPERCONTENTS_WATER, tex_blooddecal, particle_t::time2, TRANSPARENTSORT_DISTANCE, particle_t::typeindex, VectorClear, VectorCopy, VectorDistance2, VectorLength, VectorLength2, VectorMA, VectorNormalize, VectorScale, and particle_t::vel.

Referenced by R_RenderScene().

◆ R_DrawPortals()

void R_DrawPortals ( void )

Definition at line 381 of file gl_rsurf.c.

382{
383 int i, leafnum;
384 mportal_t *portal;
385 float center[3], f;
386 model_t *model = r_refdef.scene.worldmodel;
387 if (model == NULL)
388 return;
389 for (leafnum = 0;leafnum < model->brush.num_leafs;leafnum++)
390 {
391 if (r_refdef.viewcache.world_leafvisible[leafnum])
392 {
393 //for (portalnum = 0, portal = model->brush.data_portals;portalnum < model->brush.num_portals;portalnum++, portal++)
394 for (portal = model->brush.data_leafs[leafnum].portals;portal;portal = portal->next)
395 {
397 if (!R_CullFrustum(portal->mins, portal->maxs))
398 {
399 VectorClear(center);
400 for (i = 0;i < portal->numpoints;i++)
401 VectorAdd(center, portal->points[i].position, center);
402 f = ixtable[portal->numpoints];
403 VectorScale(center, f, center);
405 }
406 }
407 }
408 }
409}
qbool R_CullFrustum(const vec3_t mins, const vec3_t maxs)
Definition gl_rmain.c:3464
static void R_DrawPortal_Callback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition gl_rsurf.c:343
float ixtable[4096]
Definition mathlib.c:27
#define VectorAdd(a, b, out)
Definition mathlib.h:100
vec3_t mins
mvertex_t * points
struct mportal_s * next
vec3_t maxs
vec3_t position
Definition model_brush.h:43

References f, ixtable, mportal_t::maxs, mportal_t::mins, model, mportal_t::next, NULL, mportal_t::numpoints, mportal_t::points, POLYGONELEMENTS_MAXPOINTS, mvertex_t::position, R_CullFrustum(), R_DrawPortal_Callback(), R_MeshQueue_AddTransparent(), r_refdef, rsurface, TRANSPARENTSORT_DISTANCE, VectorAdd, VectorClear, and VectorScale.

Referenced by R_RenderScene().

◆ R_Explosion_Init()

void R_Explosion_Init ( void )

Definition at line 131 of file r_explosion.c.

132{
133#ifdef MAX_EXPLOSIONS
134 int i, x, y;
135 i = 0;
136 for (y = 0;y < EXPLOSIONGRID;y++)
137 {
138 for (x = 0;x < EXPLOSIONGRID;x++)
139 {
140 explosiontris[i][0] = R_ExplosionVert(x , y );
141 explosiontris[i][1] = R_ExplosionVert(x + 1, y );
142 explosiontris[i][2] = R_ExplosionVert(x , y + 1);
143 i++;
144 explosiontris[i][0] = R_ExplosionVert(x + 1, y );
145 explosiontris[i][1] = R_ExplosionVert(x + 1, y + 1);
146 explosiontris[i][2] = R_ExplosionVert(x , y + 1);
147 i++;
148 }
149 }
150
151#endif
153#ifdef MAX_EXPLOSIONS
155
157#endif
158}
GLint GLenum GLint GLint y
Definition glquake.h:651
GLint GLenum GLint x
Definition glquake.h:651
cvar_t r_explosionclip
Definition r_explosion.c:58
#define EXPLOSIONGRID
Definition r_explosion.c:25
static void r_explosion_newmap(void)
static void r_explosion_shutdown(void)
static int R_ExplosionVert(int column, int row)
static void r_explosion_start(void)
Definition r_explosion.c:63
static unsigned short explosiontris[EXPLOSIONTRIS][3]
Definition r_explosion.c:32

References Cvar_RegisterVariable(), EXPLOSIONGRID, explosiontris, NULL, r_drawexplosions, r_explosion_newmap(), r_explosion_shutdown(), r_explosion_start(), r_explosionclip, R_ExplosionVert(), R_RegisterModule(), x, and y.

Referenced by Render_Init().

◆ R_FillColors()

void R_FillColors ( float * out,
int verts,
float r,
float g,
float b,
float a )

Definition at line 335 of file gl_rmain.c.

336{
337 int i;
338 for (i = 0;i < verts;i++)
339 {
340 out[0] = r;
341 out[1] = g;
342 out[2] = b;
343 out[3] = a;
344 out += 4;
345 }
346}

References a, b, g, and r.

Referenced by R_DrawBBoxMesh().

◆ R_FrameData_Alloc()

void * R_FrameData_Alloc ( size_t size)

allocate some temporary memory for your purposes

Definition at line 3539 of file gl_rmain.c.

3540{
3541 void *data;
3542 float newvalue;
3543
3544 // align to 16 byte boundary - the data pointer is already aligned, so we
3545 // only need to ensure the size of every allocation is also aligned
3546 size = (size + 15) & ~15;
3547
3548 while (!r_framedata_mem || r_framedata_mem->current + size > r_framedata_mem->size)
3549 {
3550 // emergency - we ran out of space, allocate more memory
3551 // note: this has no upper-bound, we'll fail to allocate memory eventually and just die
3552 newvalue = r_framedatasize.value * 2.0f;
3553 // upper bound based on architecture - if we try to allocate more than this we could overflow, better to loop until we error out on allocation failure
3554 if (sizeof(size_t) >= 8)
3555 newvalue = bound(0.25f, newvalue, (float)(1ll << 42));
3556 else
3557 newvalue = bound(0.25f, newvalue, (float)(1 << 10));
3558 // this might not be a growing it, but we'll allocate another buffer every time
3560 R_FrameData_Resize(true);
3561 }
3562
3563 data = r_framedata_mem->data + r_framedata_mem->current;
3564 r_framedata_mem->current += size;
3565
3566 // count the usage for stats
3569
3570 return (void *)data;
3571}
static void R_FrameData_Resize(qbool mustgrow)
Definition gl_rmain.c:3503
static r_framedata_mem_t * r_framedata_mem
Definition gl_rmain.c:3491
@ r_stat_framedatacurrent
Definition r_stats.h:51
@ r_stat_framedatasize
Definition r_stats.h:52

References bound, Cvar_SetValueQuick(), data, max, r_framedata_mem, R_FrameData_Resize(), r_framedatasize, r_refdef, r_stat_framedatacurrent, r_stat_framedatasize, and size.

Referenced by R_AnimCache_GetEntity(), R_FrameData_Store(), R_Q1BSP_CallRecursiveGetLightInfo(), RSurf_ActiveCustomEntity(), RSurf_ActiveModelEntity(), and RSurf_PrepareVerticesForBatch().

◆ R_FrameData_NewFrame()

void R_FrameData_NewFrame ( void )

prepare for a new frame, recycles old buffers if a resize occurred previously

Definition at line 3521 of file gl_rmain.c.

3522{
3523 R_FrameData_Resize(false);
3524 if (!r_framedata_mem)
3525 return;
3526 // if we ran out of space on the last frame, free the old memory now
3527 while (r_framedata_mem->purge)
3528 {
3529 // repeatedly remove the second item in the list, leaving only head
3530 r_framedata_mem_t *next = r_framedata_mem->purge->purge;
3531 Mem_Free(r_framedata_mem->purge);
3532 r_framedata_mem->purge = next;
3533 }
3534 // reset the current mem pointer
3535 r_framedata_mem->current = 0;
3536 r_framedata_mem->mark = 0;
3537}

References Mem_Free, r_framedata_mem, and R_FrameData_Resize().

Referenced by CL_UpdateScreen().

◆ R_FrameData_Reset()

void R_FrameData_Reset ( void )

free all R_FrameData memory

Definition at line 3493 of file gl_rmain.c.

3494{
3495 while (r_framedata_mem)
3496 {
3497 r_framedata_mem_t *next = r_framedata_mem->purge;
3499 r_framedata_mem = next;
3500 }
3501}

References Mem_Free, and r_framedata_mem.

Referenced by gl_main_newmap(), gl_main_shutdown(), and gl_main_start().

◆ R_FrameData_ReturnToMark()

void R_FrameData_ReturnToMark ( void )

discard recent memory allocations (rewind to marker)

Definition at line 3588 of file gl_rmain.c.

3589{
3590 if (!r_framedata_mem)
3591 return;
3592 r_framedata_mem->current = r_framedata_mem->mark;
3593}

References r_framedata_mem.

Referenced by R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Q1BSP_DrawLight_TransparentCallback(), R_QueueModelSurfaceList(), and R_RTLight_Compile().

◆ R_FrameData_SetMark()

void R_FrameData_SetMark ( void )

set a marker that allows you to discard the following temporary memory allocations

Definition at line 3581 of file gl_rmain.c.

3582{
3583 if (!r_framedata_mem)
3584 return;
3585 r_framedata_mem->mark = r_framedata_mem->current;
3586}

References r_framedata_mem.

Referenced by R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Q1BSP_DrawLight_TransparentCallback(), R_QueueModelSurfaceList(), and R_RTLight_Compile().

◆ R_FrameData_Store()

void * R_FrameData_Store ( size_t size,
void * data )

allocate some temporary memory and copy this data into it

Definition at line 3573 of file gl_rmain.c.

3574{
3575 void *d = R_FrameData_Alloc(size);
3576 if (d && data)
3577 memcpy(d, data, size);
3578 return d;
3579}

References data, R_FrameData_Alloc(), and size.

Referenced by R_Shadow_PrepareLight(), and RSurf_PrepareVerticesForBatch().

◆ R_GetCubemap()

rtexture_t * R_GetCubemap ( const char * basename)

Definition at line 2982 of file gl_rmain.c.

2983{
2984 int i;
2985 for (i = 0;i < r_texture_numcubemaps;i++)
2986 if (r_texture_cubemaps[i] != NULL)
2987 if (!strcasecmp(r_texture_cubemaps[i]->basename, basename))
2988 return r_texture_cubemaps[i]->texture ? r_texture_cubemaps[i]->texture : r_texture_whitecube;
2989 if (i >= MAX_CUBEMAPS || !r_main_mempool)
2990 return r_texture_whitecube;
2993 dp_strlcpy(r_texture_cubemaps[i]->basename, basename, sizeof(r_texture_cubemaps[i]->basename));
2994 r_texture_cubemaps[i]->texture = R_LoadCubemap(r_texture_cubemaps[i]->basename);
2995 return r_texture_cubemaps[i]->texture;
2996}
rtexture_t * r_texture_whitecube
Definition gl_rmain.c:277
static rtexture_t * R_LoadCubemap(const char *basename)
Definition gl_rmain.c:2908
int r_texture_numcubemaps
Definition gl_rmain.c:294
cubemapinfo_t * r_texture_cubemaps[MAX_CUBEMAPS]
Definition gl_rmain.c:295
#define MAX_CUBEMAPS
max number of cubemap textures loaded for light filters
Definition qdefs.h:130

References dp_strlcpy, MAX_CUBEMAPS, Mem_Alloc, NULL, R_LoadCubemap(), r_main_mempool, r_texture_cubemaps, r_texture_numcubemaps, and r_texture_whitecube.

Referenced by Mod_LoadTextureFromQ3Shader(), R_Shadow_PrepareLight(), and VM_CL_loadcubemap().

◆ R_GetCurrentTexture()

texture_t * R_GetCurrentTexture ( texture_t * t)

Definition at line 6549 of file gl_rmain.c.

6550{
6551 int i, q;
6552 const entity_render_t *ent = rsurface.entity;
6553 model_t *model = ent->model; // when calling this, ent must not be NULL
6555 float specularscale = 0.0f;
6556
6557 if (t->update_lastrenderframe == r_textureframe && t->update_lastrenderentity == (void *)ent && !rsurface.forcecurrenttextureupdate)
6558 return t->currentframe;
6560 t->update_lastrenderentity = (void *)ent;
6561
6562 if(ent->entitynumber >= MAX_EDICTS && ent->entitynumber < 2 * MAX_EDICTS)
6563 t->camera_entity = ent->entitynumber;
6564 else
6565 t->camera_entity = 0;
6566
6567 // switch to an alternate material if this is a q1bsp animated material
6568 {
6569 texture_t *texture = t;
6570 int s = rsurface.ent_skinnum;
6571 if ((unsigned int)s >= (unsigned int)model->numskins)
6572 s = 0;
6573 if (model->skinscenes)
6574 {
6575 if (model->skinscenes[s].framecount > 1)
6576 s = model->skinscenes[s].firstframe + (unsigned int) (rsurface.shadertime * model->skinscenes[s].framerate) % model->skinscenes[s].framecount;
6577 else
6578 s = model->skinscenes[s].firstframe;
6579 }
6580 if (s > 0)
6581 t = t + s * model->num_surfaces;
6582 if (t->animated)
6583 {
6584 // use an alternate animation if the entity's frame is not 0,
6585 // and only if the texture has an alternate animation
6586 if (t->animated == 2) // q2bsp
6587 t = t->anim_frames[0][ent->framegroupblend[0].frame % t->anim_total[0]];
6588 else if (rsurface.ent_alttextures && t->anim_total[1])
6589 t = t->anim_frames[1][(t->anim_total[1] >= 2) ? ((int)(rsurface.shadertime * 5.0f) % t->anim_total[1]) : 0];
6590 else
6591 t = t->anim_frames[0][(t->anim_total[0] >= 2) ? ((int)(rsurface.shadertime * 5.0f) % t->anim_total[0]) : 0];
6592 }
6593 texture->currentframe = t;
6594 }
6595
6596 // update currentskinframe to be a qw skin or animation frame
6597 if (rsurface.ent_qwskin >= 0)
6598 {
6599 i = rsurface.ent_qwskin;
6600 if (!r_qwskincache || r_qwskincache_size != cl.maxclients)
6601 {
6602 r_qwskincache_size = cl.maxclients;
6603 if (r_qwskincache)
6606 }
6607 if (strcmp(r_qwskincache[i].name, cl.scores[i].qw_skin))
6608 R_LoadQWSkin(&r_qwskincache[i], cl.scores[i].qw_skin);
6609 t->currentskinframe = r_qwskincache[i].skinframe;
6612 }
6613 else if (t->materialshaderpass && t->materialshaderpass->numframes >= 2)
6617
6619 t->currentalpha = rsurface.entity->alpha * t->basealpha;
6620 if (t->basematerialflags & MATERIALFLAG_WATERALPHA && (model->brush.supportwateralpha || r_water.integer || r_novis.integer || r_trippy.integer))
6621 t->currentalpha *= r_wateralpha.value;
6622 if(t->basematerialflags & MATERIALFLAG_WATERSHADER && r_fb.water.enabled && !r_refdef.view.isoverlay)
6624 if(!r_fb.water.enabled || r_refdef.view.isoverlay)
6626
6627 // decide on which type of lighting to use for this surface
6628 if (rsurface.entity->render_modellight_forced)
6630 if (rsurface.entity->render_rtlight_disabled)
6632 if (rsurface.entity->render_lightgrid)
6635 {
6636 // some CUSTOMBLEND blendfuncs are too weird, we have to ignore colormod and view colorscale
6638 for (q = 0; q < 3; q++)
6639 {
6640 t->render_glowmod[q] = rsurface.entity->glowmod[q];
6641 t->render_modellight_lightdir_world[q] = q == 2;
6642 t->render_modellight_lightdir_local[q] = q == 2;
6643 t->render_modellight_ambient[q] = 1;
6644 t->render_modellight_diffuse[q] = 0;
6646 t->render_lightmap_ambient[q] = 0;
6647 t->render_lightmap_diffuse[q] = 0;
6648 t->render_lightmap_specular[q] = 0;
6649 t->render_rtlight_diffuse[q] = 0;
6650 t->render_rtlight_specular[q] = 0;
6651 }
6652 }
6653 else if ((t->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) || !(rsurface.ent_flags & RENDER_LIGHT))
6654 {
6655 // fullbright is basically MATERIALFLAG_MODELLIGHT but with ambient locked to 1,1,1 and no shading
6657 for (q = 0; q < 3; q++)
6658 {
6659 t->render_glowmod[q] = rsurface.entity->render_glowmod[q] * r_refdef.view.colorscale;
6660 t->render_modellight_ambient[q] = rsurface.entity->render_fullbright[q] * r_refdef.view.colorscale;
6661 t->render_modellight_lightdir_world[q] = q == 2;
6662 t->render_modellight_lightdir_local[q] = q == 2;
6663 t->render_modellight_diffuse[q] = 0;
6665 t->render_lightmap_ambient[q] = 0;
6666 t->render_lightmap_diffuse[q] = 0;
6667 t->render_lightmap_specular[q] = 0;
6668 t->render_rtlight_diffuse[q] = 0;
6669 t->render_rtlight_specular[q] = 0;
6670 }
6671 }
6673 {
6675 for (q = 0; q < 3; q++)
6676 {
6677 t->render_glowmod[q] = rsurface.entity->render_glowmod[q] * r_refdef.view.colorscale;
6678 t->render_modellight_lightdir_world[q] = q == 2;
6679 t->render_modellight_lightdir_local[q] = q == 2;
6680 t->render_modellight_ambient[q] = 0;
6681 t->render_modellight_diffuse[q] = 0;
6683 t->render_lightmap_ambient[q] = rsurface.entity->render_lightmap_ambient[q] * r_refdef.view.colorscale;
6684 t->render_lightmap_diffuse[q] = rsurface.entity->render_lightmap_diffuse[q] * 2 * r_refdef.view.colorscale;
6685 t->render_lightmap_specular[q] = rsurface.entity->render_lightmap_specular[q] * 2 * r_refdef.view.colorscale;
6686 t->render_rtlight_diffuse[q] = rsurface.entity->render_rtlight_diffuse[q] * r_refdef.view.colorscale;
6687 t->render_rtlight_specular[q] = rsurface.entity->render_rtlight_specular[q] * r_refdef.view.colorscale;
6688 }
6689 }
6690 else if ((rsurface.ent_flags & (RENDER_DYNAMICMODELLIGHT | RENDER_CUSTOMIZEDMODELLIGHT)) || rsurface.modeltexcoordlightmap2f == NULL)
6691 {
6692 // ambient + single direction light (modellight)
6694 for (q = 0; q < 3; q++)
6695 {
6696 t->render_glowmod[q] = rsurface.entity->render_glowmod[q] * r_refdef.view.colorscale;
6697 t->render_modellight_lightdir_world[q] = rsurface.entity->render_modellight_lightdir_world[q];
6698 t->render_modellight_lightdir_local[q] = rsurface.entity->render_modellight_lightdir_local[q];
6699 t->render_modellight_ambient[q] = rsurface.entity->render_modellight_ambient[q] * r_refdef.view.colorscale;
6700 t->render_modellight_diffuse[q] = rsurface.entity->render_modellight_diffuse[q] * r_refdef.view.colorscale;
6701 t->render_modellight_specular[q] = rsurface.entity->render_modellight_specular[q] * r_refdef.view.colorscale;
6702 t->render_lightmap_ambient[q] = 0;
6703 t->render_lightmap_diffuse[q] = 0;
6704 t->render_lightmap_specular[q] = 0;
6705 t->render_rtlight_diffuse[q] = rsurface.entity->render_rtlight_diffuse[q] * r_refdef.view.colorscale;
6706 t->render_rtlight_specular[q] = rsurface.entity->render_rtlight_specular[q] * r_refdef.view.colorscale;
6707 }
6708 }
6709 else
6710 {
6711 // lightmap - 2x diffuse and specular brightness because bsp files have 0-2 colors as 0-1
6712 for (q = 0; q < 3; q++)
6713 {
6714 t->render_glowmod[q] = rsurface.entity->render_glowmod[q] * r_refdef.view.colorscale;
6715 t->render_modellight_lightdir_world[q] = q == 2;
6716 t->render_modellight_lightdir_local[q] = q == 2;
6717 t->render_modellight_ambient[q] = 0;
6718 t->render_modellight_diffuse[q] = 0;
6720 t->render_lightmap_ambient[q] = rsurface.entity->render_lightmap_ambient[q] * r_refdef.view.colorscale;
6721 t->render_lightmap_diffuse[q] = rsurface.entity->render_lightmap_diffuse[q] * 2 * r_refdef.view.colorscale;
6722 t->render_lightmap_specular[q] = rsurface.entity->render_lightmap_specular[q] * 2 * r_refdef.view.colorscale;
6723 t->render_rtlight_diffuse[q] = rsurface.entity->render_rtlight_diffuse[q] * r_refdef.view.colorscale;
6724 t->render_rtlight_specular[q] = rsurface.entity->render_rtlight_specular[q] * r_refdef.view.colorscale;
6725 }
6726 }
6727
6729 {
6730 // since MATERIALFLAG_VERTEXCOLOR uses the lightmapcolor4f vertex
6731 // attribute, we punt it to the lightmap path and hope for the best,
6732 // but lighting doesn't work.
6733 //
6734 // FIXME: this is fine for effects but CSQC polygons should be subject
6735 // to lighting.
6737 for (q = 0; q < 3; q++)
6738 {
6739 t->render_glowmod[q] = rsurface.entity->render_glowmod[q] * r_refdef.view.colorscale;
6740 t->render_modellight_lightdir_world[q] = q == 2;
6741 t->render_modellight_lightdir_local[q] = q == 2;
6742 t->render_modellight_ambient[q] = 0;
6743 t->render_modellight_diffuse[q] = 0;
6745 t->render_lightmap_ambient[q] = 0;
6746 t->render_lightmap_diffuse[q] = rsurface.entity->render_fullbright[q] * r_refdef.view.colorscale;
6747 t->render_lightmap_specular[q] = 0;
6748 t->render_rtlight_diffuse[q] = 0;
6749 t->render_rtlight_specular[q] = 0;
6750 }
6751 }
6752
6753 for (q = 0; q < 3; q++)
6754 {
6755 t->render_colormap_pants[q] = rsurface.entity->colormap_pantscolor[q];
6756 t->render_colormap_shirt[q] = rsurface.entity->colormap_shirtcolor[q];
6757 }
6758
6759 if (rsurface.ent_flags & RENDER_ADDITIVE)
6761 else if (t->currentalpha < 1)
6763 // LadyHavoc: prevent bugs where code checks add or alpha at higher priority than customblend by clearing these flags
6766 if (rsurface.ent_flags & RENDER_DOUBLESIDED)
6768 if (rsurface.ent_flags & (RENDER_NODEPTHTEST | RENDER_VIEWMODEL))
6770 if (t->backgroundshaderpass)
6773 {
6776 }
6777 else
6780 {
6781 // promote alphablend to alphatocoverage (a type of alphatest) if antialiasing is on
6783 }
6786
6787 // there is no tcmod
6789 {
6792 }
6794 {
6797 }
6798
6799 if (t->materialshaderpass)
6800 for (i = 0, tcmod = t->materialshaderpass->tcmods;i < Q3MAXTCMODS && tcmod->tcmod;i++, tcmod++)
6802
6804 if (t->currentskinframe->qpixels)
6806 t->basetexture = (!t->colormapping && t->currentskinframe->merged) ? t->currentskinframe->merged : t->currentskinframe->base;
6807 if (!t->basetexture)
6809 t->pantstexture = t->colormapping ? t->currentskinframe->pants : NULL;
6810 t->shirttexture = t->colormapping ? t->currentskinframe->shirt : NULL;
6811 t->nmaptexture = t->currentskinframe->nmap;
6812 if (!t->nmaptexture)
6815 t->glowtexture = t->currentskinframe->glow;
6816 t->fogtexture = t->currentskinframe->fog;
6817 t->reflectmasktexture = t->currentskinframe->reflect;
6818 if (t->backgroundshaderpass)
6819 {
6820 for (i = 0, tcmod = t->backgroundshaderpass->tcmods; i < Q3MAXTCMODS && tcmod->tcmod; i++, tcmod++)
6822 t->backgroundbasetexture = (!t->colormapping && t->backgroundcurrentskinframe->merged) ? t->backgroundcurrentskinframe->merged : t->backgroundcurrentskinframe->base;
6826 if (!t->backgroundnmaptexture)
6828 // make sure that if glow is going to be used, both textures are not NULL
6829 if (!t->backgroundglowtexture && t->glowtexture)
6831 if (!t->glowtexture && t->backgroundglowtexture)
6833 }
6834 else
6835 {
6840 }
6842 // TODO: store reference values for these in the texture?
6843 if (r_shadow_gloss.integer > 0)
6844 {
6846 {
6847 if (r_shadow_glossintensity.value > 0)
6848 {
6851 specularscale = r_shadow_glossintensity.value;
6852 }
6853 }
6854 else if (r_shadow_gloss.integer >= 2 && r_shadow_gloss2intensity.value > 0)
6855 {
6858 specularscale = r_shadow_gloss2intensity.value;
6860 }
6861 }
6862 specularscale *= t->specularscalemod;
6864
6865 // lightmaps mode looks bad with dlights using actual texturing, so turn
6866 // off the colormap and glossmap, but leave the normalmap on as it still
6867 // accurately represents the shading involved
6868 if (gl_lightmaps.integer && ent != &cl_meshentities[MESH_UI].render)
6869 {
6873 if (gl_lightmaps.integer < 2)
6876 t->glowtexture = NULL;
6877 t->fogtexture = NULL;
6880 if (gl_lightmaps.integer < 2)
6884 specularscale = 0;
6886 }
6887
6888 if (specularscale != 1.0f)
6889 {
6890 for (q = 0; q < 3; q++)
6891 {
6892 t->render_modellight_specular[q] *= specularscale;
6893 t->render_lightmap_specular[q] *= specularscale;
6894 t->render_rtlight_specular[q] *= specularscale;
6895 }
6896 }
6897
6898 t->currentblendfunc[0] = GL_ONE;
6899 t->currentblendfunc[1] = GL_ZERO;
6901 {
6903 t->currentblendfunc[1] = GL_ONE;
6904 }
6906 {
6909 }
6911 {
6912 t->currentblendfunc[0] = t->customblendfunc[0];
6913 t->currentblendfunc[1] = t->customblendfunc[1];
6914 }
6915
6916 return t;
6917}
entity_t cl_meshentities[NUM_MESHENTITIES]
Definition cl_main.c:2513
@ MESH_UI
Definition client.h:1365
static void R_LoadQWSkin(r_qwskincache_t *cache, const char *skinname)
Definition gl_rmain.c:6522
rtexture_t * r_texture_grey128
Definition gl_rmain.c:274
static void R_SkinFrame_GenerateTexturesFromQPixels(skinframe_t *skinframe, qbool colormapped)
Definition gl_rmain.c:2676
rtexture_t * r_texture_black
Definition gl_rmain.c:275
static r_qwskincache_t * r_qwskincache
Definition gl_rmain.c:308
int r_textureframe
used only by R_GetCurrentTexture, incremented per view and per UI render
Definition gl_rmain.c:45
rtexture_t * r_texture_notexture
Definition gl_rmain.c:276
r_framebufferstate_t r_fb
Definition gl_rmain.c:265
matrix4x4_t r_waterscrollmatrix
Definition gl_rmain.c:5394
static void R_tcMod_ApplyToMatrix(matrix4x4_t *texmatrix, q3shaderinfo_layer_tcmod_t *tcmod, int currentmaterialflags)
Definition gl_rmain.c:6445
#define BLENDFUNC_ALLOWS_COLORMOD
Definition gl_rmain.c:1517
rtexture_t * r_texture_white
Definition gl_rmain.c:273
static int r_qwskincache_size
Definition gl_rmain.c:309
static int R_BlendFuncFlags(int src, int dst)
Definition gl_rmain.c:1522
#define GL_SRC_ALPHA
Definition glquake.h:79
#define GL_ZERO
Definition glquake.h:73
#define GL_ONE_MINUS_SRC_ALPHA
Definition glquake.h:80
#define GL_ONE
Definition glquake.h:74
int LoopingFrameNumberFromDouble(double t, int loopframes)
Definition mathlib.c:891
void Matrix4x4_CreateIdentity(matrix4x4_t *out)
Definition matrixlib.c:564
cvar_t r_shadow_gloss
Definition r_shadow.c:147
cvar_t r_novis
Definition model_brush.c:31
cvar_t r_trippy
Definition model_brush.c:29
#define MATERIALFLAG_ADD
Definition model_brush.h:81
#define MATERIALFLAG_FULLBRIGHT
Definition model_brush.h:87
#define MATERIALFLAG_REFRACTION
#define MATERIALFLAG_ALPHATEST
#define MATERIALFLAG_TRANSDEPTH
#define MATERIALFLAG_VERTEXTEXTUREBLEND
#define MATERIALFLAG_WATERALPHA
Definition model_brush.h:85
#define MATERIALFLAG_LIGHTGRID
#define MATERIALFLAG_WATERSHADER
#define MATERIALFLAG_MODELLIGHT
#define MATERIALFLAG_CAMERA
#define MATERIALFLAG_NODEPTHTEST
Definition model_brush.h:83
#define MATERIALFLAG_REFLECTION
#define MATERIALFLAG_SHORTDEPTHRANGE
#define MATERIALFLAG_NOCULLFACE
#define MATERIALFLAG_WATERSCROLL
Definition model_brush.h:94
#define MATERIALFLAG_CUSTOMBLEND
#define MATERIALFLAG_NORTLIGHT
#define RENDER_VIEWMODEL
Definition protocol.h:358
#define RENDER_DYNAMICMODELLIGHT
Definition protocol.h:373
#define RENDER_DOUBLESIDED
Definition protocol.h:371
#define RENDER_ADDITIVE
Definition protocol.h:370
#define RENDER_LIGHT
Definition protocol.h:366
#define RENDER_CUSTOMIZEDMODELLIGHT
Definition protocol.h:372
#define RENDER_NODEPTHTEST
Definition protocol.h:369
#define MAX_EDICTS
max number of objects in game world at once (32768 protocol limit)
Definition qdefs.h:105
cvar_t r_shadow_glossintensity
Definition r_shadow.c:149
cvar_t r_shadow_gloss2intensity
Definition r_shadow.c:148
cvar_t r_shadow_glossexponent
Definition r_shadow.c:150
cvar_t r_shadow_gloss2exponent
Definition r_shadow.c:151
framegroupblend_t framegroupblend[MAX_FRAMEGROUPBLENDS]
Definition client.h:363
q3shaderinfo_layer_tcmod_t tcmods[Q3MAXTCMODS]
Definition r_qshader.h:270
struct skinframe_s * skinframes[TEXTURE_MAXFRAMES]
Definition r_qshader.h:265
float specularpower
struct skinframe_s * backgroundcurrentskinframe
struct rtexture_s * basetexture
int currentblendfunc[2]
float render_rtlight_specular[3]
matrix4x4_t currenttexmatrix
qbool colormapping
struct rtexture_s * glosstexture
float render_modellight_lightdir_world[3]
float render_glowmod[3]
float render_colormap_pants[3]
struct rtexture_s * nmaptexture
int anim_total[2]
struct rtexture_s * backgroundglosstexture
struct rtexture_s * backgroundbasetexture
int currentmaterialflags
texture_shaderpass_t * backgroundshaderpass
int camera_entity
void * update_lastrenderentity
float render_colormap_shirt[3]
float basealpha
float render_modellight_diffuse[3]
float render_rtlight_diffuse[3]
float render_modellight_ambient[3]
struct rtexture_s * shirttexture
struct rtexture_s * pantstexture
float specularpowermod
int basematerialflags
struct texture_s * currentframe
struct rtexture_s * glowtexture
int update_lastrenderframe
float render_modellight_lightdir_local[3]
struct rtexture_s * backgroundglowtexture
float render_lightmap_specular[3]
struct rtexture_s * reflectmasktexture
matrix4x4_t currentbackgroundtexmatrix
struct rtexture_s * fogtexture
float render_lightmap_diffuse[3]
texture_shaderpass_t * materialshaderpass
float render_lightmap_ambient[3]
float specularscalemod
struct rtexture_s * backgroundnmaptexture
float currentalpha
float render_modellight_specular[3]
struct skinframe_s * currentskinframe
struct texture_s * anim_frames[2][10]
int customblendfunc[2]

References texture_t::anim_frames, texture_t::anim_total, texture_t::animated, texture_t::backgroundbasetexture, texture_t::backgroundcurrentskinframe, texture_t::backgroundglosstexture, texture_t::backgroundglowtexture, texture_t::backgroundnmaptexture, texture_t::backgroundshaderpass, texture_t::basealpha, texture_t::basematerialflags, texture_t::basetexture, BLENDFUNC_ALLOWS_COLORMOD, texture_t::camera_entity, cl, cl_meshentities, texture_t::colormapping, texture_t::currentalpha, texture_t::currentbackgroundtexmatrix, texture_t::currentblendfunc, texture_t::currentframe, texture_t::currentmaterialflags, texture_t::currentskinframe, texture_t::currenttexmatrix, texture_t::customblendfunc, entity_render_t::entitynumber, texture_t::fogtexture, framegroupblend_t::frame, entity_render_t::framegroupblend, texture_shaderpass_t::framerate, gl_lightmaps, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ZERO, texture_t::glosstexture, texture_t::glowtexture, int(), LoopingFrameNumberFromDouble(), MATERIALFLAG_ADD, MATERIALFLAG_ALPHA, MATERIALFLAG_ALPHATEST, MATERIALFLAG_BLENDED, MATERIALFLAG_CAMERA, MATERIALFLAG_CUSTOMBLEND, MATERIALFLAG_CUSTOMSURFACE, MATERIALFLAG_FULLBRIGHT, MATERIALFLAG_LIGHTGRID, MATERIALFLAG_MODELLIGHT, MATERIALFLAG_NOCULLFACE, MATERIALFLAG_NODEPTHTEST, MATERIALFLAG_NORTLIGHT, MATERIALFLAG_NOSHADOW, MATERIALFLAG_REFLECTION, MATERIALFLAG_REFRACTION, MATERIALFLAG_SHORTDEPTHRANGE, MATERIALFLAG_TRANSDEPTH, MATERIALFLAG_VERTEXCOLOR, MATERIALFLAG_VERTEXTEXTUREBLEND, MATERIALFLAG_WALL, MATERIALFLAG_WATERALPHA, MATERIALFLAG_WATERSCROLL, MATERIALFLAG_WATERSHADER, texture_t::materialshaderpass, Matrix4x4_CreateIdentity(), MAX_EDICTS, Mem_Alloc, Mem_Free, MESH_UI, entity_render_t::model, model, name, texture_t::nmaptexture, NULL, texture_shaderpass_t::numframes, texture_t::pantstexture, R_BlendFuncFlags(), r_fb, R_LoadQWSkin(), r_main_mempool, r_novis, r_qwskincache, r_qwskincache_size, r_refdef, r_shadow_gloss, r_shadow_gloss2exponent, r_shadow_gloss2intensity, r_shadow_glossexponent, r_shadow_glossintensity, R_SkinFrame_GenerateTexturesFromQPixels(), R_tcMod_ApplyToMatrix(), r_texture_black, r_texture_blanknormalmap, r_texture_grey128, r_texture_notexture, r_texture_white, r_textureframe, r_transparent_alphatocoverage, r_transparentdepthmasking, r_trippy, r_water, r_wateralpha, r_waterscrollmatrix, texture_t::reflectmasktexture, RENDER_ADDITIVE, texture_t::render_colormap_pants, texture_t::render_colormap_shirt, RENDER_CUSTOMIZEDMODELLIGHT, RENDER_DOUBLESIDED, RENDER_DYNAMICMODELLIGHT, texture_t::render_glowmod, RENDER_LIGHT, texture_t::render_lightmap_ambient, texture_t::render_lightmap_diffuse, texture_t::render_lightmap_specular, texture_t::render_modellight_ambient, texture_t::render_modellight_diffuse, texture_t::render_modellight_lightdir_local, texture_t::render_modellight_lightdir_world, texture_t::render_modellight_specular, RENDER_NODEPTHTEST, texture_t::render_rtlight_diffuse, texture_t::render_rtlight_specular, RENDER_VIEWMODEL, rsurface, texture_t::shirttexture, texture_shaderpass_t::skinframes, texture_t::specularpower, texture_t::specularpowermod, texture_t::specularscalemod, texture_shaderpass_t::tcmods, texture, texture_t::update_lastrenderentity, texture_t::update_lastrenderframe, VectorLength2, and vid.

Referenced by R_DrawCustomSurface_Texture(), R_DrawDebugModel(), R_DrawSurface_TransparentCallback(), R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Model_Sprite_Draw_TransparentCallback(), R_Q1BSP_DrawLight_TransparentCallback(), R_Q1BSP_RecursiveGetLightInfo_BIH(), R_Q1BSP_RecursiveGetLightInfo_BSP(), R_QueueModelSurfaceList(), and R_Water_AddWaterPlane().

◆ R_GetScenePointer()

r_refdef_scene_t * R_GetScenePointer ( r_refdef_scene_type_t scenetype)

Definition at line 5588 of file gl_rmain.c.

5589{
5590 // of course, we could also add a qbool that provides a lock state and a ReleaseScenePointer function..
5591 if( scenetype == r_currentscenetype ) {
5592 return &r_refdef.scene;
5593 } else {
5594 return &r_scenes_store[ scenetype ];
5595 }
5596}
static r_refdef_scene_type_t r_currentscenetype
Definition gl_rmain.c:5566
static r_refdef_scene_t r_scenes_store[RST_COUNT]
Definition gl_rmain.c:5567

References r_currentscenetype, r_refdef, and r_scenes_store.

Referenced by MVM_init_cmd().

◆ R_GLSL_Restart_f()

void R_GLSL_Restart_f ( cmd_state_t * cmd)

Definition at line 1394 of file gl_rmain.c.

1395{
1396 unsigned int i, limit;
1397 switch(vid.renderpath)
1398 {
1399 case RENDERPATH_GL32:
1400 case RENDERPATH_GLES2:
1401 {
1405 for (i = 0;i < limit;i++)
1406 {
1408 {
1411 }
1412 }
1414 }
1415 break;
1416 }
1417}
void GL_Backend_FreeProgram(unsigned int prog)
memexpandablearray_t r_glsl_permutationarray
storage for permutations linked in the hash table
Definition gl_rmain.c:938
r_glsl_permutation_t * r_glsl_permutation
currently selected permutation
Definition gl_rmain.c:936
r_glsl_permutation_t * r_glsl_permutationhash[SHADERMODE_COUNT][SHADERPERMUTATION_HASHSIZE]
information about each possible shader permutation
Definition gl_rmain.c:934
int program
0 if compilation failed
Definition gl_rmain.c:697
@ RENDERPATH_GLES2
Definition vid.h:38
@ RENDERPATH_GL32
Definition vid.h:37
size_t Mem_ExpandableArray_IndexRange(const memexpandablearray_t *l)
Definition zone.c:763
void Mem_ExpandableArray_FreeRecord(memexpandablearray_t *l, void *record)
Definition zone.c:743
void * Mem_ExpandableArray_RecordAtIndex(const memexpandablearray_t *l, size_t index)
Definition zone.c:780

References cmd(), GL_Backend_FreeProgram(), int(), Mem_ExpandableArray_FreeRecord(), Mem_ExpandableArray_IndexRange(), Mem_ExpandableArray_RecordAtIndex(), NULL, r_glsl_permutation_t::program, r_glsl_permutation, r_glsl_permutationarray, r_glsl_permutationhash, RENDERPATH_GL32, RENDERPATH_GLES2, and vid.

Referenced by GL_Main_Init(), gl_main_shutdown(), R_RenderView(), and R_Shadow_SetShadowMode().

◆ R_HDR_UpdateIrisAdaptation()

void R_HDR_UpdateIrisAdaptation ( const vec3_t point)

Definition at line 4144 of file gl_rmain.c.

4145{
4146 if (r_hdr_irisadaptation.integer)
4147 {
4148 vec3_t p;
4149 vec3_t ambient;
4150 vec3_t diffuse;
4151 vec3_t diffusenormal;
4153 vec_t brightness = 0.0f;
4154 vec_t goal;
4155 vec_t current;
4156 vec_t d;
4157 int c;
4158 VectorCopy(r_refdef.view.forward, forward);
4159 for (c = 0;c < (int)(sizeof(irisvecs)/sizeof(irisvecs[0]));c++)
4160 {
4161 p[0] = point[0] + irisvecs[c][0] * r_hdr_irisadaptation_radius.value;
4162 p[1] = point[1] + irisvecs[c][1] * r_hdr_irisadaptation_radius.value;
4163 p[2] = point[2] + irisvecs[c][2] * r_hdr_irisadaptation_radius.value;
4164 R_CompleteLightPoint(ambient, diffuse, diffusenormal, p, LP_LIGHTMAP | LP_RTWORLD | LP_DYNLIGHT, r_refdef.scene.lightmapintensity, r_refdef.scene.ambientintensity);
4165 d = DotProduct(forward, diffusenormal);
4166 brightness += VectorLength(ambient);
4167 if (d > 0)
4168 brightness += d * VectorLength(diffuse);
4169 }
4170 brightness *= 1.0f / c;
4171 brightness += 0.00001f; // make sure it's never zero
4172 goal = r_hdr_irisadaptation_multiplier.value / brightness;
4174 current = r_hdr_irisadaptation_value.value;
4175 if (current < goal)
4176 current = min(current + r_hdr_irisadaptation_fade_up.value * cl.realframetime, goal);
4177 else if (current > goal)
4178 current = max(current - r_hdr_irisadaptation_fade_down.value * cl.realframetime, goal);
4179 if (fabs(r_hdr_irisadaptation_value.value - current) > 0.0001f)
4181 }
4182 else if (r_hdr_irisadaptation_value.value != 1.0f)
4184}
static float irisvecs[7][3]
Definition gl_rmain.c:4142
float vec_t
Definition qtypes.h:68
void R_CompleteLightPoint(float *ambient, float *diffuse, float *lightdir, const vec3_t p, const int flags, float lightmapintensity, float ambientintensity)
Definition r_shadow.c:6014
#define LP_DYNLIGHT
Definition r_shadow.h:194
#define LP_LIGHTMAP
Definition r_shadow.h:192
#define LP_RTWORLD
Definition r_shadow.h:193
static vec3_t forward
Definition sv_user.c:305

References bound, cl, Cvar_SetValueQuick(), DotProduct, fabs(), forward, int(), irisvecs, LP_DYNLIGHT, LP_LIGHTMAP, LP_RTWORLD, max, min, R_CompleteLightPoint(), r_hdr_irisadaptation, r_hdr_irisadaptation_fade_down, r_hdr_irisadaptation_fade_up, r_hdr_irisadaptation_maxvalue, r_hdr_irisadaptation_minvalue, r_hdr_irisadaptation_multiplier, r_hdr_irisadaptation_radius, r_hdr_irisadaptation_value, r_refdef, VectorCopy, and VectorLength.

Referenced by CL_UpdateScreen().

◆ R_LightningBeams_Init()

void R_LightningBeams_Init ( void )

Definition at line 96 of file r_lightning.c.

97{
106}
cvar_t r_lightningbeam_scroll
Definition r_lightning.c:6
cvar_t r_lightningbeam_repeatdistance
Definition r_lightning.c:7
cvar_t r_lightningbeam_color_red
Definition r_lightning.c:8
cvar_t r_lightningbeam_color_blue
Definition r_lightning.c:10
cvar_t r_lightningbeam_color_green
Definition r_lightning.c:9
cvar_t r_lightningbeam_thickness
Definition r_lightning.c:5
cvar_t r_lightningbeam_qmbtexture
Definition r_lightning.c:11
static void r_lightningbeams_start(void)
Definition r_lightning.c:16
static void r_lightningbeams_shutdown(void)
Definition r_lightning.c:82
static void r_lightningbeams_newmap(void)
Definition r_lightning.c:88

References Cvar_RegisterVariable(), NULL, r_lightningbeam_color_blue, r_lightningbeam_color_green, r_lightningbeam_color_red, r_lightningbeam_qmbtexture, r_lightningbeam_repeatdistance, r_lightningbeam_scroll, r_lightningbeam_thickness, r_lightningbeams_newmap(), r_lightningbeams_shutdown(), r_lightningbeams_start(), and R_RegisterModule().

Referenced by Render_Init().

◆ R_Mesh_AddBrushMeshFromPlanes()

void R_Mesh_AddBrushMeshFromPlanes ( rmesh_t * mesh,
int numplanes,
mplane_t * planes )

Definition at line 6364 of file gl_rmain.c.

6365{
6366 int planenum, planenum2;
6367 int w;
6368 int tempnumpoints;
6369 mplane_t *plane, *plane2;
6370 double maxdist;
6371 double temppoints[2][256*3];
6372 // figure out how large a bounding box we need to properly compute this brush
6373 maxdist = 0;
6374 for (w = 0;w < numplanes;w++)
6375 maxdist = max(maxdist, fabs(planes[w].dist));
6376 // now make it large enough to enclose the entire brush, and round it off to a reasonable multiple of 1024
6377 maxdist = floor(maxdist * (4.0 / 1024.0) + 1) * 1024.0;
6378 for (planenum = 0, plane = planes;planenum < numplanes;planenum++, plane++)
6379 {
6380 w = 0;
6381 tempnumpoints = 4;
6382 PolygonD_QuadForPlane(temppoints[w], plane->normal[0], plane->normal[1], plane->normal[2], plane->dist, maxdist);
6383 for (planenum2 = 0, plane2 = planes;planenum2 < numplanes && tempnumpoints >= 3;planenum2++, plane2++)
6384 {
6385 if (planenum2 == planenum)
6386 continue;
6387 PolygonD_Divide(tempnumpoints, temppoints[w], plane2->normal[0], plane2->normal[1], plane2->normal[2], plane2->dist, R_MESH_PLANE_DIST_EPSILON, 0, NULL, NULL, 256, temppoints[!w], &tempnumpoints, NULL);
6388 w = !w;
6389 }
6390 if (tempnumpoints < 3)
6391 continue;
6392 // generate elements forming a triangle fan for this polygon
6393 R_Mesh_AddPolygon3d(mesh, tempnumpoints, temppoints[w]);
6394 }
6395}
#define R_MESH_PLANE_DIST_EPSILON
Definition gl_rmain.c:6363
static void R_Mesh_AddPolygon3d(rmesh_t *mesh, int numvertices, double *vertex3d)
Definition gl_rmain.c:6342
float floor(float f)
void PolygonD_QuadForPlane(double *outpoints, double planenormalx, double planenormaly, double planenormalz, double planedist, double quadsize)
Definition polygon.c:54
void PolygonD_Divide(int innumpoints, const double *inpoints, double planenormalx, double planenormaly, double planenormalz, double planedist, double epsilon, int outfrontmaxpoints, double *outfrontpoints, int *neededfrontpoints, int outbackmaxpoints, double *outbackpoints, int *neededbackpoints, int *oncountpointer)
Definition polygon.c:245
vec3_t normal
Definition model_brush.h:59
vec_t dist
Definition model_brush.h:60

References mplane_t::dist, fabs(), floor(), max, mplane_t::normal, NULL, PolygonD_Divide(), PolygonD_QuadForPlane(), R_Mesh_AddPolygon3d(), R_MESH_PLANE_DIST_EPSILON, and w.

◆ R_Mesh_AddPolygon3f()

void R_Mesh_AddPolygon3f ( rmesh_t * mesh,
int numvertices,
float * vertex3f )

Definition at line 6321 of file gl_rmain.c.

6322{
6323 int i;
6324 int *e, element[3];
6325 element[0] = R_Mesh_AddVertex(mesh, vertex3f[0], vertex3f[1], vertex3f[2]);vertex3f += 3;
6326 element[1] = R_Mesh_AddVertex(mesh, vertex3f[0], vertex3f[1], vertex3f[2]);vertex3f += 3;
6327 e = mesh->element3i + mesh->numtriangles * 3;
6328 for (i = 0;i < numvertices - 2;i++, vertex3f += 3)
6329 {
6330 element[2] = R_Mesh_AddVertex(mesh, vertex3f[0], vertex3f[1], vertex3f[2]);
6331 if (mesh->numtriangles < mesh->maxtriangles)
6332 {
6333 *e++ = element[0];
6334 *e++ = element[1];
6335 *e++ = element[2];
6336 mesh->numtriangles++;
6337 }
6338 element[1] = element[2];
6339 }
6340}
static int R_Mesh_AddVertex(rmesh_t *mesh, float x, float y, float z)
Definition gl_rmain.c:6299
int numtriangles
Definition render.h:169
int * element3i
Definition render.h:170
int maxtriangles
Definition render.h:168

References rmesh_t::element3i, rmesh_t::maxtriangles, rmesh_t::numtriangles, and R_Mesh_AddVertex().

◆ R_Model_Sprite_Draw()

void R_Model_Sprite_Draw ( entity_render_t * ent)

Definition at line 430 of file r_sprites.c.

431{
432 vec3_t org;
433 if (ent->frameblend[0].subframe < 0)
434 return;
435
438}
void Matrix4x4_OriginFromMatrix(const matrix4x4_t *in, float *out)
Definition matrixlib.c:1792
#define RENDER_WORLDOBJECT
Definition protocol.h:362
@ TRANSPARENTSORT_SKY
Definition r_qshader.h:193
@ TRANSPARENTSORT_HUD
Definition r_qshader.h:195
static void R_Model_Sprite_Draw_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition r_sprites.c:208
matrix4x4_t matrix
Definition client.h:332
int subframe
Definition client.h:312

References entity_render_t::flags, entity_render_t::frameblend, entity_render_t::matrix, Matrix4x4_OriginFromMatrix(), R_MeshQueue_AddTransparent(), R_Model_Sprite_Draw_TransparentCallback(), RENDER_NODEPTHTEST, RENDER_WORLDOBJECT, rsurface, frameblend_t::subframe, TRANSPARENTSORT_DISTANCE, TRANSPARENTSORT_HUD, and TRANSPARENTSORT_SKY.

Referenced by Mod_IDS2_Load(), and Mod_IDSP_Load().

◆ R_ModulateColors()

void R_ModulateColors ( float * in,
float * out,
int verts,
float r,
float g,
float b )

Definition at line 321 of file gl_rmain.c.

322{
323 int i;
324 for (i = 0;i < verts;i++)
325 {
326 out[0] = in[0] * r;
327 out[1] = in[1] * g;
328 out[2] = in[2] * b;
329 out[3] = in[3];
330 in += 4;
331 out += 4;
332 }
333}

References b, g, and r.

◆ R_NewExplosion()

void R_NewExplosion ( const vec3_t org)

Definition at line 160 of file r_explosion.c.

161{
162#ifdef MAX_EXPLOSIONS
163 int i, j;
164 float dist, n;
165 explosion_t *e;
166 trace_t trace;
167 unsigned char noise[EXPLOSIONGRID*EXPLOSIONGRID];
168 fractalnoisequick(noise, EXPLOSIONGRID, 4); // adjust noise grid size according to explosion
169 for (i = 0, e = explosion;i < MAX_EXPLOSIONS;i++, e++)
170 {
171 if (!e->alpha)
172 {
174 e->starttime = cl.time;
175 e->endtime = cl.time + cl_explosions_lifetime.value;
176 e->time = e->starttime;
179 e->clipping = r_explosionclip.integer != 0;
180 VectorCopy(org, e->origin);
181 for (j = 0;j < EXPLOSIONVERTS;j++)
182 {
183 // calculate start origin and velocity
184 n = noise[explosionnoiseindex[j]] * (1.0f / 255.0f) + 0.5;
185 dist = n * cl_explosions_size_start.value;
186 VectorMA(e->origin, dist, explosionpoint[j], e->vert[j]);
188 VectorScale(explosionpoint[j], dist, e->vertvel[j]);
189 // clip start origin
190 if (e->clipping)
191 {
192 trace = CL_TraceLine(e->origin, e->vert[j], MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, 0, 0, collision_extendmovelength.value, true, false, NULL, false, false);
193 VectorCopy(trace.endpos, e->vert[i]);
194 }
195 }
196 break;
197 }
198 }
199#endif
200}
cvar_t cl_explosions_lifetime
Definition cl_main.c:73
cvar_t cl_explosions_size_start
Definition cl_main.c:71
cvar_t cl_explosions_size_end
Definition cl_main.c:72
cvar_t cl_explosions_alpha_start
Definition cl_main.c:69
cvar_t cl_explosions_alpha_end
Definition cl_main.c:70
void fractalnoisequick(unsigned char *noise, int size, int startgrid)
string noise
Definition progsdefs.qc:209
#define MAX_EXPLOSIONS
max number of explosion shell effects active at once (not particle related)
Definition qdefs.h:131
static int explosionnoiseindex[EXPLOSIONVERTS]
Definition r_explosion.c:33
static vec3_t explosionpoint[EXPLOSIONVERTS]
Definition r_explosion.c:34
#define EXPLOSIONVERTS
Definition r_explosion.c:26
float endtime
Definition r_explosion.c:39
vec3_t origin
Definition r_explosion.c:43
vec3_t vertvel[EXPLOSIONVERTS]
Definition r_explosion.c:45
vec3_t vert[EXPLOSIONVERTS]
Definition r_explosion.c:44
qbool clipping
Definition r_explosion.c:46
float starttime
Definition r_explosion.c:38
#define MOVE_NOMONSTERS
Definition world.h:29

References explosion_t::alpha, cl, cl_explosions_alpha_end, cl_explosions_alpha_start, cl_explosions_lifetime, cl_explosions_size_end, cl_explosions_size_start, CL_TraceLine(), explosion_t::clipping, collision_extendmovelength, trace_t::endpos, explosion_t::endtime, explosion, EXPLOSIONGRID, explosionnoiseindex, explosionpoint, EXPLOSIONVERTS, explosion_t::fade, fractalnoisequick(), max, MAX_EXPLOSIONS, MOVE_NOMONSTERS, n, noise, NULL, numexplosions, explosion_t::origin, r_explosionclip, explosion_t::starttime, SUPERCONTENTS_SOLID, explosion_t::time, VectorCopy, VectorMA, VectorScale, explosion_t::vert, and explosion_t::vertvel.

Referenced by CL_ParticleExplosion().

◆ R_Particles_Init()

void R_Particles_Init ( void )

Definition at line 2602 of file cl_particles.c.

2603{
2604 int i;
2605 for (i = 0;i < MESHQUEUE_TRANSPARENT_BATCHSIZE;i++)
2606 {
2607 particle_elements[i*6+0] = i*4+0;
2608 particle_elements[i*6+1] = i*4+1;
2609 particle_elements[i*6+2] = i*4+2;
2610 particle_elements[i*6+3] = i*4+0;
2611 particle_elements[i*6+4] = i*4+2;
2612 particle_elements[i*6+5] = i*4+3;
2613 }
2614
2622}
static void r_part_start(void)
cvar_t r_drawdecals
static void r_part_newmap(void)
static cvar_t r_drawdecals_drawdistance
static void r_part_shutdown(void)
static cvar_t r_drawparticles_nearclip_max
unsigned short particle_elements[MESHQUEUE_TRANSPARENT_BATCHSIZE *6]
#define MESHQUEUE_TRANSPARENT_BATCHSIZE
Definition meshqueue.h:6

References Cvar_RegisterVariable(), MESHQUEUE_TRANSPARENT_BATCHSIZE, NULL, particle_elements, r_drawdecals, r_drawdecals_drawdistance, r_drawparticles, r_drawparticles_drawdistance, r_drawparticles_nearclip_max, r_drawparticles_nearclip_min, r_part_newmap(), r_part_shutdown(), r_part_start(), and R_RegisterModule().

Referenced by Render_Init().

◆ R_RenderScene()

void R_RenderScene ( int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )

Definition at line 5830 of file gl_rmain.c.

5831{
5832 qbool shadowmapping = false;
5833
5835 R_TimeReport("beginscene");
5836
5837 r_refdef.stats[r_stat_renders]++;
5838
5839 R_UpdateFog();
5840
5842
5844
5845 Matrix4x4_CreateTranslate(&r_waterscrollmatrix, sin(r_refdef.scene.time) * 0.025 * r_waterscroll.value, sin(r_refdef.scene.time * 0.8f) * 0.025 * r_waterscroll.value, 0);
5846
5848 R_TimeReport("skystartframe");
5849
5850 if (cl.csqc_vidvars.drawworld)
5851 {
5852 if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawSky)
5853 {
5854 r_refdef.scene.worldmodel->DrawSky(r_refdef.scene.worldentity);
5856 R_TimeReport("worldsky");
5857 }
5858
5860 R_TimeReport("bmodelsky");
5861
5863 {
5864 // we have to force off the water clipping plane while rendering sky
5865 R_SetupView(false, viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5866 R_Sky();
5867 R_SetupView(true, viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5869 R_TimeReport("sky");
5870 }
5871 }
5872
5873 // save the framebuffer info for R_Shadow_RenderMode_Reset during this view render
5874 r_shadow_viewfbo = viewfbo;
5875 r_shadow_viewdepthtexture = viewdepthtexture;
5876 r_shadow_viewcolortexture = viewcolortexture;
5877 r_shadow_viewx = viewx;
5878 r_shadow_viewy = viewy;
5879 r_shadow_viewwidth = viewwidth;
5880 r_shadow_viewheight = viewheight;
5881
5885 R_TimeReport("preparelights");
5886
5887 // render all the shadowmaps that will be used for this view
5888 shadowmapping = R_Shadow_ShadowMappingEnabled();
5889 if (shadowmapping || r_shadow_shadowmapatlas_modelshadows_size)
5890 {
5893 R_TimeReport("shadowmaps");
5894 }
5895
5896 // render prepass deferred lighting if r_shadow_deferred is on, this produces light buffers that will be sampled in forward pass
5899
5900 // now we begin the forward pass of the view render
5901 if (r_depthfirst.integer >= 1 && cl.csqc_vidvars.drawworld && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawDepth)
5902 {
5903 r_refdef.scene.worldmodel->DrawDepth(r_refdef.scene.worldentity);
5905 R_TimeReport("worlddepth");
5906 }
5907 if (r_depthfirst.integer >= 2)
5908 {
5911 R_TimeReport("modeldepth");
5912 }
5913
5914 if (cl.csqc_vidvars.drawworld && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->Draw)
5915 {
5916 r_refdef.scene.worldmodel->Draw(r_refdef.scene.worldentity);
5918 R_TimeReport("world");
5919 }
5920
5921 R_DrawModels();
5923 R_TimeReport("models");
5924
5926 {
5929 R_TimeReport("rtlights");
5930 }
5931
5932 if (cl.csqc_vidvars.drawworld)
5933 {
5936 R_TimeReport("modeldecals");
5937
5940 R_TimeReport("particles");
5941
5944 R_TimeReport("explosions");
5945 }
5946
5947 if (r_refdef.view.showdebug)
5948 {
5949 if (cl_locs_show.integer)
5950 {
5951 R_DrawLocs();
5953 R_TimeReport("showlocs");
5954 }
5955
5956 if (r_drawportals.integer)
5957 {
5958 R_DrawPortals();
5960 R_TimeReport("portals");
5961 }
5962
5963 if (r_showbboxes_client.value > 0)
5964 {
5967 R_TimeReport("clbboxes");
5968 }
5969 if (r_showbboxes.value > 0)
5970 {
5973 R_TimeReport("svbboxes");
5974 }
5975 }
5976
5977 if (r_transparent.integer)
5978 {
5981 R_TimeReport("drawtrans");
5982 }
5983
5984 if (r_refdef.view.showdebug && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawDebug && (r_showtris.value > 0 || r_shownormals.value != 0 || r_showcollisionbrushes.value > 0 || r_showoverdraw.value > 0))
5985 {
5986 r_refdef.scene.worldmodel->DrawDebug(r_refdef.scene.worldentity);
5988 R_TimeReport("worlddebug");
5991 R_TimeReport("modeldebug");
5992 }
5993
5994 if (cl.csqc_vidvars.drawworld)
5995 {
5998 R_TimeReport("coronas");
5999 }
6000}
cvar_t cl_locs_show
Definition cl_main.c:98
void R_DrawParticles(void)
static int R_DrawBrushModelsSky(void)
only used if skyrendermasked, and normally returns false
Definition gl_rmain.c:4058
static void R_DrawModelsDebug(void)
Definition gl_rmain.c:4112
qbool r_shadow_usingdeferredprepass
Definition r_shadow.c:64
static void R_DrawLocs(void)
Definition gl_rmain.c:9121
void R_UpdateFog(void)
Definition gl_rmain.c:5396
static void R_DrawModels(void)
Definition gl_rmain.c:4078
void R_SetupView(qbool allowwaterclippingplane, int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:4384
int r_shadow_shadowmapatlas_modelshadows_size
Definition r_shadow.c:69
static void R_DrawModelDecals(void)
Definition gl_rmain.c:9711
static void R_DrawModelsDepth(void)
Definition gl_rmain.c:4097
static void R_DrawEntityBBoxes(prvm_prog_t *prog)
Definition gl_rmain.c:6120
void R_DrawPortals(void)
Definition gl_rsurf.c:381
void Matrix4x4_CreateTranslate(matrix4x4_t *out, double x, double y, double z)
Definition matrixlib.c:584
float sin(float f)
void R_MeshQueue_BeginScene(void)
Definition meshqueue.c:26
void R_MeshQueue_RenderTransparent(void)
Definition meshqueue.c:62
#define SVVM_prog
Definition progsvm.h:766
void R_DrawExplosions(void)
int r_shadow_viewx
Definition r_shadow.c:127
void R_Shadow_DrawShadowMaps(void)
Definition r_shadow.c:4204
rtexture_t * r_shadow_viewdepthtexture
Definition r_shadow.c:125
int r_shadow_viewfbo
Definition r_shadow.c:124
void R_Shadow_PrepareLights(void)
Definition r_shadow.c:4031
qbool R_Shadow_ShadowMappingEnabled(void)
Definition r_shadow.c:378
void R_Shadow_PrepareModelShadows(void)
Definition r_shadow.c:4242
rtexture_t * r_shadow_viewcolortexture
Definition r_shadow.c:126
int r_shadow_viewy
Definition r_shadow.c:128
void R_Shadow_DrawCoronas(void)
Definition r_shadow.c:4528
void R_Shadow_DrawLights(void)
Definition r_shadow.c:4226
void R_Shadow_DrawPrepass(void)
Definition r_shadow.c:3958
int r_shadow_viewwidth
Definition r_shadow.c:129
int r_shadow_viewheight
Definition r_shadow.c:130
int skyrendermasked
Definition r_sky.c:11
int skyrenderlater
Definition r_sky.c:10
void R_Sky(void)
Definition r_sky.c:403
void R_SkyStartFrame(void)
Definition r_sky.c:57
int r_timereport_active
Definition r_stats.c:189
@ r_stat_renders
Definition r_stats.h:11

References cl, cl_locs_show, CLVM_prog, Matrix4x4_CreateTranslate(), r_depthfirst, R_DrawBrushModelsSky(), R_DrawEntityBBoxes(), R_DrawExplosions(), R_DrawLocs(), R_DrawModelDecals(), R_DrawModels(), R_DrawModelsDebug(), R_DrawModelsDepth(), R_DrawParticles(), R_DrawPortals(), r_drawportals, R_MeshQueue_BeginScene(), R_MeshQueue_RenderTransparent(), r_refdef, R_SetupView(), R_Shadow_DrawCoronas(), R_Shadow_DrawLights(), R_Shadow_DrawPrepass(), R_Shadow_DrawShadowMaps(), R_Shadow_PrepareLights(), R_Shadow_PrepareModelShadows(), r_shadow_shadowmapatlas_modelshadows_size, R_Shadow_ShadowMappingEnabled(), r_shadow_usingdeferredprepass, r_shadow_viewcolortexture, r_shadow_viewdepthtexture, r_shadow_viewfbo, r_shadow_viewheight, r_shadow_viewwidth, r_shadow_viewx, r_shadow_viewy, r_showbboxes, r_showbboxes_client, r_showcollisionbrushes, r_shownormals, r_showoverdraw, r_showtris, R_Sky(), R_SkyStartFrame(), r_stat_renders, R_TimeReport(), r_timereport_active, r_transparent, R_UpdateFog(), r_waterscroll, r_waterscrollmatrix, sin(), skyrenderlater, skyrendermasked, and SVVM_prog.

Referenced by R_RenderView(), and R_Water_ProcessPlanes().

◆ R_RenderTarget_FreeUnused()

void R_RenderTarget_FreeUnused ( qbool force)

Definition at line 4523 of file gl_rmain.c.

4524{
4525 unsigned int i, j, end;
4526 end = (unsigned int)Mem_ExpandableArray_IndexRange(&r_fb.rendertargets); // checked
4527 for (i = 0; i < end; i++)
4528 {
4530 // free resources for rendertargets that have not been used for a while
4531 // (note: this check is run after the frame render, so any targets used
4532 // this frame will not be affected even at low framerates)
4533 if (r && (host.realtime - r->lastusetime > 0.2 || force))
4534 {
4535 if (r->fbo)
4537 for (j = 0; j < sizeof(r->colortexture) / sizeof(r->colortexture[0]); j++)
4538 if (r->colortexture[j])
4539 R_FreeTexture(r->colortexture[j]);
4540 if (r->depthtexture)
4541 R_FreeTexture(r->depthtexture);
4542 Mem_ExpandableArray_FreeRecord(&r_fb.rendertargets, r);
4543 }
4544 }
4545}
void R_Mesh_DestroyFramebufferObject(int fbo)
void R_FreeTexture(rtexture_t *rt)
host_static_t host
Definition host.c:41

References host, int(), Mem_ExpandableArray_FreeRecord(), Mem_ExpandableArray_IndexRange(), Mem_ExpandableArray_RecordAtIndex(), r, r_fb, R_FreeTexture(), and R_Mesh_DestroyFramebufferObject().

Referenced by gl_main_shutdown(), and SCR_DrawScreen().

◆ R_RenderTarget_Get()

r_rendertarget_t * R_RenderTarget_Get ( int texturewidth,
int textureheight,
textype_t depthtextype,
qbool depthisrenderbuffer,
textype_t colortextype0,
textype_t colortextype1,
textype_t colortextype2,
textype_t colortextype3 )

Definition at line 4564 of file gl_rmain.c.

4565{
4566 unsigned int i, j, end;
4568 char vabuf[256];
4569 // first try to reuse an existing slot if possible
4570 end = (unsigned int)Mem_ExpandableArray_IndexRange(&r_fb.rendertargets); // checked
4571 for (i = 0; i < end; i++)
4572 {
4574 if (r && r->lastusetime != host.realtime && r->texturewidth == texturewidth && r->textureheight == textureheight && r->depthtextype == depthtextype && r->colortextype[0] == colortextype0 && r->colortextype[1] == colortextype1 && r->colortextype[2] == colortextype2 && r->colortextype[3] == colortextype3)
4575 break;
4576 }
4577 if (i == end)
4578 {
4579 // no unused exact match found, so we have to make one in the first unused slot
4581 r->texturewidth = texturewidth;
4582 r->textureheight = textureheight;
4583 r->colortextype[0] = colortextype0;
4584 r->colortextype[1] = colortextype1;
4585 r->colortextype[2] = colortextype2;
4586 r->colortextype[3] = colortextype3;
4587 r->depthtextype = depthtextype;
4588 r->depthisrenderbuffer = depthisrenderbuffer;
4589 for (j = 0; j < 4; j++)
4590 if (r->colortextype[j])
4591 r->colortexture[j] = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "rendertarget%i_%i_type%i", i, j, (int)r->colortextype[j]), r->texturewidth, r->textureheight, NULL, r->colortextype[j], TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
4592 if (r->depthtextype)
4593 {
4594 if (r->depthisrenderbuffer)
4595 r->depthtexture = R_LoadTextureRenderBuffer(r_main_texturepool, va(vabuf, sizeof(vabuf), "renderbuffer%i_depth_type%i", i, (int)r->depthtextype), r->texturewidth, r->textureheight, r->depthtextype);
4596 else
4597 r->depthtexture = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "rendertarget%i_depth_type%i", i, (int)r->depthtextype), r->texturewidth, r->textureheight, NULL, r->depthtextype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
4598 }
4599 r->fbo = R_Mesh_CreateFramebufferObject(r->depthtexture, r->colortexture[0], r->colortexture[1], r->colortexture[2], r->colortexture[3]);
4600 }
4602 r_refdef.stats[r_stat_rendertargets_pixels] += r->texturewidth * r->textureheight;
4603 r->lastusetime = host.realtime;
4604 R_CalcTexCoordsForView(0, 0, r->texturewidth, r->textureheight, r->texturewidth, r->textureheight, r->texcoord2f);
4605 return r;
4606}
rtexturepool_t * r_main_texturepool
Definition gl_rmain.c:43
char * va(char *buf, size_t buflen, const char *format,...)
Definition common.c:972
int R_Mesh_CreateFramebufferObject(rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4)
Definition gl_backend.c:960
static void R_CalcTexCoordsForView(float x, float y, float w, float h, float tw, float th, float *texcoord2f)
Definition gl_rmain.c:4547
rtexture_t * R_LoadTextureRenderBuffer(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, textype_t textype)
rtexture_t * R_LoadTexture2D(rtexturepool_t *rtexturepool, const char *identifier, int width, int height, const unsigned char *data, textype_t textype, int flags, int miplevel, const unsigned int *palette)
@ r_stat_rendertargets_used
Definition r_stats.h:45
@ r_stat_rendertargets_pixels
Definition r_stats.h:46
#define TEXF_FORCELINEAR
Definition r_textures.h:19
#define TEXF_CLAMP
Definition r_textures.h:15
#define TEXF_RENDERTARGET
Definition r_textures.h:37
void * Mem_ExpandableArray_AllocRecord(memexpandablearray_t *l)
Definition zone.c:695

References host, int(), Mem_ExpandableArray_AllocRecord(), Mem_ExpandableArray_IndexRange(), Mem_ExpandableArray_RecordAtIndex(), NULL, r, R_CalcTexCoordsForView(), r_fb, R_LoadTexture2D(), R_LoadTextureRenderBuffer(), r_main_texturepool, R_Mesh_CreateFramebufferObject(), r_refdef, r_stat_rendertargets_pixels, r_stat_rendertargets_used, TEXF_CLAMP, TEXF_FORCELINEAR, TEXF_RENDERTARGET, and va().

Referenced by R_Bloom_MakeTexture(), R_Bloom_StartFrame(), R_Envmap_f(), and R_Water_ProcessPlanes().

◆ R_RenderView()

void R_RenderView ( int fbo,
rtexture_t * depthtexture,
rtexture_t * colortexture,
int x,
int y,
int width,
int height )

Definition at line 5637 of file gl_rmain.c.

5638{
5639 matrix4x4_t originalmatrix = r_refdef.view.matrix, offsetmatrix;
5640 int viewfbo = 0;
5641 rtexture_t *viewdepthtexture = NULL;
5642 rtexture_t *viewcolortexture = NULL;
5643 int viewx = r_refdef.view.x, viewy = r_refdef.view.y, viewwidth = r_refdef.view.width, viewheight = r_refdef.view.height;
5644 qbool skipblend;
5645
5646 // finish any 2D rendering that was queued
5647 DrawQ_Finish();
5648
5650 R_TimeReport("start");
5651 r_textureframe++; // used only by R_GetCurrentTexture
5652 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
5653
5656
5657 if (!r_drawentities.integer)
5658 r_refdef.scene.numentities = 0;
5659 else if (r_sortentities.integer)
5661
5663
5664 /* adjust for stereo display */
5665 if(R_Stereo_Active())
5666 {
5667 Matrix4x4_CreateFromQuakeEntity(&offsetmatrix, 0, r_stereo_separation.value * (0.5f - r_stereo_side), 0, 0, r_stereo_angle.value * (0.5f - r_stereo_side), 0, 1);
5668 Matrix4x4_Concat(&r_refdef.view.matrix, &originalmatrix, &offsetmatrix);
5669 }
5670
5671 if (r_refdef.view.isoverlay)
5672 {
5673 // TODO: FIXME: move this into its own backend function maybe? [2/5/2008 Andreas]
5676 R_TimeReport("depthclear");
5677
5678 r_refdef.view.showdebug = false;
5679
5680 r_fb.water.enabled = false;
5681 r_fb.water.numwaterplanes = 0;
5682
5683 R_RenderScene(0, NULL, NULL, r_refdef.view.x, r_refdef.view.y, r_refdef.view.width, r_refdef.view.height);
5684
5685 r_refdef.view.matrix = originalmatrix;
5686
5688 return;
5689 }
5690
5691 if (!r_refdef.scene.entities || r_refdef.view.width * r_refdef.view.height == 0 || !r_renderview.integer || cl_videoplaying/* || !r_refdef.scene.worldmodel*/)
5692 {
5693 r_refdef.view.matrix = originalmatrix;
5694 return;
5695 }
5696
5697 r_refdef.view.usevieworiginculling = !r_trippy.value && r_refdef.view.useperspective;
5698 if (v_isometric.integer && r_refdef.view.ismain)
5700
5701 r_refdef.view.colorscale = r_hdr_scenebrightness.value * r_hdr_irisadaptation_value.value;
5702
5703 if(vid_sRGB.integer && vid_sRGB_fallback.integer && !vid.sRGB3D)
5704 // in sRGB fallback, behave similar to true sRGB: convert this
5705 // value from linear to sRGB
5706 r_refdef.view.colorscale = Image_sRGBFloatFromLinearFloat(r_refdef.view.colorscale);
5707
5709
5711
5712 // this will set up r_fb.rt_screen
5714
5715 // apply bloom brightness offset
5716 if(r_fb.rt_bloom)
5717 r_refdef.view.colorscale *= r_bloom_scenebrightness.value;
5718
5719 skipblend = R_BlendView_IsTrivial(r_fb.rt_screen->texturewidth, r_fb.rt_screen->textureheight, width, height);
5720 if (skipblend)
5721 {
5722 // Render to the screen right away.
5723 viewfbo = fbo;
5724 viewdepthtexture = depthtexture;
5725 viewcolortexture = colortexture;
5726 viewx = x;
5727 viewy = y;
5728 viewwidth = width;
5729 viewheight = height;
5730 }
5731 else if (r_fb.rt_screen)
5732 {
5733 // R_Bloom_StartFrame probably set up an fbo for us to render into, it will be rendered to the window later in R_BlendView
5734 viewfbo = r_fb.rt_screen->fbo;
5735 viewdepthtexture = r_fb.rt_screen->depthtexture;
5736 viewcolortexture = r_fb.rt_screen->colortexture[0];
5737 viewx = 0;
5738 viewy = 0;
5739 viewwidth = r_fb.rt_screen->texturewidth;
5740 viewheight = r_fb.rt_screen->textureheight;
5741 }
5742
5743 R_Water_StartFrame(viewwidth, viewheight);
5744
5747 R_TimeReport("viewsetup");
5748
5749 R_ResetViewRendering3D(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5750
5751 // clear the whole fbo every frame - otherwise the driver will consider
5752 // it to be an inter-frame texture and stall in multi-gpu configurations
5753 if (r_fb.rt_screen)
5754 GL_ScissorTest(false);
5755 R_ClearScreen(r_refdef.fogenabled);
5757 R_TimeReport("viewclear");
5758
5759 r_refdef.view.clear = true;
5760
5761 r_refdef.view.showdebug = true;
5762
5765 R_TimeReport("visibility");
5766
5769 R_TimeReport("animcache");
5770
5772 // R_Shadow_UpdateBounceGridTexture called R_TimeReport a few times internally, so we don't need to do that here.
5773
5774 r_fb.water.numwaterplanes = 0;
5775 if (r_fb.water.enabled)
5776 R_RenderWaterPlanes(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5777
5778 // for the actual view render we use scissoring a fair amount, so scissor
5779 // test needs to be on
5780 if (r_fb.rt_screen)
5781 GL_ScissorTest(true);
5782 GL_Scissor(r_refdef.view.viewport.x, r_refdef.view.viewport.y, r_refdef.view.viewport.width, r_refdef.view.viewport.height);
5783 R_RenderScene(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5784 r_fb.water.numwaterplanes = 0;
5785
5786 // postprocess uses textures that are not aligned with the viewport we're rendering, so no scissoring
5787 GL_ScissorTest(false);
5788
5789 R_MotionBlurView(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5790 if (!skipblend)
5791 R_BlendView(viewcolortexture, fbo, depthtexture, colortexture, x, y, width, height);
5793 R_TimeReport("blendview");
5794
5795 r_refdef.view.matrix = originalmatrix;
5796
5798
5799 // go back to 2d rendering
5800 DrawQ_Start();
5801}
int r_stereo_side
Definition cl_screen.c:1553
cvar_t r_stereo_angle
Definition cl_screen.c:87
void R_ClearScreen(qbool fogcolor)
Definition cl_screen.c:1534
qbool R_Stereo_Active(void)
Definition cl_screen.c:2077
cvar_t r_stereo_separation
Definition cl_screen.c:80
cvar_t v_isometric
Definition view.c:97
int cl_videoplaying
Definition cl_video.c:458
cmd_state_t * cmd_local
command interpreter for local commands injected by SVQC, CSQC, MQC, server or client engine code uses...
Definition cmd.c:25
void DrawQ_Start(void)
Definition gl_draw.c:789
void DrawQ_Finish(void)
Definition gl_draw.c:1456
void GL_Clear(int mask, const float *colorvalue, float depthvalue, int stencilvalue)
void R_Mesh_SetRenderTargets(int fbo)
void GL_Scissor(int x, int y, int width, int height)
void GL_ScissorTest(int state)
static void R_BlendView(rtexture_t *viewcolortexture, int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int x, int y, int width, int height)
Definition gl_rmain.c:5317
static void R_SortEntities(void)
Definition gl_rmain.c:5620
void R_RenderScene(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:5830
void R_RenderWaterPlanes(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:5803
void R_ResetViewRendering3D(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:4482
static qbool R_BlendView_IsTrivial(int viewwidth, int viewheight, int width, int height)
Definition gl_rmain.c:5224
static void R_Bloom_StartFrame(void)
Definition gl_rmain.c:5019
void V_MakeViewIsometric(void)
Definition view.c:968
static void R_MotionBlurView(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:5251
static void R_View_Update(const int *myscissor)
Definition gl_rmain.c:4374
qbool R_CompileShader_CheckStaticParms(void)
Definition gl_rmain.c:861
void R_AnimCache_ClearCache(void)
clear the animcache pointers on all known render entities
Definition gl_rmain.c:3762
static void R_Water_StartFrame(int viewwidth, int viewheight)
Definition gl_rmain.c:4608
void R_AnimCache_CacheVisibleEntities(void)
generate animcache data for all entities marked visible
Definition gl_rmain.c:3874
GLenum GLsizei GLsizei height
Definition glquake.h:622
#define CHECKGLERROR
Definition glquake.h:1059
#define GL_DEPTH_BUFFER_BIT
Definition glquake.h:169
#define Image_sRGBFloatFromLinearFloat(c)
Definition image.h:68
void Matrix4x4_Concat(matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2)
Definition matrixlib.c:83
void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, double x, double y, double z, double pitch, double yaw, double roll, double scale)
Definition matrixlib.c:715
void R_Shadow_UpdateBounceGridTexture(void)
Definition r_shadow.c:2755
void R_Shadow_UpdateWorldLightSelection(void)
Definition r_shadow.c:5289

References CHECKGLERROR, cl_videoplaying, cmd_local, DrawQ_Finish(), DrawQ_Start(), GL_Clear(), GL_DEPTH_BUFFER_BIT, GL_Scissor(), GL_ScissorTest(), height, Image_sRGBFloatFromLinearFloat, Matrix4x4_Concat(), Matrix4x4_CreateFromQuakeEntity(), NULL, R_AnimCache_CacheVisibleEntities(), R_AnimCache_ClearCache(), R_BlendView(), R_BlendView_IsTrivial(), r_bloom_scenebrightness, R_Bloom_StartFrame(), R_ClearScreen(), R_CompileShader_CheckStaticParms(), r_drawentities, r_fb, R_GLSL_Restart_f(), r_hdr_irisadaptation_value, r_hdr_scenebrightness, R_Mesh_SetRenderTargets(), R_MotionBlurView(), r_refdef, R_RenderScene(), r_renderview, R_RenderView_UpdateViewVectors(), R_RenderWaterPlanes(), R_ResetViewRendering3D(), R_Shadow_UpdateBounceGridTexture(), R_Shadow_UpdateWorldLightSelection(), R_SortEntities(), r_sortentities, R_Stereo_Active(), r_stereo_angle, r_stereo_separation, r_stereo_side, r_textureframe, R_TimeReport(), r_timereport_active, r_trippy, R_View_Update(), R_Water_StartFrame(), rsurface, v_isometric, V_MakeViewIsometric(), vid, vid_sRGB, vid_sRGB_fallback, width, x, and y.

Referenced by R_Envmap_f(), SCR_DrawScreen(), and VM_CL_R_RenderScene().

◆ R_RenderView_UpdateViewVectors()

void R_RenderView_UpdateViewVectors ( void )

Definition at line 4512 of file gl_rmain.c.

4513{
4514 // break apart the view matrix into vectors for various purposes
4515 // it is important that this occurs outside the RenderScene function because that can be called from reflection renders, where the vectors come out wrong
4516 // however the r_refdef.view.origin IS updated in RenderScene intentionally - otherwise the sky renders at the wrong origin, etc
4517 Matrix4x4_ToVectors(&r_refdef.view.matrix, r_refdef.view.forward, r_refdef.view.left, r_refdef.view.up, r_refdef.view.origin);
4518 VectorNegate(r_refdef.view.left, r_refdef.view.right);
4519 // make an inverted copy of the view matrix for tracking sprites
4520 Matrix4x4_Invert_Full(&r_refdef.view.inverse_matrix, &r_refdef.view.matrix);
4521}
#define VectorNegate(a, b)
Definition mathlib.h:95
int Matrix4x4_Invert_Full(matrix4x4_t *out, const matrix4x4_t *in1)
Definition matrixlib.c:145
void Matrix4x4_ToVectors(const matrix4x4_t *in, float vx[3], float vy[3], float vz[3], float t[3])
Definition matrixlib.c:939

References Matrix4x4_Invert_Full(), Matrix4x4_ToVectors(), r_refdef, and VectorNegate.

Referenced by CL_VM_UpdateView(), R_RenderView(), and R_Water_ProcessPlanes().

◆ R_RenderWaterPlanes()

void R_RenderWaterPlanes ( int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )

Definition at line 5803 of file gl_rmain.c.

5804{
5805 if (cl.csqc_vidvars.drawworld && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawAddWaterPlanes)
5806 {
5807 r_refdef.scene.worldmodel->DrawAddWaterPlanes(r_refdef.scene.worldentity);
5809 R_TimeReport("waterworld");
5810 }
5811
5814 R_TimeReport("watermodels");
5815
5816 if (r_fb.water.numwaterplanes)
5817 {
5818 R_Water_ProcessPlanes(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
5820 R_TimeReport("waterscenes");
5821 }
5822}
static void R_DrawModelsAddWaterPlanes(void)
Definition gl_rmain.c:4127
static void R_Water_ProcessPlanes(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, int viewx, int viewy, int viewwidth, int viewheight)
Definition gl_rmain.c:4757

References cl, R_DrawModelsAddWaterPlanes(), r_fb, r_refdef, R_TimeReport(), r_timereport_active, and R_Water_ProcessPlanes().

Referenced by R_RenderView().

◆ R_ResetSkyBox()

void R_ResetSkyBox ( void )

Definition at line 440 of file r_sky.c.

441{
443 memset(skyname,0,MAX_QPATH);
444 R_LoadSkyBox();
445}
static char skyname[MAX_QPATH]
Definition r_sky.c:17
static void R_UnloadSkyBox(void)
Definition r_sky.c:81
static int R_LoadSkyBox(void)
Definition r_sky.c:98

References MAX_QPATH, R_LoadSkyBox(), R_UnloadSkyBox(), and skyname.

Referenced by CL_ClearState().

◆ R_ResetViewRendering2D()

void R_ResetViewRendering2D ( int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )

Definition at line 4477 of file gl_rmain.c.

4478{
4479 R_ResetViewRendering2D_Common(viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight, 1.0f, 1.0f);
4480}
void R_ResetViewRendering2D_Common(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight, float x2, float y2)
Definition gl_rmain.c:4439

References R_ResetViewRendering2D_Common().

Referenced by R_BlendView(), and R_MotionBlurView().

◆ R_ResetViewRendering2D_Common()

void R_ResetViewRendering2D_Common ( int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight,
float x2,
float y2 )

Definition at line 4439 of file gl_rmain.c.

4440{
4441 r_viewport_t viewport;
4442 int viewy_adjusted;
4443
4445
4446 // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom.
4447 // Unless the render target is a FBO...
4448 viewy_adjusted = viewfbo ? viewy : vid.mode.height - viewheight - viewy;
4449
4450 R_Viewport_InitOrtho(&viewport, &identitymatrix, viewx, viewy_adjusted, viewwidth, viewheight, 0, 0, x2, y2, -10, 100, NULL);
4451 R_Mesh_SetRenderTargets(viewfbo);
4452 R_SetViewport(&viewport);
4453 GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
4454 GL_Color(1, 1, 1, 1);
4455 GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
4457 GL_ScissorTest(false);
4458 GL_DepthMask(false);
4459 GL_DepthRange(0, 1);
4460 GL_DepthTest(false);
4464 GL_PolygonOffset(0, 0);
4465 switch(vid.renderpath)
4466 {
4467 case RENDERPATH_GL32:
4468 case RENDERPATH_GLES2:
4470 break;
4471 }
4473
4475}
void GL_CullFace(int state)
void GL_ColorMask(int r, int g, int b, int a)
void GL_DepthMask(int state)
void GL_DepthFunc(int state)
void GL_DepthTest(int state)
void GL_DepthRange(float nearfrac, float farfrac)
void GL_PolygonOffset(float planeoffset, float depthoffset)
void R_SetViewport(const r_viewport_t *v)
Definition gl_backend.c:897
void R_Viewport_InitOrtho(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float x1, float y1, float x2, float y2, float nearclip, float farclip, const float *nearplane)
Definition gl_backend.c:587
void R_Mesh_ResetTextureState(void)
void GL_Color(float cr, float cg, float cb, float ca)
void GL_BlendFunc(int blendfunc1, int blendfunc2)
void R_EntityMatrix(const matrix4x4_t *matrix)
Definition gl_rmain.c:4417
#define GL_NONE
Definition glquake.h:127
#define GL_POLYGON_OFFSET_FILL
Definition glquake.h:183
#define GL_LEQUAL
Definition glquake.h:162
const matrix4x4_t identitymatrix
Definition matrixlib.c:9

References CHECKGLERROR, GL_BlendFunc(), GL_Color(), GL_ColorMask(), GL_CullFace(), GL_DepthFunc(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_LEQUAL, GL_NONE, GL_ONE, GL_POLYGON_OFFSET_FILL, GL_PolygonOffset(), GL_Scissor(), GL_ScissorTest(), GL_ZERO, r_viewport_t::height, identitymatrix, NULL, R_EntityMatrix(), R_Mesh_ResetTextureState(), R_Mesh_SetRenderTargets(), r_refdef, R_SetViewport(), R_Viewport_InitOrtho(), RENDERPATH_GL32, RENDERPATH_GLES2, vid, r_viewport_t::width, r_viewport_t::x, x2, r_viewport_t::y, and y2.

Referenced by DrawQ_Start(), and R_ResetViewRendering2D().

◆ R_ResetViewRendering3D()

void R_ResetViewRendering3D ( int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )

Definition at line 4482 of file gl_rmain.c.

4483{
4484 R_SetupView(true, viewfbo, viewdepthtexture, viewcolortexture, viewx, viewy, viewwidth, viewheight);
4485 GL_Scissor(r_refdef.view.viewport.x, r_refdef.view.viewport.y, r_refdef.view.viewport.width, r_refdef.view.viewport.height);
4486 GL_Color(1, 1, 1, 1);
4487 GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
4489 GL_ScissorTest(true);
4490 GL_DepthMask(true);
4491 GL_DepthRange(0, 1);
4492 GL_DepthTest(true);
4496 GL_PolygonOffset(r_refdef.polygonfactor, r_refdef.polygonoffset);
4497 switch(vid.renderpath)
4498 {
4499 case RENDERPATH_GL32:
4500 case RENDERPATH_GLES2:
4502 break;
4503 }
4504 GL_CullFace(r_refdef.view.cullface_back);
4505}

References CHECKGLERROR, GL_BlendFunc(), GL_Color(), GL_ColorMask(), GL_CullFace(), GL_DepthFunc(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_LEQUAL, GL_ONE, GL_POLYGON_OFFSET_FILL, GL_PolygonOffset(), GL_Scissor(), GL_ScissorTest(), GL_ZERO, identitymatrix, R_EntityMatrix(), R_Mesh_ResetTextureState(), r_refdef, R_SetupView(), RENDERPATH_GL32, RENDERPATH_GLES2, and vid.

Referenced by R_RenderView(), and R_Water_ProcessPlanes().

◆ R_SelectScene()

void R_SelectScene ( r_refdef_scene_type_t scenetype)

Definition at line 5573 of file gl_rmain.c.

5573 {
5574 if( scenetype != r_currentscenetype ) {
5575 // store the old scenetype
5577 r_currentscenetype = scenetype;
5578 // move in the new scene
5580 }
5581}

References r_currentscenetype, r_refdef, and r_scenes_store.

Referenced by MP_Draw(), and MVM_error_cmd().

◆ R_SetSkyBox()

int R_SetSkyBox ( const char * sky)

Definition at line 149 of file r_sky.c.

150{
151 if (strcmp(sky, skyname) == 0) // no change
152 return true;
153
154 if (strlen(sky) > 1000)
155 {
156 Con_Printf("sky name too long (%i, max is 1000)\n", (int)strlen(sky));
157 return false;
158 }
159
160 dp_strlcpy(skyname, sky, sizeof(skyname));
161
162 return R_LoadSkyBox();
163}
float strlen(string s)

References Con_Printf(), dp_strlcpy, R_LoadSkyBox(), skyname, and strlen().

Referenced by CL_ParseEntityLump(), CL_ParseServerMessage(), and LoadSky_f().

◆ R_SetupShader_DeferredLight()

void R_SetupShader_DeferredLight ( const rtlight_t * rtlight)

Definition at line 2091 of file gl_rmain.c.

2092{
2093 // select a permutation of the lighting shader appropriate to this
2094 // combination of texture, entity, light source, and fogging, only use the
2095 // minimum features necessary to avoid wasting rendering time in the
2096 // fragment shader on features that are not being used
2097 uint64_t permutation = 0;
2098 unsigned int mode = 0;
2099 const float *lightcolorbase = rtlight->currentcolor;
2100 float ambientscale = rtlight->ambientscale;
2101 float diffusescale = rtlight->diffusescale;
2102 float specularscale = rtlight->specularscale;
2103 // this is the location of the light in view space
2104 vec3_t viewlightorigin;
2105 // this transforms from view space (camera) to light space (cubemap)
2106 matrix4x4_t viewtolight;
2107 matrix4x4_t lighttoview;
2108 float viewtolight16f[16];
2109 // light source
2111 if (rtlight->currentcubemap != r_texture_whitecube)
2112 permutation |= SHADERPERMUTATION_CUBEFILTER;
2113 if (diffusescale > 0)
2114 permutation |= SHADERPERMUTATION_DIFFUSE;
2115 if (specularscale > 0 && r_shadow_gloss.integer > 0)
2118 {
2119 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
2121 permutation |= SHADERPERMUTATION_SHADOWMAPVSDCT;
2122
2124 permutation |= SHADERPERMUTATION_DEPTHRGB;
2125 }
2126 if (vid.allowalphatocoverage)
2127 GL_AlphaToCoverage(false);
2128 Matrix4x4_Transform(&r_refdef.view.viewport.viewmatrix, rtlight->shadoworigin, viewlightorigin);
2129 Matrix4x4_Concat(&lighttoview, &r_refdef.view.viewport.viewmatrix, &rtlight->matrix_lighttoworld);
2130 Matrix4x4_Invert_Full(&viewtolight, &lighttoview);
2131 Matrix4x4_ToArrayFloatGL(&viewtolight, viewtolight16f);
2132 switch(vid.renderpath)
2133 {
2134 case RENDERPATH_GL32:
2135 case RENDERPATH_GLES2:
2137 if (r_glsl_permutation->loc_LightPosition >= 0) qglUniform3f( r_glsl_permutation->loc_LightPosition , viewlightorigin[0], viewlightorigin[1], viewlightorigin[2]);
2138 if (r_glsl_permutation->loc_ViewToLight >= 0) qglUniformMatrix4fv(r_glsl_permutation->loc_ViewToLight , 1, false, viewtolight16f);
2139 if (r_glsl_permutation->loc_DeferredColor_Ambient >= 0) qglUniform3f( r_glsl_permutation->loc_DeferredColor_Ambient , lightcolorbase[0] * ambientscale , lightcolorbase[1] * ambientscale , lightcolorbase[2] * ambientscale );
2140 if (r_glsl_permutation->loc_DeferredColor_Diffuse >= 0) qglUniform3f( r_glsl_permutation->loc_DeferredColor_Diffuse , lightcolorbase[0] * diffusescale , lightcolorbase[1] * diffusescale , lightcolorbase[2] * diffusescale );
2141 if (r_glsl_permutation->loc_DeferredColor_Specular >= 0) qglUniform3f( r_glsl_permutation->loc_DeferredColor_Specular , lightcolorbase[0] * specularscale, lightcolorbase[1] * specularscale, lightcolorbase[2] * specularscale);
2144 if (r_glsl_permutation->loc_SpecularPower >= 0) qglUniform1f( r_glsl_permutation->loc_SpecularPower , (r_shadow_gloss.integer == 2 ? r_shadow_gloss2exponent.value : r_shadow_glossexponent.value) * (r_shadow_glossexact.integer ? 0.25f : 1.0f) - 1.0f);
2145 if (r_glsl_permutation->loc_ScreenToDepth >= 0) qglUniform2f( r_glsl_permutation->loc_ScreenToDepth , r_refdef.view.viewport.screentodepth[0], r_refdef.view.viewport.screentodepth[1]);
2146 if (r_glsl_permutation->loc_PixelToScreenTexCoord >= 0) qglUniform2f( r_glsl_permutation->loc_PixelToScreenTexCoord , 1.0f/r_fb.screentexturewidth, 1.0f/r_fb.screentextureheight);
2147
2148 if (r_glsl_permutation->tex_Texture_Attenuation >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Attenuation , r_shadow_attenuationgradienttexture );
2149 if (r_glsl_permutation->tex_Texture_ScreenNormalMap >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ScreenNormalMap , r_shadow_prepassgeometrynormalmaptexture );
2150 if (r_glsl_permutation->tex_Texture_Cube >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Cube , rsurface.rtlight->currentcubemap );
2151 if (r_glsl_permutation->tex_Texture_ShadowMap2D >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ShadowMap2D , r_shadow_shadowmap2ddepthtexture );
2152 if (r_glsl_permutation->tex_Texture_CubeProjection >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_CubeProjection , r_shadow_shadowmapvsdcttexture );
2153 break;
2154 }
2155}
void R_Mesh_TexBind(unsigned int unitnum, rtexture_t *tex)
void GL_AlphaToCoverage(qbool state)
static void R_SetupShader_SetPermutationGLSL(unsigned int mode, uint64_t permutation)
Definition gl_rmain.c:1346
GLenum mode
Definition glquake.h:718
void Matrix4x4_Transform(const matrix4x4_t *in, const float v[3], float out[3])
Definition matrixlib.c:1657
void Matrix4x4_ToArrayFloatGL(const matrix4x4_t *in, float out[16])
Definition matrixlib.c:1165
rtexture_t * r_shadow_prepassgeometrynormalmaptexture
Definition r_shadow.c:120
qbool r_shadow_shadowmapvsdct
Definition r_shadow.c:57
rtexture_t * r_shadow_attenuationgradienttexture
Definition r_shadow.c:108
float r_shadow_lightshadowmap_parameters[4]
Definition r_shadow.c:41
qbool r_shadow_usingshadowmap2d
Definition r_shadow.c:37
float r_shadow_lightshadowmap_texturescale[4]
Definition r_shadow.c:40
rtexture_t * r_shadow_shadowmapvsdcttexture
Definition r_shadow.c:112
rtexture_t * r_shadow_shadowmap2ddepthtexture
Definition r_shadow.c:111
rtexture_t * r_shadow_shadowmap2ddepthbuffer
Definition r_shadow.c:110
#define SHADERPERMUTATION_SPECULAR
(lightsource or deluxemapping) render specular effects
Definition render.h:86
#define SHADERPERMUTATION_DEPTHRGB
read/write depth values in RGB color coded format for older hardware without depth samplers
Definition render.h:101
#define SHADERPERMUTATION_SHADOWMAPVSDCT
(lightsource) use virtual shadow depth cube texture for shadowmap indexing
Definition render.h:92
#define SHADERPERMUTATION_SHADOWMAP2D
(lightsource) use shadowmap texture as light filter
Definition render.h:91
#define SHADERPERMUTATION_CUBEFILTER
(lightsource) use cubemap light filter
Definition render.h:83
#define SHADERPERMUTATION_DIFFUSE
(lightsource) whether to use directional shading
Definition render.h:73
vec_t ambientscale
ambient intensity to render
Definition client.h:128
rtexture_t * currentcubemap
this is R_GetCubemap(rtlight->cubemapname)
Definition client.h:153
vec3_t currentcolor
Definition client.h:147
vec_t specularscale
specular intensity to render
Definition client.h:132
vec3_t shadoworigin
used only for casting shadows
Definition client.h:138
matrix4x4_t matrix_lighttoworld
matrix for transforming light filter coordinates to world coordinates
Definition client.h:110
vec_t diffusescale
diffuse intensity to render
Definition client.h:130

References rtlight_t::ambientscale, rtlight_t::currentcolor, rtlight_t::currentcubemap, rtlight_t::diffusescale, GL_AlphaToCoverage(), Matrix4x4_Concat(), Matrix4x4_Invert_Full(), Matrix4x4_ToArrayFloatGL(), Matrix4x4_Transform(), rtlight_t::matrix_lighttoworld, mode, r_fb, r_glsl_permutation, R_Mesh_TexBind(), r_refdef, R_SetupShader_SetPermutationGLSL(), r_shadow_attenuationgradienttexture, r_shadow_gloss, r_shadow_gloss2exponent, r_shadow_glossexact, r_shadow_glossexponent, r_shadow_lightshadowmap_parameters, r_shadow_lightshadowmap_texturescale, r_shadow_prepassgeometrynormalmaptexture, r_shadow_shadowmap2ddepthbuffer, r_shadow_shadowmap2ddepthtexture, r_shadow_shadowmapvsdct, r_shadow_shadowmapvsdcttexture, r_shadow_usingshadowmap2d, r_texture_whitecube, RENDERPATH_GL32, RENDERPATH_GLES2, rsurface, SHADERMODE_DEFERREDLIGHTSOURCE, SHADERPERMUTATION_CUBEFILTER, SHADERPERMUTATION_DEPTHRGB, SHADERPERMUTATION_DIFFUSE, SHADERPERMUTATION_SHADOWMAP2D, SHADERPERMUTATION_SHADOWMAPVSDCT, SHADERPERMUTATION_SPECULAR, rtlight_t::shadoworigin, rtlight_t::specularscale, and vid.

Referenced by R_Shadow_RenderMode_DrawDeferredLight().

◆ R_SetupShader_DepthOrShadow()

void R_SetupShader_DepthOrShadow ( qbool notrippy,
qbool depthrgb,
qbool skeletal )

Definition at line 1493 of file gl_rmain.c.

1494{
1495 uint64_t permutation = 0;
1496 if (r_trippy.integer && !notrippy)
1497 permutation |= SHADERPERMUTATION_TRIPPY;
1498 if (depthrgb)
1499 permutation |= SHADERPERMUTATION_DEPTHRGB;
1500 if (skeletal)
1501 permutation |= SHADERPERMUTATION_SKELETAL;
1502
1503 if (vid.allowalphatocoverage)
1504 GL_AlphaToCoverage(false);
1505 switch (vid.renderpath)
1506 {
1507 case RENDERPATH_GL32:
1508 case RENDERPATH_GLES2:
1510#ifndef USE_GLES2 /* FIXME: GLES3 only */
1511 if (r_glsl_permutation->ubiloc_Skeletal_Transform12_UniformBlock >= 0 && rsurface.batchskeletaltransform3x4buffer) qglBindBufferRange(GL_UNIFORM_BUFFER, r_glsl_permutation->ubibind_Skeletal_Transform12_UniformBlock, rsurface.batchskeletaltransform3x4buffer->bufferobject, rsurface.batchskeletaltransform3x4offset, rsurface.batchskeletaltransform3x4size);
1512#endif
1513 break;
1514 }
1515}
#define GL_UNIFORM_BUFFER
Definition glquake.h:413
#define SHADERPERMUTATION_SKELETAL
(skeletal models) use skeletal matrices to deform vertices (gpu-skinning)
Definition render.h:103
#define SHADERPERMUTATION_TRIPPY
use trippy vertex shader effect
Definition render.h:100

References GL_AlphaToCoverage(), GL_UNIFORM_BUFFER, r_glsl_permutation, R_SetupShader_SetPermutationGLSL(), r_trippy, RENDERPATH_GL32, RENDERPATH_GLES2, rsurface, SHADERMODE_DEPTH_OR_SHADOW, SHADERPERMUTATION_DEPTHRGB, SHADERPERMUTATION_SKELETAL, SHADERPERMUTATION_TRIPPY, and vid.

Referenced by R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_Sky(), R_Shadow_ClearShadowMapTexture(), and R_Shadow_RenderMode_ShadowMap().

◆ R_SetupShader_Generic()

void R_SetupShader_Generic ( rtexture_t * t,
qbool usegamma,
qbool notrippy,
qbool suppresstexalpha )

Definition at line 1461 of file gl_rmain.c.

1462{
1463 uint64_t permutation = 0;
1464 if (r_trippy.integer && !notrippy)
1465 permutation |= SHADERPERMUTATION_TRIPPY;
1466 permutation |= SHADERPERMUTATION_VIEWTINT;
1467 if (t)
1468 permutation |= SHADERPERMUTATION_DIFFUSE;
1469 if (usegamma && v_glslgamma_2d.integer && !vid.sRGB2D && r_texture_gammaramps && !vid_gammatables_trivial)
1470 permutation |= SHADERPERMUTATION_GAMMARAMPS;
1471 if (suppresstexalpha)
1472 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1473 if (vid.allowalphatocoverage)
1474 GL_AlphaToCoverage(false);
1475 switch (vid.renderpath)
1476 {
1477 case RENDERPATH_GL32:
1478 case RENDERPATH_GLES2:
1480 if (r_glsl_permutation->tex_Texture_First >= 0)
1481 R_Mesh_TexBind(r_glsl_permutation->tex_Texture_First, t);
1482 if (r_glsl_permutation->tex_Texture_GammaRamps >= 0)
1483 R_Mesh_TexBind(r_glsl_permutation->tex_Texture_GammaRamps, r_texture_gammaramps);
1484 break;
1485 }
1486}
cvar_t v_glslgamma_2d
Definition vid_shared.c:186
rtexture_t * r_texture_gammaramps
Definition gl_rmain.c:281
#define SHADERPERMUTATION_VIEWTINT
view tint (postprocessing only), use vertex colors (generic only)
Definition render.h:75
#define SHADERPERMUTATION_REFLECTCUBE
fake reflections using global cubemap (not HDRI light probe)
Definition render.h:96
#define SHADERPERMUTATION_GAMMARAMPS
gamma (postprocessing only)
Definition render.h:82
qbool vid_gammatables_trivial
this is set to true if all color control values are at default setting, and it therefore would make n...

References GL_AlphaToCoverage(), r_glsl_permutation, R_Mesh_TexBind(), R_SetupShader_SetPermutationGLSL(), r_texture_gammaramps, r_trippy, RENDERPATH_GL32, RENDERPATH_GLES2, SHADERMODE_GENERIC, SHADERPERMUTATION_DIFFUSE, SHADERPERMUTATION_GAMMARAMPS, SHADERPERMUTATION_REFLECTCUBE, SHADERPERMUTATION_TRIPPY, SHADERPERMUTATION_VIEWTINT, v_glslgamma_2d, vid, and vid_gammatables_trivial.

Referenced by R_Bloom_MakeTexture(), R_DrawExplosion_TransparentCallback(), R_DrawModelDecals_Entity(), R_DrawParticle_TransparentCallback(), R_MotionBlurView(), R_SetupShader_Generic_NoTexture(), and SCR_DrawLoadingScreen().

◆ R_SetupShader_Generic_NoTexture()

void R_SetupShader_Generic_NoTexture ( qbool usegamma,
qbool notrippy )

◆ R_SetupShader_Surface()

void R_SetupShader_Surface ( const float ambientcolor[3],
const float diffusecolor[3],
const float specularcolor[3],
rsurfacepass_t rsurfacepass,
int texturenumsurfaces,
const msurface_t ** texturesurfacelist,
void * waterplane,
qbool notrippy,
qbool ui )

Definition at line 1563 of file gl_rmain.c.

1564{
1565 // select a permutation of the lighting shader appropriate to this
1566 // combination of texture, entity, light source, and fogging, only use the
1567 // minimum features necessary to avoid wasting rendering time in the
1568 // fragment shader on features that are not being used
1569 uint64_t permutation = 0;
1570 unsigned int mode = 0;
1571 int blendfuncflags;
1572 texture_t *t = rsurface.texture;
1573 float m16f[16];
1574 matrix4x4_t tempmatrix;
1575 r_waterstate_waterplane_t *waterplane = (r_waterstate_waterplane_t *)surfacewaterplane;
1576 if (r_trippy.integer && !notrippy)
1577 permutation |= SHADERPERMUTATION_TRIPPY;
1579 permutation |= SHADERPERMUTATION_ALPHAKILL;
1581 permutation |= SHADERPERMUTATION_OCCLUDE;
1582 if (t->r_water_waterscroll[0] && t->r_water_waterscroll[1])
1583 permutation |= SHADERPERMUTATION_NORMALMAPSCROLLBLEND; // todo: make generic
1584 if (rsurfacepass == RSURFPASS_BACKGROUND)
1585 {
1586 // distorted background
1588 {
1591 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1593 {
1594 // this is the right thing to do for wateralpha
1596 blendfuncflags = R_BlendFuncFlags(GL_ONE, GL_ZERO);
1597 }
1598 else
1599 {
1600 // this is the right thing to do for entity alpha
1603 }
1604 }
1606 {
1609 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1612 }
1613 else
1614 {
1619 }
1620 if (vid.allowalphatocoverage)
1621 GL_AlphaToCoverage(false);
1622 }
1623 else if (rsurfacepass == RSURFPASS_DEFERREDGEOMETRY)
1624 {
1625 if (r_glsl_offsetmapping.integer && ((R_TextureFlags(t->nmaptexture) & TEXF_ALPHA) || t->offsetbias != 0.0f))
1626 {
1627 switch(t->offsetmapping)
1628 {
1629 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1632 case OFFSETMAPPING_OFF: break;
1633 }
1634 }
1637 // normalmap (deferred prepass), may use alpha test on diffuse
1640 blendfuncflags = R_BlendFuncFlags(GL_ONE, GL_ZERO);
1641 if (vid.allowalphatocoverage)
1642 GL_AlphaToCoverage(false);
1643 }
1644 else if (rsurfacepass == RSURFPASS_RTLIGHT)
1645 {
1646 if (r_glsl_offsetmapping.integer && ((R_TextureFlags(t->nmaptexture) & TEXF_ALPHA) || t->offsetbias != 0.0f))
1647 {
1648 switch(t->offsetmapping)
1649 {
1650 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1653 case OFFSETMAPPING_OFF: break;
1654 }
1655 }
1659 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1660 // light source
1662 if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
1663 permutation |= SHADERPERMUTATION_CUBEFILTER;
1664 if (VectorLength2(rtlightdiffuse) > 0)
1665 permutation |= SHADERPERMUTATION_DIFFUSE;
1666 if (VectorLength2(rtlightspecular) > 0)
1668 if (r_refdef.fogenabled)
1670 if (t->colormapping)
1671 permutation |= SHADERPERMUTATION_COLORMAPPING;
1673 {
1674 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1676 permutation |= SHADERPERMUTATION_SHADOWMAPVSDCT;
1677
1679 permutation |= SHADERPERMUTATION_DEPTHRGB;
1680 }
1681 if (t->reflectmasktexture)
1682 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1684 blendfuncflags = R_BlendFuncFlags(GL_SRC_ALPHA, GL_ONE);
1685 if (vid.allowalphatocoverage)
1686 GL_AlphaToCoverage(false);
1687 }
1689 {
1690 if (r_glsl_offsetmapping.integer && ((R_TextureFlags(t->nmaptexture) & TEXF_ALPHA) || t->offsetbias != 0.0f))
1691 {
1692 switch(t->offsetmapping)
1693 {
1694 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1697 case OFFSETMAPPING_OFF: break;
1698 }
1699 }
1703 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1704 // directional model lighting
1706 if ((t->glowtexture || t->backgroundglowtexture) && r_hdr_glowintensity.value > 0 && !gl_lightmaps.integer)
1707 permutation |= SHADERPERMUTATION_GLOW;
1708 permutation |= SHADERPERMUTATION_DIFFUSE;
1710 permutation |= SHADERPERMUTATION_SPECULAR;
1711 if (r_refdef.fogenabled)
1713 if (t->colormapping)
1714 permutation |= SHADERPERMUTATION_COLORMAPPING;
1716 {
1717 permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
1718 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1719
1721 permutation |= SHADERPERMUTATION_DEPTHRGB;
1722 }
1724 permutation |= SHADERPERMUTATION_REFLECTION;
1727 if (t->reflectmasktexture)
1728 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1729 if (r_shadow_bouncegrid_state.texture && cl.csqc_vidvars.drawworld && !notrippy)
1730 {
1731 permutation |= SHADERPERMUTATION_BOUNCEGRID;
1732 if (r_shadow_bouncegrid_state.directional)
1734 }
1736 blendfuncflags = R_BlendFuncFlags(t->currentblendfunc[0], t->currentblendfunc[1]);
1737 // when using alphatocoverage, we don't need alphakill
1738 if (vid.allowalphatocoverage)
1739 {
1741 {
1743 permutation &= ~SHADERPERMUTATION_ALPHAKILL;
1744 }
1745 else
1746 GL_AlphaToCoverage(false);
1747 }
1748 }
1750 {
1751 if (r_glsl_offsetmapping.integer && ((R_TextureFlags(t->nmaptexture) & TEXF_ALPHA) || t->offsetbias != 0.0f))
1752 {
1753 switch(t->offsetmapping)
1754 {
1755 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1758 case OFFSETMAPPING_OFF: break;
1759 }
1760 }
1764 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1765 // directional model lighting
1767 if ((t->glowtexture || t->backgroundglowtexture) && r_hdr_glowintensity.value > 0 && !gl_lightmaps.integer)
1768 permutation |= SHADERPERMUTATION_GLOW;
1770 permutation |= SHADERPERMUTATION_DIFFUSE;
1772 permutation |= SHADERPERMUTATION_SPECULAR;
1773 if (r_refdef.fogenabled)
1775 if (t->colormapping)
1776 permutation |= SHADERPERMUTATION_COLORMAPPING;
1778 {
1779 permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
1780 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1781
1783 permutation |= SHADERPERMUTATION_DEPTHRGB;
1784 }
1786 permutation |= SHADERPERMUTATION_REFLECTION;
1789 if (t->reflectmasktexture)
1790 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1791 if (r_shadow_bouncegrid_state.texture && cl.csqc_vidvars.drawworld && !notrippy)
1792 {
1793 permutation |= SHADERPERMUTATION_BOUNCEGRID;
1794 if (r_shadow_bouncegrid_state.directional)
1796 }
1798 blendfuncflags = R_BlendFuncFlags(t->currentblendfunc[0], t->currentblendfunc[1]);
1799 // when using alphatocoverage, we don't need alphakill
1800 if (vid.allowalphatocoverage)
1801 {
1803 {
1805 permutation &= ~SHADERPERMUTATION_ALPHAKILL;
1806 }
1807 else
1808 GL_AlphaToCoverage(false);
1809 }
1810 }
1811 else
1812 {
1813 if (r_glsl_offsetmapping.integer && ((R_TextureFlags(t->nmaptexture) & TEXF_ALPHA) || t->offsetbias != 0.0f))
1814 {
1815 switch(t->offsetmapping)
1816 {
1817 case OFFSETMAPPING_LINEAR: permutation |= SHADERPERMUTATION_OFFSETMAPPING;break;
1820 case OFFSETMAPPING_OFF: break;
1821 }
1822 }
1826 permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
1827 // lightmapped wall
1828 if ((t->glowtexture || t->backgroundglowtexture) && r_hdr_glowintensity.value > 0 && !gl_lightmaps.integer)
1829 permutation |= SHADERPERMUTATION_GLOW;
1830 if (r_refdef.fogenabled && !ui)
1832 if (t->colormapping)
1833 permutation |= SHADERPERMUTATION_COLORMAPPING;
1835 {
1836 permutation |= SHADERPERMUTATION_SHADOWMAPORTHO;
1837 permutation |= SHADERPERMUTATION_SHADOWMAP2D;
1838
1840 permutation |= SHADERPERMUTATION_DEPTHRGB;
1841 }
1843 permutation |= SHADERPERMUTATION_REFLECTION;
1846 if (t->reflectmasktexture)
1847 permutation |= SHADERPERMUTATION_REFLECTCUBE;
1848 if (r_glsl_deluxemapping.integer >= 1 && rsurface.uselightmaptexture && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brushq3.deluxemapping)
1849 {
1850 // deluxemapping (light direction texture)
1851 if (rsurface.uselightmaptexture && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brushq3.deluxemapping && r_refdef.scene.worldmodel->brushq3.deluxemapping_modelspace)
1853 else
1855 permutation |= SHADERPERMUTATION_DIFFUSE;
1858 }
1859 else if (r_glsl_deluxemapping.integer >= 2)
1860 {
1861 // fake deluxemapping (uniform light direction in tangentspace)
1862 if (rsurface.uselightmaptexture)
1864 else
1866 permutation |= SHADERPERMUTATION_DIFFUSE;
1869 }
1870 else if (rsurface.uselightmaptexture)
1871 {
1872 // ordinary lightmapping (q1bsp, q3bsp)
1874 }
1875 else
1876 {
1877 // ordinary vertex coloring (q3bsp)
1879 }
1880 if (r_shadow_bouncegrid_state.texture && cl.csqc_vidvars.drawworld && !notrippy)
1881 {
1882 permutation |= SHADERPERMUTATION_BOUNCEGRID;
1883 if (r_shadow_bouncegrid_state.directional)
1885 }
1887 blendfuncflags = R_BlendFuncFlags(t->currentblendfunc[0], t->currentblendfunc[1]);
1888 // when using alphatocoverage, we don't need alphakill
1889 if (vid.allowalphatocoverage)
1890 {
1892 {
1894 permutation &= ~SHADERPERMUTATION_ALPHAKILL;
1895 }
1896 else
1897 GL_AlphaToCoverage(false);
1898 }
1899 }
1900 if(!(blendfuncflags & BLENDFUNC_ALLOWS_ANYFOG))
1902 if(blendfuncflags & BLENDFUNC_ALLOWS_FOG_HACKALPHA && !ui)
1903 permutation |= SHADERPERMUTATION_FOGALPHAHACK;
1904 switch(vid.renderpath)
1905 {
1906 case RENDERPATH_GL32:
1907 case RENDERPATH_GLES2:
1910 // this has to be after RSurf_PrepareVerticesForBatch
1911 if (rsurface.batchskeletaltransform3x4buffer)
1912 permutation |= SHADERPERMUTATION_SKELETAL;
1914#ifndef USE_GLES2 /* FIXME: GLES3 only */
1915 if (r_glsl_permutation->ubiloc_Skeletal_Transform12_UniformBlock >= 0 && rsurface.batchskeletaltransform3x4buffer) qglBindBufferRange(GL_UNIFORM_BUFFER, r_glsl_permutation->ubibind_Skeletal_Transform12_UniformBlock, rsurface.batchskeletaltransform3x4buffer->bufferobject, rsurface.batchskeletaltransform3x4offset, rsurface.batchskeletaltransform3x4size);
1916#endif
1917 if (r_glsl_permutation->loc_ModelToReflectCube >= 0) {Matrix4x4_ToArrayFloatGL(&rsurface.matrix, m16f);qglUniformMatrix4fv(r_glsl_permutation->loc_ModelToReflectCube, 1, false, m16f);}
1919 {
1920 if (r_glsl_permutation->loc_ModelToLight >= 0) {Matrix4x4_ToArrayFloatGL(&rsurface.entitytolight, m16f);qglUniformMatrix4fv(r_glsl_permutation->loc_ModelToLight, 1, false, m16f);}
1921 if (r_glsl_permutation->loc_LightPosition >= 0) qglUniform3f(r_glsl_permutation->loc_LightPosition, rsurface.entitylightorigin[0], rsurface.entitylightorigin[1], rsurface.entitylightorigin[2]);
1922 if (r_glsl_permutation->loc_LightColor >= 0) qglUniform3f(r_glsl_permutation->loc_LightColor, 1, 1, 1); // DEPRECATED
1923 if (r_glsl_permutation->loc_Color_Ambient >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Ambient, rtlightambient[0], rtlightambient[1], rtlightambient[2]);
1924 if (r_glsl_permutation->loc_Color_Diffuse >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Diffuse, rtlightdiffuse[0], rtlightdiffuse[1], rtlightdiffuse[2]);
1925 if (r_glsl_permutation->loc_Color_Specular >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Specular, rtlightspecular[0], rtlightspecular[1], rtlightspecular[2]);
1926
1927 // additive passes are only darkened by fog, not tinted
1928 if (r_glsl_permutation->loc_FogColor >= 0)
1929 qglUniform3f(r_glsl_permutation->loc_FogColor, 0, 0, 0);
1930 if (r_glsl_permutation->loc_SpecularPower >= 0) qglUniform1f(r_glsl_permutation->loc_SpecularPower, t->specularpower * (r_shadow_glossexact.integer ? 0.25f : 1.0f) - 1.0f);
1931 }
1932 else
1933 {
1935 {
1936 if (r_glsl_permutation->loc_Color_Ambient >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Ambient, t->render_modellight_ambient[0], t->render_modellight_ambient[1], t->render_modellight_ambient[2]);
1937 }
1938 else if (mode == SHADERMODE_LIGHTGRID)
1939 {
1940 if (r_glsl_permutation->loc_Color_Ambient >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Ambient, t->render_lightmap_ambient[0], t->render_lightmap_ambient[1], t->render_lightmap_ambient[2]);
1941 if (r_glsl_permutation->loc_Color_Diffuse >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Diffuse, t->render_lightmap_diffuse[0], t->render_lightmap_diffuse[1], t->render_lightmap_diffuse[2]);
1942 if (r_glsl_permutation->loc_Color_Specular >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Specular, t->render_lightmap_specular[0], t->render_lightmap_specular[1], t->render_lightmap_specular[2]);
1943 // other LightGrid uniforms handled below
1944 }
1945 else if (mode == SHADERMODE_LIGHTDIRECTION)
1946 {
1947 if (r_glsl_permutation->loc_Color_Ambient >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Ambient, t->render_modellight_ambient[0], t->render_modellight_ambient[1], t->render_modellight_ambient[2]);
1948 if (r_glsl_permutation->loc_Color_Diffuse >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Diffuse, t->render_modellight_diffuse[0], t->render_modellight_diffuse[1], t->render_modellight_diffuse[2]);
1949 if (r_glsl_permutation->loc_Color_Specular >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Specular, t->render_modellight_specular[0], t->render_modellight_specular[1], t->render_modellight_specular[2]);
1950 if (r_glsl_permutation->loc_DeferredMod_Diffuse >= 0) qglUniform3f(r_glsl_permutation->loc_DeferredMod_Diffuse, t->render_rtlight_diffuse[0], t->render_rtlight_diffuse[1], t->render_rtlight_diffuse[2]);
1951 if (r_glsl_permutation->loc_DeferredMod_Specular >= 0) qglUniform3f(r_glsl_permutation->loc_DeferredMod_Specular, t->render_rtlight_specular[0], t->render_rtlight_specular[1], t->render_rtlight_specular[2]);
1952 if (r_glsl_permutation->loc_LightColor >= 0) qglUniform3f(r_glsl_permutation->loc_LightColor, 1, 1, 1); // DEPRECATED
1954 }
1955 else
1956 {
1957 if (r_glsl_permutation->loc_Color_Ambient >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Ambient, t->render_lightmap_ambient[0], t->render_lightmap_ambient[1], t->render_lightmap_ambient[2]);
1958 if (r_glsl_permutation->loc_Color_Diffuse >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Diffuse, t->render_lightmap_diffuse[0], t->render_lightmap_diffuse[1], t->render_lightmap_diffuse[2]);
1959 if (r_glsl_permutation->loc_Color_Specular >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Specular, t->render_lightmap_specular[0], t->render_lightmap_specular[1], t->render_lightmap_specular[2]);
1960 if (r_glsl_permutation->loc_DeferredMod_Diffuse >= 0) qglUniform3f(r_glsl_permutation->loc_DeferredMod_Diffuse, t->render_rtlight_diffuse[0], t->render_rtlight_diffuse[1], t->render_rtlight_diffuse[2]);
1961 if (r_glsl_permutation->loc_DeferredMod_Specular >= 0) qglUniform3f(r_glsl_permutation->loc_DeferredMod_Specular, t->render_rtlight_specular[0], t->render_rtlight_specular[1], t->render_rtlight_specular[2]);
1962 }
1963 // additive passes are only darkened by fog, not tinted
1964 if (r_glsl_permutation->loc_FogColor >= 0 && !ui)
1965 {
1966 if(blendfuncflags & BLENDFUNC_ALLOWS_FOG_HACK0)
1967 qglUniform3f(r_glsl_permutation->loc_FogColor, 0, 0, 0);
1968 else
1969 qglUniform3f(r_glsl_permutation->loc_FogColor, r_refdef.fogcolor[0], r_refdef.fogcolor[1], r_refdef.fogcolor[2]);
1970 }
1971 if (r_glsl_permutation->loc_DistortScaleRefractReflect >= 0) qglUniform4f(r_glsl_permutation->loc_DistortScaleRefractReflect, r_water_refractdistort.value * t->refractfactor, r_water_refractdistort.value * t->refractfactor, r_water_reflectdistort.value * t->reflectfactor, r_water_reflectdistort.value * t->reflectfactor);
1972 if (r_glsl_permutation->loc_ScreenScaleRefractReflect >= 0) qglUniform4f(r_glsl_permutation->loc_ScreenScaleRefractReflect, r_fb.water.screenscale[0], r_fb.water.screenscale[1], r_fb.water.screenscale[0], r_fb.water.screenscale[1]);
1973 if (r_glsl_permutation->loc_ScreenCenterRefractReflect >= 0) qglUniform4f(r_glsl_permutation->loc_ScreenCenterRefractReflect, r_fb.water.screencenter[0], r_fb.water.screencenter[1], r_fb.water.screencenter[0], r_fb.water.screencenter[1]);
1974 if (r_glsl_permutation->loc_RefractColor >= 0) qglUniform4f(r_glsl_permutation->loc_RefractColor, t->refractcolor4f[0], t->refractcolor4f[1], t->refractcolor4f[2], t->refractcolor4f[3] * t->currentalpha);
1975 if (r_glsl_permutation->loc_ReflectColor >= 0) qglUniform4f(r_glsl_permutation->loc_ReflectColor, t->reflectcolor4f[0], t->reflectcolor4f[1], t->reflectcolor4f[2], t->reflectcolor4f[3] * t->currentalpha);
1976 if (r_glsl_permutation->loc_ReflectFactor >= 0) qglUniform1f(r_glsl_permutation->loc_ReflectFactor, t->reflectmax - t->reflectmin);
1977 if (r_glsl_permutation->loc_ReflectOffset >= 0) qglUniform1f(r_glsl_permutation->loc_ReflectOffset, t->reflectmin);
1978 if (r_glsl_permutation->loc_SpecularPower >= 0) qglUniform1f(r_glsl_permutation->loc_SpecularPower, t->specularpower * (r_shadow_glossexact.integer ? 0.25f : 1.0f) - 1.0f);
1979 if (r_glsl_permutation->loc_NormalmapScrollBlend >= 0) qglUniform2f(r_glsl_permutation->loc_NormalmapScrollBlend, t->r_water_waterscroll[0], t->r_water_waterscroll[1]);
1980 }
1981 if (r_glsl_permutation->loc_TexMatrix >= 0) {Matrix4x4_ToArrayFloatGL(&t->currenttexmatrix, m16f);qglUniformMatrix4fv(r_glsl_permutation->loc_TexMatrix, 1, false, m16f);}
1982 if (r_glsl_permutation->loc_BackgroundTexMatrix >= 0) {Matrix4x4_ToArrayFloatGL(&t->currentbackgroundtexmatrix, m16f);qglUniformMatrix4fv(r_glsl_permutation->loc_BackgroundTexMatrix, 1, false, m16f);}
1983 if (r_glsl_permutation->loc_ShadowMapMatrix >= 0) {Matrix4x4_ToArrayFloatGL(&r_shadow_shadowmapmatrix, m16f);qglUniformMatrix4fv(r_glsl_permutation->loc_ShadowMapMatrix, 1, false, m16f);}
1984 if (permutation & SHADERPERMUTATION_SHADOWMAPORTHO)
1985 {
1988 }
1989 else
1990 {
1993 }
1994
1995 if (r_glsl_permutation->loc_Color_Glow >= 0) qglUniform3f(r_glsl_permutation->loc_Color_Glow, t->render_glowmod[0], t->render_glowmod[1], t->render_glowmod[2]);
1996 if (r_glsl_permutation->loc_Alpha >= 0) qglUniform1f(r_glsl_permutation->loc_Alpha, t->currentalpha * ((t->basematerialflags & MATERIALFLAG_WATERSHADER && r_fb.water.enabled && !r_refdef.view.isoverlay) ? t->r_water_wateralpha : 1));
1997 if (r_glsl_permutation->loc_EyePosition >= 0) qglUniform3f(r_glsl_permutation->loc_EyePosition, rsurface.localvieworigin[0], rsurface.localvieworigin[1], rsurface.localvieworigin[2]);
1998 if (r_glsl_permutation->loc_Color_Pants >= 0)
1999 {
2000 if (t->pantstexture)
2001 qglUniform3f(r_glsl_permutation->loc_Color_Pants, t->render_colormap_pants[0], t->render_colormap_pants[1], t->render_colormap_pants[2]);
2002 else
2003 qglUniform3f(r_glsl_permutation->loc_Color_Pants, 0, 0, 0);
2004 }
2005 if (r_glsl_permutation->loc_Color_Shirt >= 0)
2006 {
2007 if (t->shirttexture)
2008 qglUniform3f(r_glsl_permutation->loc_Color_Shirt, t->render_colormap_shirt[0], t->render_colormap_shirt[1], t->render_colormap_shirt[2]);
2009 else
2010 qglUniform3f(r_glsl_permutation->loc_Color_Shirt, 0, 0, 0);
2011 }
2012 if (r_glsl_permutation->loc_FogPlane >= 0) qglUniform4f(r_glsl_permutation->loc_FogPlane, rsurface.fogplane[0], rsurface.fogplane[1], rsurface.fogplane[2], rsurface.fogplane[3]);
2013 if (r_glsl_permutation->loc_FogPlaneViewDist >= 0) qglUniform1f(r_glsl_permutation->loc_FogPlaneViewDist, rsurface.fogplaneviewdist);
2014 if (r_glsl_permutation->loc_FogRangeRecip >= 0) qglUniform1f(r_glsl_permutation->loc_FogRangeRecip, rsurface.fograngerecip);
2015 if (r_glsl_permutation->loc_FogHeightFade >= 0) qglUniform1f(r_glsl_permutation->loc_FogHeightFade, rsurface.fogheightfade);
2016 if (r_glsl_permutation->loc_OffsetMapping_ScaleSteps >= 0) qglUniform4f(r_glsl_permutation->loc_OffsetMapping_ScaleSteps,
2021 );
2022 if (r_glsl_permutation->loc_OffsetMapping_LodDistance >= 0) qglUniform1f(r_glsl_permutation->loc_OffsetMapping_LodDistance, r_glsl_offsetmapping_lod_distance.integer * r_refdef.view.quality);
2023 if (r_glsl_permutation->loc_OffsetMapping_Bias >= 0) qglUniform1f(r_glsl_permutation->loc_OffsetMapping_Bias, t->offsetbias);
2024 if (r_glsl_permutation->loc_ScreenToDepth >= 0) qglUniform2f(r_glsl_permutation->loc_ScreenToDepth, r_refdef.view.viewport.screentodepth[0], r_refdef.view.viewport.screentodepth[1]);
2025 if (r_glsl_permutation->loc_PixelToScreenTexCoord >= 0) qglUniform2f(r_glsl_permutation->loc_PixelToScreenTexCoord, 1.0f/r_fb.screentexturewidth, 1.0f/r_fb.screentextureheight);
2026 if (r_glsl_permutation->loc_BounceGridMatrix >= 0) {Matrix4x4_Concat(&tempmatrix, &r_shadow_bouncegrid_state.matrix, &rsurface.matrix);Matrix4x4_ToArrayFloatGL(&tempmatrix, m16f);qglUniformMatrix4fv(r_glsl_permutation->loc_BounceGridMatrix, 1, false, m16f);}
2027 if (r_glsl_permutation->loc_BounceGridIntensity >= 0) qglUniform1f(r_glsl_permutation->loc_BounceGridIntensity, r_shadow_bouncegrid_state.intensity*r_refdef.view.colorscale);
2028 if (r_glsl_permutation->loc_LightGridMatrix >= 0 && r_refdef.scene.worldmodel)
2029 {
2030 float m9f[9];
2031 Matrix4x4_Concat(&tempmatrix, &r_refdef.scene.worldmodel->brushq3.lightgridworldtotexturematrix, &rsurface.matrix);
2032 Matrix4x4_ToArrayFloatGL(&tempmatrix, m16f);
2033 qglUniformMatrix4fv(r_glsl_permutation->loc_LightGridMatrix, 1, false, m16f);
2034 Matrix4x4_Normalize3(&tempmatrix, &rsurface.matrix);
2035 Matrix4x4_ToArrayFloatGL(&tempmatrix, m16f);
2036 m9f[0] = m16f[0];m9f[1] = m16f[1];m9f[2] = m16f[2];
2037 m9f[3] = m16f[4];m9f[4] = m16f[5];m9f[5] = m16f[6];
2038 m9f[6] = m16f[8];m9f[7] = m16f[9];m9f[8] = m16f[10];
2039 qglUniformMatrix3fv(r_glsl_permutation->loc_LightGridNormalMatrix, 1, false, m9f);
2040 }
2041
2042 if (r_glsl_permutation->tex_Texture_First >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_First , r_texture_white );
2043 if (r_glsl_permutation->tex_Texture_Second >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Second , r_texture_white );
2044 if (r_glsl_permutation->tex_Texture_GammaRamps >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_GammaRamps , r_texture_gammaramps );
2045 if (r_glsl_permutation->tex_Texture_Normal >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Normal , t->nmaptexture );
2046 if (r_glsl_permutation->tex_Texture_Color >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Color , t->basetexture );
2047 if (r_glsl_permutation->tex_Texture_Gloss >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Gloss , t->glosstexture );
2048 if (r_glsl_permutation->tex_Texture_Glow >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Glow , t->glowtexture );
2049 if (r_glsl_permutation->tex_Texture_SecondaryNormal >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_SecondaryNormal , t->backgroundnmaptexture );
2050 if (r_glsl_permutation->tex_Texture_SecondaryColor >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_SecondaryColor , t->backgroundbasetexture );
2051 if (r_glsl_permutation->tex_Texture_SecondaryGloss >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_SecondaryGloss , t->backgroundglosstexture );
2052 if (r_glsl_permutation->tex_Texture_SecondaryGlow >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_SecondaryGlow , t->backgroundglowtexture );
2053 if (r_glsl_permutation->tex_Texture_Pants >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Pants , t->pantstexture );
2054 if (r_glsl_permutation->tex_Texture_Shirt >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Shirt , t->shirttexture );
2055 if (r_glsl_permutation->tex_Texture_ReflectMask >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ReflectMask , t->reflectmasktexture );
2056 if (r_glsl_permutation->tex_Texture_ReflectCube >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ReflectCube , t->reflectcubetexture ? t->reflectcubetexture : r_texture_whitecube);
2057 if (r_glsl_permutation->tex_Texture_FogHeightTexture>= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_FogHeightTexture , r_texture_fogheighttexture );
2058 if (r_glsl_permutation->tex_Texture_FogMask >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_FogMask , r_texture_fogattenuation );
2059 if (r_glsl_permutation->tex_Texture_Lightmap >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Lightmap , rsurface.lightmaptexture ? rsurface.lightmaptexture : r_texture_white);
2060 if (r_glsl_permutation->tex_Texture_Deluxemap >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Deluxemap , rsurface.deluxemaptexture ? rsurface.deluxemaptexture : r_texture_blanknormalmap);
2061 if (r_glsl_permutation->tex_Texture_Attenuation >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Attenuation , r_shadow_attenuationgradienttexture );
2062 if (rsurfacepass == RSURFPASS_BACKGROUND)
2063 {
2064 if (r_glsl_permutation->tex_Texture_Refraction >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Refraction , waterplane->rt_refraction ? waterplane->rt_refraction->colortexture[0] : r_texture_black);
2065 if (r_glsl_permutation->tex_Texture_First >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_First , waterplane->rt_camera ? waterplane->rt_camera->colortexture[0] : r_texture_black);
2066 if (r_glsl_permutation->tex_Texture_Reflection >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Reflection , waterplane->rt_reflection ? waterplane->rt_reflection->colortexture[0] : r_texture_black);
2067 }
2068 else
2069 {
2070 if (r_glsl_permutation->tex_Texture_Reflection >= 0 && waterplane) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Reflection , waterplane->rt_reflection ? waterplane->rt_reflection->colortexture[0] : r_texture_black);
2071 }
2072 if (r_glsl_permutation->tex_Texture_ScreenNormalMap >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ScreenNormalMap , r_shadow_prepassgeometrynormalmaptexture );
2073 if (r_glsl_permutation->tex_Texture_ScreenDiffuse >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ScreenDiffuse , r_shadow_prepasslightingdiffusetexture );
2074 if (r_glsl_permutation->tex_Texture_ScreenSpecular >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ScreenSpecular , r_shadow_prepasslightingspeculartexture );
2075 if (rsurface.rtlight || (r_shadow_usingshadowmaportho && !(rsurface.ent_flags & RENDER_NOSELFSHADOW)))
2076 {
2077 if (r_glsl_permutation->tex_Texture_ShadowMap2D >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_ShadowMap2D, r_shadow_shadowmap2ddepthtexture );
2078 if (rsurface.rtlight)
2079 {
2080 if (r_glsl_permutation->tex_Texture_Cube >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Cube , rsurface.rtlight->currentcubemap );
2081 if (r_glsl_permutation->tex_Texture_CubeProjection >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_CubeProjection , r_shadow_shadowmapvsdcttexture );
2082 }
2083 }
2084 if (r_glsl_permutation->tex_Texture_BounceGrid >= 0) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_BounceGrid, r_shadow_bouncegrid_state.texture);
2085 if (r_glsl_permutation->tex_Texture_LightGrid >= 0 && r_refdef.scene.worldmodel) R_Mesh_TexBind(r_glsl_permutation->tex_Texture_LightGrid, r_refdef.scene.worldmodel->brushq3.lightgridtexture);
2087 break;
2088 }
2089}
void RSurf_PrepareVerticesForBatch(int batchneed, int texturenumsurfaces, const msurface_t **texturesurfacelist)
Definition gl_rmain.c:7388
#define BLENDFUNC_ALLOWS_FOG_HACK0
Definition gl_rmain.c:1519
rtexture_t * r_shadow_prepasslightingdiffusetexture
Definition r_shadow.c:121
rtexture_t * r_texture_fogattenuation
Definition gl_rmain.c:279
rtexture_t * r_shadow_prepasslightingspeculartexture
Definition r_shadow.c:122
#define BLENDFUNC_ALLOWS_FOG_HACKALPHA
Definition gl_rmain.c:1520
rtexture_t * r_texture_fogheighttexture
Definition gl_rmain.c:280
void RSurf_UploadBuffersForBatch(void)
Definition gl_rmain.c:7340
#define BLENDFUNC_ALLOWS_ANYFOG
Definition gl_rmain.c:1521
int R_TextureFlags(rtexture_t *rt)
void Matrix4x4_Normalize3(matrix4x4_t *out, matrix4x4_t *in1)
Definition matrixlib.c:508
#define MATERIALFLAG_OCCLUDE
#define RENDER_NOSELFSHADOW
Definition protocol.h:367
@ OFFSETMAPPING_DEFAULT
Definition r_qshader.h:186
@ OFFSETMAPPING_LINEAR
Definition r_qshader.h:187
@ OFFSETMAPPING_RELIEF
Definition r_qshader.h:188
float r_shadow_modelshadowmap_parameters[4]
Definition r_shadow.c:43
qbool r_shadow_usingshadowmaportho
Definition r_shadow.c:38
matrix4x4_t r_shadow_shadowmapmatrix
Definition r_shadow.c:62
r_shadow_bouncegrid_state_t r_shadow_bouncegrid_state
Definition r_shadow.c:259
float r_shadow_modelshadowmap_texturescale[4]
Definition r_shadow.c:42
#define TEXF_ALPHA
Definition r_textures.h:9
#define SHADERPERMUTATION_FOGALPHAHACK
fog color and density determined by texture mapped on vertical axis
Definition render.h:81
#define SHADERPERMUTATION_ALPHAKILL
(deferredgeometry) discard pixel if diffuse texture alpha below 0.5, (generic) apply global alpha
Definition render.h:95
#define SHADERPERMUTATION_ALPHAGEN_VERTEX
alphaGen vertex
Definition render.h:102
#define SHADERPERMUTATION_GLOW
(lightmap) blend in an additive glow texture
Definition render.h:84
#define SHADERPERMUTATION_FOGHEIGHTTEXTURE
fog color and density determined by texture mapped on vertical axis
Definition render.h:80
#define SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL
(lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standar...
Definition render.h:99
#define SHADERPERMUTATION_FOGOUTSIDE
tint the color by fog color or black if using additive blend mode
Definition render.h:79
#define BATCHNEED_ALLOWMULTIDRAW
Definition render.h:795
#define BATCHNEED_ARRAY_VERTEXCOLOR
Definition render.h:789
#define BATCHNEED_ARRAY_NORMAL
Definition render.h:786
#define SHADERPERMUTATION_OCCLUDE
use occlusion buffer for corona
Definition render.h:104
#define BATCHNEED_ARRAY_LIGHTMAP
Definition render.h:791
#define SHADERPERMUTATION_OFFSETMAPPING
adjust texcoords to roughly simulate a displacement mapped surface
Definition render.h:89
#define SHADERPERMUTATION_BOUNCEGRID
(lightmap) use Texture_BounceGrid as an additional source of ambient light
Definition render.h:98
#define SHADERPERMUTATION_VERTEXTEXTUREBLEND
indicates this is a two-layer material blend based on vertex alpha (q3bsp)
Definition render.h:74
#define BATCHNEED_ARRAY_VECTOR
Definition render.h:787
#define SHADERPERMUTATION_FOGINSIDE
tint the color by fog color or black if using additive blend mode
Definition render.h:78
#define SHADERPERMUTATION_NORMALMAPSCROLLBLEND
(water) counter-direction normalmaps scrolling
Definition render.h:97
#define SHADERPERMUTATION_SHADOWMAPORTHO
(lightsource) use orthographic shadowmap projection
Definition render.h:93
#define BATCHNEED_ARRAY_VERTEX
Definition render.h:785
#define SHADERPERMUTATION_REFLECTION
normalmap-perturbed reflection of the scene infront of the surface, preformed as an overlay on the su...
Definition render.h:88
#define SHADERPERMUTATION_DEFERREDLIGHTMAP
(lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping
Definition render.h:94
#define SHADERPERMUTATION_COLORMAPPING
indicates this is a colormapped skin
Definition render.h:76
#define BATCHNEED_ARRAY_TEXCOORD
Definition render.h:790
#define SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING
adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also...
Definition render.h:90
rtexture_t * colortexture[4]
Definition render.h:834
r_rendertarget_t * rt_refraction
Definition render.h:849
r_rendertarget_t * rt_camera
Definition render.h:851
r_rendertarget_t * rt_reflection
Definition render.h:850
float refractfactor
dpoffsetmapping_technique_t offsetmapping
float r_water_waterscroll[2]
float reflectmin
vec4_t refractcolor4f
struct rtexture_s * reflectcubetexture
float reflectmax
float offsetscale
float r_water_wateralpha
float reflectfactor
float offsetbias
vec4_t reflectcolor4f

References texture_t::backgroundbasetexture, texture_t::backgroundglosstexture, texture_t::backgroundglowtexture, texture_t::backgroundnmaptexture, texture_t::basematerialflags, texture_t::basetexture, BATCHNEED_ALLOWMULTIDRAW, BATCHNEED_ARRAY_LIGHTMAP, BATCHNEED_ARRAY_NORMAL, BATCHNEED_ARRAY_TEXCOORD, BATCHNEED_ARRAY_VECTOR, BATCHNEED_ARRAY_VERTEX, BATCHNEED_ARRAY_VERTEXCOLOR, BLENDFUNC_ALLOWS_ANYFOG, BLENDFUNC_ALLOWS_FOG_HACK0, BLENDFUNC_ALLOWS_FOG_HACKALPHA, CHECKGLERROR, cl, texture_t::colormapping, r_rendertarget_t::colortexture, texture_t::currentalpha, texture_t::currentbackgroundtexmatrix, texture_t::currentblendfunc, texture_t::currentmaterialflags, texture_t::currenttexmatrix, GL_AlphaToCoverage(), GL_BlendFunc(), gl_lightmaps, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_UNIFORM_BUFFER, GL_ZERO, texture_t::glosstexture, texture_t::glowtexture, MATERIALFLAG_ALPHAGEN_VERTEX, MATERIALFLAG_ALPHATEST, MATERIALFLAG_BLENDED, MATERIALFLAG_LIGHTGRID, MATERIALFLAG_MODELLIGHT, MATERIALFLAG_OCCLUDE, MATERIALFLAG_REFLECTION, MATERIALFLAG_REFRACTION, MATERIALFLAG_VERTEXTEXTUREBLEND, MATERIALFLAG_WATERALPHA, MATERIALFLAG_WATERSHADER, Matrix4x4_Concat(), Matrix4x4_Normalize3(), Matrix4x4_ToArrayFloatGL(), max, mode, texture_t::nmaptexture, texture_t::offsetbias, texture_t::offsetmapping, OFFSETMAPPING_DEFAULT, OFFSETMAPPING_LINEAR, OFFSETMAPPING_OFF, OFFSETMAPPING_RELIEF, texture_t::offsetscale, texture_t::pantstexture, R_BlendFuncFlags(), r_fb, r_glsl_deluxemapping, r_glsl_offsetmapping, r_glsl_offsetmapping_lod_distance, r_glsl_offsetmapping_reliefmapping, r_glsl_offsetmapping_reliefmapping_refinesteps, r_glsl_offsetmapping_reliefmapping_steps, r_glsl_offsetmapping_scale, r_glsl_offsetmapping_steps, r_glsl_permutation, r_hdr_glowintensity, R_Mesh_TexBind(), r_refdef, R_SetupShader_SetPermutationGLSL(), r_shadow_attenuationgradienttexture, r_shadow_bouncegrid_state, r_shadow_glossexact, r_shadow_lightshadowmap_parameters, r_shadow_lightshadowmap_texturescale, r_shadow_modelshadowmap_parameters, r_shadow_modelshadowmap_texturescale, r_shadow_prepassgeometrynormalmaptexture, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, r_shadow_shadowmap2ddepthbuffer, r_shadow_shadowmap2ddepthtexture, r_shadow_shadowmapmatrix, r_shadow_shadowmapvsdct, r_shadow_shadowmapvsdcttexture, r_shadow_usingdeferredprepass, r_shadow_usingshadowmap2d, r_shadow_usingshadowmaportho, r_texture_black, r_texture_blanknormalmap, r_texture_fogattenuation, r_texture_fogheighttexture, r_texture_gammaramps, r_texture_white, r_texture_whitecube, R_TextureFlags(), r_transparent_alphatocoverage, r_trippy, r_water_reflectdistort, r_water_refractdistort, texture_t::r_water_wateralpha, texture_t::r_water_waterscroll, r_wateralpha, texture_t::reflectcolor4f, texture_t::reflectcubetexture, texture_t::reflectfactor, texture_t::reflectmasktexture, texture_t::reflectmax, texture_t::reflectmin, texture_t::refractcolor4f, texture_t::refractfactor, texture_t::render_colormap_pants, texture_t::render_colormap_shirt, texture_t::render_glowmod, texture_t::render_lightmap_ambient, texture_t::render_lightmap_diffuse, texture_t::render_lightmap_specular, texture_t::render_modellight_ambient, texture_t::render_modellight_diffuse, texture_t::render_modellight_lightdir_local, texture_t::render_modellight_specular, RENDER_NOSELFSHADOW, texture_t::render_rtlight_diffuse, texture_t::render_rtlight_specular, RENDERPATH_GL32, RENDERPATH_GLES2, RSurf_PrepareVerticesForBatch(), RSurf_UploadBuffersForBatch(), rsurface, RSURFPASS_BACKGROUND, RSURFPASS_DEFERREDGEOMETRY, RSURFPASS_RTLIGHT, r_waterstate_waterplane_t::rt_camera, r_waterstate_waterplane_t::rt_reflection, r_waterstate_waterplane_t::rt_refraction, SHADERMODE_DEFERREDGEOMETRY, SHADERMODE_FLATCOLOR, SHADERMODE_GENERIC, SHADERMODE_LIGHTDIRECTION, SHADERMODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP, SHADERMODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR, SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE, SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE, SHADERMODE_LIGHTGRID, SHADERMODE_LIGHTMAP, SHADERMODE_LIGHTSOURCE, SHADERMODE_REFRACTION, SHADERMODE_VERTEXCOLOR, SHADERMODE_WATER, SHADERPERMUTATION_ALPHAGEN_VERTEX, SHADERPERMUTATION_ALPHAKILL, SHADERPERMUTATION_BOUNCEGRID, SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL, SHADERPERMUTATION_COLORMAPPING, SHADERPERMUTATION_CUBEFILTER, SHADERPERMUTATION_DEFERREDLIGHTMAP, SHADERPERMUTATION_DEPTHRGB, SHADERPERMUTATION_DIFFUSE, SHADERPERMUTATION_FOGALPHAHACK, SHADERPERMUTATION_FOGHEIGHTTEXTURE, SHADERPERMUTATION_FOGINSIDE, SHADERPERMUTATION_FOGOUTSIDE, SHADERPERMUTATION_GLOW, SHADERPERMUTATION_NORMALMAPSCROLLBLEND, SHADERPERMUTATION_OCCLUDE, SHADERPERMUTATION_OFFSETMAPPING, SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING, SHADERPERMUTATION_REFLECTCUBE, SHADERPERMUTATION_REFLECTION, SHADERPERMUTATION_SHADOWMAP2D, SHADERPERMUTATION_SHADOWMAPORTHO, SHADERPERMUTATION_SHADOWMAPVSDCT, SHADERPERMUTATION_SKELETAL, SHADERPERMUTATION_SPECULAR, SHADERPERMUTATION_TRIPPY, SHADERPERMUTATION_VERTEXTEXTUREBLEND, texture_t::shirttexture, texture_t::specularpower, TEXF_ALPHA, VectorLength2, and vid.

Referenced by R_DrawTextureSurfaceList_GL20(), and R_Shadow_RenderLighting_Light_GLSL().

◆ R_SetupView()

void R_SetupView ( qbool allowwaterclippingplane,
int viewfbo,
rtexture_t * viewdepthtexture,
rtexture_t * viewcolortexture,
int viewx,
int viewy,
int viewwidth,
int viewheight )

Definition at line 4384 of file gl_rmain.c.

4385{
4386 const float *customclipplane = NULL;
4387 float plane[4];
4388 int viewy_adjusted;
4389 if (r_refdef.view.useclipplane && allowwaterclippingplane)
4390 {
4391 // LadyHavoc: couldn't figure out how to make this approach work the same in DPSOFTRAST
4392 vec_t dist = r_refdef.view.clipplane.dist - r_water_clippingplanebias.value;
4393 vec_t viewdist = DotProduct(r_refdef.view.origin, r_refdef.view.clipplane.normal);
4394 if (viewdist < r_refdef.view.clipplane.dist + r_water_clippingplanebias.value)
4395 dist = r_refdef.view.clipplane.dist;
4396 plane[0] = r_refdef.view.clipplane.normal[0];
4397 plane[1] = r_refdef.view.clipplane.normal[1];
4398 plane[2] = r_refdef.view.clipplane.normal[2];
4399 plane[3] = -dist;
4400 customclipplane = plane;
4401 }
4402
4403 // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom.
4404 // Unless the render target is a FBO...
4405 viewy_adjusted = viewfbo ? viewy : vid.mode.height - viewheight - viewy;
4406
4407 if (!r_refdef.view.useperspective)
4408 R_Viewport_InitOrtho3D(&r_refdef.view.viewport, &r_refdef.view.matrix, viewx, viewy_adjusted, viewwidth, viewheight, r_refdef.view.ortho_x, r_refdef.view.ortho_y, -r_refdef.farclip, r_refdef.farclip, customclipplane);
4409 else if (vid.stencil && r_useinfinitefarclip.integer)
4410 R_Viewport_InitPerspectiveInfinite(&r_refdef.view.viewport, &r_refdef.view.matrix, viewx, viewy_adjusted, viewwidth, viewheight, r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, customclipplane);
4411 else
4412 R_Viewport_InitPerspective(&r_refdef.view.viewport, &r_refdef.view.matrix, viewx, viewy_adjusted, viewwidth, viewheight, r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, r_refdef.farclip, customclipplane);
4413 R_Mesh_SetRenderTargets(viewfbo);
4414 R_SetViewport(&r_refdef.view.viewport);
4415}
void R_Viewport_InitPerspective(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float nearclip, float farclip, const float *nearplane)
Definition gl_backend.c:677
void R_Viewport_InitOrtho3D(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float nearclip, float farclip, const float *nearplane)
Definition gl_backend.c:635
void R_Viewport_InitPerspectiveInfinite(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float nearclip, const float *nearplane)
Definition gl_backend.c:719

References DotProduct, NULL, R_Mesh_SetRenderTargets(), r_refdef, R_SetViewport(), r_useinfinitefarclip, R_Viewport_InitOrtho3D(), R_Viewport_InitPerspective(), R_Viewport_InitPerspectiveInfinite(), r_water_clippingplanebias, and vid.

Referenced by R_RenderScene(), R_ResetViewRendering3D(), and R_Water_ProcessPlanes().

◆ R_Shadow_EditLights_DrawSelectedLightProperties()

void R_Shadow_EditLights_DrawSelectedLightProperties ( void )

Definition at line 5713 of file r_shadow.c.

5714{
5715 int lightnumber, lightcount;
5716 size_t lightindex, range;
5717 dlight_t *light;
5718 char temp[256];
5719 float x, y;
5720
5721 if (!r_editlights.integer)
5722 return;
5723
5724 // update cvars so QC can query them
5726 {
5727 dpsnprintf(temp, sizeof(temp), "%f %f %f", r_shadow_selectedlight->origin[0], r_shadow_selectedlight->origin[1], r_shadow_selectedlight->origin[2]);
5729 dpsnprintf(temp, sizeof(temp), "%f %f %f", r_shadow_selectedlight->angles[0], r_shadow_selectedlight->angles[1], r_shadow_selectedlight->angles[2]);
5731 dpsnprintf(temp, sizeof(temp), "%f %f %f", r_shadow_selectedlight->color[0], r_shadow_selectedlight->color[1], r_shadow_selectedlight->color[2]);
5744 }
5745
5746 // draw properties on screen
5747 if (!r_editlights_drawproperties.integer)
5748 return;
5749 x = vid_conwidth.value - 320;
5750 y = 5;
5751 DrawQ_Pic(x-5, y-5, NULL, 250, 243, 0, 0, 0, 0.75, 0);
5752 lightnumber = -1;
5753 lightcount = 0;
5755 for (lightindex = 0;lightindex < range;lightindex++)
5756 {
5758 if (!light)
5759 continue;
5760 if (light == r_shadow_selectedlight)
5761 lightnumber = (int)lightindex;
5762 lightcount++;
5763 }
5764 dpsnprintf(temp, sizeof(temp), "Cursor origin: %.0f %.0f %.0f", r_editlights_cursorlocation[0], r_editlights_cursorlocation[1], r_editlights_cursorlocation[2]); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, false, FONT_DEFAULT);y += 8;
5765 dpsnprintf(temp, sizeof(temp), "Total lights : %i active (%i total)", lightcount, (int)Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray)); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, false, FONT_DEFAULT);y += 8;
5766 y += 8;
5768 return;
5769 dpsnprintf(temp, sizeof(temp), "Light #%i properties:", lightnumber);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5770 dpsnprintf(temp, sizeof(temp), "Origin : %.0f %.0f %.0f\n", r_shadow_selectedlight->origin[0], r_shadow_selectedlight->origin[1], r_shadow_selectedlight->origin[2]);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5771 dpsnprintf(temp, sizeof(temp), "Angles : %.0f %.0f %.0f\n", r_shadow_selectedlight->angles[0], r_shadow_selectedlight->angles[1], r_shadow_selectedlight->angles[2]);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5772 dpsnprintf(temp, sizeof(temp), "Color : %.2f %.2f %.2f\n", r_shadow_selectedlight->color[0], r_shadow_selectedlight->color[1], r_shadow_selectedlight->color[2]);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5773 dpsnprintf(temp, sizeof(temp), "Radius : %.0f\n", r_shadow_selectedlight->radius);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5774 dpsnprintf(temp, sizeof(temp), "Corona : %.0f\n", r_shadow_selectedlight->corona);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5775 dpsnprintf(temp, sizeof(temp), "Style : %i\n", r_shadow_selectedlight->style);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5776 dpsnprintf(temp, sizeof(temp), "Shadows : %s\n", r_shadow_selectedlight->shadow ? "yes" : "no");DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5777 dpsnprintf(temp, sizeof(temp), "Cubemap : %s\n", r_shadow_selectedlight->cubemapname);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5778 dpsnprintf(temp, sizeof(temp), "CoronaSize : %.2f\n", r_shadow_selectedlight->coronasizescale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5779 dpsnprintf(temp, sizeof(temp), "Ambient : %.2f\n", r_shadow_selectedlight->ambientscale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5780 dpsnprintf(temp, sizeof(temp), "Diffuse : %.2f\n", r_shadow_selectedlight->diffusescale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5781 dpsnprintf(temp, sizeof(temp), "Specular : %.2f\n", r_shadow_selectedlight->specularscale);DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5782 dpsnprintf(temp, sizeof(temp), "NormalMode : %s\n", (r_shadow_selectedlight->flags & LIGHTFLAG_NORMALMODE) ? "yes" : "no");DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5783 dpsnprintf(temp, sizeof(temp), "RealTimeMode : %s\n", (r_shadow_selectedlight->flags & LIGHTFLAG_REALTIMEMODE) ? "yes" : "no");DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT);y += 8;
5784 y += 8;
5785 dpsnprintf(temp, sizeof(temp), "Render stats\n"); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT); y += 8;
5786 dpsnprintf(temp, sizeof(temp), "Current color: %.3f %.3f %.3f\n", r_shadow_selectedlight->rtlight.currentcolor[0], r_shadow_selectedlight->rtlight.currentcolor[1], r_shadow_selectedlight->rtlight.currentcolor[2]); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT); y += 8;
5787 dpsnprintf(temp, sizeof(temp), "Shadow size : %ix%ix6\n", r_shadow_selectedlight->rtlight.shadowmapatlassidesize, r_shadow_selectedlight->rtlight.shadowmapatlassidesize); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT); y += 8;
5788 dpsnprintf(temp, sizeof(temp), "World surfs : %i\n", r_shadow_selectedlight->rtlight.cached_numsurfaces); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT); y += 8;
5789 dpsnprintf(temp, sizeof(temp), "Shadow ents : %i + %i noself\n", r_shadow_selectedlight->rtlight.cached_numshadowentities, r_shadow_selectedlight->rtlight.cached_numshadowentities_noselfshadow); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT); y += 8;
5790 dpsnprintf(temp, sizeof(temp), "Lit ents : %i + %i noself\n", r_shadow_selectedlight->rtlight.cached_numlightentities, r_shadow_selectedlight->rtlight.cached_numlightentities_noselfshadow); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT); y += 8;
5791 dpsnprintf(temp, sizeof(temp), "BG photons : %.3f\n", r_shadow_selectedlight->rtlight.bouncegrid_photons); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT); y += 8;
5792 dpsnprintf(temp, sizeof(temp), "BG radius : %.0f\n", r_shadow_selectedlight->rtlight.bouncegrid_effectiveradius); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT); y += 8;
5793 dpsnprintf(temp, sizeof(temp), "BG color : %.3f %.3f %.3f\n", r_shadow_selectedlight->rtlight.bouncegrid_photoncolor[0], r_shadow_selectedlight->rtlight.bouncegrid_photoncolor[1], r_shadow_selectedlight->rtlight.bouncegrid_photoncolor[2]); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT); y += 8;
5794 dpsnprintf(temp, sizeof(temp), "BG stats : %i traces %i hits\n", r_shadow_selectedlight->rtlight.bouncegrid_traces, r_shadow_selectedlight->rtlight.bouncegrid_hits); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT); y += 8;
5795}
#define LIGHTFLAG_NORMALMODE
Definition client.h:34
#define LIGHTFLAG_REALTIMEMODE
Definition client.h:35
void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, float red, float green, float blue, float alpha, int flags)
Definition gl_draw.c:797
float DrawQ_String(float x, float y, const char *text, size_t maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qbool ignorecolorcodes, const dp_font_t *fnt)
Definition gl_draw.c:1320
cvar_t r_editlights_current_realtimemode
Definition r_shadow.c:257
cvar_t r_editlights_current_angles
Definition r_shadow.c:245
cvar_t r_editlights_current_color
Definition r_shadow.c:246
vec3_t r_editlights_cursorlocation
Definition r_shadow.c:276
cvar_t r_editlights_current_style
Definition r_shadow.c:250
cvar_t r_editlights_current_normalmode
Definition r_shadow.c:256
dlight_t * r_shadow_selectedlight
Definition r_shadow.c:274
cvar_t r_editlights_current_cubemap
Definition r_shadow.c:252
cvar_t r_editlights_current_coronasize
Definition r_shadow.c:249
cvar_t r_editlights_current_origin
Definition r_shadow.c:244
cvar_t r_editlights
Definition r_shadow.c:237
cvar_t r_editlights_current_corona
Definition r_shadow.c:248
cvar_t r_editlights_current_ambient
Definition r_shadow.c:253
static memexpandablearray_t r_shadow_worldlightsarray
Definition r_shadow.c:273
cvar_t r_editlights_current_diffuse
Definition r_shadow.c:254
cvar_t r_editlights_current_radius
Definition r_shadow.c:247
cvar_t r_editlights_current_specular
Definition r_shadow.c:255
cvar_t r_editlights_current_shadows
Definition r_shadow.c:251
cvar_t r_editlights_drawproperties
Definition r_shadow.c:243

References Cvar_SetQuick(), Cvar_SetValueQuick(), dpsnprintf(), DrawQ_Pic(), DrawQ_String(), FONT_DEFAULT, int(), LIGHTFLAG_NORMALMODE, LIGHTFLAG_REALTIMEMODE, Mem_ExpandableArray_IndexRange(), Mem_ExpandableArray_RecordAtIndex(), NULL, r_editlights, r_editlights_current_ambient, r_editlights_current_angles, r_editlights_current_color, r_editlights_current_corona, r_editlights_current_coronasize, r_editlights_current_cubemap, r_editlights_current_diffuse, r_editlights_current_normalmode, r_editlights_current_origin, r_editlights_current_radius, r_editlights_current_realtimemode, r_editlights_current_shadows, r_editlights_current_specular, r_editlights_current_style, r_editlights_cursorlocation, r_editlights_drawproperties, r_shadow_selectedlight, r_shadow_worldlightsarray, vid_conwidth, x, and y.

Referenced by SCR_DrawScreen().

◆ R_Shadow_GetRTLightInfo()

int R_Shadow_GetRTLightInfo ( unsigned int lightindex,
float * origin,
float * radius,
float * color )

Definition at line 4777 of file r_shadow.c.

4778{
4779 unsigned int range;
4780 dlight_t *light;
4781 rtlight_t *rtlight;
4783 if (lightindex >= range)
4784 return -1;
4786 if (!light)
4787 return 0;
4788 rtlight = &light->rtlight;
4789 //if (!(rtlight->flags & flag))
4790 // return 0;
4791 VectorCopy(rtlight->shadoworigin, origin);
4792 *radius = rtlight->radius;
4793 VectorCopy(rtlight->color, color);
4794 return 1;
4795}
rtlight_t rtlight
Definition client.h:301
vec3_t color
typically 1 1 1, can be lower (dim) or higher (overbright)
Definition client.h:114
vec_t radius
size of the light (remove?)
Definition client.h:116

References color, rtlight_t::color, int(), Mem_ExpandableArray_IndexRange(), Mem_ExpandableArray_RecordAtIndex(), origin, r_shadow_worldlightsarray, rtlight_t::radius, dlight_t::rtlight, rtlight_t::shadoworigin, and VectorCopy.

Referenced by Mod_GenerateLightmaps_CreateLights(), and Mod_GenerateLightmaps_LightPoint().

◆ R_Shadow_Init()

void R_Shadow_Init ( void )

Definition at line 601 of file r_shadow.c.

602{
643// Cvar_RegisterVariable(&r_shadow_shadowmapping_lod_bias);
644// Cvar_RegisterVariable(&r_shadow_shadowmapping_lod_scale);
708 maxvertexupdate = 0;
711 vertexupdatenum = 0;
712 maxshadowmark = 0;
713 numshadowmark = 0;
716 shadowmarkcount = 0;
717 maxshadowsides = 0;
718 numshadowsides = 0;
732}
cvar_t r_shadow_bouncegrid
Definition r_shadow.c:198
cvar_t r_shadow_sortsurfaces
Definition r_shadow.c:188
cvar_t r_shadow_realtime_dlight
Definition r_shadow.c:159
cvar_t r_shadow_realtime_world_shadows
Definition r_shadow.c:166
cvar_t r_shadow_realtime_world
Definition r_shadow.c:163
cvar_t r_coronas
Definition r_shadow.c:233
cvar_t r_shadow_realtime_dlight_shadows
Definition r_shadow.c:160
cvar_t r_shadow_realtime_world_lightmaps
Definition r_shadow.c:165
cvar_t gl_flashblend
Definition r_shadow.c:236
cvar_t r_shadow_lightattenuationdividebias
Definition r_shadow.c:153
cvar_t r_shadow_lightattenuationlinearscale
Definition r_shadow.c:154
cvar_t r_shadow_shadowmapping_filterquality
Definition r_shadow.c:173
cvar_t r_shadow_lightradiusscale
Definition r_shadow.c:156
cvar_t r_shadow_shadowmapping_maxsize
Definition r_shadow.c:178
cvar_t r_shadow_culllights_trace
Definition r_shadow.c:190
unsigned char * r_shadow_buffer_surfacesides
Definition r_shadow.c:100
int * r_shadow_buffer_leaflist
Definition r_shadow.c:95
cvar_t r_shadow_bumpscale_bumpmap
Definition r_shadow.c:142
cvar_t r_shadow_realtime_world_compileportalculling
Definition r_shadow.c:170
cvar_t r_shadow_shadowmapping_vsdct
Definition r_shadow.c:176
cvar_t r_shadow_culllights_trace_enlarge
Definition r_shadow.c:192
cvar_t r_shadow_usenormalmap
Definition r_shadow.c:146
unsigned char * r_shadow_buffer_leafpvs
Definition r_shadow.c:94
cvar_t r_shadow_culllights_trace_expand
Definition r_shadow.c:193
cvar_t r_shadow_bouncegrid_static
Definition r_shadow.c:223
cvar_t r_shadow_bouncegrid_static_maxbounce
Definition r_shadow.c:227
cvar_t r_shadow_bouncegrid_static_lightradiusscale
Definition r_shadow.c:226
int maxshadowmark
Definition r_shadow.c:76
cvar_t r_shadow_shadowmapping_nearclip
Definition r_shadow.c:184
cvar_t r_shadow_usebihculling
Definition r_shadow.c:145
cvar_t r_shadow_bouncegrid_dynamic_hitmodels
Definition r_shadow.c:204
cvar_t r_shadow_bouncegrid_includedirectlighting
Definition r_shadow.c:215
cvar_t r_shadow_shadowmapping_bordersize
Definition r_shadow.c:183
int r_shadow_scenenumlights
Definition r_shadow.c:35
unsigned char * r_shadow_buffer_surfacepvs
Definition r_shadow.c:98
int maxshadowsides
Definition r_shadow.c:82
unsigned char * r_shadow_buffer_visitingleafpvs
Definition r_shadow.c:93
cvar_t r_shadow_debuglight
Definition r_shadow.c:143
cvar_t r_shadow_shadowmapping_minsize
Definition r_shadow.c:177
int * vertexupdate
Definition r_shadow.c:88
cvar_t r_shadow_culllights_trace_samples
Definition r_shadow.c:195
cvar_t r_shadow_shadowmapping_depthbits
Definition r_shadow.c:175
cvar_t r_shadow_bouncegrid_dynamic_dlightparticlemultiplier
Definition r_shadow.c:203
cvar_t r_shadow_bouncegrid_dynamic_maxbounce
Definition r_shadow.c:206
cvar_t r_shadow_bouncegrid_static_quality
Definition r_shadow.c:229
int maxshadowtriangles
Definition r_shadow.c:70
cvar_t r_shadow_bouncegrid_static_directionalshading
Definition r_shadow.c:225
cvar_t r_shadow_realtime_dlight_svbspculling
Definition r_shadow.c:161
cvar_t r_shadow_shadowmapping
Definition r_shadow.c:172
cvar_t r_shadow_scissor
Definition r_shadow.c:171
cvar_t r_shadow_bouncegrid_particleintensity
Definition r_shadow.c:220
cvar_t r_shadow_shadowmapping_precision
Definition r_shadow.c:180
cvar_t r_shadow_bouncegrid_lightpathsize
Definition r_shadow.c:217
cvar_t r_shadow_projectdistance
Definition r_shadow.c:157
cvar_t r_shadow_shadowmapping_useshadowsampler
Definition r_shadow.c:174
static void R_Shadow_EditLights_Init(void)
Definition r_shadow.c:5964
int numshadowsides
Definition r_shadow.c:83
cvar_t r_shadow_realtime_world_importlightentitiesfrommap
Definition r_shadow.c:164
int maxshadowvertices
Definition r_shadow.c:73
int maxvertexupdate
Definition r_shadow.c:87
cvar_t r_shadow_bouncegrid_intensity
Definition r_shadow.c:216
unsigned char * r_shadow_buffer_lighttrispvs
Definition r_shadow.c:105
int * shadowmark
Definition r_shadow.c:78
cvar_t r_shadow_bouncegrid_dynamic_bounceminimumintensity
Definition r_shadow.c:200
int * r_shadow_buffer_surfacelist
Definition r_shadow.c:99
cvar_t r_shadow_bouncegrid_rng_seed
Definition r_shadow.c:221
cvar_t r_shadow_bouncegrid_static_bounceminimumintensity
Definition r_shadow.c:224
cvar_t r_shadow_culllights_trace_eyejitter
Definition r_shadow.c:191
cvar_t r_shadow_bouncegrid_dynamic_lightradiusscale
Definition r_shadow.c:205
cvar_t r_shadow_culllights_trace_pad
Definition r_shadow.c:194
cvar_t r_shadow_bouncegrid_dynamic_updateinterval
Definition r_shadow.c:210
cvar_t r_shadow_bouncegrid_static_spacing
Definition r_shadow.c:230
float * shadowvertex3f
Definition r_shadow.c:74
int numshadowmark
Definition r_shadow.c:77
static void r_shadow_shutdown(void)
Definition r_shadow.c:503
cvar_t r_shadow_lightintensityscale
Definition r_shadow.c:155
cvar_t r_shadow_bouncegrid_subsamples
Definition r_shadow.c:231
cvar_t r_shadow_bouncegrid_particlebounceintensity
Definition r_shadow.c:219
rtlight_t ** r_shadow_scenelightlist
Definition r_shadow.c:36
cvar_t r_shadow_realtime_world_compile
Definition r_shadow.c:167
int r_shadow_buffer_numleafpvsbytes
Definition r_shadow.c:92
cvar_t r_shadow_realtime_world_compilesvbsp
Definition r_shadow.c:169
cvar_t r_shadow_bouncegrid_dynamic_y
Definition r_shadow.c:212
cvar_t r_shadow_bouncegrid_rng_type
Definition r_shadow.c:222
unsigned char * shadowsides
Definition r_shadow.c:84
cvar_t r_shadow_frontsidecasting
Definition r_shadow.c:158
cvar_t r_shadow_culllights_pvs
Definition r_shadow.c:189
int shadowmarkcount
Definition r_shadow.c:80
cvar_t r_shadow_realtime_world_compileshadow
Definition r_shadow.c:168
int * shadowsideslist
Definition r_shadow.c:85
cvar_t r_shadow_bouncegrid_blur
Definition r_shadow.c:199
cvar_t r_shadow_bouncegrid_dynamic_maxphotons
Definition r_shadow.c:207
int r_shadow_scenemaxlights
Definition r_shadow.c:34
cvar_t r_shadow_bouncegrid_normalizevectors
Definition r_shadow.c:218
cvar_t r_shadow_deferred
Definition r_shadow.c:144
cvar_t r_shadow_culllights_trace_delay
Definition r_shadow.c:197
unsigned char * r_shadow_buffer_shadowtrispvs
Definition r_shadow.c:103
cvar_t r_shadow_realtime_dlight_portalculling
Definition r_shadow.c:162
static void r_shadow_start(void)
Definition r_shadow.c:416
int r_shadow_buffer_numsurfacepvsbytes
Definition r_shadow.c:97
int * shadowmarklist
Definition r_shadow.c:79
cvar_t r_shadow_bouncegrid_dynamic_z
Definition r_shadow.c:213
cvar_t r_shadow_bouncegrid_dynamic_spacing
Definition r_shadow.c:209
cvar_t r_coronas_occlusionquery
Definition r_shadow.c:235
cvar_t r_shadow_bouncegrid_dynamic_culllightpaths
Definition r_shadow.c:201
cvar_t r_shadow_shadowmapping_bias
Definition r_shadow.c:185
cvar_t r_shadow_bouncegrid_floatcolors
Definition r_shadow.c:214
cvar_t r_shadow_bouncegrid_dynamic_quality
Definition r_shadow.c:208
static void r_shadow_newmap(void)
Definition r_shadow.c:585
cvar_t r_shadow_culllights_trace_tempsamples
Definition r_shadow.c:196
cvar_t r_shadow_bouncegrid_threaded
Definition r_shadow.c:232
cvar_t r_shadow_bouncegrid_dynamic_x
Definition r_shadow.c:211
cvar_t r_shadow_bouncegrid_dynamic_directionalshading
Definition r_shadow.c:202
int * shadowelements
Definition r_shadow.c:71
cvar_t r_shadow_bumpscale_basetexture
Definition r_shadow.c:141
cvar_t r_shadow_shadowmapping_polygonoffset
Definition r_shadow.c:187
cvar_t r_shadow_bouncegrid_static_maxphotons
Definition r_shadow.c:228
int vertexupdatenum
Definition r_shadow.c:90
cvar_t r_shadow_shadowmapping_texturesize
Definition r_shadow.c:179
cvar_t r_coronas_occlusionsizescale
Definition r_shadow.c:234
cvar_t r_shadow_shadowmapping_polygonfactor
Definition r_shadow.c:186
int * vertexremap
Definition r_shadow.c:89
void Mem_ExpandableArray_NewArray(memexpandablearray_t *l, mempool_t *mempool, size_t recordsize, int numrecordsperarray)
Definition zone.c:675

References Cvar_RegisterVariable(), gl_flashblend, maxshadowmark, maxshadowsides, maxshadowtriangles, maxshadowvertices, maxvertexupdate, Mem_ExpandableArray_NewArray(), NULL, numshadowmark, numshadowsides, r_coronas, r_coronas_occlusionquery, r_coronas_occlusionsizescale, r_main_mempool, R_RegisterModule(), r_shadow_bouncegrid, r_shadow_bouncegrid_blur, r_shadow_bouncegrid_dynamic_bounceminimumintensity, r_shadow_bouncegrid_dynamic_culllightpaths, r_shadow_bouncegrid_dynamic_directionalshading, r_shadow_bouncegrid_dynamic_dlightparticlemultiplier, r_shadow_bouncegrid_dynamic_hitmodels, r_shadow_bouncegrid_dynamic_lightradiusscale, r_shadow_bouncegrid_dynamic_maxbounce, r_shadow_bouncegrid_dynamic_maxphotons, r_shadow_bouncegrid_dynamic_quality, r_shadow_bouncegrid_dynamic_spacing, r_shadow_bouncegrid_dynamic_updateinterval, r_shadow_bouncegrid_dynamic_x, r_shadow_bouncegrid_dynamic_y, r_shadow_bouncegrid_dynamic_z, r_shadow_bouncegrid_floatcolors, r_shadow_bouncegrid_includedirectlighting, r_shadow_bouncegrid_intensity, r_shadow_bouncegrid_lightpathsize, r_shadow_bouncegrid_normalizevectors, r_shadow_bouncegrid_particlebounceintensity, r_shadow_bouncegrid_particleintensity, r_shadow_bouncegrid_rng_seed, r_shadow_bouncegrid_rng_type, r_shadow_bouncegrid_static, r_shadow_bouncegrid_static_bounceminimumintensity, r_shadow_bouncegrid_static_directionalshading, r_shadow_bouncegrid_static_lightradiusscale, r_shadow_bouncegrid_static_maxbounce, r_shadow_bouncegrid_static_maxphotons, r_shadow_bouncegrid_static_quality, r_shadow_bouncegrid_static_spacing, r_shadow_bouncegrid_subsamples, r_shadow_bouncegrid_threaded, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, r_shadow_buffer_lighttrispvs, r_shadow_buffer_numleafpvsbytes, r_shadow_buffer_numsurfacepvsbytes, r_shadow_buffer_shadowtrispvs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, r_shadow_buffer_surfacesides, r_shadow_buffer_visitingleafpvs, r_shadow_bumpscale_basetexture, r_shadow_bumpscale_bumpmap, r_shadow_culllights_pvs, r_shadow_culllights_trace, r_shadow_culllights_trace_delay, r_shadow_culllights_trace_enlarge, r_shadow_culllights_trace_expand, r_shadow_culllights_trace_eyejitter, r_shadow_culllights_trace_pad, r_shadow_culllights_trace_samples, r_shadow_culllights_trace_tempsamples, r_shadow_debuglight, r_shadow_deferred, R_Shadow_EditLights_Init(), r_shadow_frontsidecasting, r_shadow_gloss, r_shadow_gloss2exponent, r_shadow_gloss2intensity, r_shadow_glossexact, r_shadow_glossexponent, r_shadow_glossintensity, r_shadow_lightattenuationdividebias, r_shadow_lightattenuationlinearscale, r_shadow_lightintensityscale, r_shadow_lightradiusscale, r_shadow_newmap(), r_shadow_projectdistance, r_shadow_realtime_dlight, r_shadow_realtime_dlight_portalculling, r_shadow_realtime_dlight_shadows, r_shadow_realtime_dlight_svbspculling, r_shadow_realtime_world, r_shadow_realtime_world_compile, r_shadow_realtime_world_compileportalculling, r_shadow_realtime_world_compileshadow, r_shadow_realtime_world_compilesvbsp, r_shadow_realtime_world_importlightentitiesfrommap, r_shadow_realtime_world_lightmaps, r_shadow_realtime_world_shadows, r_shadow_scenelightlist, r_shadow_scenemaxlights, r_shadow_scenenumlights, r_shadow_scissor, r_shadow_shadowmapping, r_shadow_shadowmapping_bias, r_shadow_shadowmapping_bordersize, r_shadow_shadowmapping_depthbits, r_shadow_shadowmapping_filterquality, r_shadow_shadowmapping_maxsize, r_shadow_shadowmapping_minsize, r_shadow_shadowmapping_nearclip, r_shadow_shadowmapping_polygonfactor, r_shadow_shadowmapping_polygonoffset, r_shadow_shadowmapping_precision, r_shadow_shadowmapping_texturesize, r_shadow_shadowmapping_useshadowsampler, r_shadow_shadowmapping_vsdct, r_shadow_shutdown(), r_shadow_sortsurfaces, r_shadow_start(), r_shadow_usebihculling, r_shadow_usenormalmap, r_shadow_worldlightsarray, shadowelements, shadowmark, shadowmarkcount, shadowmarklist, shadowsides, shadowsideslist, shadowvertex3f, vertexremap, vertexupdate, and vertexupdatenum.

Referenced by Render_Init().

◆ R_Shadow_UpdateBounceGridTexture()

void R_Shadow_UpdateBounceGridTexture ( void )

Definition at line 2755 of file r_shadow.c.

2756{
2757 int flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;
2759 qbool enable = false;
2760 qbool settingschanged;
2761
2762 enable = R_Shadow_BounceGrid_CheckEnable(flag);
2763
2765
2766 // changing intensity does not require an update
2768
2769 settingschanged = memcmp(&r_shadow_bouncegrid_state.settings, &settings, sizeof(settings)) != 0;
2770
2771 // when settings change, we free everything as it is just simpler that way.
2772 if (settingschanged || !enable)
2773 {
2774 // not enabled, make sure we free anything we don't need anymore.
2775 if (r_shadow_bouncegrid_state.texture)
2776 {
2779 }
2781 r_shadow_bouncegrid_state.numpixels = 0;
2782 r_shadow_bouncegrid_state.numphotons = 0;
2783 r_shadow_bouncegrid_state.directional = false;
2784
2785 if (!enable)
2786 return;
2787 }
2788
2789 // if all the settings seem identical to the previous update, return
2790 if (r_shadow_bouncegrid_state.texture && (settings.staticmode || host.realtime < r_shadow_bouncegrid_state.lastupdatetime + r_shadow_bouncegrid_dynamic_updateinterval.value) && !settingschanged)
2791 return;
2792
2793 // store the new settings
2794 r_shadow_bouncegrid_state.settings = settings;
2795
2797
2798 // allocate the highpixels array we'll be accumulating light into
2799 if (r_shadow_bouncegrid_state.blurpixels[0] == NULL)
2800 r_shadow_bouncegrid_state.blurpixels[0] = (float *)Mem_Alloc(r_main_mempool, r_shadow_bouncegrid_state.numpixels * sizeof(float[4]));
2801 if (r_shadow_bouncegrid_state.settings.blur && r_shadow_bouncegrid_state.blurpixels[1] == NULL)
2802 r_shadow_bouncegrid_state.blurpixels[1] = (float *)Mem_Alloc(r_main_mempool, r_shadow_bouncegrid_state.numpixels * sizeof(float[4]));
2803 r_shadow_bouncegrid_state.highpixels_index = 0;
2804 r_shadow_bouncegrid_state.highpixels = r_shadow_bouncegrid_state.blurpixels[r_shadow_bouncegrid_state.highpixels_index];
2805
2806 // set up the tracking of photon data
2807 if (r_shadow_bouncegrid_state.photons == NULL)
2809 if (r_shadow_bouncegrid_state.photons_tasks == NULL)
2811 r_shadow_bouncegrid_state.numphotons = 0;
2812
2813 // set up the tracking of slice tasks
2814 if (r_shadow_bouncegrid_state.slices_tasks == NULL)
2816
2817 memset(&r_shadow_bouncegrid_state.cleartex_task, 0, sizeof(taskqueue_task_t));
2818 memset(&r_shadow_bouncegrid_state.assignphotons_task, 0, sizeof(taskqueue_task_t));
2819 memset(&r_shadow_bouncegrid_state.enqueuephotons_task, 0, sizeof(taskqueue_task_t));
2820 memset(r_shadow_bouncegrid_state.photons_tasks, 0, r_shadow_bouncegrid_state.settings.maxphotons * sizeof(taskqueue_task_t));
2821 memset(&r_shadow_bouncegrid_state.photons_done_task, 0, sizeof(taskqueue_task_t));
2822 memset(&r_shadow_bouncegrid_state.enqueue_slices_task, 0, sizeof(taskqueue_task_t));
2823 memset(r_shadow_bouncegrid_state.slices_tasks, 0, r_shadow_bouncegrid_state.resolution[2] * sizeof(taskqueue_task_t));
2824 memset(&r_shadow_bouncegrid_state.slices_done_task, 0, sizeof(taskqueue_task_t));
2825 memset(&r_shadow_bouncegrid_state.blurpixels_task, 0, sizeof(taskqueue_task_t));
2826
2827 // clear the texture
2830
2831 // calculate weighting factors for distributing photons among the lights
2833 TaskQueue_Enqueue(1, &r_shadow_bouncegrid_state.assignphotons_task);
2834
2835 // enqueue tasks to trace the photons from lights
2837 TaskQueue_Enqueue(1, &r_shadow_bouncegrid_state.enqueuephotons_task);
2838
2839 // accumulate the light paths into texture
2841 TaskQueue_Enqueue(1, &r_shadow_bouncegrid_state.enqueue_slices_task);
2842
2843 // apply a mild blur filter to the texture
2845 TaskQueue_Enqueue(1, &r_shadow_bouncegrid_state.blurpixels_task);
2846
2848 R_TimeReport("bouncegrid_gen");
2849
2850 // convert the pixels to lower precision and upload the texture
2851 // this unfortunately has to run on the main thread for OpenGL calls, so we have to block on the previous task...
2853 R_TimeReport("bouncegrid_tex");
2854
2855 // after we compute the static lighting we don't need to keep the highpixels array around
2856 if (settings.staticmode)
2858}
static void R_Shadow_BounceGrid_BlurPixels_Task(taskqueue_task_t *t)
Definition r_shadow.c:2391
static void R_Shadow_BounceGrid_ClearTex_Task(taskqueue_task_t *t)
Definition r_shadow.c:2592
static void R_Shadow_BounceGrid_UpdateSpacing(void)
Definition r_shadow.c:1751
static void R_Shadow_BounceGrid_EnqueueSlices_Task(taskqueue_task_t *t)
Definition r_shadow.c:2341
static void R_Shadow_BounceGrid_FreeHighPixels(void)
Definition r_shadow.c:490
static void R_Shadow_BounceGrid_EnqueuePhotons_Task(taskqueue_task_t *t)
Definition r_shadow.c:2734
static void R_Shadow_BounceGrid_ConvertPixelsAndUpload(void)
Definition r_shadow.c:2418
static void R_Shadow_BounceGrid_AssignPhotons_Task(taskqueue_task_t *t)
Definition r_shadow.c:1922
static void R_Shadow_BounceGrid_GenerateSettings(r_shadow_bouncegrid_settings_t *settings)
Definition r_shadow.c:1708
static qbool R_Shadow_BounceGrid_CheckEnable(int flag)
Definition r_shadow.c:1674
void TaskQueue_WaitForTaskDone(taskqueue_task_t *t)
Definition taskqueue.c:199
void TaskQueue_Setup(taskqueue_task_t *t, taskqueue_task_t *preceding, void(*func)(taskqueue_task_t *), size_t i0, size_t i1, void *p0, void *p1)
Definition taskqueue.c:282
void TaskQueue_Enqueue(int numtasks, taskqueue_task_t *tasks)
Definition taskqueue.c:105

References host, LIGHTFLAG_NORMALMODE, LIGHTFLAG_REALTIMEMODE, Mem_Alloc, NULL, R_FreeTexture(), r_main_mempool, r_refdef, R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_BounceGrid_BlurPixels_Task(), R_Shadow_BounceGrid_CheckEnable(), R_Shadow_BounceGrid_ClearTex_Task(), R_Shadow_BounceGrid_ConvertPixelsAndUpload(), r_shadow_bouncegrid_dynamic_updateinterval, R_Shadow_BounceGrid_EnqueuePhotons_Task(), R_Shadow_BounceGrid_EnqueueSlices_Task(), R_Shadow_BounceGrid_FreeHighPixels(), R_Shadow_BounceGrid_GenerateSettings(), r_shadow_bouncegrid_intensity, r_shadow_bouncegrid_state, R_Shadow_BounceGrid_UpdateSpacing(), R_TimeReport(), r_shadow_bouncegrid_settings_t::staticmode, TaskQueue_Enqueue(), TaskQueue_Setup(), and TaskQueue_WaitForTaskDone().

Referenced by R_RenderView().

◆ R_SkinFrame_Find()

skinframe_t * R_SkinFrame_Find ( const char * name,
int textureflags,
int comparewidth,
int compareheight,
int comparecrc,
qbool add )

Definition at line 2240 of file gl_rmain.c.

2241{
2242 skinframe_t *item;
2243 int compareflags = textureflags & TEXF_IMPORTANTBITS;
2244 int hashindex;
2245 char basename[MAX_QPATH];
2246
2247 Image_StripImageExtension(name, basename, sizeof(basename));
2248
2249 hashindex = CRC_Block((unsigned char *)basename, strlen(basename)) & (SKINFRAME_HASH - 1);
2250 for (item = r_skinframe.hash[hashindex];item;item = item->next)
2251 if (!strcmp(item->basename, basename) &&
2252 item->textureflags == compareflags &&
2253 item->comparewidth == comparewidth &&
2254 item->compareheight == compareheight &&
2255 item->comparecrc == comparecrc)
2256 break;
2257
2258 if (!item)
2259 {
2260 if (!add)
2261 return NULL;
2263 memset(item, 0, sizeof(*item));
2264 dp_strlcpy(item->basename, basename, sizeof(item->basename));
2265 item->textureflags = compareflags;
2266 item->comparewidth = comparewidth;
2267 item->compareheight = compareheight;
2268 item->comparecrc = comparecrc;
2269 item->next = r_skinframe.hash[hashindex];
2270 r_skinframe.hash[hashindex] = item;
2271 }
2272 else if (textureflags & TEXF_FORCE_RELOAD)
2274
2276 return item;
2277}
unsigned short CRC_Block(const unsigned char *data, size_t size)
Definition com_crc16.c:75
r_skinframe_t r_skinframe
Definition gl_rmain.c:2166
#define SKINFRAME_HASH
Definition gl_rmain.c:2157
void R_SkinFrame_PurgeSkinFrame(skinframe_t *s)
Definition gl_rmain.c:2184
void R_SkinFrame_MarkUsed(skinframe_t *skinframe)
Definition gl_rmain.c:2176
void Image_StripImageExtension(const char *in, char *out, size_t size_out)
Definition image.c:913
#define TEXF_IMPORTANTBITS
Definition r_textures.h:39
#define TEXF_FORCE_RELOAD
Definition r_textures.h:41
struct skinframe_s * next
Definition r_textures.h:142
int compareheight
Definition r_textures.h:146
char basename[MAX_QPATH]
Definition r_textures.h:143

References skinframe_t::basename, skinframe_t::comparecrc, skinframe_t::compareheight, skinframe_t::comparewidth, CRC_Block(), dp_strlcpy, Image_StripImageExtension(), MAX_QPATH, Mem_ExpandableArray_AllocRecord(), name, skinframe_t::next, NULL, r_skinframe, R_SkinFrame_MarkUsed(), R_SkinFrame_PurgeSkinFrame(), SKINFRAME_HASH, strlen(), TEXF_FORCE_RELOAD, TEXF_IMPORTANTBITS, and skinframe_t::textureflags.

Referenced by R_LoadQWSkin(), R_SkinFrame_LoadExternal(), R_SkinFrame_LoadExternal_SkinFrame(), R_SkinFrame_LoadInternal8bit(), R_SkinFrame_LoadInternalBGRA(), R_SkinFrame_LoadInternalQuake(), R_SkinFrame_LoadInternalUsingTexture(), and R_SkinFrame_LoadMissing().

◆ R_SkinFrame_FindNextByName()

skinframe_t * R_SkinFrame_FindNextByName ( skinframe_t * last,
const char * name )

Definition at line 2217 of file gl_rmain.c.

2217 {
2218 skinframe_t *item;
2219 char basename[MAX_QPATH];
2220
2221 Image_StripImageExtension(name, basename, sizeof(basename));
2222
2223 if( last == NULL ) {
2224 int hashindex;
2225 hashindex = CRC_Block((unsigned char *)basename, strlen(basename)) & (SKINFRAME_HASH - 1);
2226 item = r_skinframe.hash[hashindex];
2227 } else {
2228 item = last->next;
2229 }
2230
2231 // linearly search through the hash bucket
2232 for( ; item ; item = item->next ) {
2233 if( !strcmp( item->basename, basename ) ) {
2234 return item;
2235 }
2236 }
2237 return NULL;
2238}

References skinframe_t::basename, CRC_Block(), Image_StripImageExtension(), MAX_QPATH, name, skinframe_t::next, NULL, r_skinframe, SKINFRAME_HASH, and strlen().

◆ R_SkinFrame_LoadExternal()

skinframe_t * R_SkinFrame_LoadExternal ( const char * name,
int textureflags,
qbool complain,
qbool fallbacknotexture )

Definition at line 2314 of file gl_rmain.c.

2315{
2316 skinframe_t *skinframe;
2317
2318 if (cls.state == ca_dedicated)
2319 return NULL;
2320
2321 // return an existing skinframe if already loaded
2322 skinframe = R_SkinFrame_Find(name, textureflags, 0, 0, 0, false);
2323 if (skinframe && skinframe->base)
2324 return skinframe;
2325
2326 // if the skinframe doesn't exist this will create it
2327 return R_SkinFrame_LoadExternal_SkinFrame(skinframe, name, textureflags, complain, fallbacknotexture);
2328}
@ ca_dedicated
Definition client.h:530
skinframe_t * R_SkinFrame_Find(const char *name, int textureflags, int comparewidth, int compareheight, int comparecrc, qbool add)
Definition gl_rmain.c:2240
skinframe_t * R_SkinFrame_LoadExternal_SkinFrame(skinframe_t *skinframe, const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
Definition gl_rmain.c:2331
struct rtexture_s * base
Definition r_textures.h:129

References skinframe_t::base, ca_dedicated, cls, name, NULL, R_SkinFrame_Find(), and R_SkinFrame_LoadExternal_SkinFrame().

Referenced by Draw_CachePic_Flags(), Draw_GetPicTexture(), Draw_IsPicLoaded(), Mod_CreateShaderPassFromQ3ShaderLayer(), Mod_IDP0_Load(), Mod_IDS2_Load(), Mod_LoadTextureFromQ3Shader(), Mod_Q1BSP_LoadTextures(), Mod_Sprite_SharedSetup(), R_InitParticleTexture(), and R_ReplaceWorldTexture_f().

◆ R_SkinFrame_LoadExternal_SkinFrame()

skinframe_t * R_SkinFrame_LoadExternal_SkinFrame ( skinframe_t * skinframe,
const char * name,
int textureflags,
qbool complain,
qbool fallbacknotexture )

Definition at line 2331 of file gl_rmain.c.

2332{
2333 int j;
2334 unsigned char *pixels;
2335 unsigned char *bumppixels;
2336 unsigned char *basepixels = NULL;
2337 int basepixels_width = 0;
2338 int basepixels_height = 0;
2339 rtexture_t *ddsbase = NULL;
2340 qbool ddshasalpha = false;
2341 float ddsavgcolor[4];
2342 char basename[MAX_QPATH];
2343 int miplevel = R_PicmipForFlags(textureflags);
2344 int savemiplevel = miplevel;
2345 int mymiplevel;
2346 char vabuf[1024];
2347
2348 if (cls.state == ca_dedicated)
2349 return NULL;
2350
2351 Image_StripImageExtension(name, basename, sizeof(basename));
2352
2353 // check for DDS texture file first
2354 if (!r_loaddds || !(ddsbase = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s.dds", basename), vid.sRGB3D, textureflags, &ddshasalpha, ddsavgcolor, miplevel, false)))
2355 {
2356 basepixels = loadimagepixelsbgra(name, complain, true, false, &miplevel);
2357 if (basepixels == NULL && fallbacknotexture)
2358 basepixels = Image_GenerateNoTexture();
2359 if (basepixels == NULL)
2360 return NULL;
2361 }
2362
2363 // FIXME handle miplevel
2364
2365 if (developer_loading.integer)
2366 Con_Printf("loading skin \"%s\"\n", name);
2367
2368 // we've got some pixels to store, so really allocate this new texture now
2369 if (!skinframe)
2370 skinframe = R_SkinFrame_Find(name, textureflags, 0, 0, 0, true);
2371 textureflags &= ~TEXF_FORCE_RELOAD;
2372 skinframe->stain = NULL;
2373 skinframe->merged = NULL;
2374 skinframe->base = NULL;
2375 skinframe->pants = NULL;
2376 skinframe->shirt = NULL;
2377 skinframe->nmap = NULL;
2378 skinframe->gloss = NULL;
2379 skinframe->glow = NULL;
2380 skinframe->fog = NULL;
2381 skinframe->reflect = NULL;
2382 skinframe->hasalpha = false;
2383 // we could store the q2animname here too
2384
2385 if (ddsbase)
2386 {
2387 skinframe->base = ddsbase;
2388 skinframe->hasalpha = ddshasalpha;
2389 VectorCopy(ddsavgcolor, skinframe->avgcolor);
2390 if (r_loadfog && skinframe->hasalpha)
2391 skinframe->fog = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_mask.dds", skinframe->basename), false, textureflags | TEXF_ALPHA, NULL, NULL, miplevel, true);
2392 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2393 }
2394 else
2395 {
2396 basepixels_width = image_width;
2397 basepixels_height = image_height;
2398 skinframe->base = R_LoadTexture2D (r_main_texturepool, skinframe->basename, basepixels_width, basepixels_height, basepixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags & (gl_texturecompression_color.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), miplevel, NULL);
2399 if (textureflags & TEXF_ALPHA)
2400 {
2401 for (j = 3;j < basepixels_width * basepixels_height * 4;j += 4)
2402 {
2403 if (basepixels[j] < 255)
2404 {
2405 skinframe->hasalpha = true;
2406 break;
2407 }
2408 }
2409 if (r_loadfog && skinframe->hasalpha)
2410 {
2411 // has transparent pixels
2412 pixels = (unsigned char *)Mem_Alloc(tempmempool, image_width * image_height * 4);
2413 for (j = 0;j < image_width * image_height * 4;j += 4)
2414 {
2415 pixels[j+0] = 255;
2416 pixels[j+1] = 255;
2417 pixels[j+2] = 255;
2418 pixels[j+3] = basepixels[j+3];
2419 }
2420 skinframe->fog = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_mask", skinframe->basename), image_width, image_height, pixels, TEXTYPE_BGRA, textureflags & (gl_texturecompression_color.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), miplevel, NULL);
2422 }
2423 }
2424 R_SKINFRAME_LOAD_AVERAGE_COLORS(basepixels_width * basepixels_height, basepixels[4 * pix + comp]);
2425#ifndef USE_GLES2
2426 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2427 if (r_savedds && skinframe->base)
2428 R_SaveTextureDDSFile(skinframe->base, va(vabuf, sizeof(vabuf), "dds/%s.dds", skinframe->basename), r_texture_dds_save.integer < 2, skinframe->hasalpha);
2429 if (r_savedds && skinframe->fog)
2430 R_SaveTextureDDSFile(skinframe->fog, va(vabuf, sizeof(vabuf), "dds/%s_mask.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2431#endif
2432 }
2433
2434 if (r_loaddds)
2435 {
2436 mymiplevel = savemiplevel;
2437 if (r_loadnormalmap)
2438 skinframe->nmap = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_norm.dds", skinframe->basename), false, (TEXF_ALPHA | textureflags) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP), NULL, NULL, mymiplevel, true);
2439 skinframe->glow = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_glow.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2440 if (r_loadgloss)
2441 skinframe->gloss = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_gloss.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2442 skinframe->pants = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_pants.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2443 skinframe->shirt = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_shirt.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2444 skinframe->reflect = R_LoadTextureDDSFile(r_main_texturepool, va(vabuf, sizeof(vabuf), "dds/%s_reflect.dds", skinframe->basename), vid.sRGB3D, textureflags, NULL, NULL, mymiplevel, true);
2445 }
2446
2447 // _norm is the name used by tenebrae and has been adopted as standard
2448 if (r_loadnormalmap && skinframe->nmap == NULL)
2449 {
2450 mymiplevel = savemiplevel;
2451 if ((pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_norm", skinframe->basename), false, false, false, &mymiplevel)) != NULL)
2452 {
2453 skinframe->nmap = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nmap", skinframe->basename), image_width, image_height, pixels, TEXTYPE_BGRA, (TEXF_ALPHA | textureflags) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP) & (gl_texturecompression_normal.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2455 pixels = NULL;
2456 }
2457 else if (r_shadow_bumpscale_bumpmap.value > 0 && (bumppixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_bump", skinframe->basename), false, false, false, &mymiplevel)) != NULL)
2458 {
2459 pixels = (unsigned char *)Mem_Alloc(tempmempool, image_width * image_height * 4);
2461 skinframe->nmap = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nmap", skinframe->basename), image_width, image_height, pixels, TEXTYPE_BGRA, (TEXF_ALPHA | textureflags) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP) & (gl_texturecompression_normal.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2463 Mem_Free(bumppixels);
2464 }
2465 else if (r_shadow_bumpscale_basetexture.value > 0)
2466 {
2467 pixels = (unsigned char *)Mem_Alloc(tempmempool, basepixels_width * basepixels_height * 4);
2468 Image_HeightmapToNormalmap_BGRA(basepixels, pixels, basepixels_width, basepixels_height, false, r_shadow_bumpscale_basetexture.value);
2469 skinframe->nmap = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nmap", skinframe->basename), basepixels_width, basepixels_height, pixels, TEXTYPE_BGRA, (TEXF_ALPHA | textureflags) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP) & (gl_texturecompression_normal.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2471 }
2472#ifndef USE_GLES2
2473 if (r_savedds && skinframe->nmap)
2474 R_SaveTextureDDSFile(skinframe->nmap, va(vabuf, sizeof(vabuf), "dds/%s_norm.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2475#endif
2476 }
2477
2478 // _luma is supported only for tenebrae compatibility
2479 // _blend and .blend are supported only for Q3 & QL compatibility, this hack can be removed if better Q3 shader support is implemented
2480 // _glow is the preferred name
2481 mymiplevel = savemiplevel;
2482 if (skinframe->glow == NULL && ((pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), false, false, false, &mymiplevel)) || (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s.blend", skinframe->basename), false, false, false, &mymiplevel)) || (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_blend", skinframe->basename), false, false, false, &mymiplevel)) || (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_luma", skinframe->basename), false, false, false, &mymiplevel))))
2483 {
2484 skinframe->glow = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_glow", skinframe->basename), image_width, image_height, pixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags & (gl_texturecompression_glow.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2485#ifndef USE_GLES2
2486 if (r_savedds && skinframe->glow)
2487 R_SaveTextureDDSFile(skinframe->glow, va(vabuf, sizeof(vabuf), "dds/%s_glow.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2488#endif
2490 }
2491
2492 mymiplevel = savemiplevel;
2493 if (skinframe->gloss == NULL && r_loadgloss && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_gloss", skinframe->basename), false, false, false, &mymiplevel)))
2494 {
2495 skinframe->gloss = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_gloss", skinframe->basename), image_width, image_height, pixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, (TEXF_ALPHA | textureflags) & (gl_texturecompression_gloss.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2496#ifndef USE_GLES2
2497 if (r_savedds && skinframe->gloss)
2498 R_SaveTextureDDSFile(skinframe->gloss, va(vabuf, sizeof(vabuf), "dds/%s_gloss.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2499#endif
2501 pixels = NULL;
2502 }
2503
2504 mymiplevel = savemiplevel;
2505 if (skinframe->pants == NULL && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_pants", skinframe->basename), false, false, false, &mymiplevel)))
2506 {
2507 skinframe->pants = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_pants", skinframe->basename), image_width, image_height, pixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags & (gl_texturecompression_color.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2508#ifndef USE_GLES2
2509 if (r_savedds && skinframe->pants)
2510 R_SaveTextureDDSFile(skinframe->pants, va(vabuf, sizeof(vabuf), "dds/%s_pants.dds", skinframe->basename), r_texture_dds_save.integer < 2, false);
2511#endif
2513 pixels = NULL;
2514 }
2515
2516 mymiplevel = savemiplevel;
2517 if (skinframe->shirt == NULL && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_shirt", skinframe->basename), false, false, false, &mymiplevel)))
2518 {
2519 skinframe->shirt = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_shirt", skinframe->basename), image_width, image_height, pixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags & (gl_texturecompression_color.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2520#ifndef USE_GLES2
2521 if (r_savedds && skinframe->shirt)
2522 R_SaveTextureDDSFile(skinframe->shirt, va(vabuf, sizeof(vabuf), "dds/%s_shirt.dds", skinframe->basename), r_texture_dds_save.integer < 2, false);
2523#endif
2525 pixels = NULL;
2526 }
2527
2528 mymiplevel = savemiplevel;
2529 if (skinframe->reflect == NULL && (pixels = loadimagepixelsbgra(va(vabuf, sizeof(vabuf), "%s_reflect", skinframe->basename), false, false, false, &mymiplevel)))
2530 {
2531 skinframe->reflect = R_LoadTexture2D (r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_reflect", skinframe->basename), image_width, image_height, pixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags & (gl_texturecompression_reflectmask.integer && gl_texturecompression.integer ? ~0 : ~TEXF_COMPRESS), mymiplevel, NULL);
2532#ifndef USE_GLES2
2533 if (r_savedds && skinframe->reflect)
2534 R_SaveTextureDDSFile(skinframe->reflect, va(vabuf, sizeof(vabuf), "dds/%s_reflect.dds", skinframe->basename), r_texture_dds_save.integer < 2, true);
2535#endif
2537 pixels = NULL;
2538 }
2539
2540 if (basepixels)
2541 Mem_Free(basepixels);
2542
2543 return skinframe;
2544}
static qbool r_savedds
Definition gl_rmain.c:51
qbool r_loadfog
Definition gl_rmain.c:49
static qbool r_loadnormalmap
Definition gl_rmain.c:47
#define R_SKINFRAME_LOAD_AVERAGE_COLORS(cnt, getpixel)
Definition gl_rmain.c:2279
static qbool r_loadgloss
Definition gl_rmain.c:48
static qbool r_loaddds
Definition gl_rmain.c:50
cvar_t gl_texturecompression
Definition gl_textures.c:37
cvar_t gl_texturecompression_reflectmask
Definition gl_textures.c:47
cvar_t gl_texturecompression_color
Definition gl_textures.c:38
rtexture_t * R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filename, qbool srgb, int flags, qbool *hasalphaflag, float *avgcolor, int miplevel, qbool optionaltexture)
int R_SaveTextureDDSFile(rtexture_t *rt, const char *filename, qbool skipuncompressed, qbool hasalpha)
cvar_t gl_texturecompression_glow
Definition gl_textures.c:41
cvar_t gl_texturecompression_gloss
Definition gl_textures.c:40
int R_PicmipForFlags(int flags)
cvar_t gl_texturecompression_normal
Definition gl_textures.c:39
GLint GLenum GLenum GLvoid * pixels
Definition glquake.h:706
cvar_t developer_loading
Definition host.c:52
unsigned char * Image_GenerateNoTexture(void)
Definition image.c:1876
int image_height
Definition image.c:10
void Image_HeightmapToNormalmap_BGRA(const unsigned char *inpixels, unsigned char *outpixels, int width, int height, int clamp, float bumpscale)
Definition image.c:1758
unsigned char * loadimagepixelsbgra(const char *filename, qbool complain, qbool allowFixtrans, qbool convertsRGB, int *miplevel)
Definition image.c:1034
int image_width
Definition image.c:9
cvar_t r_mipnormalmaps
#define TEXF_MIPMAP
Definition r_textures.h:11
#define TEXF_COMPRESS
Definition r_textures.h:23
@ TEXTYPE_SRGB_BGRA
Definition r_textures.h:73
@ TEXTYPE_BGRA
Definition r_textures.h:53
struct rtexture_s * pants
Definition r_textures.h:130
struct rtexture_s * stain
Definition r_textures.h:127
struct rtexture_s * merged
Definition r_textures.h:128
struct rtexture_s * shirt
Definition r_textures.h:131
struct rtexture_s * reflect
Definition r_textures.h:136
struct rtexture_s * gloss
Definition r_textures.h:133
struct rtexture_s * fog
Definition r_textures.h:135
float avgcolor[4]
Definition r_textures.h:155
struct rtexture_s * nmap
Definition r_textures.h:132
struct rtexture_s * glow
Definition r_textures.h:134
qbool hasalpha
Definition r_textures.h:153

References skinframe_t::avgcolor, skinframe_t::base, skinframe_t::basename, ca_dedicated, cls, Con_Printf(), developer_loading, skinframe_t::fog, gl_texturecompression, gl_texturecompression_color, gl_texturecompression_gloss, gl_texturecompression_glow, gl_texturecompression_normal, gl_texturecompression_reflectmask, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, Image_GenerateNoTexture(), image_height, Image_HeightmapToNormalmap_BGRA(), Image_StripImageExtension(), image_width, loadimagepixelsbgra(), MAX_QPATH, Mem_Alloc, Mem_Free, skinframe_t::merged, name, skinframe_t::nmap, NULL, skinframe_t::pants, pixels, r_loaddds, r_loadfog, r_loadgloss, r_loadnormalmap, R_LoadTexture2D(), R_LoadTextureDDSFile(), r_main_texturepool, r_mipnormalmaps, R_PicmipForFlags(), r_savedds, R_SaveTextureDDSFile(), r_shadow_bumpscale_basetexture, r_shadow_bumpscale_bumpmap, R_SkinFrame_Find(), R_SKINFRAME_LOAD_AVERAGE_COLORS, r_texture_dds_save, skinframe_t::reflect, skinframe_t::shirt, skinframe_t::stain, tempmempool, TEXF_ALPHA, TEXF_COMPRESS, TEXF_FORCE_RELOAD, TEXF_MIPMAP, TEXTYPE_BGRA, TEXTYPE_SRGB_BGRA, va(), VectorCopy, and vid.

Referenced by Draw_CachePic_Flags(), and R_SkinFrame_LoadExternal().

◆ R_SkinFrame_LoadInternal8bit()

skinframe_t * R_SkinFrame_LoadInternal8bit ( const char * name,
int textureflags,
const unsigned char * skindata,
int width,
int height,
const unsigned int * palette,
const unsigned int * alphapalette )

Definition at line 2749 of file gl_rmain.c.

2750{
2751 int i;
2752 skinframe_t *skinframe;
2753 char vabuf[1024];
2754
2755 if (cls.state == ca_dedicated)
2756 return NULL;
2757
2758 // if already loaded just return it, otherwise make a new skinframe
2759 skinframe = R_SkinFrame_Find(name, textureflags, width, height, skindata ? CRC_Block(skindata, width*height) : 0, true);
2760 if (skinframe->base)
2761 return skinframe;
2762 textureflags &= ~TEXF_FORCE_RELOAD;
2763
2764 skinframe->stain = NULL;
2765 skinframe->merged = NULL;
2766 skinframe->base = NULL;
2767 skinframe->pants = NULL;
2768 skinframe->shirt = NULL;
2769 skinframe->nmap = NULL;
2770 skinframe->gloss = NULL;
2771 skinframe->glow = NULL;
2772 skinframe->fog = NULL;
2773 skinframe->reflect = NULL;
2774 skinframe->hasalpha = false;
2775
2776 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2777 if (!skindata)
2778 return NULL;
2779
2780 if (developer_loading.integer)
2781 Con_Printf("loading embedded 8bit image \"%s\"\n", name);
2782
2783 skinframe->base = skinframe->merged = R_LoadTexture2D(r_main_texturepool, skinframe->basename, width, height, skindata, TEXTYPE_PALETTE, textureflags, -1, palette);
2784 if ((textureflags & TEXF_ALPHA) && alphapalette)
2785 {
2786 for (i = 0;i < width * height;i++)
2787 {
2788 if (((unsigned char *)palette)[skindata[i]*4+3] < 255)
2789 {
2790 skinframe->hasalpha = true;
2791 break;
2792 }
2793 }
2794 if (r_loadfog && skinframe->hasalpha)
2795 skinframe->fog = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_fog", skinframe->basename), width, height, skindata, TEXTYPE_PALETTE, textureflags, -1, alphapalette);
2796 }
2797
2798 R_SKINFRAME_LOAD_AVERAGE_COLORS(width * height, ((unsigned char *)palette)[skindata[pix]*4 + comp]);
2799 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2800
2801 return skinframe;
2802}
@ TEXTYPE_PALETTE
Definition r_textures.h:49

References skinframe_t::base, skinframe_t::basename, ca_dedicated, cls, Con_Printf(), CRC_Block(), developer_loading, skinframe_t::fog, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, height, skinframe_t::merged, name, skinframe_t::nmap, NULL, skinframe_t::pants, r_loadfog, R_LoadTexture2D(), r_main_texturepool, R_SkinFrame_Find(), R_SKINFRAME_LOAD_AVERAGE_COLORS, skinframe_t::reflect, skinframe_t::shirt, skinframe_t::stain, TEXF_ALPHA, TEXF_FORCE_RELOAD, TEXTYPE_PALETTE, va(), and width.

Referenced by R_Shadow_MakeTextures().

◆ R_SkinFrame_LoadInternalBGRA()

skinframe_t * R_SkinFrame_LoadInternalBGRA ( const char * name,
int textureflags,
const unsigned char * skindata,
int width,
int height,
int comparewidth,
int compareheight,
int comparecrc,
qbool sRGB )

Definition at line 2546 of file gl_rmain.c.

2547{
2548 int i;
2549 skinframe_t *skinframe;
2550 char vabuf[1024];
2551
2552 if (cls.state == ca_dedicated)
2553 return NULL;
2554
2555 // if already loaded just return it, otherwise make a new skinframe
2556 skinframe = R_SkinFrame_Find(name, textureflags, comparewidth, compareheight, comparecrc, true);
2557 if (skinframe->base)
2558 return skinframe;
2559 textureflags &= ~TEXF_FORCE_RELOAD;
2560
2561 skinframe->stain = NULL;
2562 skinframe->merged = NULL;
2563 skinframe->base = NULL;
2564 skinframe->pants = NULL;
2565 skinframe->shirt = NULL;
2566 skinframe->nmap = NULL;
2567 skinframe->gloss = NULL;
2568 skinframe->glow = NULL;
2569 skinframe->fog = NULL;
2570 skinframe->reflect = NULL;
2571 skinframe->hasalpha = false;
2572
2573 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2574 if (!skindata)
2575 return NULL;
2576
2577 if (developer_loading.integer)
2578 Con_Printf("loading 32bit skin \"%s\"\n", name);
2579
2581 {
2582 unsigned char *a = (unsigned char *)Mem_Alloc(tempmempool, width * height * 8);
2583 unsigned char *b = a + width * height * 4;
2585 skinframe->nmap = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_nmap", skinframe->basename), width, height, b, TEXTYPE_BGRA, (textureflags | TEXF_ALPHA) & (r_mipnormalmaps.integer ? ~0 : ~TEXF_MIPMAP), -1, NULL);
2586 Mem_Free(a);
2587 }
2588 skinframe->base = skinframe->merged = R_LoadTexture2D(r_main_texturepool, skinframe->basename, width, height, skindata, sRGB ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, textureflags, -1, NULL);
2589 if (textureflags & TEXF_ALPHA)
2590 {
2591 for (i = 3;i < width * height * 4;i += 4)
2592 {
2593 if (skindata[i] < 255)
2594 {
2595 skinframe->hasalpha = true;
2596 break;
2597 }
2598 }
2599 if (r_loadfog && skinframe->hasalpha)
2600 {
2601 unsigned char *fogpixels = (unsigned char *)Mem_Alloc(tempmempool, width * height * 4);
2602 memcpy(fogpixels, skindata, width * height * 4);
2603 for (i = 0;i < width * height * 4;i += 4)
2604 fogpixels[i] = fogpixels[i+1] = fogpixels[i+2] = 255;
2605 skinframe->fog = R_LoadTexture2D(r_main_texturepool, va(vabuf, sizeof(vabuf), "%s_fog", skinframe->basename), width, height, fogpixels, TEXTYPE_BGRA, textureflags, -1, NULL);
2606 Mem_Free(fogpixels);
2607 }
2608 }
2609
2610 R_SKINFRAME_LOAD_AVERAGE_COLORS(width * height, skindata[4 * pix + comp]);
2611 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2612
2613 return skinframe;
2614}

References a, b, skinframe_t::base, skinframe_t::basename, ca_dedicated, cls, Con_Printf(), developer_loading, skinframe_t::fog, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, height, Image_HeightmapToNormalmap_BGRA(), Mem_Alloc, Mem_Free, skinframe_t::merged, name, skinframe_t::nmap, NULL, skinframe_t::pants, r_loadfog, r_loadnormalmap, R_LoadTexture2D(), r_main_texturepool, r_mipnormalmaps, r_shadow_bumpscale_basetexture, R_SkinFrame_Find(), R_SKINFRAME_LOAD_AVERAGE_COLORS, skinframe_t::reflect, skinframe_t::shirt, skinframe_t::stain, tempmempool, TEXF_ALPHA, TEXF_FORCE_RELOAD, TEXF_MIPMAP, TEXTYPE_BGRA, TEXTYPE_SRGB_BGRA, va(), and width.

Referenced by CL_Beams_SetupBuiltinTexture(), Curl_EndDownload(), Draw_NewPic(), Mod_Q1BSP_LoadSplitSky(), Mod_Q1BSP_LoadTextures(), Mod_Sprite_SharedSetup(), R_InitParticleTexture(), R_LoadSkyBox(), R_Shadow_MakeTextures_MakeCorona(), and R_SkinFrame_LoadNoTexture().

◆ R_SkinFrame_LoadInternalQuake()

skinframe_t * R_SkinFrame_LoadInternalQuake ( const char * name,
int textureflags,
int loadpantsandshirt,
int loadglowtexture,
const unsigned char * skindata,
int width,
int height )

Definition at line 2616 of file gl_rmain.c.

2617{
2618 int i;
2619 int featuresmask;
2620 skinframe_t *skinframe;
2621
2622 if (cls.state == ca_dedicated)
2623 return NULL;
2624
2625 // if already loaded just return it, otherwise make a new skinframe
2626 skinframe = R_SkinFrame_Find(name, textureflags, width, height, skindata ? CRC_Block(skindata, width*height) : 0, true);
2627 if (skinframe->base)
2628 return skinframe;
2629 //textureflags &= ~TEXF_FORCE_RELOAD;
2630
2631 skinframe->stain = NULL;
2632 skinframe->merged = NULL;
2633 skinframe->base = NULL;
2634 skinframe->pants = NULL;
2635 skinframe->shirt = NULL;
2636 skinframe->nmap = NULL;
2637 skinframe->gloss = NULL;
2638 skinframe->glow = NULL;
2639 skinframe->fog = NULL;
2640 skinframe->reflect = NULL;
2641 skinframe->hasalpha = false;
2642
2643 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2644 if (!skindata)
2645 return NULL;
2646
2647 if (developer_loading.integer)
2648 Con_Printf("loading quake skin \"%s\"\n", name);
2649
2650 // we actually don't upload anything until the first use, because mdl skins frequently go unused, and are almost never used in both modes (colormapped and non-colormapped)
2651 skinframe->qpixels = (unsigned char *)Mem_Alloc(r_main_mempool, width*height); // FIXME LEAK
2652 memcpy(skinframe->qpixels, skindata, width*height);
2653 skinframe->qwidth = width;
2654 skinframe->qheight = height;
2655
2656 featuresmask = 0;
2657 for (i = 0;i < width * height;i++)
2658 featuresmask |= palette_featureflags[skindata[i]];
2659
2660 skinframe->hasalpha = false;
2661 // fence textures
2662 if (name[0] == '{')
2663 skinframe->hasalpha = true;
2664 skinframe->qhascolormapping = loadpantsandshirt && (featuresmask & (PALETTEFEATURE_PANTS | PALETTEFEATURE_SHIRT));
2665 skinframe->qgeneratenmap = r_shadow_bumpscale_basetexture.value > 0;
2666 skinframe->qgeneratemerged = true;
2667 skinframe->qgeneratebase = skinframe->qhascolormapping;
2668 skinframe->qgenerateglow = loadglowtexture && (featuresmask & PALETTEFEATURE_GLOW);
2669
2670 R_SKINFRAME_LOAD_AVERAGE_COLORS(width * height, ((unsigned char *)palette_bgra_complete)[skindata[pix]*4 + comp]);
2671 //Con_Printf("Texture %s has average colors %f %f %f alpha %f\n", name, skinframe->avgcolor[0], skinframe->avgcolor[1], skinframe->avgcolor[2], skinframe->avgcolor[3]);
2672
2673 return skinframe;
2674}
unsigned int palette_bgra_complete[256]
Definition palette.c:13
unsigned char palette_featureflags[256]
Definition palette.c:26
#define PALETTEFEATURE_SHIRT
Definition palette.h:8
#define PALETTEFEATURE_GLOW
Definition palette.h:9
#define PALETTEFEATURE_PANTS
Definition palette.h:7
qbool qgeneratebase
Definition r_textures.h:161
qbool qhascolormapping
Definition r_textures.h:160
qbool qgenerateglow
Definition r_textures.h:164
unsigned char * qpixels
Definition r_textures.h:157
qbool qgeneratenmap
Definition r_textures.h:163
qbool qgeneratemerged
Definition r_textures.h:162

References skinframe_t::base, ca_dedicated, cls, Con_Printf(), CRC_Block(), developer_loading, skinframe_t::fog, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, height, Mem_Alloc, skinframe_t::merged, name, skinframe_t::nmap, NULL, palette_bgra_complete, palette_featureflags, PALETTEFEATURE_GLOW, PALETTEFEATURE_PANTS, PALETTEFEATURE_SHIRT, skinframe_t::pants, skinframe_t::qgeneratebase, skinframe_t::qgenerateglow, skinframe_t::qgeneratemerged, skinframe_t::qgeneratenmap, skinframe_t::qhascolormapping, skinframe_t::qheight, skinframe_t::qpixels, skinframe_t::qwidth, r_main_mempool, r_shadow_bumpscale_basetexture, R_SkinFrame_Find(), R_SKINFRAME_LOAD_AVERAGE_COLORS, skinframe_t::reflect, skinframe_t::shirt, skinframe_t::stain, and width.

Referenced by Mod_IDP0_Load(), Mod_Q1BSP_LoadTextures(), and R_LoadQWSkin().

◆ R_SkinFrame_LoadInternalUsingTexture()

skinframe_t * R_SkinFrame_LoadInternalUsingTexture ( const char * name,
int textureflags,
rtexture_t * tex,
int width,
int height,
qbool sRGB )

Definition at line 2840 of file gl_rmain.c.

2841{
2842 skinframe_t *skinframe;
2843 if (cls.state == ca_dedicated)
2844 return NULL;
2845 // if already loaded just return it, otherwise make a new skinframe
2846 skinframe = R_SkinFrame_Find(name, textureflags, width, height, 0, true);
2847 if (skinframe->base)
2848 return skinframe;
2849 textureflags &= ~TEXF_FORCE_RELOAD;
2850 skinframe->stain = NULL;
2851 skinframe->merged = NULL;
2852 skinframe->base = NULL;
2853 skinframe->pants = NULL;
2854 skinframe->shirt = NULL;
2855 skinframe->nmap = NULL;
2856 skinframe->gloss = NULL;
2857 skinframe->glow = NULL;
2858 skinframe->fog = NULL;
2859 skinframe->reflect = NULL;
2860 skinframe->hasalpha = (textureflags & TEXF_ALPHA) != 0;
2861 // if no data was provided, then clearly the caller wanted to get a blank skinframe
2862 if (!tex)
2863 return NULL;
2864 if (developer_loading.integer)
2865 Con_Printf("loading 32bit skin \"%s\"\n", name);
2866 skinframe->base = skinframe->merged = tex;
2867 Vector4Set(skinframe->avgcolor, 1, 1, 1, 1); // bogus placeholder
2868 return skinframe;
2869}

References skinframe_t::avgcolor, skinframe_t::base, ca_dedicated, cls, Con_Printf(), developer_loading, skinframe_t::fog, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, height, skinframe_t::merged, name, skinframe_t::nmap, NULL, skinframe_t::pants, R_SkinFrame_Find(), skinframe_t::reflect, skinframe_t::shirt, skinframe_t::stain, TEXF_ALPHA, TEXF_FORCE_RELOAD, Vector4Set, and width.

◆ R_SkinFrame_LoadMissing()

skinframe_t * R_SkinFrame_LoadMissing ( void )

Definition at line 2804 of file gl_rmain.c.

2805{
2806 skinframe_t *skinframe;
2807
2808 if (cls.state == ca_dedicated)
2809 return NULL;
2810
2811 skinframe = R_SkinFrame_Find("missing", TEXF_FORCENEAREST, 0, 0, 0, true);
2812 skinframe->stain = NULL;
2813 skinframe->merged = NULL;
2814 skinframe->base = NULL;
2815 skinframe->pants = NULL;
2816 skinframe->shirt = NULL;
2817 skinframe->nmap = NULL;
2818 skinframe->gloss = NULL;
2819 skinframe->glow = NULL;
2820 skinframe->fog = NULL;
2821 skinframe->reflect = NULL;
2822 skinframe->hasalpha = false;
2823
2824 skinframe->avgcolor[0] = rand() / RAND_MAX;
2825 skinframe->avgcolor[1] = rand() / RAND_MAX;
2826 skinframe->avgcolor[2] = rand() / RAND_MAX;
2827 skinframe->avgcolor[3] = 1;
2828
2829 return skinframe;
2830}
#define TEXF_FORCENEAREST
Definition r_textures.h:17

References skinframe_t::avgcolor, skinframe_t::base, ca_dedicated, cls, skinframe_t::fog, skinframe_t::gloss, skinframe_t::glow, skinframe_t::hasalpha, skinframe_t::merged, skinframe_t::nmap, NULL, skinframe_t::pants, R_SkinFrame_Find(), skinframe_t::reflect, skinframe_t::shirt, skinframe_t::stain, and TEXF_FORCENEAREST.

Referenced by Mod_BuildAliasSkinsFromSkinFiles(), Mod_IDP2_Load(), Mod_IDS2_Load(), Mod_LoadTextureFromQ3Shader(), Mod_Q1BSP_LoadTextures(), Mod_Sprite_SharedSetup(), and Mod_SpriteSetupTexture().

◆ R_SkinFrame_LoadNoTexture()

skinframe_t * R_SkinFrame_LoadNoTexture ( void )

Definition at line 2832 of file gl_rmain.c.

2833{
2834 if (cls.state == ca_dedicated)
2835 return NULL;
2836
2837 return R_SkinFrame_LoadInternalBGRA("notexture", TEXF_FORCENEAREST, Image_GenerateNoTexture(), 16, 16, 0, 0, 0, false);
2838}
skinframe_t * R_SkinFrame_LoadInternalBGRA(const char *name, int textureflags, const unsigned char *skindata, int width, int height, int comparewidth, int compareheight, int comparecrc, qbool sRGB)
Definition gl_rmain.c:2546

References ca_dedicated, cls, Image_GenerateNoTexture(), NULL, R_SkinFrame_LoadInternalBGRA(), and TEXF_FORCENEAREST.

◆ R_SkinFrame_MarkUsed()

void R_SkinFrame_MarkUsed ( skinframe_t * skinframe)

Definition at line 2176 of file gl_rmain.c.

2177{
2178 if (!skinframe)
2179 return;
2180 // mark the skinframe as used for the purging code
2181 skinframe->loadsequence = r_skinframe.loadsequence;
2182}
unsigned int loadsequence
Definition r_textures.h:151

References skinframe_t::loadsequence, and r_skinframe.

Referenced by Draw_CachePic_Flags(), Draw_NewPic(), gl_draw_newmap(), mod_newmap(), r_lightningbeams_newmap(), r_part_newmap(), r_shadow_newmap(), and R_SkinFrame_Find().

◆ R_SkinFrame_PrepareForPurge()

void R_SkinFrame_PrepareForPurge ( void )

Definition at line 2168 of file gl_rmain.c.

2169{
2170 r_skinframe.loadsequence++;
2171 // wrap it without hitting zero
2172 if (r_skinframe.loadsequence >= 200)
2173 r_skinframe.loadsequence = 1;
2174}

References r_skinframe.

Referenced by R_Modules_NewMap().

◆ R_SkinFrame_Purge()

void R_SkinFrame_Purge ( void )

Definition at line 2203 of file gl_rmain.c.

2204{
2205 int i;
2206 skinframe_t *s;
2207 for (i = 0;i < SKINFRAME_HASH;i++)
2208 {
2209 for (s = r_skinframe.hash[i];s;s = s->next)
2210 {
2211 if (s->loadsequence && s->loadsequence != r_skinframe.loadsequence)
2213 }
2214 }
2215}

References skinframe_t::loadsequence, skinframe_t::next, r_skinframe, R_SkinFrame_PurgeSkinFrame(), and SKINFRAME_HASH.

Referenced by R_Modules_NewMap().

◆ R_SkinFrame_PurgeSkinFrame()

void R_SkinFrame_PurgeSkinFrame ( skinframe_t * skinframe)

Definition at line 2184 of file gl_rmain.c.

2185{
2186 if (s == NULL)
2187 return;
2188 if (s->merged == s->base)
2189 s->merged = NULL;
2190 R_PurgeTexture(s->stain); s->stain = NULL;
2191 R_PurgeTexture(s->merged); s->merged = NULL;
2192 R_PurgeTexture(s->base); s->base = NULL;
2193 R_PurgeTexture(s->pants); s->pants = NULL;
2194 R_PurgeTexture(s->shirt); s->shirt = NULL;
2195 R_PurgeTexture(s->nmap); s->nmap = NULL;
2196 R_PurgeTexture(s->gloss); s->gloss = NULL;
2197 R_PurgeTexture(s->glow); s->glow = NULL;
2198 R_PurgeTexture(s->fog); s->fog = NULL;
2199 R_PurgeTexture(s->reflect); s->reflect = NULL;
2200 s->loadsequence = 0;
2201}
void R_PurgeTexture(rtexture_t *rt)

References skinframe_t::base, skinframe_t::fog, skinframe_t::gloss, skinframe_t::glow, skinframe_t::loadsequence, skinframe_t::merged, skinframe_t::nmap, NULL, skinframe_t::pants, R_PurgeTexture(), skinframe_t::reflect, skinframe_t::shirt, and skinframe_t::stain.

Referenced by Draw_CachePic_Flags(), Draw_Frame(), Draw_FreePic(), Draw_NewPic(), Mod_UnloadCustomMaterial(), R_SkinFrame_Find(), R_SkinFrame_Purge(), and R_UnloadSkyBox().

◆ R_Sky()

void R_Sky ( void )

Definition at line 403 of file r_sky.c.

404{
405 Matrix4x4_CreateFromQuakeEntity(&skymatrix, r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2], 0, 0, 0, r_refdef.farclip * (0.5f / 16.0f));
407
408 if (r_sky_scissor.integer)
409 {
410 // if the scissor is empty just return
411 if (skyscissor[2] == 0 || skyscissor[3] == 0)
412 return;
414 GL_ScissorTest(true);
415 }
416 if (skyrendersphere)
417 {
418 // this does not modify depth buffer
419 R_SkySphere();
420 }
421 else if (skyrenderbox)
422 {
423 // this does not modify depth buffer
424 R_SkyBox();
425 }
426 /* this will be skyroom someday
427 else
428 {
429 // this modifies the depth buffer so we have to clear it afterward
430 //R_SkyRoom();
431 // clear the depthbuffer that was used while rendering the skyroom
432 //GL_Clear(GL_DEPTH_BUFFER_BIT);
433 }
434 */
435 GL_Scissor(r_refdef.view.viewport.x, r_refdef.view.viewport.y, r_refdef.view.viewport.width, r_refdef.view.viewport.height);
436}
void Matrix4x4_Invert_Simple(matrix4x4_t *out, const matrix4x4_t *in1)
Definition matrixlib.c:422
cvar_t r_sky_scissor
Definition r_sky.c:9
static matrix4x4_t skymatrix
Definition r_sky.c:18
static void R_SkyBox(void)
Definition r_sky.c:305
static matrix4x4_t skyinversematrix
Definition r_sky.c:19
static int skyrendersphere
Definition r_sky.c:14
static void R_SkySphere(void)
Definition r_sky.c:376
int skyscissor[4]
Definition r_sky.c:12
static int skyrenderbox
Definition r_sky.c:15

References GL_Scissor(), GL_ScissorTest(), Matrix4x4_CreateFromQuakeEntity(), Matrix4x4_Invert_Simple(), r_refdef, r_sky_scissor, R_SkyBox(), R_SkySphere(), skyinversematrix, skymatrix, skyrenderbox, skyrendersphere, and skyscissor.

Referenced by R_RenderScene().

◆ R_Sky_Init()

void R_Sky_Init ( void )

Definition at line 464 of file r_sky.c.

465{
466 Cmd_AddCommand(CF_CLIENT, "loadsky", &LoadSky_f, "load a skybox by basename (for example loadsky mtnsun_ loads mtnsun_ft.tga and so on)");
471 memset(&skyboxskinframe, 0, sizeof(skyboxskinframe));
472 skyname[0] = 0;
474}
static skinframe_t * skyboxskinframe[6]
Definition r_sky.c:55
static void r_sky_newmap(void)
Definition r_sky.c:459
cvar_t r_skyscroll1
Definition r_sky.c:7
static void r_sky_shutdown(void)
Definition r_sky.c:453
static void r_sky_start(void)
Definition r_sky.c:447
cvar_t r_sky
Definition r_sky.c:6
cvar_t r_skyscroll2
Definition r_sky.c:8
static void LoadSky_f(cmd_state_t *cmd)
Definition r_sky.c:166

References CF_CLIENT, Cmd_AddCommand(), Cvar_RegisterVariable(), LoadSky_f(), NULL, R_RegisterModule(), r_sky, r_sky_newmap(), r_sky_scissor, r_sky_shutdown(), r_sky_start(), r_skyscroll1, r_skyscroll2, skyboxskinframe, and skyname.

Referenced by Render_Init().

◆ R_SkyStartFrame()

void R_SkyStartFrame ( void )

Definition at line 57 of file r_sky.c.

58{
59 skyrendersphere = false;
60 skyrenderbox = false;
61 skyrendermasked = false;
62 // for depth-masked sky, we need to know whether any sky was rendered
63 skyrenderlater = false;
64 // we can scissor the sky to just the relevant area
66 if (r_sky.integer)
67 {
69 skyrenderbox = true;
70 else if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.solidskyskinframe)
71 skyrendersphere = true;
72 skyrendermasked = true;
73 }
74}
#define Vector4Clear(a)
Definition mathlib.h:82

References r_refdef, r_sky, skyboxskinframe, skyrenderbox, skyrenderlater, skyrendermasked, skyrendersphere, skyscissor, and Vector4Clear.

Referenced by R_RenderScene().

◆ R_Stain()

void R_Stain ( const vec3_t origin,
float radius,
int cr1,
int cg1,
int cb1,
int ca1,
int cr2,
int cg2,
int cb2,
int ca2 )

Definition at line 298 of file gl_rsurf.c.

299{
300 int n;
301 float fcolor[8];
302 entity_render_t *ent;
303 model_t *model;
304 vec3_t org;
305 if (r_refdef.scene.worldmodel == NULL || !r_refdef.scene.worldmodel->brush.data_nodes || !r_refdef.scene.worldmodel->brushq1.lightdata)
306 return;
307 fcolor[0] = cr1;
308 fcolor[1] = cg1;
309 fcolor[2] = cb1;
310 fcolor[3] = ca1 * (1.0f / 64.0f);
311 fcolor[4] = cr2 - cr1;
312 fcolor[5] = cg2 - cg1;
313 fcolor[6] = cb2 - cb1;
314 fcolor[7] = (ca2 - ca1) * (1.0f / 64.0f);
315
316 R_StainNode(r_refdef.scene.worldmodel->brush.data_nodes + r_refdef.scene.worldmodel->brushq1.hulls[0].firstclipnode, r_refdef.scene.worldmodel, origin, radius, fcolor);
317
318 // look for embedded bmodels
319 for (n = 0;n < cl.num_brushmodel_entities;n++)
320 {
321 ent = &cl.entities[cl.brushmodel_entities[n]].render;
322 model = ent->model;
323 if (model && model->name[0] == '*')
324 {
325 if (model->brush.data_nodes)
326 {
328 R_StainNode(model->brush.data_nodes + model->brushq1.hulls[0].firstclipnode, model, org, radius, fcolor);
329 }
330 }
331 }
332}
static void R_StainNode(mnode_t *node, model_t *model, const vec3_t origin, float radius, const float fcolor[8])
Definition gl_rsurf.c:176
matrix4x4_t inversematrix
Definition client.h:334

References cl, entity_render_t::inversematrix, Matrix4x4_Transform(), entity_render_t::model, model, n, NULL, origin, r_refdef, and R_StainNode().

Referenced by CL_ParticleEffect_Fallback(), CL_ParticleExplosion(), and R_DrawParticles().

◆ R_Textures_Init()

void R_Textures_Init ( void )

Definition at line 720 of file gl_textures.c.

721{
722 Cmd_AddCommand(CF_CLIENT, "gl_texturemode", &GL_TextureMode_f, "set texture filtering mode (GL_NEAREST, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, etc); an additional argument 'force' forces the texture mode even in cases where it may not be appropriate");
723 Cmd_AddCommand(CF_CLIENT, "r_texturestats", R_TextureStats_f, "print information about all loaded textures and some statistics");
749
751}
cvar_t gl_picmip
Definition gl_textures.c:29
cvar_t gl_texturecompression_q3bsplightmaps
Definition gl_textures.c:43
static void r_textures_shutdown(void)
static void r_textures_newmap(void)
cvar_t gl_texturecompression_lightcubemaps
Definition gl_textures.c:46
cvar_t gl_max_size
Definition gl_textures.c:27
cvar_t r_picmipworld
Definition gl_textures.c:31
cvar_t r_texture_dds_swdecode
Definition gl_textures.c:51
static void r_textures_devicerestored(void)
cvar_t gl_texturecompression_sprites
Definition gl_textures.c:48
cvar_t gl_picmip_sprites
Definition gl_textures.c:32
cvar_t gl_texturecompression_sky
Definition gl_textures.c:45
cvar_t gl_picmip_world
Definition gl_textures.c:30
static void GL_TextureMode_f(cmd_state_t *cmd)
cvar_t gl_picmip_other
Definition gl_textures.c:34
static void r_textures_start(void)
static void r_textures_devicelost(void)
cvar_t r_texture_dds_load_alphamode
Definition gl_textures.c:49
cvar_t r_texture_dds_load_logfailure
Definition gl_textures.c:50
cvar_t gl_texturecompression_2d
Definition gl_textures.c:42
cvar_t gl_texture_anisotropy
Definition gl_textures.c:36
cvar_t r_picmipsprites
Definition gl_textures.c:33
cvar_t gl_texturecompression_q3bspdeluxemaps
Definition gl_textures.c:44
cvar_t gl_max_lightmapsize
Definition gl_textures.c:28
cvar_t r_lerpimages
Definition gl_textures.c:35
static void R_TextureStats_f(cmd_state_t *cmd)

References CF_CLIENT, Cmd_AddCommand(), Cvar_RegisterVariable(), gl_max_lightmapsize, gl_max_size, gl_picmip, gl_picmip_other, gl_picmip_sprites, gl_picmip_world, gl_texture_anisotropy, gl_texturecompression, gl_texturecompression_2d, gl_texturecompression_color, gl_texturecompression_gloss, gl_texturecompression_glow, gl_texturecompression_lightcubemaps, gl_texturecompression_normal, gl_texturecompression_q3bspdeluxemaps, gl_texturecompression_q3bsplightmaps, gl_texturecompression_reflectmask, gl_texturecompression_sky, gl_texturecompression_sprites, GL_TextureMode_f(), r_lerpimages, r_picmipsprites, r_picmipworld, R_RegisterModule(), r_texture_dds_load_alphamode, r_texture_dds_load_logfailure, r_texture_dds_swdecode, r_textures_devicelost(), r_textures_devicerestored(), r_textures_newmap(), r_textures_shutdown(), r_textures_start(), and R_TextureStats_f().

Referenced by Render_Init().

◆ R_TimeReport()

void R_TimeReport ( const char * name)

Definition at line 193 of file r_stats.c.

194{
195 char tempbuf[256];
196 int length;
197 int t;
198
199 if (r_speeds.integer < 2 || !r_timereport_active)
200 return;
201
203 if (r_speeds.integer == 2)
204 GL_Finish();
208 t = (int) ((r_timereport_current - r_timereport_temp) * 1000000.0 + 0.5);
209
210 length = dpsnprintf(tempbuf, sizeof(tempbuf), "%8i %s", t, desc);
211 if (length < 0)
212 length = (int)sizeof(tempbuf) - 1;
216 tempbuf[length] = ' ';
217 tempbuf[length] = 0;
218
219 if (speedstringcount + length > (vid_conwidth.integer / 8))
220 {
223 }
226}
#define dp_strlcat(dst, src, dsize)
Definition common.h:304
void GL_Finish(void)
Definition gl_backend.c:399
GLenum GLuint GLenum GLsizei length
Definition glquake.h:657
char r_speeds_timestring[4096]
Definition r_stats.c:188
double r_timereport_temp
Definition r_stats.c:190
double r_timereport_current
Definition r_stats.c:190
int r_speeds_longestitem
Definition r_stats.c:191
int speedstringcount
Definition r_stats.c:189
double Sys_DirtyTime(void)
Definition sys_shared.c:417

References CHECKGLERROR, dp_strlcat, dpsnprintf(), GL_Finish(), int(), length, r_speeds, r_speeds_longestitem, r_speeds_timestring, r_timereport_active, r_timereport_current, r_timereport_temp, speedstringcount, Sys_DirtyTime(), and vid_conwidth.

Referenced by CL_Frame(), CL_VM_DrawHud(), CL_VM_UpdateView(), Host_Frame(), R_RenderScene(), R_RenderView(), R_RenderWaterPlanes(), R_Shadow_DrawPrepass(), R_Shadow_UpdateBounceGridTexture(), S_PaintAndSubmit(), S_Update(), SCR_DrawScreen(), and SV_Frame().

◆ R_UpdateFog()

void R_UpdateFog ( void )

Definition at line 5396 of file gl_rmain.c.

5397{
5398 // Nehahra fog
5399 if (gamemode == GAME_NEHAHRA)
5400 {
5401 if (gl_fogenable.integer)
5402 {
5403 r_refdef.oldgl_fogenable = true;
5404 r_refdef.fog_density = gl_fogdensity.value;
5405 r_refdef.fog_red = gl_fogred.value;
5406 r_refdef.fog_green = gl_foggreen.value;
5407 r_refdef.fog_blue = gl_fogblue.value;
5408 r_refdef.fog_alpha = 1;
5409 r_refdef.fog_start = 0;
5410 r_refdef.fog_end = gl_skyclip.value;
5411 r_refdef.fog_height = 1<<30;
5412 r_refdef.fog_fadedepth = 128;
5413 }
5414 else if (r_refdef.oldgl_fogenable)
5415 {
5416 r_refdef.oldgl_fogenable = false;
5417 r_refdef.fog_density = 0;
5418 r_refdef.fog_red = 0;
5419 r_refdef.fog_green = 0;
5420 r_refdef.fog_blue = 0;
5421 r_refdef.fog_alpha = 0;
5422 r_refdef.fog_start = 0;
5423 r_refdef.fog_end = 0;
5424 r_refdef.fog_height = 1<<30;
5425 r_refdef.fog_fadedepth = 128;
5426 }
5427 }
5428
5429 // fog parms
5430 r_refdef.fog_alpha = bound(0, r_refdef.fog_alpha, 1);
5431 r_refdef.fog_start = max(0, r_refdef.fog_start);
5432 r_refdef.fog_end = max(r_refdef.fog_start + 0.01, r_refdef.fog_end);
5433
5434 if (r_refdef.fog_density && r_drawfog.integer)
5435 {
5436 r_refdef.fogenabled = true;
5437 // this is the point where the fog reaches 0.9986 alpha, which we
5438 // consider a good enough cutoff point for the texture
5439 // (0.9986 * 256 == 255.6)
5440 if (r_fog_exp2.integer)
5441 r_refdef.fogrange = 32 / (r_refdef.fog_density * r_refdef.fog_density) + r_refdef.fog_start;
5442 else
5443 r_refdef.fogrange = 2048 / r_refdef.fog_density + r_refdef.fog_start;
5444 r_refdef.fogrange = bound(r_refdef.fog_start, r_refdef.fogrange, r_refdef.fog_end);
5445 r_refdef.fograngerecip = 1.0f / r_refdef.fogrange;
5446 r_refdef.fogmasktabledistmultiplier = FOGMASKTABLEWIDTH * r_refdef.fograngerecip;
5447 if (strcmp(r_refdef.fogheighttexturename, r_refdef.fog_height_texturename))
5449 // fog color was already set
5450 // update the fog texture
5451 if (r_refdef.fogmasktable_start != r_refdef.fog_start || r_refdef.fogmasktable_alpha != r_refdef.fog_alpha || r_refdef.fogmasktable_density != r_refdef.fog_density || r_refdef.fogmasktable_range != r_refdef.fogrange)
5453 r_refdef.fog_height_texcoordscale = 1.0f / max(0.125f, r_refdef.fog_fadedepth);
5454 r_refdef.fog_height_tablescale = r_refdef.fog_height_tablesize * r_refdef.fog_height_texcoordscale;
5455 }
5456 else
5457 r_refdef.fogenabled = false;
5458
5459 // fog color
5460 if (r_refdef.fog_density)
5461 {
5462 r_refdef.fogcolor[0] = r_refdef.fog_red;
5463 r_refdef.fogcolor[1] = r_refdef.fog_green;
5464 r_refdef.fogcolor[2] = r_refdef.fog_blue;
5465
5466 Vector4Set(r_refdef.fogplane, 0, 0, 1, -r_refdef.fog_height);
5467 r_refdef.fogplaneviewdist = DotProduct(r_refdef.fogplane, r_refdef.view.origin) + r_refdef.fogplane[3];
5468 r_refdef.fogplaneviewabove = r_refdef.fogplaneviewdist >= 0;
5469 r_refdef.fogheightfade = -0.5f/max(0.125f, r_refdef.fog_fadedepth);
5470
5471 {
5472 vec3_t fogvec;
5473 VectorCopy(r_refdef.fogcolor, fogvec);
5474 // color.rgb *= ContrastBoost * SceneBrightness;
5475 VectorScale(fogvec, r_refdef.view.colorscale, fogvec);
5476 r_refdef.fogcolor[0] = bound(0.0f, fogvec[0], 1.0f);
5477 r_refdef.fogcolor[1] = bound(0.0f, fogvec[1], 1.0f);
5478 r_refdef.fogcolor[2] = bound(0.0f, fogvec[2], 1.0f);
5479 }
5480 }
5481}
static void R_BuildFogTexture(void)
Definition gl_rmain.c:470
static void R_BuildFogHeightTexture(void)
Definition gl_rmain.c:526
#define FOGMASKTABLEWIDTH
Definition render.h:428

References bound, DotProduct, FOGMASKTABLEWIDTH, GAME_NEHAHRA, gamemode, gl_fogblue, gl_fogdensity, gl_fogenable, gl_foggreen, gl_fogred, gl_skyclip, max, R_BuildFogHeightTexture(), R_BuildFogTexture(), r_drawfog, r_fog_exp2, r_refdef, Vector4Set, VectorCopy, and VectorScale.

Referenced by R_ClearScreen(), and R_RenderScene().

◆ R_UpdateVariables()

void R_UpdateVariables ( void )

Definition at line 5483 of file gl_rmain.c.

5484{
5486
5487 r_refdef.scene.ambientintensity = r_ambient.value * (1.0f / 64.0f);
5488
5489 r_refdef.farclip = r_farclip_base.value;
5490 if (r_refdef.scene.worldmodel)
5491 r_refdef.farclip += r_refdef.scene.worldmodel->radius * r_farclip_world.value * 2;
5492 r_refdef.nearclip = bound (0.001f, r_nearclip.value, r_refdef.farclip - 1.0f);
5493
5494 if (r_shadow_frontsidecasting.integer < 0 || r_shadow_frontsidecasting.integer > 1)
5496 r_refdef.polygonfactor = 0;
5497 r_refdef.polygonoffset = 0;
5498
5499 r_refdef.scene.rtworld = r_shadow_realtime_world.integer != 0;
5500 r_refdef.scene.rtworldshadows = r_shadow_realtime_world_shadows.integer && vid.stencil;
5501 r_refdef.scene.rtdlight = r_shadow_realtime_dlight.integer != 0 && !gl_flashblend.integer && r_dynamic.integer;
5502 r_refdef.scene.rtdlightshadows = r_refdef.scene.rtdlight && r_shadow_realtime_dlight_shadows.integer && vid.stencil;
5503 r_refdef.scene.lightmapintensity = r_refdef.scene.rtworld ? r_shadow_realtime_world_lightmaps.value : 1;
5504 if (r_refdef.scene.worldmodel)
5505 {
5506 r_refdef.scene.lightmapintensity *= r_refdef.scene.worldmodel->lightmapscale;
5507
5508 // Apply the default lightstyle to the lightmap even on q3bsp
5509 if (cl.worldmodel && cl.worldmodel->type == mod_brushq3) {
5510 r_refdef.scene.lightmapintensity *= r_refdef.scene.rtlightstylevalue[0];
5511 }
5512 }
5513 if (r_showsurfaces.integer)
5514 {
5515 r_refdef.scene.rtworld = false;
5516 r_refdef.scene.rtworldshadows = false;
5517 r_refdef.scene.rtdlight = false;
5518 r_refdef.scene.rtdlightshadows = false;
5519 r_refdef.scene.lightmapintensity = 0;
5520 }
5521
5522 r_gpuskeletal = false;
5523 switch(vid.renderpath)
5524 {
5525 case RENDERPATH_GL32:
5526 r_gpuskeletal = r_glsl_skeletal.integer && !r_showsurfaces.integer;
5527 case RENDERPATH_GLES2:
5529 {
5531 {
5532 // build GLSL gamma texture
5533#define RAMPWIDTH 256
5534 unsigned short ramp[RAMPWIDTH * 3];
5535 unsigned char rampbgr[RAMPWIDTH][4];
5536 int i;
5537
5539
5541 for(i = 0; i < RAMPWIDTH; ++i)
5542 {
5543 rampbgr[i][0] = (unsigned char) (ramp[i + 2 * RAMPWIDTH] * 255.0 / 65535.0 + 0.5);
5544 rampbgr[i][1] = (unsigned char) (ramp[i + RAMPWIDTH] * 255.0 / 65535.0 + 0.5);
5545 rampbgr[i][2] = (unsigned char) (ramp[i] * 255.0 / 65535.0 + 0.5);
5546 rampbgr[i][3] = 0;
5547 }
5549 {
5550 R_UpdateTexture(r_texture_gammaramps, &rampbgr[0][0], 0, 0, 0, RAMPWIDTH, 1, 1, 0);
5551 }
5552 else
5553 {
5555 }
5556 }
5557 }
5558 else
5559 {
5560 // remove GLSL gamma texture
5561 }
5562 break;
5563 }
5564}
unsigned int r_texture_gammaramps_serial
Definition gl_rmain.c:282
#define RAMPWIDTH
void R_Textures_Frame(void)
@ mod_brushq3
#define TEXF_PERSISTENT
Definition r_textures.h:25
unsigned int vid_gammatables_serial
so other subsystems can poll if gamma parameters have changed; this starts with 0 and gets increased ...
void VID_BuildGammaTables(unsigned short *ramps, int rampsize)
builds the current gamma tables into an array (needs 3*rampsize items)

References bound, cl, Cvar_SetValueQuick(), gl_flashblend, mod_brushq3, NULL, r_ambient, r_dynamic, r_farclip_base, r_farclip_world, r_glsl_skeletal, r_gpuskeletal, R_LoadTexture2D(), r_main_texturepool, r_nearclip, r_refdef, r_shadow_frontsidecasting, r_shadow_realtime_dlight, r_shadow_realtime_dlight_shadows, r_shadow_realtime_world, r_shadow_realtime_world_lightmaps, r_shadow_realtime_world_shadows, r_showsurfaces, r_texture_gammaramps, r_texture_gammaramps_serial, R_Textures_Frame(), R_UpdateTexture(), RAMPWIDTH, RENDERPATH_GL32, RENDERPATH_GLES2, TEXF_CLAMP, TEXF_FORCELINEAR, TEXF_PERSISTENT, TEXTYPE_BGRA, vid, VID_BuildGammaTables(), vid_gammatables_serial, and vid_gammatables_trivial.

Referenced by R_Envmap_f(), and SCR_DrawScreen().

◆ R_View_WorldVisibility()

void R_View_WorldVisibility ( qbool forcenovis)

Definition at line 436 of file gl_rsurf.c.

437{
438 int i, j, *mark;
439 mleaf_t *leaf;
440 mleaf_t *viewleaf;
441 model_t *model = r_refdef.scene.worldmodel;
442
443 if (!model)
444 return;
445
446 if (r_lockvisibility.integer)
447 return;
448
449 // clear the visible surface and leaf flags arrays
450 memset(r_refdef.viewcache.world_surfacevisible, 0, model->num_surfaces);
451 if(!r_lockpvs.integer)
452 memset(r_refdef.viewcache.world_leafvisible, 0, model->brush.num_leafs);
453
454 r_refdef.viewcache.world_novis = false;
455
456 if (r_refdef.view.usecustompvs)
457 {
458 // simply cull each marked leaf to the frustum (view pyramid)
459 for (j = 0, leaf = model->brush.data_leafs;j < model->brush.num_leafs;j++, leaf++)
460 {
461 // if leaf is in current pvs and on the screen, mark its surfaces
462 if (CHECKPVSBIT(r_refdef.viewcache.world_pvsbits, leaf->clusterindex) && !R_CullFrustum(leaf->mins, leaf->maxs))
463 {
465 r_refdef.viewcache.world_leafvisible[j] = true;
466 if (leaf->numleafsurfaces)
467 for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
468 r_refdef.viewcache.world_surfacevisible[*mark] = true;
469 }
470 }
471 }
472 else
473 {
474 // if possible find the leaf the view origin is in
475 viewleaf = model->brush.PointInLeaf ? model->brush.PointInLeaf(model, r_refdef.view.origin) : NULL;
476 // if possible fetch the visible cluster bits
477 if (!r_lockpvs.integer && model->brush.FatPVS)
478 model->brush.FatPVS(model, r_refdef.view.origin, 2, &r_refdef.viewcache.world_pvsbits, r_main_mempool, false);
479
480 // if floating around in the void (no pvs data available, and no
481 // portals available), simply use all on-screen leafs.
482 if (!viewleaf || viewleaf->clusterindex < 0 || forcenovis || !r_refdef.view.usevieworiginculling)
483 {
484 // no visibility method: (used when floating around in the void)
485 // simply cull each leaf to the frustum (view pyramid)
486 // similar to quake's RecursiveWorldNode but without cache misses
487 r_refdef.viewcache.world_novis = true;
488 for (j = 0, leaf = model->brush.data_leafs;j < model->brush.num_leafs;j++, leaf++)
489 {
490 if (leaf->clusterindex < 0)
491 continue;
492 // if leaf is in current pvs and on the screen, mark its surfaces
493 if (!R_CullFrustum(leaf->mins, leaf->maxs))
494 {
496 r_refdef.viewcache.world_leafvisible[j] = true;
497 if (leaf->numleafsurfaces)
498 for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
499 r_refdef.viewcache.world_surfacevisible[*mark] = true;
500 }
501 }
502 }
503 // just check if each leaf in the PVS is on screen
504 // (unless portal culling is enabled)
505 else if (!model->brush.data_portals || r_useportalculling.integer < 1 || (r_useportalculling.integer < 2 && !r_novis.integer))
506 {
507 // pvs method:
508 // simply check if each leaf is in the Potentially Visible Set,
509 // and cull to frustum (view pyramid)
510 // similar to quake's RecursiveWorldNode but without cache misses
511 for (j = 0, leaf = model->brush.data_leafs;j < model->brush.num_leafs;j++, leaf++)
512 {
513 if (leaf->clusterindex < 0)
514 continue;
515 // if leaf is in current pvs and on the screen, mark its surfaces
516 if (CHECKPVSBIT(r_refdef.viewcache.world_pvsbits, leaf->clusterindex) && !R_CullFrustum(leaf->mins, leaf->maxs))
517 {
519 r_refdef.viewcache.world_leafvisible[j] = true;
520 if (leaf->numleafsurfaces)
521 for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
522 r_refdef.viewcache.world_surfacevisible[*mark] = true;
523 }
524 }
525 }
526 // if desired use a recursive portal flow, culling each portal to
527 // frustum and checking if the leaf the portal leads to is in the pvs
528 else
529 {
530 int leafstackpos;
531 mportal_t *p;
532 mleaf_t *leafstack[8192];
533 vec3_t cullmins, cullmaxs;
534 float cullbias = r_nearclip.value * 2.0f; // the nearclip plane can easily end up culling portals in certain perfectly-aligned views, causing view blackouts
535 // simple-frustum portal method:
536 // follows portals leading outward from viewleaf, does not venture
537 // offscreen or into leafs that are not visible, faster than
538 // Quake's RecursiveWorldNode and vastly better in unvised maps,
539 // often culls some surfaces that pvs alone would miss
540 // (such as a room in pvs that is hidden behind a wall, but the
541 // passage leading to the room is off-screen)
542 leafstack[0] = viewleaf;
543 leafstackpos = 1;
544 while (leafstackpos)
545 {
546 leaf = leafstack[--leafstackpos];
547 if (r_refdef.viewcache.world_leafvisible[leaf - model->brush.data_leafs])
548 continue;
549 if (leaf->clusterindex < 0)
550 continue;
552 r_refdef.viewcache.world_leafvisible[leaf - model->brush.data_leafs] = true;
553 // mark any surfaces bounding this leaf
554 if (leaf->numleafsurfaces)
555 for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
556 r_refdef.viewcache.world_surfacevisible[*mark] = true;
557 // follow portals into other leafs
558 // the checks are:
559 // the leaf has not been visited yet
560 // and the leaf is visible in the pvs
561 // the portal polygon's bounding box is on the screen
562 for (p = leaf->portals;p;p = p->next)
563 {
565 if (r_refdef.viewcache.world_leafvisible[p->past - model->brush.data_leafs])
566 continue;
567 if (!CHECKPVSBIT(r_refdef.viewcache.world_pvsbits, p->past->clusterindex))
568 continue;
569 cullmins[0] = p->mins[0] - cullbias;
570 cullmins[1] = p->mins[1] - cullbias;
571 cullmins[2] = p->mins[2] - cullbias;
572 cullmaxs[0] = p->maxs[0] + cullbias;
573 cullmaxs[1] = p->maxs[1] + cullbias;
574 cullmaxs[2] = p->maxs[2] + cullbias;
575 if (R_CullFrustum(cullmins, cullmaxs))
576 continue;
577 if (r_vis_trace.integer)
578 {
579 if (p->tracetime != host.realtime && R_CanSeeBox(r_vis_trace_samples.value, r_vis_trace_eyejitter.value, r_vis_trace_enlarge.value, r_vis_trace_expand.value, r_vis_trace_pad.value, r_refdef.view.origin, cullmins, cullmaxs))
580 p->tracetime = host.realtime;
581 if (host.realtime - p->tracetime > r_vis_trace_delay.value)
582 continue;
583 }
584 if (leafstackpos >= (int)(sizeof(leafstack) / sizeof(leafstack[0])))
585 break;
586 leafstack[leafstackpos++] = p->past;
587 }
588 }
589 }
590 }
591
592 // Cull the rest
594}
qbool R_CanSeeBox(int numsamples, vec_t eyejitter, vec_t entboxenlarge, vec_t entboxexpand, vec_t pad, vec3_t eye, vec3_t entboxmins, vec3_t entboxmaxs)
Definition gl_rmain.c:3888
static void R_View_WorldVisibility_CullSurfaces(void)
Definition gl_rsurf.c:411
@ r_stat_world_portals
Definition r_stats.h:16
@ r_stat_world_leafs
Definition r_stats.h:15
vec3_t mins
int * firstleafsurface
vec3_t maxs
int numleafsurfaces
struct mportal_s * portals
double tracetime
mleaf_t * past

References CHECKPVSBIT, mleaf_t::clusterindex, mleaf_t::firstleafsurface, host, mleaf_t::maxs, mportal_t::maxs, mleaf_t::mins, mportal_t::mins, model, mportal_t::next, NULL, mleaf_t::numleafsurfaces, mportal_t::past, mleaf_t::portals, R_CanSeeBox(), R_CullFrustum(), r_lockpvs, r_lockvisibility, r_main_mempool, r_nearclip, r_novis, r_refdef, r_stat_world_leafs, r_stat_world_portals, r_useportalculling, R_View_WorldVisibility_CullSurfaces(), r_vis_trace, r_vis_trace_delay, r_vis_trace_enlarge, r_vis_trace_expand, r_vis_trace_eyejitter, r_vis_trace_pad, r_vis_trace_samples, and mportal_t::tracetime.

Referenced by R_View_Update().

◆ R_Water_AddWaterPlane()

void R_Water_AddWaterPlane ( msurface_t * surface,
int entno )

Definition at line 4640 of file gl_rmain.c.

4641{
4642 int planeindex, bestplaneindex, vertexindex;
4643 vec3_t mins, maxs, normal, center, v, n;
4644 vec_t planescore, bestplanescore;
4645 mplane_t plane;
4647 texture_t *t = R_GetCurrentTexture(surface->texture);
4648
4649 rsurface.texture = t;
4651 // if the model has no normals, it's probably off-screen and they were not generated, so don't add it anyway
4652 if (!rsurface.batchnormal3f || rsurface.batchnumvertices < 1)
4653 return;
4654 // average the vertex normals, find the surface bounds (after deformvertexes)
4655 Matrix4x4_Transform(&rsurface.matrix, rsurface.batchvertex3f, v);
4656 Matrix4x4_Transform3x3(&rsurface.matrix, rsurface.batchnormal3f, n);
4658 VectorCopy(v, mins);
4659 VectorCopy(v, maxs);
4660 for (vertexindex = 1;vertexindex < rsurface.batchnumvertices;vertexindex++)
4661 {
4662 Matrix4x4_Transform(&rsurface.matrix, rsurface.batchvertex3f + vertexindex*3, v);
4663 Matrix4x4_Transform3x3(&rsurface.matrix, rsurface.batchnormal3f + vertexindex*3, n);
4665 mins[0] = min(mins[0], v[0]);
4666 mins[1] = min(mins[1], v[1]);
4667 mins[2] = min(mins[2], v[2]);
4668 maxs[0] = max(maxs[0], v[0]);
4669 maxs[1] = max(maxs[1], v[1]);
4670 maxs[2] = max(maxs[2], v[2]);
4671 }
4673 VectorMAM(0.5f, mins, 0.5f, maxs, center);
4674
4675 VectorCopy(normal, plane.normal);
4676 VectorNormalize(plane.normal);
4677 plane.dist = DotProduct(center, plane.normal);
4678 PlaneClassify(&plane);
4679 if (PlaneDiff(r_refdef.view.origin, &plane) < 0)
4680 {
4681 // skip backfaces (except if nocullface is set)
4682// if (!(t->currentmaterialflags & MATERIALFLAG_NOCULLFACE))
4683// return;
4684 VectorNegate(plane.normal, plane.normal);
4685 plane.dist *= -1;
4686 PlaneClassify(&plane);
4687 }
4688
4689
4690 // find a matching plane if there is one
4691 bestplaneindex = -1;
4692 bestplanescore = 1048576.0f;
4693 for (planeindex = 0, p = r_fb.water.waterplanes;planeindex < r_fb.water.numwaterplanes;planeindex++, p++)
4694 {
4695 if(p->camera_entity == t->camera_entity)
4696 {
4697 planescore = 1.0f - DotProduct(plane.normal, p->plane.normal) + fabs(plane.dist - p->plane.dist) * 0.001f;
4698 if (bestplaneindex < 0 || bestplanescore > planescore)
4699 {
4700 bestplaneindex = planeindex;
4701 bestplanescore = planescore;
4702 }
4703 }
4704 }
4705 planeindex = bestplaneindex;
4706
4707 // if this surface does not fit any known plane rendered this frame, add one
4708 if (planeindex < 0 || bestplanescore > 0.001f)
4709 {
4710 if (r_fb.water.numwaterplanes < r_fb.water.maxwaterplanes)
4711 {
4712 // store the new plane
4713 planeindex = r_fb.water.numwaterplanes++;
4714 p = r_fb.water.waterplanes + planeindex;
4715 p->plane = plane;
4716 // clear materialflags and pvs
4717 p->materialflags = 0;
4718 p->pvsvalid = false;
4720 VectorCopy(mins, p->mins);
4721 VectorCopy(maxs, p->maxs);
4722 }
4723 else
4724 {
4725 // We're totally screwed.
4726 return;
4727 }
4728 }
4729 else
4730 {
4731 // merge mins/maxs when we're adding this surface to the plane
4732 p = r_fb.water.waterplanes + planeindex;
4733 p->mins[0] = min(p->mins[0], mins[0]);
4734 p->mins[1] = min(p->mins[1], mins[1]);
4735 p->mins[2] = min(p->mins[2], mins[2]);
4736 p->maxs[0] = max(p->maxs[0], maxs[0]);
4737 p->maxs[1] = max(p->maxs[1], maxs[1]);
4738 p->maxs[2] = max(p->maxs[2], maxs[2]);
4739 }
4740 // merge this surface's materialflags into the waterplane
4743 {
4744 // merge this surface's PVS into the waterplane
4745 if (p->materialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION) && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.FatPVS
4746 && r_refdef.scene.worldmodel->brush.PointInLeaf && r_refdef.scene.worldmodel->brush.PointInLeaf(r_refdef.scene.worldmodel, center)->clusterindex >= 0)
4747 {
4748 r_refdef.scene.worldmodel->brush.FatPVS(r_refdef.scene.worldmodel, center, 2, &p->pvsbits, r_main_mempool, p->pvsvalid);
4749 p->pvsvalid = true;
4750 }
4751 }
4752}
const GLdouble * v
Definition glquake.h:762
void PlaneClassify(mplane_t *p)
Definition mathlib.c:310
#define PlaneDiff(point, plane)
Definition mathlib.h:257
void Matrix4x4_Transform3x3(const matrix4x4_t *in, const float v[3], float out[3])
Definition matrixlib.c:1685
#define BATCHNEED_NOGAPS
Definition render.h:793
unsigned char * pvsbits
Definition render.h:854

References BATCHNEED_ARRAY_NORMAL, BATCHNEED_ARRAY_VERTEX, BATCHNEED_NOGAPS, r_waterstate_waterplane_t::camera_entity, texture_t::camera_entity, texture_t::currentmaterialflags, mplane_t::dist, DotProduct, fabs(), MATERIALFLAG_CAMERA, MATERIALFLAG_REFLECTION, MATERIALFLAG_REFRACTION, MATERIALFLAG_WATERSHADER, r_waterstate_waterplane_t::materialflags, Matrix4x4_Transform(), Matrix4x4_Transform3x3(), max, maxs, r_waterstate_waterplane_t::maxs, min, mins, r_waterstate_waterplane_t::mins, n, mplane_t::normal, normal, r_waterstate_waterplane_t::plane, PlaneClassify(), PlaneDiff, r_waterstate_waterplane_t::pvsbits, r_waterstate_waterplane_t::pvsvalid, r_fb, R_GetCurrentTexture(), r_main_mempool, r_refdef, RSurf_PrepareVerticesForBatch(), rsurface, msurface_t::texture, v, VectorAdd, VectorCopy, VectorMAM, VectorNegate, and VectorNormalize.

Referenced by R_Mod_DrawAddWaterPlanes().

◆ Render_Init()

void Render_Init ( void )

Definition at line 3420 of file gl_rmain.c.

3421{
3424 GL_Main_Init();
3425 Font_Init();
3426 GL_Draw_Init();
3427 R_Shadow_Init();
3428 R_Sky_Init();
3429 GL_Surf_Init();
3430 Sbar_Init();
3436}
void CL_MeshEntities_Init(void)
Definition cl_main.c:2555
void R_Particles_Init(void)
void Font_Init(void)
Definition ft2.c:443
void gl_backend_init(void)
Definition gl_backend.c:339
void GL_Draw_Init(void)
Definition gl_draw.c:747
void GL_Main_Init(void)
Definition gl_rmain.c:3220
void GL_Surf_Init(void)
Definition gl_rsurf.c:1564
void R_Textures_Init(void)
void Mod_RenderInit(void)
void R_Explosion_Init(void)
void R_LightningBeams_Init(void)
Definition r_lightning.c:96
void R_Shadow_Init(void)
Definition r_shadow.c:601
void R_Sky_Init(void)
Definition r_sky.c:464
void Sbar_Init(void)
Definition sbar.c:359

References CL_MeshEntities_Init(), Font_Init(), gl_backend_init(), GL_Draw_Init(), GL_Main_Init(), GL_Surf_Init(), Mod_RenderInit(), R_Explosion_Init(), R_LightningBeams_Init(), R_Particles_Init(), R_Shadow_Init(), R_Sky_Init(), R_Textures_Init(), and Sbar_Init().

Referenced by CL_Init().

◆ RSurf_ActiveCustomEntity()

void RSurf_ActiveCustomEntity ( const matrix4x4_t * matrix,
const matrix4x4_t * inversematrix,
int entflags,
double shadertime,
float r,
float g,
float b,
float a,
int numvertices,
const float * vertex3f,
const float * texcoord2f,
const float * normal3f,
const float * svector3f,
const float * tvector3f,
const float * color4f,
int numtriangles,
const int * element3i,
const unsigned short * element3s,
qbool wantnormals,
qbool wanttangents )

Definition at line 7146 of file gl_rmain.c.

7147{
7148 rsurface.entity = r_refdef.scene.worldentity;
7149 if (r != 1.0f || g != 1.0f || b != 1.0f || a != 1.0f) {
7150 // HACK to provide a valid entity with modded colors to R_GetCurrentTexture.
7151 // A better approach could be making this copy only once per frame.
7152 static entity_render_t custom_entity;
7153 int q;
7154 custom_entity = *rsurface.entity;
7155 for (q = 0; q < 3; ++q) {
7156 float colormod = q == 0 ? r : q == 1 ? g : b;
7157 custom_entity.render_fullbright[q] *= colormod;
7158 custom_entity.render_modellight_ambient[q] *= colormod;
7159 custom_entity.render_modellight_diffuse[q] *= colormod;
7160 custom_entity.render_lightmap_ambient[q] *= colormod;
7161 custom_entity.render_lightmap_diffuse[q] *= colormod;
7162 custom_entity.render_rtlight_diffuse[q] *= colormod;
7163 }
7164 custom_entity.alpha *= a;
7165 rsurface.entity = &custom_entity;
7166 }
7167 rsurface.skeleton = NULL;
7168 rsurface.ent_skinnum = 0;
7169 rsurface.ent_qwskin = -1;
7170 rsurface.ent_flags = entflags;
7171 rsurface.shadertime = r_refdef.scene.time - shadertime;
7172 rsurface.modelnumvertices = numvertices;
7173 rsurface.modelnumtriangles = numtriangles;
7174 rsurface.matrix = *matrix;
7175 rsurface.inversematrix = *inversematrix;
7176 rsurface.matrixscale = Matrix4x4_ScaleFromMatrix(&rsurface.matrix);
7177 rsurface.inversematrixscale = 1.0f / rsurface.matrixscale;
7178 R_EntityMatrix(&rsurface.matrix);
7179 Matrix4x4_Transform(&rsurface.inversematrix, r_refdef.view.origin, rsurface.localvieworigin);
7180 Matrix4x4_TransformStandardPlane(&rsurface.inversematrix, r_refdef.fogplane[0], r_refdef.fogplane[1], r_refdef.fogplane[2], r_refdef.fogplane[3], rsurface.fogplane);
7181 rsurface.fogplaneviewdist *= rsurface.inversematrixscale;
7182 rsurface.fograngerecip = r_refdef.fograngerecip * rsurface.matrixscale;
7183 rsurface.fogheightfade = r_refdef.fogheightfade * rsurface.matrixscale;
7184 rsurface.fogmasktabledistmultiplier = FOGMASKTABLEWIDTH * rsurface.fograngerecip;
7185 memset(rsurface.frameblend, 0, sizeof(rsurface.frameblend));
7186 rsurface.frameblend[0].lerp = 1;
7187 rsurface.ent_alttextures = false;
7188 rsurface.basepolygonfactor = r_refdef.polygonfactor;
7189 rsurface.basepolygonoffset = r_refdef.polygonoffset;
7190 rsurface.entityskeletaltransform3x4 = NULL;
7191 rsurface.entityskeletaltransform3x4buffer = NULL;
7192 rsurface.entityskeletaltransform3x4offset = 0;
7193 rsurface.entityskeletaltransform3x4size = 0;
7194 rsurface.entityskeletalnumtransforms = 0;
7197 r_refdef.stats[r_stat_batch_entitycustom_vertices] += rsurface.modelnumvertices;
7198 r_refdef.stats[r_stat_batch_entitycustom_triangles] += rsurface.modelnumtriangles;
7199 if (wanttangents)
7200 {
7201 rsurface.modelvertex3f = (float *)vertex3f;
7202 rsurface.modelsvector3f = svector3f ? (float *)svector3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7203 rsurface.modeltvector3f = tvector3f ? (float *)tvector3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7204 rsurface.modelnormal3f = normal3f ? (float *)normal3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7205 }
7206 else if (wantnormals)
7207 {
7208 rsurface.modelvertex3f = (float *)vertex3f;
7209 rsurface.modelsvector3f = NULL;
7210 rsurface.modeltvector3f = NULL;
7211 rsurface.modelnormal3f = normal3f ? (float *)normal3f : (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7212 }
7213 else
7214 {
7215 rsurface.modelvertex3f = (float *)vertex3f;
7216 rsurface.modelsvector3f = NULL;
7217 rsurface.modeltvector3f = NULL;
7218 rsurface.modelnormal3f = NULL;
7219 }
7220 rsurface.modelvertex3f_vertexbuffer = 0;
7221 rsurface.modelvertex3f_bufferoffset = 0;
7222 rsurface.modelsvector3f_vertexbuffer = 0;
7223 rsurface.modelsvector3f_bufferoffset = 0;
7224 rsurface.modeltvector3f_vertexbuffer = 0;
7225 rsurface.modeltvector3f_bufferoffset = 0;
7226 rsurface.modelnormal3f_vertexbuffer = 0;
7227 rsurface.modelnormal3f_bufferoffset = 0;
7228 rsurface.modelgeneratedvertex = true;
7229 rsurface.modellightmapcolor4f = (float *)color4f;
7230 rsurface.modellightmapcolor4f_vertexbuffer = 0;
7231 rsurface.modellightmapcolor4f_bufferoffset = 0;
7232 rsurface.modeltexcoordtexture2f = (float *)texcoord2f;
7233 rsurface.modeltexcoordtexture2f_vertexbuffer = 0;
7234 rsurface.modeltexcoordtexture2f_bufferoffset = 0;
7235 rsurface.modeltexcoordlightmap2f = NULL;
7236 rsurface.modeltexcoordlightmap2f_vertexbuffer = 0;
7237 rsurface.modeltexcoordlightmap2f_bufferoffset = 0;
7238 rsurface.modelskeletalindex4ub = NULL;
7239 rsurface.modelskeletalindex4ub_vertexbuffer = NULL;
7240 rsurface.modelskeletalindex4ub_bufferoffset = 0;
7241 rsurface.modelskeletalweight4ub = NULL;
7242 rsurface.modelskeletalweight4ub_vertexbuffer = NULL;
7243 rsurface.modelskeletalweight4ub_bufferoffset = 0;
7244 rsurface.modelelement3i = (int *)element3i;
7245 rsurface.modelelement3i_indexbuffer = NULL;
7246 rsurface.modelelement3i_bufferoffset = 0;
7247 rsurface.modelelement3s = (unsigned short *)element3s;
7248 rsurface.modelelement3s_indexbuffer = NULL;
7249 rsurface.modelelement3s_bufferoffset = 0;
7250 rsurface.modellightmapoffsets = NULL;
7251 rsurface.modelsurfaces = NULL;
7252 rsurface.batchgeneratedvertex = false;
7253 rsurface.batchfirstvertex = 0;
7254 rsurface.batchnumvertices = 0;
7255 rsurface.batchfirsttriangle = 0;
7256 rsurface.batchnumtriangles = 0;
7257 rsurface.batchvertex3f = NULL;
7258 rsurface.batchvertex3f_vertexbuffer = NULL;
7259 rsurface.batchvertex3f_bufferoffset = 0;
7260 rsurface.batchsvector3f = NULL;
7261 rsurface.batchsvector3f_vertexbuffer = NULL;
7262 rsurface.batchsvector3f_bufferoffset = 0;
7263 rsurface.batchtvector3f = NULL;
7264 rsurface.batchtvector3f_vertexbuffer = NULL;
7265 rsurface.batchtvector3f_bufferoffset = 0;
7266 rsurface.batchnormal3f = NULL;
7267 rsurface.batchnormal3f_vertexbuffer = NULL;
7268 rsurface.batchnormal3f_bufferoffset = 0;
7269 rsurface.batchlightmapcolor4f = NULL;
7270 rsurface.batchlightmapcolor4f_vertexbuffer = NULL;
7271 rsurface.batchlightmapcolor4f_bufferoffset = 0;
7272 rsurface.batchtexcoordtexture2f = NULL;
7273 rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
7274 rsurface.batchtexcoordtexture2f_bufferoffset = 0;
7275 rsurface.batchtexcoordlightmap2f = NULL;
7276 rsurface.batchtexcoordlightmap2f_vertexbuffer = NULL;
7277 rsurface.batchtexcoordlightmap2f_bufferoffset = 0;
7278 rsurface.batchskeletalindex4ub = NULL;
7279 rsurface.batchskeletalindex4ub_vertexbuffer = NULL;
7280 rsurface.batchskeletalindex4ub_bufferoffset = 0;
7281 rsurface.batchskeletalweight4ub = NULL;
7282 rsurface.batchskeletalweight4ub_vertexbuffer = NULL;
7283 rsurface.batchskeletalweight4ub_bufferoffset = 0;
7284 rsurface.batchelement3i = NULL;
7285 rsurface.batchelement3i_indexbuffer = NULL;
7286 rsurface.batchelement3i_bufferoffset = 0;
7287 rsurface.batchelement3s = NULL;
7288 rsurface.batchelement3s_indexbuffer = NULL;
7289 rsurface.batchelement3s_bufferoffset = 0;
7290 rsurface.forcecurrenttextureupdate = true;
7291
7292 if (rsurface.modelnumvertices && rsurface.modelelement3i)
7293 {
7294 if ((wantnormals || wanttangents) && !normal3f)
7295 {
7296 rsurface.modelnormal3f = (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7297 Mod_BuildNormals(0, rsurface.modelnumvertices, rsurface.modelnumtriangles, rsurface.modelvertex3f, rsurface.modelelement3i, rsurface.modelnormal3f, r_smoothnormals_areaweighting.integer != 0);
7298 }
7299 if (wanttangents && !svector3f)
7300 {
7301 rsurface.modelsvector3f = (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7302 rsurface.modeltvector3f = (float *)R_FrameData_Alloc(rsurface.modelnumvertices * sizeof(float[3]));
7303 Mod_BuildTextureVectorsFromNormals(0, rsurface.modelnumvertices, rsurface.modelnumtriangles, rsurface.modelvertex3f, rsurface.modeltexcoordtexture2f, rsurface.modelnormal3f, rsurface.modelelement3i, rsurface.modelsvector3f, rsurface.modeltvector3f, r_smoothnormals_areaweighting.integer != 0);
7304 }
7305 }
7306}
vector colormod
void Matrix4x4_TransformStandardPlane(const matrix4x4_t *in, float x, float y, float z, float d, float *o)
Definition matrixlib.c:1717
double Matrix4x4_ScaleFromMatrix(const matrix4x4_t *in)
Definition matrixlib.c:1805
void Mod_BuildNormals(int firstvertex, int numvertices, int numtriangles, const float *vertex3f, const int *elements, float *normal3f, qbool areaweighting)
void Mod_BuildTextureVectorsFromNormals(int firstvertex, int numvertices, int numtriangles, const float *vertex3f, const float *texcoord2f, const float *normal3f, const int *elements, float *svector3f, float *tvector3f, qbool areaweighting)
@ r_stat_batch_entitycustom_surfaces
Definition r_stats.h:164
@ r_stat_batch_entitycustom_triangles
Definition r_stats.h:166
@ r_stat_batch_entitycustom_vertices
Definition r_stats.h:165
@ r_stat_batch_entitycustom_count
Definition r_stats.h:163
precision highp float
Definition shader_glsl.h:53
float render_fullbright[3]
Definition client.h:412
float render_rtlight_diffuse[3]
Definition client.h:426
float render_lightmap_ambient[3]
Definition client.h:422
float render_lightmap_diffuse[3]
Definition client.h:423
float render_modellight_ambient[3]
Definition client.h:416
float render_modellight_diffuse[3]
Definition client.h:417

References a, entity_render_t::alpha, b, colormod, FOGMASKTABLEWIDTH, g, Matrix4x4_ScaleFromMatrix(), Matrix4x4_Transform(), Matrix4x4_TransformStandardPlane(), Mod_BuildNormals(), Mod_BuildTextureVectorsFromNormals(), NULL, r, R_EntityMatrix(), R_FrameData_Alloc(), r_refdef, r_smoothnormals_areaweighting, r_stat_batch_entitycustom_count, r_stat_batch_entitycustom_surfaces, r_stat_batch_entitycustom_triangles, r_stat_batch_entitycustom_vertices, entity_render_t::render_fullbright, entity_render_t::render_lightmap_ambient, entity_render_t::render_lightmap_diffuse, entity_render_t::render_modellight_ambient, entity_render_t::render_modellight_diffuse, entity_render_t::render_rtlight_diffuse, and rsurface.

Referenced by R_DrawCorona(), R_DrawModelDecals_Entity(), R_DrawNoModel_TransparentCallback(), R_Model_Sprite_Draw_TransparentCallback(), R_Shadow_DrawCursor_TransparentCallback(), R_Shadow_DrawLightSprite_TransparentCallback(), R_SkyBox(), and R_SkySphere().

◆ RSurf_ActiveModelEntity()

void RSurf_ActiveModelEntity ( const entity_render_t * ent,
qbool wantnormals,
qbool wanttangents,
qbool prepass )

Definition at line 6921 of file gl_rmain.c.

6922{
6923 model_t *model = ent->model;
6924 //if (rsurface.entity == ent && (!model->surfmesh.isanimated || (!wantnormals && !wanttangents)))
6925 // return;
6926 rsurface.entity = (entity_render_t *)ent;
6927 rsurface.skeleton = ent->skeleton;
6928 memcpy(rsurface.userwavefunc_param, ent->userwavefunc_param, sizeof(rsurface.userwavefunc_param));
6929 rsurface.ent_skinnum = ent->skinnum;
6930 rsurface.ent_qwskin = (ent->entitynumber <= cl.maxclients && ent->entitynumber >= 1 && cls.protocol == PROTOCOL_QUAKEWORLD && cl.scores[ent->entitynumber - 1].qw_skin[0] && !strcmp(ent->model->name, "progs/player.mdl")) ? (ent->entitynumber - 1) : -1;
6931 rsurface.ent_flags = ent->flags;
6932 if (r_fullbright_directed.integer && (r_fullbright.integer || !model->lit))
6934 rsurface.shadertime = r_refdef.scene.time - ent->shadertime;
6935 rsurface.matrix = ent->matrix;
6936 rsurface.inversematrix = ent->inversematrix;
6937 rsurface.matrixscale = Matrix4x4_ScaleFromMatrix(&rsurface.matrix);
6938 rsurface.inversematrixscale = 1.0f / rsurface.matrixscale;
6939 R_EntityMatrix(&rsurface.matrix);
6940 Matrix4x4_Transform(&rsurface.inversematrix, r_refdef.view.origin, rsurface.localvieworigin);
6941 Matrix4x4_TransformStandardPlane(&rsurface.inversematrix, r_refdef.fogplane[0], r_refdef.fogplane[1], r_refdef.fogplane[2], r_refdef.fogplane[3], rsurface.fogplane);
6942 rsurface.fogplaneviewdist = r_refdef.fogplaneviewdist * rsurface.inversematrixscale;
6943 rsurface.fograngerecip = r_refdef.fograngerecip * rsurface.matrixscale;
6944 rsurface.fogheightfade = r_refdef.fogheightfade * rsurface.matrixscale;
6945 rsurface.fogmasktabledistmultiplier = FOGMASKTABLEWIDTH * rsurface.fograngerecip;
6946 memcpy(rsurface.frameblend, ent->frameblend, sizeof(ent->frameblend));
6947 rsurface.ent_alttextures = ent->framegroupblend[0].frame != 0;
6948 rsurface.basepolygonfactor = r_refdef.polygonfactor;
6949 rsurface.basepolygonoffset = r_refdef.polygonoffset;
6950 if (ent->model->brush.submodel && !prepass)
6951 {
6952 rsurface.basepolygonfactor += r_polygonoffset_submodel_factor.value;
6953 rsurface.basepolygonoffset += r_polygonoffset_submodel_offset.value;
6954 }
6955 // if the animcache code decided it should use the shader path, skip the deform step
6956 rsurface.entityskeletaltransform3x4 = ent->animcache_skeletaltransform3x4;
6957 rsurface.entityskeletaltransform3x4buffer = ent->animcache_skeletaltransform3x4buffer;
6958 rsurface.entityskeletaltransform3x4offset = ent->animcache_skeletaltransform3x4offset;
6959 rsurface.entityskeletaltransform3x4size = ent->animcache_skeletaltransform3x4size;
6960 rsurface.entityskeletalnumtransforms = rsurface.entityskeletaltransform3x4 ? model->num_bones : 0;
6961 if (model->surfmesh.isanimated && model->AnimateVertices && !rsurface.entityskeletaltransform3x4)
6962 {
6963 if (ent->animcache_vertex3f)
6964 {
6966 r_refdef.stats[r_stat_batch_entitycache_surfaces] += model->num_surfaces;
6967 r_refdef.stats[r_stat_batch_entitycache_vertices] += model->surfmesh.num_vertices;
6968 r_refdef.stats[r_stat_batch_entitycache_triangles] += model->surfmesh.num_triangles;
6969 rsurface.modelvertex3f = ent->animcache_vertex3f;
6970 rsurface.modelvertex3f_vertexbuffer = ent->animcache_vertex3f_vertexbuffer;
6971 rsurface.modelvertex3f_bufferoffset = ent->animcache_vertex3f_bufferoffset;
6972 rsurface.modelsvector3f = wanttangents ? ent->animcache_svector3f : NULL;
6973 rsurface.modelsvector3f_vertexbuffer = wanttangents ? ent->animcache_svector3f_vertexbuffer : NULL;
6974 rsurface.modelsvector3f_bufferoffset = wanttangents ? ent->animcache_svector3f_bufferoffset : 0;
6975 rsurface.modeltvector3f = wanttangents ? ent->animcache_tvector3f : NULL;
6976 rsurface.modeltvector3f_vertexbuffer = wanttangents ? ent->animcache_tvector3f_vertexbuffer : NULL;
6977 rsurface.modeltvector3f_bufferoffset = wanttangents ? ent->animcache_tvector3f_bufferoffset : 0;
6978 rsurface.modelnormal3f = wantnormals ? ent->animcache_normal3f : NULL;
6979 rsurface.modelnormal3f_vertexbuffer = wantnormals ? ent->animcache_normal3f_vertexbuffer : NULL;
6980 rsurface.modelnormal3f_bufferoffset = wantnormals ? ent->animcache_normal3f_bufferoffset : 0;
6981 }
6982 else if (wanttangents)
6983 {
6985 r_refdef.stats[r_stat_batch_entityanimate_surfaces] += model->num_surfaces;
6986 r_refdef.stats[r_stat_batch_entityanimate_vertices] += model->surfmesh.num_vertices;
6987 r_refdef.stats[r_stat_batch_entityanimate_triangles] += model->surfmesh.num_triangles;
6988 rsurface.modelvertex3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
6989 rsurface.modelsvector3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
6990 rsurface.modeltvector3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
6991 rsurface.modelnormal3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
6992 model->AnimateVertices(model, rsurface.frameblend, rsurface.skeleton, rsurface.modelvertex3f, rsurface.modelnormal3f, rsurface.modelsvector3f, rsurface.modeltvector3f);
6993 rsurface.modelvertex3f_vertexbuffer = NULL;
6994 rsurface.modelvertex3f_bufferoffset = 0;
6995 rsurface.modelvertex3f_vertexbuffer = 0;
6996 rsurface.modelvertex3f_bufferoffset = 0;
6997 rsurface.modelsvector3f_vertexbuffer = 0;
6998 rsurface.modelsvector3f_bufferoffset = 0;
6999 rsurface.modeltvector3f_vertexbuffer = 0;
7000 rsurface.modeltvector3f_bufferoffset = 0;
7001 rsurface.modelnormal3f_vertexbuffer = 0;
7002 rsurface.modelnormal3f_bufferoffset = 0;
7003 }
7004 else if (wantnormals)
7005 {
7007 r_refdef.stats[r_stat_batch_entityanimate_surfaces] += model->num_surfaces;
7008 r_refdef.stats[r_stat_batch_entityanimate_vertices] += model->surfmesh.num_vertices;
7009 r_refdef.stats[r_stat_batch_entityanimate_triangles] += model->surfmesh.num_triangles;
7010 rsurface.modelvertex3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7011 rsurface.modelsvector3f = NULL;
7012 rsurface.modeltvector3f = NULL;
7013 rsurface.modelnormal3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7014 model->AnimateVertices(model, rsurface.frameblend, rsurface.skeleton, rsurface.modelvertex3f, rsurface.modelnormal3f, NULL, NULL);
7015 rsurface.modelvertex3f_vertexbuffer = NULL;
7016 rsurface.modelvertex3f_bufferoffset = 0;
7017 rsurface.modelvertex3f_vertexbuffer = 0;
7018 rsurface.modelvertex3f_bufferoffset = 0;
7019 rsurface.modelsvector3f_vertexbuffer = 0;
7020 rsurface.modelsvector3f_bufferoffset = 0;
7021 rsurface.modeltvector3f_vertexbuffer = 0;
7022 rsurface.modeltvector3f_bufferoffset = 0;
7023 rsurface.modelnormal3f_vertexbuffer = 0;
7024 rsurface.modelnormal3f_bufferoffset = 0;
7025 }
7026 else
7027 {
7029 r_refdef.stats[r_stat_batch_entityanimate_surfaces] += model->num_surfaces;
7030 r_refdef.stats[r_stat_batch_entityanimate_vertices] += model->surfmesh.num_vertices;
7031 r_refdef.stats[r_stat_batch_entityanimate_triangles] += model->surfmesh.num_triangles;
7032 rsurface.modelvertex3f = (float *)R_FrameData_Alloc(model->surfmesh.num_vertices * sizeof(float[3]));
7033 rsurface.modelsvector3f = NULL;
7034 rsurface.modeltvector3f = NULL;
7035 rsurface.modelnormal3f = NULL;
7036 model->AnimateVertices(model, rsurface.frameblend, rsurface.skeleton, rsurface.modelvertex3f, NULL, NULL, NULL);
7037 rsurface.modelvertex3f_vertexbuffer = NULL;
7038 rsurface.modelvertex3f_bufferoffset = 0;
7039 rsurface.modelvertex3f_vertexbuffer = 0;
7040 rsurface.modelvertex3f_bufferoffset = 0;
7041 rsurface.modelsvector3f_vertexbuffer = 0;
7042 rsurface.modelsvector3f_bufferoffset = 0;
7043 rsurface.modeltvector3f_vertexbuffer = 0;
7044 rsurface.modeltvector3f_bufferoffset = 0;
7045 rsurface.modelnormal3f_vertexbuffer = 0;
7046 rsurface.modelnormal3f_bufferoffset = 0;
7047 }
7048 rsurface.modelgeneratedvertex = true;
7049 }
7050 else
7051 {
7052 if (rsurface.entityskeletaltransform3x4)
7053 {
7055 r_refdef.stats[r_stat_batch_entityskeletal_surfaces] += model->num_surfaces;
7056 r_refdef.stats[r_stat_batch_entityskeletal_vertices] += model->surfmesh.num_vertices;
7057 r_refdef.stats[r_stat_batch_entityskeletal_triangles] += model->surfmesh.num_triangles;
7058 }
7059 else
7060 {
7062 r_refdef.stats[r_stat_batch_entitystatic_surfaces] += model->num_surfaces;
7063 r_refdef.stats[r_stat_batch_entitystatic_vertices] += model->surfmesh.num_vertices;
7064 r_refdef.stats[r_stat_batch_entitystatic_triangles] += model->surfmesh.num_triangles;
7065 }
7066 rsurface.modelvertex3f = model->surfmesh.data_vertex3f;
7067 rsurface.modelvertex3f_vertexbuffer = model->surfmesh.data_vertex3f_vertexbuffer;
7068 rsurface.modelvertex3f_bufferoffset = model->surfmesh.data_vertex3f_bufferoffset;
7069 rsurface.modelsvector3f = model->surfmesh.data_svector3f;
7070 rsurface.modelsvector3f_vertexbuffer = model->surfmesh.data_svector3f_vertexbuffer;
7071 rsurface.modelsvector3f_bufferoffset = model->surfmesh.data_svector3f_bufferoffset;
7072 rsurface.modeltvector3f = model->surfmesh.data_tvector3f;
7073 rsurface.modeltvector3f_vertexbuffer = model->surfmesh.data_tvector3f_vertexbuffer;
7074 rsurface.modeltvector3f_bufferoffset = model->surfmesh.data_tvector3f_bufferoffset;
7075 rsurface.modelnormal3f = model->surfmesh.data_normal3f;
7076 rsurface.modelnormal3f_vertexbuffer = model->surfmesh.data_normal3f_vertexbuffer;
7077 rsurface.modelnormal3f_bufferoffset = model->surfmesh.data_normal3f_bufferoffset;
7078 rsurface.modelgeneratedvertex = false;
7079 }
7080 rsurface.modellightmapcolor4f = model->surfmesh.data_lightmapcolor4f;
7081 rsurface.modellightmapcolor4f_vertexbuffer = model->surfmesh.data_lightmapcolor4f_vertexbuffer;
7082 rsurface.modellightmapcolor4f_bufferoffset = model->surfmesh.data_lightmapcolor4f_bufferoffset;
7083 rsurface.modeltexcoordtexture2f = model->surfmesh.data_texcoordtexture2f;
7084 rsurface.modeltexcoordtexture2f_vertexbuffer = model->surfmesh.data_texcoordtexture2f_vertexbuffer;
7085 rsurface.modeltexcoordtexture2f_bufferoffset = model->surfmesh.data_texcoordtexture2f_bufferoffset;
7086 rsurface.modeltexcoordlightmap2f = model->surfmesh.data_texcoordlightmap2f;
7087 rsurface.modeltexcoordlightmap2f_vertexbuffer = model->surfmesh.data_texcoordlightmap2f_vertexbuffer;
7088 rsurface.modeltexcoordlightmap2f_bufferoffset = model->surfmesh.data_texcoordlightmap2f_bufferoffset;
7089 rsurface.modelskeletalindex4ub = model->surfmesh.data_skeletalindex4ub;
7090 rsurface.modelskeletalindex4ub_vertexbuffer = model->surfmesh.data_skeletalindex4ub_vertexbuffer;
7091 rsurface.modelskeletalindex4ub_bufferoffset = model->surfmesh.data_skeletalindex4ub_bufferoffset;
7092 rsurface.modelskeletalweight4ub = model->surfmesh.data_skeletalweight4ub;
7093 rsurface.modelskeletalweight4ub_vertexbuffer = model->surfmesh.data_skeletalweight4ub_vertexbuffer;
7094 rsurface.modelskeletalweight4ub_bufferoffset = model->surfmesh.data_skeletalweight4ub_bufferoffset;
7095 rsurface.modelelement3i = model->surfmesh.data_element3i;
7096 rsurface.modelelement3i_indexbuffer = model->surfmesh.data_element3i_indexbuffer;
7097 rsurface.modelelement3i_bufferoffset = model->surfmesh.data_element3i_bufferoffset;
7098 rsurface.modelelement3s = model->surfmesh.data_element3s;
7099 rsurface.modelelement3s_indexbuffer = model->surfmesh.data_element3s_indexbuffer;
7100 rsurface.modelelement3s_bufferoffset = model->surfmesh.data_element3s_bufferoffset;
7101 rsurface.modellightmapoffsets = model->surfmesh.data_lightmapoffsets;
7102 rsurface.modelnumvertices = model->surfmesh.num_vertices;
7103 rsurface.modelnumtriangles = model->surfmesh.num_triangles;
7104 rsurface.modelsurfaces = model->data_surfaces;
7105 rsurface.batchgeneratedvertex = false;
7106 rsurface.batchfirstvertex = 0;
7107 rsurface.batchnumvertices = 0;
7108 rsurface.batchfirsttriangle = 0;
7109 rsurface.batchnumtriangles = 0;
7110 rsurface.batchvertex3f = NULL;
7111 rsurface.batchvertex3f_vertexbuffer = NULL;
7112 rsurface.batchvertex3f_bufferoffset = 0;
7113 rsurface.batchsvector3f = NULL;
7114 rsurface.batchsvector3f_vertexbuffer = NULL;
7115 rsurface.batchsvector3f_bufferoffset = 0;
7116 rsurface.batchtvector3f = NULL;
7117 rsurface.batchtvector3f_vertexbuffer = NULL;
7118 rsurface.batchtvector3f_bufferoffset = 0;
7119 rsurface.batchnormal3f = NULL;
7120 rsurface.batchnormal3f_vertexbuffer = NULL;
7121 rsurface.batchnormal3f_bufferoffset = 0;
7122 rsurface.batchlightmapcolor4f = NULL;
7123 rsurface.batchlightmapcolor4f_vertexbuffer = NULL;
7124 rsurface.batchlightmapcolor4f_bufferoffset = 0;
7125 rsurface.batchtexcoordtexture2f = NULL;
7126 rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
7127 rsurface.batchtexcoordtexture2f_bufferoffset = 0;
7128 rsurface.batchtexcoordlightmap2f = NULL;
7129 rsurface.batchtexcoordlightmap2f_vertexbuffer = NULL;
7130 rsurface.batchtexcoordlightmap2f_bufferoffset = 0;
7131 rsurface.batchskeletalindex4ub = NULL;
7132 rsurface.batchskeletalindex4ub_vertexbuffer = NULL;
7133 rsurface.batchskeletalindex4ub_bufferoffset = 0;
7134 rsurface.batchskeletalweight4ub = NULL;
7135 rsurface.batchskeletalweight4ub_vertexbuffer = NULL;
7136 rsurface.batchskeletalweight4ub_bufferoffset = 0;
7137 rsurface.batchelement3i = NULL;
7138 rsurface.batchelement3i_indexbuffer = NULL;
7139 rsurface.batchelement3i_bufferoffset = 0;
7140 rsurface.batchelement3s = NULL;
7141 rsurface.batchelement3s_indexbuffer = NULL;
7142 rsurface.batchelement3s_bufferoffset = 0;
7143 rsurface.forcecurrenttextureupdate = false;
7144}
@ PROTOCOL_QUAKEWORLD
quakeworld protocol
Definition common.h:145
@ r_stat_batch_entityanimate_count
Definition r_stats.h:151
@ r_stat_batch_entitycache_triangles
Definition r_stats.h:150
@ r_stat_batch_entityskeletal_vertices
Definition r_stats.h:157
@ r_stat_batch_entitystatic_surfaces
Definition r_stats.h:160
@ r_stat_batch_entitycache_vertices
Definition r_stats.h:149
@ r_stat_batch_entitycache_surfaces
Definition r_stats.h:148
@ r_stat_batch_entityanimate_surfaces
Definition r_stats.h:152
@ r_stat_batch_entitystatic_triangles
Definition r_stats.h:162
@ r_stat_batch_entitystatic_count
Definition r_stats.h:159
@ r_stat_batch_entityskeletal_surfaces
Definition r_stats.h:156
@ r_stat_batch_entitystatic_vertices
Definition r_stats.h:161
@ r_stat_batch_entityanimate_vertices
Definition r_stats.h:153
@ r_stat_batch_entitycache_count
Definition r_stats.h:147
@ r_stat_batch_entityskeletal_triangles
Definition r_stats.h:158
@ r_stat_batch_entityskeletal_count
Definition r_stats.h:155
@ r_stat_batch_entityanimate_triangles
Definition r_stats.h:154
vec_t userwavefunc_param[Q3WAVEFUNC_USER_COUNT]
Definition client.h:445
double shadertime
Definition client.h:366
model_brush_t brush
char name[MAX_QPATH]

References entity_render_t::animcache_normal3f, entity_render_t::animcache_normal3f_bufferoffset, entity_render_t::animcache_normal3f_vertexbuffer, entity_render_t::animcache_skeletaltransform3x4, entity_render_t::animcache_skeletaltransform3x4buffer, entity_render_t::animcache_skeletaltransform3x4offset, entity_render_t::animcache_skeletaltransform3x4size, entity_render_t::animcache_svector3f, entity_render_t::animcache_svector3f_bufferoffset, entity_render_t::animcache_svector3f_vertexbuffer, entity_render_t::animcache_tvector3f, entity_render_t::animcache_tvector3f_bufferoffset, entity_render_t::animcache_tvector3f_vertexbuffer, entity_render_t::animcache_vertex3f, entity_render_t::animcache_vertex3f_bufferoffset, entity_render_t::animcache_vertex3f_vertexbuffer, model_t::brush, cl, cls, entity_render_t::entitynumber, entity_render_t::flags, FOGMASKTABLEWIDTH, framegroupblend_t::frame, entity_render_t::frameblend, entity_render_t::framegroupblend, entity_render_t::inversematrix, entity_render_t::matrix, Matrix4x4_ScaleFromMatrix(), Matrix4x4_Transform(), Matrix4x4_TransformStandardPlane(), entity_render_t::model, model, model_t::name, NULL, PROTOCOL_QUAKEWORLD, R_EntityMatrix(), R_FrameData_Alloc(), r_fullbright, r_fullbright_directed, r_polygonoffset_submodel_factor, r_polygonoffset_submodel_offset, r_refdef, r_stat_batch_entityanimate_count, r_stat_batch_entityanimate_surfaces, r_stat_batch_entityanimate_triangles, r_stat_batch_entityanimate_vertices, r_stat_batch_entitycache_count, r_stat_batch_entitycache_surfaces, r_stat_batch_entitycache_triangles, r_stat_batch_entitycache_vertices, r_stat_batch_entityskeletal_count, r_stat_batch_entityskeletal_surfaces, r_stat_batch_entityskeletal_triangles, r_stat_batch_entityskeletal_vertices, r_stat_batch_entitystatic_count, r_stat_batch_entitystatic_surfaces, r_stat_batch_entitystatic_triangles, r_stat_batch_entitystatic_vertices, RENDER_DYNAMICMODELLIGHT, RENDER_LIGHT, rsurface, entity_render_t::shadertime, entity_render_t::skeleton, entity_render_t::skinnum, model_brush_t::submodel, and entity_render_t::userwavefunc_param.

Referenced by R_DecalSystem_SplatEntity(), R_DrawBBoxMesh(), R_DrawModelDecals_Entity(), R_DrawModelSurfaces(), R_DrawParticle_TransparentCallback(), R_DrawSurface_TransparentCallback(), R_Mod_DrawAddWaterPlanes(), R_Mod_GetLightInfo(), R_Shadow_DrawCoronas(), R_Shadow_DrawEntityShadow(), R_Shadow_DrawModelShadowMaps(), R_Shadow_DrawWorldLight(), R_Shadow_DrawWorldShadow_ShadowMap(), and R_Shadow_SetupEntityLight().

◆ RSurf_DrawBatch()

void RSurf_DrawBatch ( void )

Definition at line 8477 of file gl_rmain.c.

8478{
8479 // sometimes a zero triangle surface (usually a degenerate patch) makes it
8480 // through the pipeline, killing it earlier in the pipeline would have
8481 // per-surface overhead rather than per-batch overhead, so it's best to
8482 // reject it here, before it hits glDraw.
8483 if (rsurface.batchnumtriangles == 0)
8484 return;
8485#if 0
8486 // batch debugging code
8487 if (r_test.integer && rsurface.entity == r_refdef.scene.worldentity && rsurface.batchvertex3f == r_refdef.scene.worldentity->model->surfmesh.data_vertex3f)
8488 {
8489 int i;
8490 int j;
8491 int c;
8492 const int *e;
8493 e = rsurface.batchelement3i + rsurface.batchfirsttriangle*3;
8494 for (i = 0;i < rsurface.batchnumtriangles*3;i++)
8495 {
8496 c = e[i];
8497 for (j = 0;j < rsurface.entity->model->num_surfaces;j++)
8498 {
8499 if (c >= rsurface.modelsurfaces[j].num_firstvertex && c < (rsurface.modelsurfaces[j].num_firstvertex + rsurface.modelsurfaces[j].num_vertices))
8500 {
8501 if (rsurface.modelsurfaces[j].texture != rsurface.texture)
8502 Sys_Error("RSurf_DrawBatch: index %i uses different texture (%s) than surface %i which it belongs to (which uses %s)\n", c, rsurface.texture->name, j, rsurface.modelsurfaces[j].texture->name);
8503 break;
8504 }
8505 }
8506 }
8507 }
8508#endif
8509 if (rsurface.batchmultidraw)
8510 {
8511 // issue multiple draws rather than copying index data
8512 int numsurfaces = rsurface.batchmultidrawnumsurfaces;
8513 const msurface_t **surfacelist = rsurface.batchmultidrawsurfacelist;
8514 int i, j, k, firstvertex, endvertex, firsttriangle, endtriangle;
8515 for (i = 0;i < numsurfaces;)
8516 {
8517 // combine consecutive surfaces as one draw
8518 for (k = i, j = i + 1;j < numsurfaces;k = j, j++)
8519 if (surfacelist[j] != surfacelist[k] + 1)
8520 break;
8521 firstvertex = surfacelist[i]->num_firstvertex;
8522 endvertex = surfacelist[k]->num_firstvertex + surfacelist[k]->num_vertices;
8523 firsttriangle = surfacelist[i]->num_firsttriangle;
8524 endtriangle = surfacelist[k]->num_firsttriangle + surfacelist[k]->num_triangles;
8525 R_Mesh_Draw(firstvertex, endvertex - firstvertex, firsttriangle, endtriangle - firsttriangle, rsurface.batchelement3i, rsurface.batchelement3i_indexbuffer, rsurface.batchelement3i_bufferoffset, rsurface.batchelement3s, rsurface.batchelement3s_indexbuffer, rsurface.batchelement3s_bufferoffset);
8526 i = j;
8527 }
8528 }
8529 else
8530 {
8531 // there is only one consecutive run of index data (may have been combined)
8532 R_Mesh_Draw(rsurface.batchfirstvertex, rsurface.batchnumvertices, rsurface.batchfirsttriangle, rsurface.batchnumtriangles, rsurface.batchelement3i, rsurface.batchelement3i_indexbuffer, rsurface.batchelement3i_bufferoffset, rsurface.batchelement3s, rsurface.batchelement3s_indexbuffer, rsurface.batchelement3s_bufferoffset);
8533 }
8534}
void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtriangles, const int *element3i, const r_meshbuffer_t *element3i_indexbuffer, int element3i_bufferoffset, const unsigned short *element3s, const r_meshbuffer_t *element3s_indexbuffer, int element3s_bufferoffset)

References msurface_t::num_firsttriangle, msurface_t::num_firstvertex, msurface_t::num_triangles, msurface_t::num_vertices, R_Mesh_Draw(), r_refdef, r_test, rsurface, and Sys_Error().

Referenced by R_DrawDebugModel(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_GL20(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_Mod_DrawShadowMap(), R_Shadow_RenderLighting_Light_GLSL(), and R_Shadow_RenderLighting_VisibleLighting().

◆ RSurf_FogPoint()

float RSurf_FogPoint ( const float * v)

Definition at line 7308 of file gl_rmain.c.

7309{
7310 // this code is identical to the USEFOGINSIDE/USEFOGOUTSIDE code in the shader
7311 float FogPlaneViewDist = r_refdef.fogplaneviewdist;
7312 float FogPlaneVertexDist = DotProduct(r_refdef.fogplane, v) + r_refdef.fogplane[3];
7313 float FogHeightFade = r_refdef.fogheightfade;
7314 float fogfrac;
7315 unsigned int fogmasktableindex;
7316 if (r_refdef.fogplaneviewabove)
7318 else
7320 fogmasktableindex = (unsigned int)(VectorDistance(r_refdef.view.origin, v) * fogfrac * r_refdef.fogmasktabledistmultiplier);
7321 return r_refdef.fogmasktable[min(fogmasktableindex, FOGMASKTABLEWIDTH - 1)];
7322}
#define VectorDistance(a, b)
Definition mathlib.h:108
uniform highp float FogHeightFade
float fogfrac
vec3 float FogPlaneVertexDist
uniform highp float FogPlaneViewDist

References DotProduct, fogfrac, FogHeightFade, FOGMASKTABLEWIDTH, FogPlaneVertexDist, FogPlaneViewDist, int(), max, min, r_refdef, v, and VectorDistance.

◆ RSurf_FogVertex()

float RSurf_FogVertex ( const float * v)

Definition at line 7324 of file gl_rmain.c.

7325{
7326 // this code is identical to the USEFOGINSIDE/USEFOGOUTSIDE code in the shader
7327 float FogPlaneViewDist = rsurface.fogplaneviewdist;
7328 float FogPlaneVertexDist = DotProduct(rsurface.fogplane, v) + rsurface.fogplane[3];
7329 float FogHeightFade = rsurface.fogheightfade;
7330 float fogfrac;
7331 unsigned int fogmasktableindex;
7332 if (r_refdef.fogplaneviewabove)
7334 else
7336 fogmasktableindex = (unsigned int)(VectorDistance(rsurface.localvieworigin, v) * fogfrac * rsurface.fogmasktabledistmultiplier);
7337 return r_refdef.fogmasktable[min(fogmasktableindex, FOGMASKTABLEWIDTH - 1)];
7338}

References DotProduct, fogfrac, FogHeightFade, FOGMASKTABLEWIDTH, FogPlaneVertexDist, FogPlaneViewDist, int(), max, min, r_refdef, rsurface, v, and VectorDistance.

Referenced by R_DrawBBoxMesh(), R_DrawModelDecals_Entity(), R_DrawNoModel_TransparentCallback(), and R_DrawParticle_TransparentCallback().

◆ RSurf_PrepareVerticesForBatch()

void RSurf_PrepareVerticesForBatch ( int batchneed,
int texturenumsurfaces,
const msurface_t ** texturesurfacelist )

Definition at line 7388 of file gl_rmain.c.

7389{
7390 int deformindex;
7391 int firsttriangle;
7392 int numtriangles;
7393 int firstvertex;
7394 int endvertex;
7395 int numvertices;
7396 int surfacefirsttriangle;
7397 int surfacenumtriangles;
7398 int surfacefirstvertex;
7399 int surfaceendvertex;
7400 int surfacenumvertices;
7401 int batchnumsurfaces = texturenumsurfaces;
7402 int batchnumvertices;
7403 int batchnumtriangles;
7404 int i, j;
7405 qbool gaps;
7406 qbool dynamicvertex;
7407 float amplitude;
7408 float animpos;
7409 float center[3], forward[3], right[3], up[3], v[3], newforward[3], newright[3], newup[3];
7410 float waveparms[4];
7411 unsigned char *ub;
7412 q3shaderinfo_deform_t *deform;
7413 const msurface_t *surface, *firstsurface;
7414 if (!texturenumsurfaces)
7415 return;
7416 // find vertex range of this surface batch
7417 gaps = false;
7418 firstsurface = texturesurfacelist[0];
7419 firsttriangle = firstsurface->num_firsttriangle;
7420 batchnumvertices = 0;
7421 batchnumtriangles = 0;
7422 firstvertex = endvertex = firstsurface->num_firstvertex;
7423 for (i = 0;i < texturenumsurfaces;i++)
7424 {
7425 surface = texturesurfacelist[i];
7426 if (surface != firstsurface + i)
7427 gaps = true;
7428 surfacefirstvertex = surface->num_firstvertex;
7429 surfaceendvertex = surfacefirstvertex + surface->num_vertices;
7430 surfacenumvertices = surface->num_vertices;
7431 surfacenumtriangles = surface->num_triangles;
7432 if (firstvertex > surfacefirstvertex)
7433 firstvertex = surfacefirstvertex;
7434 if (endvertex < surfaceendvertex)
7435 endvertex = surfaceendvertex;
7436 batchnumvertices += surfacenumvertices;
7437 batchnumtriangles += surfacenumtriangles;
7438 }
7439
7441 if (gaps)
7443 r_refdef.stats[r_stat_batch_surfaces] += batchnumsurfaces;
7444 r_refdef.stats[r_stat_batch_vertices] += batchnumvertices;
7445 r_refdef.stats[r_stat_batch_triangles] += batchnumtriangles;
7446
7447 // we now know the vertex range used, and if there are any gaps in it
7448 rsurface.batchfirstvertex = firstvertex;
7449 rsurface.batchnumvertices = endvertex - firstvertex;
7450 rsurface.batchfirsttriangle = firsttriangle;
7451 rsurface.batchnumtriangles = batchnumtriangles;
7452
7453 // check if any dynamic vertex processing must occur
7454 dynamicvertex = false;
7455
7456 // we must use vertexbuffers for rendering, we can upload vertex buffers
7457 // easily enough but if the basevertex is non-zero it becomes more
7458 // difficult, so force dynamicvertex path in that case - it's suboptimal
7459 // but the most optimal case is to have the geometry sources provide their
7460 // own anyway.
7461 if (!rsurface.modelvertex3f_vertexbuffer && firstvertex != 0)
7462 dynamicvertex = true;
7463
7464 // a cvar to force the dynamic vertex path to be taken, for debugging
7466 {
7467 if (!dynamicvertex)
7468 {
7470 r_refdef.stats[r_stat_batch_dynamic_surfaces_because_cvar] += batchnumsurfaces;
7471 r_refdef.stats[r_stat_batch_dynamic_vertices_because_cvar] += batchnumvertices;
7472 r_refdef.stats[r_stat_batch_dynamic_triangles_because_cvar] += batchnumtriangles;
7473 }
7474 dynamicvertex = true;
7475 }
7476
7477 // if there is a chance of animated vertex colors, it's a dynamic batch
7478 if ((batchneed & BATCHNEED_ARRAY_VERTEXCOLOR) && texturesurfacelist[0]->lightmapinfo)
7479 {
7480 if (!dynamicvertex)
7481 {
7486 }
7487 dynamicvertex = true;
7488 }
7489
7490 for (deformindex = 0, deform = rsurface.texture->deforms;deformindex < Q3MAXDEFORMS && deform->deform && r_deformvertexes.integer;deformindex++, deform++)
7491 {
7492 switch (deform->deform)
7493 {
7494 default:
7496 case Q3DEFORM_TEXT0:
7497 case Q3DEFORM_TEXT1:
7498 case Q3DEFORM_TEXT2:
7499 case Q3DEFORM_TEXT3:
7500 case Q3DEFORM_TEXT4:
7501 case Q3DEFORM_TEXT5:
7502 case Q3DEFORM_TEXT6:
7503 case Q3DEFORM_TEXT7:
7504 case Q3DEFORM_NONE:
7505 break;
7507 if (!dynamicvertex)
7508 {
7513 }
7514 dynamicvertex = true;
7516 break;
7518 if (!dynamicvertex)
7519 {
7524 }
7525 dynamicvertex = true;
7527 break;
7528 case Q3DEFORM_NORMAL:
7529 if (!dynamicvertex)
7530 {
7535 }
7536 dynamicvertex = true;
7538 break;
7539 case Q3DEFORM_WAVE:
7540 if(!R_TestQ3WaveFunc(deform->wavefunc, deform->waveparms))
7541 break; // if wavefunc is a nop, ignore this transform
7542 if (!dynamicvertex)
7543 {
7548 }
7549 dynamicvertex = true;
7551 break;
7552 case Q3DEFORM_BULGE:
7553 if (!dynamicvertex)
7554 {
7559 }
7560 dynamicvertex = true;
7562 break;
7563 case Q3DEFORM_MOVE:
7564 if(!R_TestQ3WaveFunc(deform->wavefunc, deform->waveparms))
7565 break; // if wavefunc is a nop, ignore this transform
7566 if (!dynamicvertex)
7567 {
7572 }
7573 dynamicvertex = true;
7574 batchneed |= BATCHNEED_ARRAY_VERTEX;
7575 break;
7576 }
7577 }
7578 if (rsurface.texture->materialshaderpass)
7579 {
7580 switch (rsurface.texture->materialshaderpass->tcgen.tcgen)
7581 {
7582 default:
7583 case Q3TCGEN_TEXTURE:
7584 break;
7585 case Q3TCGEN_LIGHTMAP:
7586 if (!dynamicvertex)
7587 {
7592 }
7593 dynamicvertex = true;
7594 batchneed |= BATCHNEED_ARRAY_LIGHTMAP;
7595 break;
7596 case Q3TCGEN_VECTOR:
7597 if (!dynamicvertex)
7598 {
7603 }
7604 dynamicvertex = true;
7605 batchneed |= BATCHNEED_ARRAY_VERTEX;
7606 break;
7608 if (!dynamicvertex)
7609 {
7614 }
7615 dynamicvertex = true;
7617 break;
7618 }
7619 if (rsurface.texture->materialshaderpass->tcmods[0].tcmod == Q3TCMOD_TURBULENT)
7620 {
7621 if (!dynamicvertex)
7622 {
7627 }
7628 dynamicvertex = true;
7630 }
7631 }
7632
7633 // the caller can specify BATCHNEED_NOGAPS to force a batch with
7634 // firstvertex = 0 and endvertex = numvertices (no gaps, no firstvertex),
7635 // we ensure this by treating the vertex batch as dynamic...
7636 if ((batchneed & BATCHNEED_ALWAYSCOPY) || ((batchneed & BATCHNEED_NOGAPS) && (gaps || firstvertex > 0)))
7637 {
7638 if (!dynamicvertex)
7639 {
7641 r_refdef.stats[r_stat_batch_dynamic_surfaces_because_nogaps] += batchnumsurfaces;
7642 r_refdef.stats[r_stat_batch_dynamic_vertices_because_nogaps] += batchnumvertices;
7643 r_refdef.stats[r_stat_batch_dynamic_triangles_because_nogaps] += batchnumtriangles;
7644 }
7645 dynamicvertex = true;
7646 }
7647
7648 // if we're going to have to apply the skeletal transform manually, we need to batch the skeletal data
7649 if (dynamicvertex && rsurface.entityskeletaltransform3x4)
7650 batchneed |= BATCHNEED_ARRAY_SKELETAL;
7651
7652 rsurface.batchvertex3f = rsurface.modelvertex3f;
7653 rsurface.batchvertex3f_vertexbuffer = rsurface.modelvertex3f_vertexbuffer;
7654 rsurface.batchvertex3f_bufferoffset = rsurface.modelvertex3f_bufferoffset;
7655 rsurface.batchsvector3f = rsurface.modelsvector3f;
7656 rsurface.batchsvector3f_vertexbuffer = rsurface.modelsvector3f_vertexbuffer;
7657 rsurface.batchsvector3f_bufferoffset = rsurface.modelsvector3f_bufferoffset;
7658 rsurface.batchtvector3f = rsurface.modeltvector3f;
7659 rsurface.batchtvector3f_vertexbuffer = rsurface.modeltvector3f_vertexbuffer;
7660 rsurface.batchtvector3f_bufferoffset = rsurface.modeltvector3f_bufferoffset;
7661 rsurface.batchnormal3f = rsurface.modelnormal3f;
7662 rsurface.batchnormal3f_vertexbuffer = rsurface.modelnormal3f_vertexbuffer;
7663 rsurface.batchnormal3f_bufferoffset = rsurface.modelnormal3f_bufferoffset;
7664 rsurface.batchlightmapcolor4f = rsurface.modellightmapcolor4f;
7665 rsurface.batchlightmapcolor4f_vertexbuffer = rsurface.modellightmapcolor4f_vertexbuffer;
7666 rsurface.batchlightmapcolor4f_bufferoffset = rsurface.modellightmapcolor4f_bufferoffset;
7667 rsurface.batchtexcoordtexture2f = rsurface.modeltexcoordtexture2f;
7668 rsurface.batchtexcoordtexture2f_vertexbuffer = rsurface.modeltexcoordtexture2f_vertexbuffer;
7669 rsurface.batchtexcoordtexture2f_bufferoffset = rsurface.modeltexcoordtexture2f_bufferoffset;
7670 rsurface.batchtexcoordlightmap2f = rsurface.modeltexcoordlightmap2f;
7671 rsurface.batchtexcoordlightmap2f_vertexbuffer = rsurface.modeltexcoordlightmap2f_vertexbuffer;
7672 rsurface.batchtexcoordlightmap2f_bufferoffset = rsurface.modeltexcoordlightmap2f_bufferoffset;
7673 rsurface.batchskeletalindex4ub = rsurface.modelskeletalindex4ub;
7674 rsurface.batchskeletalindex4ub_vertexbuffer = rsurface.modelskeletalindex4ub_vertexbuffer;
7675 rsurface.batchskeletalindex4ub_bufferoffset = rsurface.modelskeletalindex4ub_bufferoffset;
7676 rsurface.batchskeletalweight4ub = rsurface.modelskeletalweight4ub;
7677 rsurface.batchskeletalweight4ub_vertexbuffer = rsurface.modelskeletalweight4ub_vertexbuffer;
7678 rsurface.batchskeletalweight4ub_bufferoffset = rsurface.modelskeletalweight4ub_bufferoffset;
7679 rsurface.batchelement3i = rsurface.modelelement3i;
7680 rsurface.batchelement3i_indexbuffer = rsurface.modelelement3i_indexbuffer;
7681 rsurface.batchelement3i_bufferoffset = rsurface.modelelement3i_bufferoffset;
7682 rsurface.batchelement3s = rsurface.modelelement3s;
7683 rsurface.batchelement3s_indexbuffer = rsurface.modelelement3s_indexbuffer;
7684 rsurface.batchelement3s_bufferoffset = rsurface.modelelement3s_bufferoffset;
7685 rsurface.batchskeletaltransform3x4 = rsurface.entityskeletaltransform3x4;
7686 rsurface.batchskeletaltransform3x4buffer = rsurface.entityskeletaltransform3x4buffer;
7687 rsurface.batchskeletaltransform3x4offset = rsurface.entityskeletaltransform3x4offset;
7688 rsurface.batchskeletaltransform3x4size = rsurface.entityskeletaltransform3x4size;
7689 rsurface.batchskeletalnumtransforms = rsurface.entityskeletalnumtransforms;
7690
7691 // if any dynamic vertex processing has to occur in software, we copy the
7692 // entire surface list together before processing to rebase the vertices
7693 // to start at 0 (otherwise we waste a lot of room in a vertex buffer).
7694 //
7695 // if any gaps exist and we do not have a static vertex buffer, we have to
7696 // copy the surface list together to avoid wasting upload bandwidth on the
7697 // vertices in the gaps.
7698 //
7699 // if gaps exist and we have a static vertex buffer, we can choose whether
7700 // to combine the index buffer ranges into one dynamic index buffer or
7701 // simply issue multiple glDrawElements calls (BATCHNEED_ALLOWMULTIDRAW).
7702 //
7703 // in many cases the batch is reduced to one draw call.
7704
7705 rsurface.batchmultidraw = false;
7706 rsurface.batchmultidrawnumsurfaces = 0;
7707 rsurface.batchmultidrawsurfacelist = NULL;
7708
7709 if (!dynamicvertex)
7710 {
7711 // static vertex data, just set pointers...
7712 rsurface.batchgeneratedvertex = false;
7713 // if there are gaps, we want to build a combined index buffer,
7714 // otherwise use the original static buffer with an appropriate offset
7715 if (gaps)
7716 {
7718 r_refdef.stats[r_stat_batch_copytriangles_surfaces] += batchnumsurfaces;
7719 r_refdef.stats[r_stat_batch_copytriangles_vertices] += batchnumvertices;
7720 r_refdef.stats[r_stat_batch_copytriangles_triangles] += batchnumtriangles;
7721 if ((batchneed & BATCHNEED_ALLOWMULTIDRAW) && r_batch_multidraw.integer && batchnumtriangles >= r_batch_multidraw_mintriangles.integer)
7722 {
7723 rsurface.batchmultidraw = true;
7724 rsurface.batchmultidrawnumsurfaces = texturenumsurfaces;
7725 rsurface.batchmultidrawsurfacelist = texturesurfacelist;
7726 return;
7727 }
7728 // build a new triangle elements array for this batch
7729 rsurface.batchelement3i = (int *)R_FrameData_Alloc(batchnumtriangles * sizeof(int[3]));
7730 rsurface.batchfirsttriangle = 0;
7731 numtriangles = 0;
7732 for (i = 0;i < texturenumsurfaces;i++)
7733 {
7734 surfacefirsttriangle = texturesurfacelist[i]->num_firsttriangle;
7735 surfacenumtriangles = texturesurfacelist[i]->num_triangles;
7736 memcpy(rsurface.batchelement3i + 3*numtriangles, rsurface.modelelement3i + 3*surfacefirsttriangle, surfacenumtriangles*sizeof(int[3]));
7737 numtriangles += surfacenumtriangles;
7738 }
7739 rsurface.batchelement3i_indexbuffer = NULL;
7740 rsurface.batchelement3i_bufferoffset = 0;
7741 rsurface.batchelement3s = NULL;
7742 rsurface.batchelement3s_indexbuffer = NULL;
7743 rsurface.batchelement3s_bufferoffset = 0;
7744 if (endvertex <= 65536)
7745 {
7746 // make a 16bit (unsigned short) index array if possible
7747 rsurface.batchelement3s = (unsigned short *)R_FrameData_Alloc(batchnumtriangles * sizeof(unsigned short[3]));
7748 for (i = 0;i < numtriangles*3;i++)
7749 rsurface.batchelement3s[i] = rsurface.batchelement3i[i];
7750 }
7751 }
7752 else
7753 {
7755 r_refdef.stats[r_stat_batch_fast_surfaces] += batchnumsurfaces;
7756 r_refdef.stats[r_stat_batch_fast_vertices] += batchnumvertices;
7757 r_refdef.stats[r_stat_batch_fast_triangles] += batchnumtriangles;
7758 }
7759 return;
7760 }
7761
7762 // something needs software processing, do it for real...
7763 // we only directly handle separate array data in this case and then
7764 // generate interleaved data if needed...
7765 rsurface.batchgeneratedvertex = true;
7767 r_refdef.stats[r_stat_batch_dynamic_surfaces] += batchnumsurfaces;
7768 r_refdef.stats[r_stat_batch_dynamic_vertices] += batchnumvertices;
7769 r_refdef.stats[r_stat_batch_dynamic_triangles] += batchnumtriangles;
7770
7771 // now copy the vertex data into a combined array and make an index array
7772 // (this is what Quake3 does all the time)
7773 // we also apply any skeletal animation here that would have been done in
7774 // the vertex shader, because most of the dynamic vertex animation cases
7775 // need actual vertex positions and normals
7776 //if (dynamicvertex)
7777 {
7778 rsurface.batchvertex3f = NULL;
7779 rsurface.batchvertex3f_vertexbuffer = NULL;
7780 rsurface.batchvertex3f_bufferoffset = 0;
7781 rsurface.batchsvector3f = NULL;
7782 rsurface.batchsvector3f_vertexbuffer = NULL;
7783 rsurface.batchsvector3f_bufferoffset = 0;
7784 rsurface.batchtvector3f = NULL;
7785 rsurface.batchtvector3f_vertexbuffer = NULL;
7786 rsurface.batchtvector3f_bufferoffset = 0;
7787 rsurface.batchnormal3f = NULL;
7788 rsurface.batchnormal3f_vertexbuffer = NULL;
7789 rsurface.batchnormal3f_bufferoffset = 0;
7790 rsurface.batchlightmapcolor4f = NULL;
7791 rsurface.batchlightmapcolor4f_vertexbuffer = NULL;
7792 rsurface.batchlightmapcolor4f_bufferoffset = 0;
7793 rsurface.batchtexcoordtexture2f = NULL;
7794 rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
7795 rsurface.batchtexcoordtexture2f_bufferoffset = 0;
7796 rsurface.batchtexcoordlightmap2f = NULL;
7797 rsurface.batchtexcoordlightmap2f_vertexbuffer = NULL;
7798 rsurface.batchtexcoordlightmap2f_bufferoffset = 0;
7799 rsurface.batchskeletalindex4ub = NULL;
7800 rsurface.batchskeletalindex4ub_vertexbuffer = NULL;
7801 rsurface.batchskeletalindex4ub_bufferoffset = 0;
7802 rsurface.batchskeletalweight4ub = NULL;
7803 rsurface.batchskeletalweight4ub_vertexbuffer = NULL;
7804 rsurface.batchskeletalweight4ub_bufferoffset = 0;
7805 rsurface.batchelement3i = (int *)R_FrameData_Alloc(batchnumtriangles * sizeof(int[3]));
7806 rsurface.batchelement3i_indexbuffer = NULL;
7807 rsurface.batchelement3i_bufferoffset = 0;
7808 rsurface.batchelement3s = NULL;
7809 rsurface.batchelement3s_indexbuffer = NULL;
7810 rsurface.batchelement3s_bufferoffset = 0;
7811 rsurface.batchskeletaltransform3x4buffer = NULL;
7812 rsurface.batchskeletaltransform3x4offset = 0;
7813 rsurface.batchskeletaltransform3x4size = 0;
7814 // we'll only be setting up certain arrays as needed
7815 if (batchneed & BATCHNEED_ARRAY_VERTEX)
7816 rsurface.batchvertex3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7817 if (batchneed & BATCHNEED_ARRAY_NORMAL)
7818 rsurface.batchnormal3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7819 if (batchneed & BATCHNEED_ARRAY_VECTOR)
7820 {
7821 rsurface.batchsvector3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7822 rsurface.batchtvector3f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
7823 }
7824 if (batchneed & BATCHNEED_ARRAY_VERTEXCOLOR)
7825 rsurface.batchlightmapcolor4f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[4]));
7826 if (batchneed & BATCHNEED_ARRAY_TEXCOORD)
7827 rsurface.batchtexcoordtexture2f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
7828 if (batchneed & BATCHNEED_ARRAY_LIGHTMAP)
7829 rsurface.batchtexcoordlightmap2f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
7830 if (batchneed & BATCHNEED_ARRAY_SKELETAL)
7831 {
7832 rsurface.batchskeletalindex4ub = (unsigned char *)R_FrameData_Alloc(batchnumvertices * sizeof(unsigned char[4]));
7833 rsurface.batchskeletalweight4ub = (unsigned char *)R_FrameData_Alloc(batchnumvertices * sizeof(unsigned char[4]));
7834 }
7835 numvertices = 0;
7836 numtriangles = 0;
7837 for (i = 0;i < texturenumsurfaces;i++)
7838 {
7839 surfacefirstvertex = texturesurfacelist[i]->num_firstvertex;
7840 surfacenumvertices = texturesurfacelist[i]->num_vertices;
7841 surfacefirsttriangle = texturesurfacelist[i]->num_firsttriangle;
7842 surfacenumtriangles = texturesurfacelist[i]->num_triangles;
7843 // copy only the data requested
7845 {
7846 if (batchneed & BATCHNEED_ARRAY_VERTEX)
7847 {
7848 if (rsurface.batchvertex3f)
7849 memcpy(rsurface.batchvertex3f + 3*numvertices, rsurface.modelvertex3f + 3*surfacefirstvertex, surfacenumvertices * sizeof(float[3]));
7850 else
7851 memset(rsurface.batchvertex3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7852 }
7853 if (batchneed & BATCHNEED_ARRAY_NORMAL)
7854 {
7855 if (rsurface.modelnormal3f)
7856 memcpy(rsurface.batchnormal3f + 3*numvertices, rsurface.modelnormal3f + 3*surfacefirstvertex, surfacenumvertices * sizeof(float[3]));
7857 else
7858 memset(rsurface.batchnormal3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7859 }
7860 if (batchneed & BATCHNEED_ARRAY_VECTOR)
7861 {
7862 if (rsurface.modelsvector3f)
7863 {
7864 memcpy(rsurface.batchsvector3f + 3*numvertices, rsurface.modelsvector3f + 3*surfacefirstvertex, surfacenumvertices * sizeof(float[3]));
7865 memcpy(rsurface.batchtvector3f + 3*numvertices, rsurface.modeltvector3f + 3*surfacefirstvertex, surfacenumvertices * sizeof(float[3]));
7866 }
7867 else
7868 {
7869 memset(rsurface.batchsvector3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7870 memset(rsurface.batchtvector3f + 3*numvertices, 0, surfacenumvertices * sizeof(float[3]));
7871 }
7872 }
7873 if (batchneed & BATCHNEED_ARRAY_VERTEXCOLOR)
7874 {
7875 if (rsurface.modellightmapcolor4f)
7876 memcpy(rsurface.batchlightmapcolor4f + 4*numvertices, rsurface.modellightmapcolor4f + 4*surfacefirstvertex, surfacenumvertices * sizeof(float[4]));
7877 else
7878 memset(rsurface.batchlightmapcolor4f + 4*numvertices, 0, surfacenumvertices * sizeof(float[4]));
7879 }
7880 if (batchneed & BATCHNEED_ARRAY_TEXCOORD)
7881 {
7882 if (rsurface.modeltexcoordtexture2f)
7883 memcpy(rsurface.batchtexcoordtexture2f + 2*numvertices, rsurface.modeltexcoordtexture2f + 2*surfacefirstvertex, surfacenumvertices * sizeof(float[2]));
7884 else
7885 memset(rsurface.batchtexcoordtexture2f + 2*numvertices, 0, surfacenumvertices * sizeof(float[2]));
7886 }
7887 if (batchneed & BATCHNEED_ARRAY_LIGHTMAP)
7888 {
7889 if (rsurface.modeltexcoordlightmap2f)
7890 memcpy(rsurface.batchtexcoordlightmap2f + 2*numvertices, rsurface.modeltexcoordlightmap2f + 2*surfacefirstvertex, surfacenumvertices * sizeof(float[2]));
7891 else
7892 memset(rsurface.batchtexcoordlightmap2f + 2*numvertices, 0, surfacenumvertices * sizeof(float[2]));
7893 }
7894 if (batchneed & BATCHNEED_ARRAY_SKELETAL)
7895 {
7896 if (rsurface.modelskeletalindex4ub)
7897 {
7898 memcpy(rsurface.batchskeletalindex4ub + 4*numvertices, rsurface.modelskeletalindex4ub + 4*surfacefirstvertex, surfacenumvertices * sizeof(unsigned char[4]));
7899 memcpy(rsurface.batchskeletalweight4ub + 4*numvertices, rsurface.modelskeletalweight4ub + 4*surfacefirstvertex, surfacenumvertices * sizeof(unsigned char[4]));
7900 }
7901 else
7902 {
7903 memset(rsurface.batchskeletalindex4ub + 4*numvertices, 0, surfacenumvertices * sizeof(unsigned char[4]));
7904 memset(rsurface.batchskeletalweight4ub + 4*numvertices, 0, surfacenumvertices * sizeof(unsigned char[4]));
7905 ub = rsurface.batchskeletalweight4ub + 4*numvertices;
7906 for (j = 0;j < surfacenumvertices;j++)
7907 ub[j*4] = 255;
7908 }
7909 }
7910 }
7911 RSurf_RenumberElements(rsurface.modelelement3i + 3*surfacefirsttriangle, rsurface.batchelement3i + 3*numtriangles, 3*surfacenumtriangles, numvertices - surfacefirstvertex);
7912 numvertices += surfacenumvertices;
7913 numtriangles += surfacenumtriangles;
7914 }
7915
7916 // generate a 16bit index array as well if possible
7917 // (in general, dynamic batches fit)
7918 if (numvertices <= 65536)
7919 {
7920 rsurface.batchelement3s = (unsigned short *)R_FrameData_Alloc(batchnumtriangles * sizeof(unsigned short[3]));
7921 for (i = 0;i < numtriangles*3;i++)
7922 rsurface.batchelement3s[i] = rsurface.batchelement3i[i];
7923 }
7924
7925 // since we've copied everything, the batch now starts at 0
7926 rsurface.batchfirstvertex = 0;
7927 rsurface.batchnumvertices = batchnumvertices;
7928 rsurface.batchfirsttriangle = 0;
7929 rsurface.batchnumtriangles = batchnumtriangles;
7930 }
7931
7932 // apply skeletal animation that would have been done in the vertex shader
7933 if (rsurface.batchskeletaltransform3x4)
7934 {
7935 const unsigned char *si;
7936 const unsigned char *sw;
7937 const float *t[4];
7938 const float *b = rsurface.batchskeletaltransform3x4;
7939 float *vp, *vs, *vt, *vn;
7940 float w[4];
7941 float m[3][4], n[3][4];
7942 float tp[3], ts[3], tt[3], tn[3];
7944 r_refdef.stats[r_stat_batch_dynamicskeletal_surfaces] += batchnumsurfaces;
7945 r_refdef.stats[r_stat_batch_dynamicskeletal_vertices] += batchnumvertices;
7946 r_refdef.stats[r_stat_batch_dynamicskeletal_triangles] += batchnumtriangles;
7947 si = rsurface.batchskeletalindex4ub;
7948 sw = rsurface.batchskeletalweight4ub;
7949 vp = rsurface.batchvertex3f;
7950 vs = rsurface.batchsvector3f;
7951 vt = rsurface.batchtvector3f;
7952 vn = rsurface.batchnormal3f;
7953 memset(m[0], 0, sizeof(m));
7954 memset(n[0], 0, sizeof(n));
7955 for (i = 0;i < batchnumvertices;i++)
7956 {
7957 t[0] = b + si[0]*12;
7958 if (sw[0] == 255)
7959 {
7960 // common case - only one matrix
7961 m[0][0] = t[0][ 0];
7962 m[0][1] = t[0][ 1];
7963 m[0][2] = t[0][ 2];
7964 m[0][3] = t[0][ 3];
7965 m[1][0] = t[0][ 4];
7966 m[1][1] = t[0][ 5];
7967 m[1][2] = t[0][ 6];
7968 m[1][3] = t[0][ 7];
7969 m[2][0] = t[0][ 8];
7970 m[2][1] = t[0][ 9];
7971 m[2][2] = t[0][10];
7972 m[2][3] = t[0][11];
7973 }
7974 else if (sw[2] + sw[3])
7975 {
7976 // blend 4 matrices
7977 t[1] = b + si[1]*12;
7978 t[2] = b + si[2]*12;
7979 t[3] = b + si[3]*12;
7980 w[0] = sw[0] * (1.0f / 255.0f);
7981 w[1] = sw[1] * (1.0f / 255.0f);
7982 w[2] = sw[2] * (1.0f / 255.0f);
7983 w[3] = sw[3] * (1.0f / 255.0f);
7984 // blend the matrices
7985 m[0][0] = t[0][ 0] * w[0] + t[1][ 0] * w[1] + t[2][ 0] * w[2] + t[3][ 0] * w[3];
7986 m[0][1] = t[0][ 1] * w[0] + t[1][ 1] * w[1] + t[2][ 1] * w[2] + t[3][ 1] * w[3];
7987 m[0][2] = t[0][ 2] * w[0] + t[1][ 2] * w[1] + t[2][ 2] * w[2] + t[3][ 2] * w[3];
7988 m[0][3] = t[0][ 3] * w[0] + t[1][ 3] * w[1] + t[2][ 3] * w[2] + t[3][ 3] * w[3];
7989 m[1][0] = t[0][ 4] * w[0] + t[1][ 4] * w[1] + t[2][ 4] * w[2] + t[3][ 4] * w[3];
7990 m[1][1] = t[0][ 5] * w[0] + t[1][ 5] * w[1] + t[2][ 5] * w[2] + t[3][ 5] * w[3];
7991 m[1][2] = t[0][ 6] * w[0] + t[1][ 6] * w[1] + t[2][ 6] * w[2] + t[3][ 6] * w[3];
7992 m[1][3] = t[0][ 7] * w[0] + t[1][ 7] * w[1] + t[2][ 7] * w[2] + t[3][ 7] * w[3];
7993 m[2][0] = t[0][ 8] * w[0] + t[1][ 8] * w[1] + t[2][ 8] * w[2] + t[3][ 8] * w[3];
7994 m[2][1] = t[0][ 9] * w[0] + t[1][ 9] * w[1] + t[2][ 9] * w[2] + t[3][ 9] * w[3];
7995 m[2][2] = t[0][10] * w[0] + t[1][10] * w[1] + t[2][10] * w[2] + t[3][10] * w[3];
7996 m[2][3] = t[0][11] * w[0] + t[1][11] * w[1] + t[2][11] * w[2] + t[3][11] * w[3];
7997 }
7998 else
7999 {
8000 // blend 2 matrices
8001 t[1] = b + si[1]*12;
8002 w[0] = sw[0] * (1.0f / 255.0f);
8003 w[1] = sw[1] * (1.0f / 255.0f);
8004 // blend the matrices
8005 m[0][0] = t[0][ 0] * w[0] + t[1][ 0] * w[1];
8006 m[0][1] = t[0][ 1] * w[0] + t[1][ 1] * w[1];
8007 m[0][2] = t[0][ 2] * w[0] + t[1][ 2] * w[1];
8008 m[0][3] = t[0][ 3] * w[0] + t[1][ 3] * w[1];
8009 m[1][0] = t[0][ 4] * w[0] + t[1][ 4] * w[1];
8010 m[1][1] = t[0][ 5] * w[0] + t[1][ 5] * w[1];
8011 m[1][2] = t[0][ 6] * w[0] + t[1][ 6] * w[1];
8012 m[1][3] = t[0][ 7] * w[0] + t[1][ 7] * w[1];
8013 m[2][0] = t[0][ 8] * w[0] + t[1][ 8] * w[1];
8014 m[2][1] = t[0][ 9] * w[0] + t[1][ 9] * w[1];
8015 m[2][2] = t[0][10] * w[0] + t[1][10] * w[1];
8016 m[2][3] = t[0][11] * w[0] + t[1][11] * w[1];
8017 }
8018 si += 4;
8019 sw += 4;
8020 // modify the vertex
8021 VectorCopy(vp, tp);
8022 vp[0] = tp[0] * m[0][0] + tp[1] * m[0][1] + tp[2] * m[0][2] + m[0][3];
8023 vp[1] = tp[0] * m[1][0] + tp[1] * m[1][1] + tp[2] * m[1][2] + m[1][3];
8024 vp[2] = tp[0] * m[2][0] + tp[1] * m[2][1] + tp[2] * m[2][2] + m[2][3];
8025 vp += 3;
8026 if (vn)
8027 {
8028 // the normal transformation matrix is a set of cross products...
8029 CrossProduct(m[1], m[2], n[0]);
8030 CrossProduct(m[2], m[0], n[1]);
8031 CrossProduct(m[0], m[1], n[2]); // is actually transpose(inverse(m)) * det(m)
8032 VectorCopy(vn, tn);
8033 vn[0] = tn[0] * n[0][0] + tn[1] * n[0][1] + tn[2] * n[0][2];
8034 vn[1] = tn[0] * n[1][0] + tn[1] * n[1][1] + tn[2] * n[1][2];
8035 vn[2] = tn[0] * n[2][0] + tn[1] * n[2][1] + tn[2] * n[2][2];
8036 VectorNormalize(vn);
8037 vn += 3;
8038 if (vs)
8039 {
8040 VectorCopy(vs, ts);
8041 vs[0] = ts[0] * n[0][0] + ts[1] * n[0][1] + ts[2] * n[0][2];
8042 vs[1] = ts[0] * n[1][0] + ts[1] * n[1][1] + ts[2] * n[1][2];
8043 vs[2] = ts[0] * n[2][0] + ts[1] * n[2][1] + ts[2] * n[2][2];
8044 VectorNormalize(vs);
8045 vs += 3;
8046 VectorCopy(vt, tt);
8047 vt[0] = tt[0] * n[0][0] + tt[1] * n[0][1] + tt[2] * n[0][2];
8048 vt[1] = tt[0] * n[1][0] + tt[1] * n[1][1] + tt[2] * n[1][2];
8049 vt[2] = tt[0] * n[2][0] + tt[1] * n[2][1] + tt[2] * n[2][2];
8050 VectorNormalize(vt);
8051 vt += 3;
8052 }
8053 }
8054 }
8055 rsurface.batchskeletaltransform3x4 = NULL;
8056 rsurface.batchskeletalnumtransforms = 0;
8057 }
8058
8059 // q1bsp surfaces rendered in vertex color mode have to have colors
8060 // calculated based on lightstyles
8061 if ((batchneed & BATCHNEED_ARRAY_VERTEXCOLOR) && texturesurfacelist[0]->lightmapinfo)
8062 {
8063 // generate color arrays for the surfaces in this list
8064 int c[4];
8065 int scale;
8066 int size3;
8067 const int *offsets;
8068 const unsigned char *lm;
8069 rsurface.batchlightmapcolor4f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[4]));
8070 rsurface.batchlightmapcolor4f_vertexbuffer = NULL;
8071 rsurface.batchlightmapcolor4f_bufferoffset = 0;
8072 numvertices = 0;
8073 for (i = 0;i < texturenumsurfaces;i++)
8074 {
8075 surface = texturesurfacelist[i];
8076 offsets = rsurface.modellightmapoffsets + surface->num_firstvertex;
8077 surfacenumvertices = surface->num_vertices;
8078 if (surface->lightmapinfo->samples)
8079 {
8080 for (j = 0;j < surfacenumvertices;j++)
8081 {
8082 lm = surface->lightmapinfo->samples + offsets[j];
8083 scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[0]];
8084 VectorScale(lm, scale, c);
8085 if (surface->lightmapinfo->styles[1] != 255)
8086 {
8087 size3 = ((surface->lightmapinfo->extents[0]>>4)+1)*((surface->lightmapinfo->extents[1]>>4)+1)*3;
8088 lm += size3;
8089 scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[1]];
8090 VectorMA(c, scale, lm, c);
8091 if (surface->lightmapinfo->styles[2] != 255)
8092 {
8093 lm += size3;
8094 scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[2]];
8095 VectorMA(c, scale, lm, c);
8096 if (surface->lightmapinfo->styles[3] != 255)
8097 {
8098 lm += size3;
8099 scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[3]];
8100 VectorMA(c, scale, lm, c);
8101 }
8102 }
8103 }
8104 c[0] >>= 7;
8105 c[1] >>= 7;
8106 c[2] >>= 7;
8107 Vector4Set(rsurface.batchlightmapcolor4f + 4*numvertices, min(c[0], 255) * (1.0f / 255.0f), min(c[1], 255) * (1.0f / 255.0f), min(c[2], 255) * (1.0f / 255.0f), 1);
8108 numvertices++;
8109 }
8110 }
8111 else
8112 {
8113 for (j = 0;j < surfacenumvertices;j++)
8114 {
8115 Vector4Set(rsurface.batchlightmapcolor4f + 4*numvertices, 0, 0, 0, 1);
8116 numvertices++;
8117 }
8118 }
8119 }
8120 }
8121
8122 // if vertices are deformed (sprite flares and things in maps, possibly
8123 // water waves, bulges and other deformations), modify the copied vertices
8124 // in place
8125 for (deformindex = 0, deform = rsurface.texture->deforms;deformindex < Q3MAXDEFORMS && deform->deform && r_deformvertexes.integer;deformindex++, deform++)
8126 {
8127 float scale;
8128 switch (deform->deform)
8129 {
8130 default:
8132 case Q3DEFORM_TEXT0:
8133 case Q3DEFORM_TEXT1:
8134 case Q3DEFORM_TEXT2:
8135 case Q3DEFORM_TEXT3:
8136 case Q3DEFORM_TEXT4:
8137 case Q3DEFORM_TEXT5:
8138 case Q3DEFORM_TEXT6:
8139 case Q3DEFORM_TEXT7:
8140 case Q3DEFORM_NONE:
8141 break;
8143 Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.forward, newforward);
8144 Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.right, newright);
8145 Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.up, newup);
8146 VectorNormalize(newforward);
8147 VectorNormalize(newright);
8148 VectorNormalize(newup);
8149// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8150// rsurface.batchvertex3f_vertexbuffer = NULL;
8151// rsurface.batchvertex3f_bufferoffset = 0;
8152// rsurface.batchsvector3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchsvector3f);
8153// rsurface.batchsvector3f_vertexbuffer = NULL;
8154// rsurface.batchsvector3f_bufferoffset = 0;
8155// rsurface.batchtvector3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchtvector3f);
8156// rsurface.batchtvector3f_vertexbuffer = NULL;
8157// rsurface.batchtvector3f_bufferoffset = 0;
8158// rsurface.batchnormal3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8159// rsurface.batchnormal3f_vertexbuffer = NULL;
8160// rsurface.batchnormal3f_bufferoffset = 0;
8161 // sometimes we're on a renderpath that does not use vectors (GL11/GL13/GLES1)
8162 if (!VectorLength2(rsurface.batchnormal3f + 3*rsurface.batchfirstvertex))
8163 Mod_BuildNormals(rsurface.batchfirstvertex, batchnumvertices, batchnumtriangles, rsurface.batchvertex3f, rsurface.batchelement3i + 3 * rsurface.batchfirsttriangle, rsurface.batchnormal3f, r_smoothnormals_areaweighting.integer != 0);
8164 if (!VectorLength2(rsurface.batchsvector3f + 3*rsurface.batchfirstvertex))
8165 Mod_BuildTextureVectorsFromNormals(rsurface.batchfirstvertex, batchnumvertices, batchnumtriangles, rsurface.batchvertex3f, rsurface.batchtexcoordtexture2f, rsurface.batchnormal3f, rsurface.batchelement3i + 3 * rsurface.batchfirsttriangle, rsurface.batchsvector3f, rsurface.batchtvector3f, r_smoothnormals_areaweighting.integer != 0);
8166 // a single autosprite surface can contain multiple sprites...
8167 for (j = 0;j < batchnumvertices - 3;j += 4)
8168 {
8169 VectorClear(center);
8170 for (i = 0;i < 4;i++)
8171 VectorAdd(center, rsurface.batchvertex3f + 3*(j+i), center);
8172 VectorScale(center, 0.25f, center);
8173 VectorCopy(rsurface.batchnormal3f + 3*j, forward);
8174 VectorCopy(rsurface.batchsvector3f + 3*j, right);
8175 VectorCopy(rsurface.batchtvector3f + 3*j, up);
8176 for (i = 0;i < 4;i++)
8177 {
8178 VectorSubtract(rsurface.batchvertex3f + 3*(j+i), center, v);
8179 VectorMAMAMAM(1, center, DotProduct(forward, v), newforward, DotProduct(right, v), newright, DotProduct(up, v), newup, rsurface.batchvertex3f + 3*(j+i));
8180 }
8181 }
8182 // if we get here, BATCHNEED_ARRAY_NORMAL and BATCHNEED_ARRAY_VECTOR are in batchneed, so no need to check
8183 Mod_BuildNormals(rsurface.batchfirstvertex, batchnumvertices, batchnumtriangles, rsurface.batchvertex3f, rsurface.batchelement3i + 3 * rsurface.batchfirsttriangle, rsurface.batchnormal3f, r_smoothnormals_areaweighting.integer != 0);
8184 Mod_BuildTextureVectorsFromNormals(rsurface.batchfirstvertex, batchnumvertices, batchnumtriangles, rsurface.batchvertex3f, rsurface.batchtexcoordtexture2f, rsurface.batchnormal3f, rsurface.batchelement3i + 3 * rsurface.batchfirsttriangle, rsurface.batchsvector3f, rsurface.batchtvector3f, r_smoothnormals_areaweighting.integer != 0);
8185 break;
8187 Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.forward, newforward);
8188 Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.right, newright);
8189 Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.up, newup);
8190 VectorNormalize(newforward);
8191 VectorNormalize(newright);
8192 VectorNormalize(newup);
8193// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8194// rsurface.batchvertex3f_vertexbuffer = NULL;
8195// rsurface.batchvertex3f_bufferoffset = 0;
8196 {
8197 const float *v1, *v2;
8198 vec3_t start, end;
8199 float f, l;
8200 struct
8201 {
8202 float length2;
8203 const float *v1;
8204 const float *v2;
8205 }
8206 shortest[2];
8207 memset(shortest, 0, sizeof(shortest));
8208 // a single autosprite surface can contain multiple sprites...
8209 for (j = 0;j < batchnumvertices - 3;j += 4)
8210 {
8211 VectorClear(center);
8212 for (i = 0;i < 4;i++)
8213 VectorAdd(center, rsurface.batchvertex3f + 3*(j+i), center);
8214 VectorScale(center, 0.25f, center);
8215 // find the two shortest edges, then use them to define the
8216 // axis vectors for rotating around the central axis
8217 for (i = 0;i < 6;i++)
8218 {
8219 v1 = rsurface.batchvertex3f + 3*(j+quadedges[i][0]);
8220 v2 = rsurface.batchvertex3f + 3*(j+quadedges[i][1]);
8221 l = VectorDistance2(v1, v2);
8222 // this length bias tries to make sense of square polygons, assuming they are meant to be upright
8223 if (v1[2] != v2[2])
8224 l += (1.0f / 1024.0f);
8225 if (shortest[0].length2 > l || i == 0)
8226 {
8227 shortest[1] = shortest[0];
8228 shortest[0].length2 = l;
8229 shortest[0].v1 = v1;
8230 shortest[0].v2 = v2;
8231 }
8232 else if (shortest[1].length2 > l || i == 1)
8233 {
8234 shortest[1].length2 = l;
8235 shortest[1].v1 = v1;
8236 shortest[1].v2 = v2;
8237 }
8238 }
8239 VectorLerp(shortest[0].v1, 0.5f, shortest[0].v2, start);
8240 VectorLerp(shortest[1].v1, 0.5f, shortest[1].v2, end);
8241 // this calculates the right vector from the shortest edge
8242 // and the up vector from the edge midpoints
8243 VectorSubtract(shortest[0].v1, shortest[0].v2, right);
8245 VectorSubtract(end, start, up);
8247 // calculate a forward vector to use instead of the original plane normal (this is how we get a new right vector)
8248 VectorSubtract(rsurface.localvieworigin, center, forward);
8249 //Matrix4x4_Transform3x3(&rsurface.inversematrix, r_refdef.view.forward, forward);
8253 CrossProduct(up, forward, newright);
8254 VectorNormalize(newright);
8255 // rotate the quad around the up axis vector, this is made
8256 // especially easy by the fact we know the quad is flat,
8257 // so we only have to subtract the center position and
8258 // measure distance along the right vector, and then
8259 // multiply that by the newright vector and add back the
8260 // center position
8261 // we also need to subtract the old position to undo the
8262 // displacement from the center, which we do with a
8263 // DotProduct, the subtraction/addition of center is also
8264 // optimized into DotProducts here
8265 l = DotProduct(right, center);
8266 for (i = 0;i < 4;i++)
8267 {
8268 v1 = rsurface.batchvertex3f + 3*(j+i);
8269 f = DotProduct(right, v1) - l;
8270 VectorMAMAM(1, v1, -f, right, f, newright, rsurface.batchvertex3f + 3*(j+i));
8271 }
8272 }
8273 }
8274 if(batchneed & (BATCHNEED_ARRAY_NORMAL | BATCHNEED_ARRAY_VECTOR)) // otherwise these can stay NULL
8275 {
8276// rsurface.batchnormal3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8277// rsurface.batchnormal3f_vertexbuffer = NULL;
8278// rsurface.batchnormal3f_bufferoffset = 0;
8279 Mod_BuildNormals(rsurface.batchfirstvertex, batchnumvertices, batchnumtriangles, rsurface.batchvertex3f, rsurface.batchelement3i + 3 * rsurface.batchfirsttriangle, rsurface.batchnormal3f, r_smoothnormals_areaweighting.integer != 0);
8280 }
8281 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8282 {
8283// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8284// rsurface.batchsvector3f_vertexbuffer = NULL;
8285// rsurface.batchsvector3f_bufferoffset = 0;
8286// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8287// rsurface.batchtvector3f_vertexbuffer = NULL;
8288// rsurface.batchtvector3f_bufferoffset = 0;
8289 Mod_BuildTextureVectorsFromNormals(rsurface.batchfirstvertex, batchnumvertices, batchnumtriangles, rsurface.batchvertex3f, rsurface.batchtexcoordtexture2f, rsurface.batchnormal3f, rsurface.batchelement3i + 3 * rsurface.batchfirsttriangle, rsurface.batchsvector3f, rsurface.batchtvector3f, r_smoothnormals_areaweighting.integer != 0);
8290 }
8291 break;
8292 case Q3DEFORM_NORMAL:
8293 // deform the normals to make reflections wavey
8294 rsurface.batchnormal3f = (float *)R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8295 rsurface.batchnormal3f_vertexbuffer = NULL;
8296 rsurface.batchnormal3f_bufferoffset = 0;
8297 for (j = 0;j < batchnumvertices;j++)
8298 {
8299 float vertex[3];
8300 float *normal = rsurface.batchnormal3f + 3*j;
8301 VectorScale(rsurface.batchvertex3f + 3*j, 0.98f, vertex);
8302 normal[0] = rsurface.batchnormal3f[j*3+0] + deform->parms[0] * noise4f( vertex[0], vertex[1], vertex[2], rsurface.shadertime * deform->parms[1]);
8303 normal[1] = rsurface.batchnormal3f[j*3+1] + deform->parms[0] * noise4f( 98 + vertex[0], vertex[1], vertex[2], rsurface.shadertime * deform->parms[1]);
8304 normal[2] = rsurface.batchnormal3f[j*3+2] + deform->parms[0] * noise4f(196 + vertex[0], vertex[1], vertex[2], rsurface.shadertime * deform->parms[1]);
8306 }
8307 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8308 {
8309// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8310// rsurface.batchsvector3f_vertexbuffer = NULL;
8311// rsurface.batchsvector3f_bufferoffset = 0;
8312// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8313// rsurface.batchtvector3f_vertexbuffer = NULL;
8314// rsurface.batchtvector3f_bufferoffset = 0;
8315 Mod_BuildTextureVectorsFromNormals(rsurface.batchfirstvertex, batchnumvertices, batchnumtriangles, rsurface.batchvertex3f, rsurface.batchtexcoordtexture2f, rsurface.batchnormal3f, rsurface.batchelement3i + 3 * rsurface.batchfirsttriangle, rsurface.batchsvector3f, rsurface.batchtvector3f, r_smoothnormals_areaweighting.integer != 0);
8316 }
8317 break;
8318 case Q3DEFORM_WAVE:
8319 // deform vertex array to make wavey water and flags and such
8320 waveparms[0] = deform->waveparms[0];
8321 waveparms[1] = deform->waveparms[1];
8322 waveparms[2] = deform->waveparms[2];
8323 waveparms[3] = deform->waveparms[3];
8324 if(!R_TestQ3WaveFunc(deform->wavefunc, waveparms))
8325 break; // if wavefunc is a nop, don't make a dynamic vertex array
8326 // this is how a divisor of vertex influence on deformation
8327 animpos = deform->parms[0] ? 1.0f / deform->parms[0] : 100.0f;
8328 scale = R_EvaluateQ3WaveFunc(deform->wavefunc, waveparms);
8329// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8330// rsurface.batchvertex3f_vertexbuffer = NULL;
8331// rsurface.batchvertex3f_bufferoffset = 0;
8332// rsurface.batchnormal3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8333// rsurface.batchnormal3f_vertexbuffer = NULL;
8334// rsurface.batchnormal3f_bufferoffset = 0;
8335 for (j = 0;j < batchnumvertices;j++)
8336 {
8337 // if the wavefunc depends on time, evaluate it per-vertex
8338 if (waveparms[3])
8339 {
8340 waveparms[2] = deform->waveparms[2] + (rsurface.batchvertex3f[j*3+0] + rsurface.batchvertex3f[j*3+1] + rsurface.batchvertex3f[j*3+2]) * animpos;
8341 scale = R_EvaluateQ3WaveFunc(deform->wavefunc, waveparms);
8342 }
8343 VectorMA(rsurface.batchvertex3f + 3*j, scale, rsurface.batchnormal3f + 3*j, rsurface.batchvertex3f + 3*j);
8344 }
8345 // if we get here, BATCHNEED_ARRAY_NORMAL is in batchneed, so no need to check
8346 Mod_BuildNormals(rsurface.batchfirstvertex, batchnumvertices, batchnumtriangles, rsurface.batchvertex3f, rsurface.batchelement3i + 3 * rsurface.batchfirsttriangle, rsurface.batchnormal3f, r_smoothnormals_areaweighting.integer != 0);
8347 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8348 {
8349// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8350// rsurface.batchsvector3f_vertexbuffer = NULL;
8351// rsurface.batchsvector3f_bufferoffset = 0;
8352// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8353// rsurface.batchtvector3f_vertexbuffer = NULL;
8354// rsurface.batchtvector3f_bufferoffset = 0;
8355 Mod_BuildTextureVectorsFromNormals(rsurface.batchfirstvertex, batchnumvertices, batchnumtriangles, rsurface.batchvertex3f, rsurface.batchtexcoordtexture2f, rsurface.batchnormal3f, rsurface.batchelement3i + 3 * rsurface.batchfirsttriangle, rsurface.batchsvector3f, rsurface.batchtvector3f, r_smoothnormals_areaweighting.integer != 0);
8356 }
8357 break;
8358 case Q3DEFORM_BULGE:
8359 // deform vertex array to make the surface have moving bulges
8360// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8361// rsurface.batchvertex3f_vertexbuffer = NULL;
8362// rsurface.batchvertex3f_bufferoffset = 0;
8363// rsurface.batchnormal3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f);
8364// rsurface.batchnormal3f_vertexbuffer = NULL;
8365// rsurface.batchnormal3f_bufferoffset = 0;
8366 for (j = 0;j < batchnumvertices;j++)
8367 {
8368 scale = sin(rsurface.batchtexcoordtexture2f[j*2+0] * deform->parms[0] + rsurface.shadertime * deform->parms[2]) * deform->parms[1];
8369 VectorMA(rsurface.batchvertex3f + 3*j, scale, rsurface.batchnormal3f + 3*j, rsurface.batchvertex3f + 3*j);
8370 }
8371 // if we get here, BATCHNEED_ARRAY_NORMAL is in batchneed, so no need to check
8372 Mod_BuildNormals(rsurface.batchfirstvertex, batchnumvertices, batchnumtriangles, rsurface.batchvertex3f, rsurface.batchelement3i + 3 * rsurface.batchfirsttriangle, rsurface.batchnormal3f, r_smoothnormals_areaweighting.integer != 0);
8373 if(batchneed & BATCHNEED_ARRAY_VECTOR) // otherwise these can stay NULL
8374 {
8375// rsurface.batchsvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8376// rsurface.batchsvector3f_vertexbuffer = NULL;
8377// rsurface.batchsvector3f_bufferoffset = 0;
8378// rsurface.batchtvector3f = R_FrameData_Alloc(batchnumvertices * sizeof(float[3]));
8379// rsurface.batchtvector3f_vertexbuffer = NULL;
8380// rsurface.batchtvector3f_bufferoffset = 0;
8381 Mod_BuildTextureVectorsFromNormals(rsurface.batchfirstvertex, batchnumvertices, batchnumtriangles, rsurface.batchvertex3f, rsurface.batchtexcoordtexture2f, rsurface.batchnormal3f, rsurface.batchelement3i + 3 * rsurface.batchfirsttriangle, rsurface.batchsvector3f, rsurface.batchtvector3f, r_smoothnormals_areaweighting.integer != 0);
8382 }
8383 break;
8384 case Q3DEFORM_MOVE:
8385 // deform vertex array
8386 if(!R_TestQ3WaveFunc(deform->wavefunc, deform->waveparms))
8387 break; // if wavefunc is a nop, don't make a dynamic vertex array
8388 scale = R_EvaluateQ3WaveFunc(deform->wavefunc, deform->waveparms);
8389 VectorScale(deform->parms, scale, waveparms);
8390// rsurface.batchvertex3f = R_FrameData_Store(batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f);
8391// rsurface.batchvertex3f_vertexbuffer = NULL;
8392// rsurface.batchvertex3f_bufferoffset = 0;
8393 for (j = 0;j < batchnumvertices;j++)
8394 VectorAdd(rsurface.batchvertex3f + 3*j, waveparms, rsurface.batchvertex3f + 3*j);
8395 break;
8396 }
8397 }
8398
8399 if (rsurface.batchtexcoordtexture2f && rsurface.texture->materialshaderpass)
8400 {
8401 // generate texcoords based on the chosen texcoord source
8402 switch(rsurface.texture->materialshaderpass->tcgen.tcgen)
8403 {
8404 default:
8405 case Q3TCGEN_TEXTURE:
8406 break;
8407 case Q3TCGEN_LIGHTMAP:
8408 // rsurface.batchtexcoordtexture2f = R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8409 // rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
8410 // rsurface.batchtexcoordtexture2f_bufferoffset = 0;
8411 if (rsurface.batchtexcoordlightmap2f)
8412 memcpy(rsurface.batchtexcoordtexture2f, rsurface.batchtexcoordlightmap2f, batchnumvertices * sizeof(float[2]));
8413 break;
8414 case Q3TCGEN_VECTOR:
8415 // rsurface.batchtexcoordtexture2f = R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8416 // rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
8417 // rsurface.batchtexcoordtexture2f_bufferoffset = 0;
8418 for (j = 0;j < batchnumvertices;j++)
8419 {
8420 rsurface.batchtexcoordtexture2f[j*2+0] = DotProduct(rsurface.batchvertex3f + 3*j, rsurface.texture->materialshaderpass->tcgen.parms);
8421 rsurface.batchtexcoordtexture2f[j*2+1] = DotProduct(rsurface.batchvertex3f + 3*j, rsurface.texture->materialshaderpass->tcgen.parms + 3);
8422 }
8423 break;
8425 // make environment reflections using a spheremap
8426 rsurface.batchtexcoordtexture2f = (float *)R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8427 rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
8428 rsurface.batchtexcoordtexture2f_bufferoffset = 0;
8429 for (j = 0;j < batchnumvertices;j++)
8430 {
8431 // identical to Q3A's method, but executed in worldspace so
8432 // carried models can be shiny too
8433
8434 float viewer[3], d, reflected[3], worldreflected[3];
8435
8436 VectorSubtract(rsurface.localvieworigin, rsurface.batchvertex3f + 3*j, viewer);
8437 // VectorNormalize(viewer);
8438
8439 d = DotProduct(rsurface.batchnormal3f + 3*j, viewer);
8440
8441 reflected[0] = rsurface.batchnormal3f[j*3+0]*2*d - viewer[0];
8442 reflected[1] = rsurface.batchnormal3f[j*3+1]*2*d - viewer[1];
8443 reflected[2] = rsurface.batchnormal3f[j*3+2]*2*d - viewer[2];
8444 // note: this is proportinal to viewer, so we can normalize later
8445
8446 Matrix4x4_Transform3x3(&rsurface.matrix, reflected, worldreflected);
8447 VectorNormalize(worldreflected);
8448
8449 // note: this sphere map only uses world x and z!
8450 // so positive and negative y will LOOK THE SAME.
8451 rsurface.batchtexcoordtexture2f[j*2+0] = 0.5 + 0.5 * worldreflected[1];
8452 rsurface.batchtexcoordtexture2f[j*2+1] = 0.5 - 0.5 * worldreflected[2];
8453 }
8454 break;
8455 }
8456 // the only tcmod that needs software vertex processing is turbulent, so
8457 // check for it here and apply the changes if needed
8458 // and we only support that as the first one
8459 // (handling a mixture of turbulent and other tcmods would be problematic
8460 // without punting it entirely to a software path)
8461 if (rsurface.texture->materialshaderpass->tcmods[0].tcmod == Q3TCMOD_TURBULENT)
8462 {
8463 amplitude = rsurface.texture->materialshaderpass->tcmods[0].parms[1];
8464 animpos = rsurface.texture->materialshaderpass->tcmods[0].parms[2] + rsurface.shadertime * rsurface.texture->materialshaderpass->tcmods[0].parms[3];
8465 // rsurface.batchtexcoordtexture2f = R_FrameData_Alloc(batchnumvertices * sizeof(float[2]));
8466 // rsurface.batchtexcoordtexture2f_vertexbuffer = NULL;
8467 // rsurface.batchtexcoordtexture2f_bufferoffset = 0;
8468 for (j = 0;j < batchnumvertices;j++)
8469 {
8470 rsurface.batchtexcoordtexture2f[j*2+0] += amplitude * sin(((rsurface.batchvertex3f[j*3+0] + rsurface.batchvertex3f[j*3+2]) * 1.0 / 1024.0f + animpos) * M_PI * 2);
8471 rsurface.batchtexcoordtexture2f[j*2+1] += amplitude * sin(((rsurface.batchvertex3f[j*3+1] ) * 1.0 / 1024.0f + animpos) * M_PI * 2);
8472 }
8473 }
8474 }
8475}
static vec3_t offsets[NUMOFFSETS]
Definition cl_input.c:838
float noise4f(float x, float y, float z, float w)
static void RSurf_RenumberElements(const int *inelement3i, int *outelement3i, int numelements, int adjust)
Definition gl_rmain.c:7380
static const int quadedges[6][2]
Definition gl_rmain.c:7387
static qbool R_TestQ3WaveFunc(q3wavefunc_t func, const float *parms)
Definition gl_rmain.c:6397
static float R_EvaluateQ3WaveFunc(q3wavefunc_t func, const float *parms)
Definition gl_rmain.c:6407
void * R_FrameData_Store(size_t size, void *data)
allocate some temporary memory and copy this data into it
Definition gl_rmain.c:3573
GLfloat GLfloat GLfloat v2
Definition glquake.h:747
GLfloat GLfloat v1
Definition glquake.h:743
#define VectorLerp(v1, lerp, v2, out)
Definition mathlib.h:120
#define VectorReflect(a, r, b, out)
Definition mathlib.h:121
#define VectorMAMAM(scale1, b1, scale2, b2, scale3, b3, out)
Definition mathlib.h:117
#define M_PI
Definition mathlib.h:28
#define VectorMAMAMAM(scale1, b1, scale2, b2, scale3, b3, scale4, b4, out)
Definition mathlib.h:118
@ Q3DEFORM_NORMAL
Definition r_qshader.h:61
@ Q3DEFORM_TEXT3
Definition r_qshader.h:54
@ Q3DEFORM_TEXT5
Definition r_qshader.h:56
@ Q3DEFORM_TEXT0
Definition r_qshader.h:51
@ Q3DEFORM_AUTOSPRITE
Definition r_qshader.h:49
@ Q3DEFORM_PROJECTIONSHADOW
Definition r_qshader.h:48
@ Q3DEFORM_WAVE
Definition r_qshader.h:60
@ Q3DEFORM_TEXT1
Definition r_qshader.h:52
@ Q3DEFORM_TEXT2
Definition r_qshader.h:53
@ Q3DEFORM_NONE
Definition r_qshader.h:47
@ Q3DEFORM_AUTOSPRITE2
Definition r_qshader.h:50
@ Q3DEFORM_TEXT7
Definition r_qshader.h:58
@ Q3DEFORM_MOVE
Definition r_qshader.h:62
@ Q3DEFORM_TEXT6
Definition r_qshader.h:57
@ Q3DEFORM_TEXT4
Definition r_qshader.h:55
@ Q3DEFORM_BULGE
Definition r_qshader.h:59
@ Q3TCMOD_TURBULENT
Definition r_qshader.h:118
@ Q3TCGEN_VECTOR
Definition r_qshader.h:104
@ Q3TCGEN_ENVIRONMENT
Definition r_qshader.h:102
@ Q3TCGEN_LIGHTMAP
Definition r_qshader.h:103
@ Q3TCGEN_TEXTURE
Definition r_qshader.h:101
@ r_stat_batch_fast_vertices
Definition r_stats.h:77
@ r_stat_batch_dynamic_triangles_because_deformvertexes_normal
Definition r_stats.h:110
@ r_stat_batch_dynamic_vertices_because_deformvertexes_move
Definition r_stats.h:121
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_wave
Definition r_stats.h:112
@ r_stat_batch_dynamic_batches_because_deformvertexes_autosprite
Definition r_stats.h:99
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_move
Definition r_stats.h:120
@ r_stat_batch_dynamic_vertices_because_deformvertexes_normal
Definition r_stats.h:109
@ r_stat_batch_dynamic_vertices_because_nogaps
Definition r_stats.h:141
@ r_stat_batch_dynamic_vertices_because_cvar
Definition r_stats.h:93
@ r_stat_batch_dynamic_batches_because_deformvertexes_bulge
Definition r_stats.h:115
@ r_stat_batch_dynamic_batches_because_tcmod_turbulent
Definition r_stats.h:135
@ r_stat_batch_dynamic_batches
Definition r_stats.h:83
@ r_stat_batch_dynamic_vertices_because_tcgen_lightmap
Definition r_stats.h:125
@ r_stat_batch_dynamic_surfaces_because_tcgen_environment
Definition r_stats.h:132
@ r_stat_batch_vertices
Definition r_stats.h:73
@ r_stat_batch_dynamic_batches_because_deformvertexes_move
Definition r_stats.h:119
@ r_stat_batch_copytriangles_vertices
Definition r_stats.h:81
@ r_stat_batch_dynamic_vertices_because_deformvertexes_wave
Definition r_stats.h:113
@ r_stat_batch_dynamic_triangles_because_cvar
Definition r_stats.h:94
@ r_stat_batch_dynamic_vertices_because_tcgen_environment
Definition r_stats.h:133
@ r_stat_batch_dynamic_batches_because_cvar
Definition r_stats.h:91
@ r_stat_batch_dynamic_batches_because_deformvertexes_wave
Definition r_stats.h:111
@ r_stat_batch_dynamic_triangles_because_deformvertexes_wave
Definition r_stats.h:114
@ r_stat_batch_dynamic_batches_because_lightmapvertex
Definition r_stats.h:95
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_normal
Definition r_stats.h:108
@ r_stat_batch_copytriangles_batches
Definition r_stats.h:79
@ r_stat_batch_dynamic_surfaces_because_tcgen_vector
Definition r_stats.h:128
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite2
Definition r_stats.h:104
@ r_stat_batch_dynamic_vertices
Definition r_stats.h:85
@ r_stat_batch_dynamic_triangles_because_deformvertexes_bulge
Definition r_stats.h:118
@ r_stat_batch_dynamic_triangles
Definition r_stats.h:86
@ r_stat_batch_dynamic_surfaces_because_nogaps
Definition r_stats.h:140
@ r_stat_batch_dynamic_vertices_because_tcgen_vector
Definition r_stats.h:129
@ r_stat_batch_triangles
Definition r_stats.h:74
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite
Definition r_stats.h:100
@ r_stat_batch_dynamicskeletal_triangles
Definition r_stats.h:90
@ r_stat_batch_dynamicskeletal_batches
Definition r_stats.h:87
@ r_stat_batch_dynamic_surfaces_because_tcgen_lightmap
Definition r_stats.h:124
@ r_stat_batch_surfaces
Definition r_stats.h:72
@ r_stat_batch_dynamicskeletal_vertices
Definition r_stats.h:89
@ r_stat_batch_dynamic_batches_because_nogaps
Definition r_stats.h:139
@ r_stat_batch_copytriangles_surfaces
Definition r_stats.h:80
@ r_stat_batch_fast_surfaces
Definition r_stats.h:76
@ r_stat_batch_dynamic_batches_because_tcgen_environment
Definition r_stats.h:131
@ r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite2
Definition r_stats.h:106
@ r_stat_batch_dynamic_surfaces_because_tcmod_turbulent
Definition r_stats.h:136
@ r_stat_batch_dynamic_batches_because_deformvertexes_normal
Definition r_stats.h:107
@ r_stat_batch_dynamic_surfaces_because_cvar
Definition r_stats.h:92
@ r_stat_batch_dynamic_batches_because_deformvertexes_autosprite2
Definition r_stats.h:103
@ r_stat_batch_dynamic_vertices_because_deformvertexes_bulge
Definition r_stats.h:117
@ r_stat_batch_dynamic_triangles_because_tcgen_environment
Definition r_stats.h:134
@ r_stat_batch_fast_triangles
Definition r_stats.h:78
@ r_stat_batch_dynamic_batches_because_tcgen_vector
Definition r_stats.h:127
@ r_stat_batch_dynamic_triangles_because_lightmapvertex
Definition r_stats.h:98
@ r_stat_batch_dynamic_triangles_because_nogaps
Definition r_stats.h:142
@ r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite
Definition r_stats.h:102
@ r_stat_batch_dynamic_surfaces_because_deformvertexes_bulge
Definition r_stats.h:116
@ r_stat_batch_copytriangles_triangles
Definition r_stats.h:82
@ r_stat_batch_fast_batches
Definition r_stats.h:75
@ r_stat_batch_dynamicskeletal_surfaces
Definition r_stats.h:88
@ r_stat_batch_dynamic_vertices_because_lightmapvertex
Definition r_stats.h:97
@ r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite2
Definition r_stats.h:105
@ r_stat_batch_dynamic_batches_because_tcgen_lightmap
Definition r_stats.h:123
@ r_stat_batch_dynamic_surfaces_because_lightmapvertex
Definition r_stats.h:96
@ r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite
Definition r_stats.h:101
@ r_stat_batch_withgaps
Definition r_stats.h:71
@ r_stat_batch_dynamic_vertices_because_tcmod_turbulent
Definition r_stats.h:137
@ r_stat_batch_dynamic_triangles_because_tcgen_vector
Definition r_stats.h:130
@ r_stat_batch_dynamic_triangles_because_tcmod_turbulent
Definition r_stats.h:138
@ r_stat_batch_batches
Definition r_stats.h:70
@ r_stat_batch_dynamic_surfaces
Definition r_stats.h:84
@ r_stat_batch_dynamic_triangles_because_deformvertexes_move
Definition r_stats.h:122
@ r_stat_batch_dynamic_triangles_because_tcgen_lightmap
Definition r_stats.h:126
#define BATCHNEED_ALWAYSCOPY
Definition render.h:794
#define BATCHNEED_ARRAY_SKELETAL
Definition render.h:792
vec4 sw
q3wavefunc_t wavefunc
Definition r_qshader.h:178
float parms[Q3DEFORM_MAXPARMS]
Definition r_qshader.h:177
float waveparms[Q3WAVEPARMS]
Definition r_qshader.h:179
static vec3_t right
Definition sv_user.c:305

References b, BATCHNEED_ALLOWMULTIDRAW, BATCHNEED_ALWAYSCOPY, BATCHNEED_ARRAY_LIGHTMAP, BATCHNEED_ARRAY_NORMAL, BATCHNEED_ARRAY_SKELETAL, BATCHNEED_ARRAY_TEXCOORD, BATCHNEED_ARRAY_VECTOR, BATCHNEED_ARRAY_VERTEX, BATCHNEED_ARRAY_VERTEXCOLOR, BATCHNEED_NOGAPS, CrossProduct, q3shaderinfo_deform_t::deform, DotProduct, msurface_lightmapinfo_t::extents, f, forward, msurface_t::lightmapinfo, M_PI, Matrix4x4_Transform3x3(), min, Mod_BuildNormals(), Mod_BuildTextureVectorsFromNormals(), n, noise4f(), normal, NULL, msurface_t::num_firsttriangle, msurface_t::num_firstvertex, msurface_t::num_triangles, msurface_t::num_vertices, offsets, q3shaderinfo_deform_t::parms, Q3DEFORM_AUTOSPRITE, Q3DEFORM_AUTOSPRITE2, Q3DEFORM_BULGE, Q3DEFORM_MOVE, Q3DEFORM_NONE, Q3DEFORM_NORMAL, Q3DEFORM_PROJECTIONSHADOW, Q3DEFORM_TEXT0, Q3DEFORM_TEXT1, Q3DEFORM_TEXT2, Q3DEFORM_TEXT3, Q3DEFORM_TEXT4, Q3DEFORM_TEXT5, Q3DEFORM_TEXT6, Q3DEFORM_TEXT7, Q3DEFORM_WAVE, Q3TCGEN_ENVIRONMENT, Q3TCGEN_LIGHTMAP, Q3TCGEN_TEXTURE, Q3TCGEN_VECTOR, Q3TCMOD_TURBULENT, quadedges, r_batch_debugdynamicvertexpath, r_batch_multidraw, r_batch_multidraw_mintriangles, r_deformvertexes, R_EvaluateQ3WaveFunc(), R_FrameData_Alloc(), R_FrameData_Store(), r_refdef, r_smoothnormals_areaweighting, r_stat_batch_batches, r_stat_batch_copytriangles_batches, r_stat_batch_copytriangles_surfaces, r_stat_batch_copytriangles_triangles, r_stat_batch_copytriangles_vertices, r_stat_batch_dynamic_batches, r_stat_batch_dynamic_batches_because_cvar, r_stat_batch_dynamic_batches_because_deformvertexes_autosprite, r_stat_batch_dynamic_batches_because_deformvertexes_autosprite2, r_stat_batch_dynamic_batches_because_deformvertexes_bulge, r_stat_batch_dynamic_batches_because_deformvertexes_move, r_stat_batch_dynamic_batches_because_deformvertexes_normal, r_stat_batch_dynamic_batches_because_deformvertexes_wave, r_stat_batch_dynamic_batches_because_lightmapvertex, r_stat_batch_dynamic_batches_because_nogaps, r_stat_batch_dynamic_batches_because_tcgen_environment, r_stat_batch_dynamic_batches_because_tcgen_lightmap, r_stat_batch_dynamic_batches_because_tcgen_vector, r_stat_batch_dynamic_batches_because_tcmod_turbulent, r_stat_batch_dynamic_surfaces, r_stat_batch_dynamic_surfaces_because_cvar, r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite, r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite2, r_stat_batch_dynamic_surfaces_because_deformvertexes_bulge, r_stat_batch_dynamic_surfaces_because_deformvertexes_move, r_stat_batch_dynamic_surfaces_because_deformvertexes_normal, r_stat_batch_dynamic_surfaces_because_deformvertexes_wave, r_stat_batch_dynamic_surfaces_because_lightmapvertex, r_stat_batch_dynamic_surfaces_because_nogaps, r_stat_batch_dynamic_surfaces_because_tcgen_environment, r_stat_batch_dynamic_surfaces_because_tcgen_lightmap, r_stat_batch_dynamic_surfaces_because_tcgen_vector, r_stat_batch_dynamic_surfaces_because_tcmod_turbulent, r_stat_batch_dynamic_triangles, r_stat_batch_dynamic_triangles_because_cvar, r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite, r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite2, r_stat_batch_dynamic_triangles_because_deformvertexes_bulge, r_stat_batch_dynamic_triangles_because_deformvertexes_move, r_stat_batch_dynamic_triangles_because_deformvertexes_normal, r_stat_batch_dynamic_triangles_because_deformvertexes_wave, r_stat_batch_dynamic_triangles_because_lightmapvertex, r_stat_batch_dynamic_triangles_because_nogaps, r_stat_batch_dynamic_triangles_because_tcgen_environment, r_stat_batch_dynamic_triangles_because_tcgen_lightmap, r_stat_batch_dynamic_triangles_because_tcgen_vector, r_stat_batch_dynamic_triangles_because_tcmod_turbulent, r_stat_batch_dynamic_vertices, r_stat_batch_dynamic_vertices_because_cvar, r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite, r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite2, r_stat_batch_dynamic_vertices_because_deformvertexes_bulge, r_stat_batch_dynamic_vertices_because_deformvertexes_move, r_stat_batch_dynamic_vertices_because_deformvertexes_normal, r_stat_batch_dynamic_vertices_because_deformvertexes_wave, r_stat_batch_dynamic_vertices_because_lightmapvertex, r_stat_batch_dynamic_vertices_because_nogaps, r_stat_batch_dynamic_vertices_because_tcgen_environment, r_stat_batch_dynamic_vertices_because_tcgen_lightmap, r_stat_batch_dynamic_vertices_because_tcgen_vector, r_stat_batch_dynamic_vertices_because_tcmod_turbulent, r_stat_batch_dynamicskeletal_batches, r_stat_batch_dynamicskeletal_surfaces, r_stat_batch_dynamicskeletal_triangles, r_stat_batch_dynamicskeletal_vertices, r_stat_batch_fast_batches, r_stat_batch_fast_surfaces, r_stat_batch_fast_triangles, r_stat_batch_fast_vertices, r_stat_batch_surfaces, r_stat_batch_triangles, r_stat_batch_vertices, r_stat_batch_withgaps, R_TestQ3WaveFunc(), right, RSurf_RenumberElements(), rsurface, msurface_lightmapinfo_t::samples, scale, sin(), msurface_lightmapinfo_t::styles, sw, up, v, v1, v2, Vector4Set, VectorAdd, VectorClear, VectorCopy, VectorDistance2, VectorLength2, VectorLerp, VectorMA, VectorMAMAM, VectorMAMAMAM, VectorNegate, VectorNormalize, VectorReflect, VectorScale, VectorSubtract, w, q3shaderinfo_deform_t::wavefunc, and q3shaderinfo_deform_t::waveparms.

Referenced by R_DrawDebugModel(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_Mod_DrawShadowMap(), R_SetupShader_Surface(), R_Shadow_RenderLighting_VisibleLighting(), R_Water_AddWaterPlane(), and RSurf_FindWaterPlaneForSurface().

◆ RSurf_SetupDepthAndCulling()

void RSurf_SetupDepthAndCulling ( bool ui)

Definition at line 8576 of file gl_rmain.c.

8577{
8578 // submodels are biased to avoid z-fighting with world surfaces that they
8579 // may be exactly overlapping (avoids z-fighting artifacts on certain
8580 // doors and things in Quake maps)
8581 GL_DepthRange(0, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SHORTDEPTHRANGE) ? 0.0625 : 1);
8582 GL_PolygonOffset(rsurface.basepolygonfactor + rsurface.texture->biaspolygonfactor, rsurface.basepolygonoffset + rsurface.texture->biaspolygonoffset);
8583 GL_DepthTest(!ui && !(rsurface.texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
8584 GL_CullFace((rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE) ? GL_NONE : r_refdef.view.cullface_back);
8585}

References GL_CullFace(), GL_DepthRange(), GL_DepthTest(), GL_NONE, GL_PolygonOffset(), MATERIALFLAG_NOCULLFACE, MATERIALFLAG_NODEPTHTEST, MATERIALFLAG_SHORTDEPTHRANGE, r_refdef, and rsurface.

Referenced by R_DrawModelTextureSurfaceList(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_Sky(), and R_Shadow_RenderLighting().

◆ RSurf_UploadBuffersForBatch()

void RSurf_UploadBuffersForBatch ( void )

Definition at line 7340 of file gl_rmain.c.

7341{
7342 // upload buffer data for generated vertex data (dynamicvertex case) or index data (copytriangles case) and models that lack it to begin with (e.g. DrawQ_FlushUI)
7343 // note that if rsurface.batchvertex3f_vertexbuffer is NULL, dynamicvertex is forced as we don't account for the proper base vertex here.
7344 if (rsurface.batchvertex3f && !rsurface.batchvertex3f_vertexbuffer)
7345 rsurface.batchvertex3f_vertexbuffer = R_BufferData_Store(rsurface.batchnumvertices * sizeof(float[3]), rsurface.batchvertex3f, R_BUFFERDATA_VERTEX, &rsurface.batchvertex3f_bufferoffset);
7346 if (rsurface.batchsvector3f && !rsurface.batchsvector3f_vertexbuffer)
7347 rsurface.batchsvector3f_vertexbuffer = R_BufferData_Store(rsurface.batchnumvertices * sizeof(float[3]), rsurface.batchsvector3f, R_BUFFERDATA_VERTEX, &rsurface.batchsvector3f_bufferoffset);
7348 if (rsurface.batchtvector3f && !rsurface.batchtvector3f_vertexbuffer)
7349 rsurface.batchtvector3f_vertexbuffer = R_BufferData_Store(rsurface.batchnumvertices * sizeof(float[3]), rsurface.batchtvector3f, R_BUFFERDATA_VERTEX, &rsurface.batchtvector3f_bufferoffset);
7350 if (rsurface.batchnormal3f && !rsurface.batchnormal3f_vertexbuffer)
7351 rsurface.batchnormal3f_vertexbuffer = R_BufferData_Store(rsurface.batchnumvertices * sizeof(float[3]), rsurface.batchnormal3f, R_BUFFERDATA_VERTEX, &rsurface.batchnormal3f_bufferoffset);
7352 if (rsurface.batchlightmapcolor4f && !rsurface.batchlightmapcolor4f_vertexbuffer)
7353 rsurface.batchlightmapcolor4f_vertexbuffer = R_BufferData_Store(rsurface.batchnumvertices * sizeof(float[4]), rsurface.batchlightmapcolor4f, R_BUFFERDATA_VERTEX, &rsurface.batchlightmapcolor4f_bufferoffset);
7354 if (rsurface.batchtexcoordtexture2f && !rsurface.batchtexcoordtexture2f_vertexbuffer)
7355 rsurface.batchtexcoordtexture2f_vertexbuffer = R_BufferData_Store(rsurface.batchnumvertices * sizeof(float[2]), rsurface.batchtexcoordtexture2f, R_BUFFERDATA_VERTEX, &rsurface.batchtexcoordtexture2f_bufferoffset);
7356 if (rsurface.batchtexcoordlightmap2f && !rsurface.batchtexcoordlightmap2f_vertexbuffer)
7357 rsurface.batchtexcoordlightmap2f_vertexbuffer = R_BufferData_Store(rsurface.batchnumvertices * sizeof(float[2]), rsurface.batchtexcoordlightmap2f, R_BUFFERDATA_VERTEX, &rsurface.batchtexcoordlightmap2f_bufferoffset);
7358 if (rsurface.batchskeletalindex4ub && !rsurface.batchskeletalindex4ub_vertexbuffer)
7359 rsurface.batchskeletalindex4ub_vertexbuffer = R_BufferData_Store(rsurface.batchnumvertices * sizeof(unsigned char[4]), rsurface.batchskeletalindex4ub, R_BUFFERDATA_VERTEX, &rsurface.batchskeletalindex4ub_bufferoffset);
7360 if (rsurface.batchskeletalweight4ub && !rsurface.batchskeletalweight4ub_vertexbuffer)
7361 rsurface.batchskeletalweight4ub_vertexbuffer = R_BufferData_Store(rsurface.batchnumvertices * sizeof(unsigned char[4]), rsurface.batchskeletalweight4ub, R_BUFFERDATA_VERTEX, &rsurface.batchskeletalweight4ub_bufferoffset);
7362
7363 if (rsurface.batchelement3s && !rsurface.batchelement3s_indexbuffer)
7364 rsurface.batchelement3s_indexbuffer = R_BufferData_Store(rsurface.batchnumtriangles * sizeof(short[3]), rsurface.batchelement3s, R_BUFFERDATA_INDEX16, &rsurface.batchelement3s_bufferoffset);
7365 else if (rsurface.batchelement3i && !rsurface.batchelement3i_indexbuffer)
7366 rsurface.batchelement3i_indexbuffer = R_BufferData_Store(rsurface.batchnumtriangles * sizeof(int[3]), rsurface.batchelement3i, R_BUFFERDATA_INDEX32, &rsurface.batchelement3i_bufferoffset);
7367
7368 R_Mesh_VertexPointer( 3, GL_FLOAT, sizeof(float[3]), rsurface.batchvertex3f, rsurface.batchvertex3f_vertexbuffer, rsurface.batchvertex3f_bufferoffset);
7369 R_Mesh_ColorPointer( 4, GL_FLOAT, sizeof(float[4]), rsurface.batchlightmapcolor4f, rsurface.batchlightmapcolor4f_vertexbuffer, rsurface.batchlightmapcolor4f_bufferoffset);
7370 R_Mesh_TexCoordPointer(0, 2, GL_FLOAT, sizeof(float[2]), rsurface.batchtexcoordtexture2f, rsurface.batchtexcoordtexture2f_vertexbuffer, rsurface.batchtexcoordtexture2f_bufferoffset);
7371 R_Mesh_TexCoordPointer(1, 3, GL_FLOAT, sizeof(float[3]), rsurface.batchsvector3f, rsurface.batchsvector3f_vertexbuffer, rsurface.batchsvector3f_bufferoffset);
7372 R_Mesh_TexCoordPointer(2, 3, GL_FLOAT, sizeof(float[3]), rsurface.batchtvector3f, rsurface.batchtvector3f_vertexbuffer, rsurface.batchtvector3f_bufferoffset);
7373 R_Mesh_TexCoordPointer(3, 3, GL_FLOAT, sizeof(float[3]), rsurface.batchnormal3f, rsurface.batchnormal3f_vertexbuffer, rsurface.batchnormal3f_bufferoffset);
7374 R_Mesh_TexCoordPointer(4, 2, GL_FLOAT, sizeof(float[2]), rsurface.batchtexcoordlightmap2f, rsurface.batchtexcoordlightmap2f_vertexbuffer, rsurface.batchtexcoordlightmap2f_bufferoffset);
7375 R_Mesh_TexCoordPointer(5, 2, GL_FLOAT, sizeof(float[2]), NULL, NULL, 0);
7376 R_Mesh_TexCoordPointer(6, 4, GL_UNSIGNED_BYTE | 0x80000000, sizeof(unsigned char[4]), rsurface.batchskeletalindex4ub, rsurface.batchskeletalindex4ub_vertexbuffer, rsurface.batchskeletalindex4ub_bufferoffset);
7377 R_Mesh_TexCoordPointer(7, 4, GL_UNSIGNED_BYTE, sizeof(unsigned char[4]), rsurface.batchskeletalweight4ub, rsurface.batchskeletalweight4ub_vertexbuffer, rsurface.batchskeletalweight4ub_bufferoffset);
7378}
void R_Mesh_VertexPointer(int components, int gltype, size_t stride, const void *pointer, const r_meshbuffer_t *vertexbuffer, size_t bufferoffset)
void R_Mesh_TexCoordPointer(unsigned int unitnum, int components, int gltype, size_t stride, const void *pointer, const r_meshbuffer_t *vertexbuffer, size_t bufferoffset)
void R_Mesh_ColorPointer(int components, int gltype, size_t stride, const void *pointer, const r_meshbuffer_t *vertexbuffer, size_t bufferoffset)
#define GL_FLOAT
Definition glquake.h:124
#define GL_UNSIGNED_BYTE
Definition glquake.h:119

References GL_FLOAT, GL_UNSIGNED_BYTE, NULL, R_BUFFERDATA_INDEX16, R_BUFFERDATA_INDEX32, R_BufferData_Store(), R_BUFFERDATA_VERTEX, R_Mesh_ColorPointer(), R_Mesh_TexCoordPointer(), R_Mesh_VertexPointer(), and rsurface.

Referenced by R_SetupShader_Surface().

◆ Sbar_Init()

void Sbar_Init ( void )

Definition at line 359 of file sbar.c.

360{
361 Cmd_AddCommand(CF_CLIENT, "+showscores", Sbar_ShowScores_f, "show scoreboard");
362 Cmd_AddCommand(CF_CLIENT, "-showscores", Sbar_DontShowScores_f, "hide scoreboard");
374
375 Cvar_RegisterVirtual(&cl_showfps, "showfps");
376 Cvar_RegisterVirtual(&cl_showsound, "showsound");
377 Cvar_RegisterVirtual(&cl_showblur, "showblur");
378 Cvar_RegisterVirtual(&cl_showspeed, "showspeed");
379 Cvar_RegisterVirtual(&cl_showtopspeed, "showtopspeed");
380 Cvar_RegisterVirtual(&cl_showtime, "showtime");
381 Cvar_RegisterVirtual(&cl_showtime_format, "showtime_format");
382 Cvar_RegisterVirtual(&cl_showdate, "showdate");
383 Cvar_RegisterVirtual(&cl_showdate_format, "showdate_format");
384 Cvar_RegisterVirtual(&cl_showtex, "showtex");
385
394 // This cvar is found in Fitzquake-derived engines and FTEQW and is read by the Alkaline 1.2 and Arcane Dimensions 1.80 CSQC
395 Cvar_RegisterVirtual(&sbar_alpha_bg, "scr_sbaralpha");
396
402
403 Cvar_RegisterVariable(&sbar_flagstatus_right); // (GAME_NEXUZI ONLY)
404 Cvar_RegisterVariable(&sbar_flagstatus_pos); // (GAME_NEXUIZ ONLY)
405
407}
cvar_t sbar_info_pos
Definition sbar.c:108
void Cvar_RegisterVirtual(cvar_t *variable, const char *name)
Definition cvar.c:513
static void Sbar_ShowScores_f(cmd_state_t *cmd)
Definition sbar.c:131
cvar_t sbar_flagstatus_right
Definition sbar.c:106
cvar_t cl_showfps
Definition sbar.c:88
cvar_t cl_showspeed
Definition sbar.c:91
cvar_t cl_showtime_format
Definition sbar.c:95
cvar_t sbar_hudselector
Definition sbar.c:102
cvar_t cl_showsound
Definition sbar.c:89
static void sbar_shutdown(void)
Definition sbar.c:351
cvar_t sbar_scorerank
Definition sbar.c:103
cvar_t sbar_miniscoreboard_size
Definition sbar.c:105
cvar_t crosshair_color_green
Definition sbar.c:113
cvar_t cl_showtex
Definition sbar.c:98
cvar_t crosshair_color_alpha
Definition sbar.c:115
cvar_t cl_showtime
Definition sbar.c:94
cvar_t sbar_flagstatus_pos
Definition sbar.c:107
cvar_t cl_showblur
Definition sbar.c:90
cvar_t cl_showtopspeed
Definition sbar.c:93
static void sbar_start(void)
Definition sbar.c:152
cvar_t cl_showdate
Definition sbar.c:96
cvar_t sbar_alpha_fg
Definition sbar.c:101
cvar_t cl_showspeed_factor
Definition sbar.c:92
cvar_t sbar_gametime
Definition sbar.c:104
static void sbar_newmap(void)
Definition sbar.c:355
cvar_t crosshair_color_blue
Definition sbar.c:114
static void Sbar_DontShowScores_f(cmd_state_t *cmd)
Definition sbar.c:146
cvar_t cl_showdate_format
Definition sbar.c:97
cvar_t sbar_alpha_bg
Definition sbar.c:100
cvar_t crosshair_color_red
Definition sbar.c:112
cvar_t crosshair_size
Definition sbar.c:116

References CF_CLIENT, cl_deathscoreboard, cl_showblur, cl_showdate, cl_showdate_format, cl_showfps, cl_showsound, cl_showspeed, cl_showspeed_factor, cl_showtex, cl_showtime, cl_showtime_format, cl_showtopspeed, Cmd_AddCommand(), crosshair_color_alpha, crosshair_color_blue, crosshair_color_green, crosshair_color_red, crosshair_size, Cvar_RegisterVariable(), Cvar_RegisterVirtual(), NULL, R_RegisterModule(), sbar_alpha_bg, sbar_alpha_fg, Sbar_DontShowScores_f(), sbar_flagstatus_pos, sbar_flagstatus_right, sbar_gametime, sbar_hudselector, sbar_info_pos, sbar_miniscoreboard_size, sbar_newmap(), sbar_scorerank, Sbar_ShowScores_f(), sbar_shutdown(), and sbar_start().

Referenced by Render_Init().

◆ SCR_DrawConsole()

void SCR_DrawConsole ( void )

Definition at line 750 of file cl_screen.c.

751{
752 // infobar and loading progress are not drawn simultaneously
757 {
758 // full screen
760 }
761 else if (scr_con_current)
763 else
764 con_vislines = 0;
765}
unsigned int scr_con_current
Definition cl_screen.c:106
static unsigned int scr_con_margin_bottom
Definition cl_screen.c:107
cvar_t scr_loadingscreen_barheight
Definition cl_screen.c:51
static int SCR_InfobarHeight(void)
Definition cl_screen.c:661
int con_vislines
Definition console.c:95
qbool scr_loading
Definition cl_screen.c:104
void Con_DrawConsole(int lines, qbool forcedfullscreen)
Definition console.c:2138
int key_consoleactive
Definition keys.c:38
#define KEY_CONSOLEACTIVE_FORCED
Definition keys.h:382

References Con_DrawConsole(), con_vislines, key_consoleactive, KEY_CONSOLEACTIVE_FORCED, min, scr_con_current, scr_con_margin_bottom, SCR_InfobarHeight(), scr_loading, scr_loadingscreen_barheight, and vid_conheight.

Referenced by SCR_DrawScreen().

◆ SHOWLMP_decodehide()

void SHOWLMP_decodehide ( void )

Definition at line 1368 of file cl_screen.c.

1369{
1370 int i;
1371 char *lmplabel;
1373 for (i = 0;i < cl.num_showlmps;i++)
1374 if (cl.showlmps[i].isactive && strcmp(cl.showlmps[i].label, lmplabel) == 0)
1375 {
1376 cl.showlmps[i].isactive = false;
1377 return;
1378 }
1379}
char * MSG_ReadString(sizebuf_t *sb, char *string, size_t maxstring)
Definition com_msg.c:341
sizebuf_t cl_message
Definition netconn.c:71
char cl_readstring[MAX_INPUTLINE]
Definition netconn.c:75

References cl, cl_message, cl_readstring, and MSG_ReadString().

Referenced by CL_ParseServerMessage().

◆ SHOWLMP_decodeshow()

void SHOWLMP_decodeshow ( void )

Definition at line 1381 of file cl_screen.c.

1382{
1383 int k;
1384 char lmplabel[256], picname[256];
1385 float x, y;
1386 dp_strlcpy (lmplabel,MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)), sizeof (lmplabel));
1387 dp_strlcpy (picname, MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)), sizeof (picname));
1388 if (gamemode == GAME_NEHAHRA) // LadyHavoc: nasty old legacy junk
1389 {
1392 }
1393 else
1394 {
1397 }
1398 if (!cl.showlmps || cl.num_showlmps >= cl.max_showlmps)
1399 {
1400 showlmp_t *oldshowlmps = cl.showlmps;
1401 cl.max_showlmps += 16;
1402 cl.showlmps = (showlmp_t *) Mem_Alloc(cls.levelmempool, cl.max_showlmps * sizeof(showlmp_t));
1403 if (oldshowlmps)
1404 {
1405 if (cl.num_showlmps)
1406 memcpy(cl.showlmps, oldshowlmps, cl.num_showlmps * sizeof(showlmp_t));
1407 Mem_Free(oldshowlmps);
1408 }
1409 }
1410 for (k = 0;k < cl.max_showlmps;k++)
1411 if (cl.showlmps[k].isactive && !strcmp(cl.showlmps[k].label, lmplabel))
1412 break;
1413 if (k == cl.max_showlmps)
1414 for (k = 0;k < cl.max_showlmps;k++)
1415 if (!cl.showlmps[k].isactive)
1416 break;
1417 cl.showlmps[k].isactive = true;
1418 dp_strlcpy (cl.showlmps[k].label, lmplabel, sizeof (cl.showlmps[k].label));
1419 dp_strlcpy (cl.showlmps[k].pic, picname, sizeof (cl.showlmps[k].pic));
1420 cl.showlmps[k].x = x;
1421 cl.showlmps[k].y = y;
1422 cl.num_showlmps = max(cl.num_showlmps, k + 1);
1423}
#define MSG_ReadShort
Definition common.h:191
#define MSG_ReadByte(sb)
Definition common.h:188

References cl, cl_message, cl_readstring, cls, dp_strlcpy, GAME_NEHAHRA, gamemode, max, Mem_Alloc, Mem_Free, MSG_ReadByte, MSG_ReadShort, MSG_ReadString(), x, and y.

Referenced by CL_ParseServerMessage().

◆ SHOWLMP_drawall()

void SHOWLMP_drawall ( void )

Definition at line 1425 of file cl_screen.c.

1426{
1427 int i;
1428 for (i = 0;i < cl.num_showlmps;i++)
1429 if (cl.showlmps[i].isactive)
1430 DrawQ_Pic(cl.showlmps[i].x, cl.showlmps[i].y, Draw_CachePic_Flags (cl.showlmps[i].pic, CACHEPICFLAG_NOTPERSISTENT), 0, 0, 1, 1, 1, 1, 0);
1431}
@ CACHEPICFLAG_NOTPERSISTENT
Definition draw.h:36
cachepic_t * Draw_CachePic_Flags(const char *path, unsigned int cachepicflags)
Definition gl_draw.c:86

References CACHEPICFLAG_NOTPERSISTENT, cl, Draw_CachePic_Flags(), and DrawQ_Pic().

Referenced by SCR_DrawScreen().

Variable Documentation

◆ cl_deathfade

cvar_t cl_deathfade
extern

Definition at line 83 of file cl_main.c.

83{CF_CLIENT | CF_ARCHIVE, "cl_deathfade", "0", "fade screen to dark red when dead, value represents how fast the fade is (higher is faster)"};
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
Definition cmd.h:53

Referenced by CL_Init(), and V_CalcViewBlend().

◆ developer_texturelogging

cvar_t developer_texturelogging
extern

Definition at line 231 of file gl_rmain.c.

231{CF_CLIENT, "developer_texturelogging", "0", "produces a textures.log file containing names of skins and map textures the engine tried to load"};

Referenced by GL_Main_Init(), and loadimagepixelsbgra().

◆ gl_flashblend

cvar_t gl_flashblend
extern

Definition at line 236 of file r_shadow.c.

236{CF_CLIENT | CF_ARCHIVE, "gl_flashblend", "0", "render bright coronas for dynamic lights instead of actual lighting, fast but ugly"};

◆ gl_polyblend

cvar_t gl_polyblend
extern

Definition at line 17 of file gl_backend.c.

17{CF_CLIENT | CF_ARCHIVE, "gl_polyblend", "1", "tints view while underwater, hurt, etc"};

Referenced by gl_backend_init(), M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), and V_CalcViewBlend().

◆ ixtable

float ixtable[4096]
extern

◆ r_ambient

cvar_t r_ambient
extern

Definition at line 28 of file gl_rsurf.c.

28{CF_CLIENT, "r_ambient", "0", "brightens map, value is 0-128"};

Referenced by GL_Surf_Init(), and R_UpdateVariables().

◆ r_draw2d

cvar_t r_draw2d
extern

Definition at line 97 of file gl_rmain.c.

97{CF_CLIENT, "r_draw2d","1", "draw 2D stuff (dangerous to turn off)"};

Referenced by DrawQ_FlushUI(), DrawQ_String_Scale(), and GL_Main_Init().

◆ r_draw2d_force

qbool r_draw2d_force
extern

◆ r_drawentities

cvar_t r_drawentities
extern

Definition at line 96 of file gl_rmain.c.

96{CF_CLIENT, "r_drawentities","1", "draw entities (doors, players, projectiles, etc)"};

Referenced by GL_Main_Init(), and R_RenderView().

◆ r_drawviewmodel

cvar_t r_drawviewmodel
extern

Definition at line 99 of file gl_rmain.c.

99{CF_CLIENT, "r_drawviewmodel","1", "draw your weapon model"};

Referenced by GL_Main_Init(), and R_View_UpdateEntityVisible().

◆ r_drawworld

cvar_t r_drawworld
extern

Definition at line 98 of file gl_rmain.c.

98{CF_CLIENT, "r_drawworld","1", "draw world (most static stuff)"};

Referenced by CL_ClearState(), GL_Main_Init(), VM_CL_R_ClearScene(), and VM_CL_R_SetView().

◆ r_dynamic

cvar_t r_dynamic
extern

Definition at line 121 of file gl_rmain.c.

121{CF_CLIENT | CF_ARCHIVE, "r_dynamic","1", "enables dynamic lights (rocket glow and such)"};

Referenced by CL_RelinkLightFlashes(), GL_Main_Init(), R_UpdateVariables(), and R_Water_ProcessPlanes().

◆ r_fb

◆ r_fullbright

cvar_t r_fullbright
extern

Definition at line 112 of file gl_rmain.c.

112{CF_CLIENT, "r_fullbright","0", "makes map very bright and renders faster"};

Referenced by CL_RelinkStaticEntities(), CL_RelinkWorld(), CL_UpdateEntityShading_Entity(), CL_UpdateNetworkEntity(), CSQC_AddRenderEdict(), GL_Main_Init(), RSurf_ActiveModelEntity(), and VM_CL_makestatic().

◆ r_fxaa

cvar_t r_fxaa
extern

Definition at line 190 of file gl_rmain.c.

190{CF_CLIENT | CF_ARCHIVE, "r_fxaa", "0", "fast approximate anti aliasing"};

Referenced by GL_Main_Init(), R_BlendView_IsTrivial(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_deluxemapping

cvar_t r_glsl_deluxemapping
extern

Definition at line 171 of file gl_rmain.c.

171{CF_CLIENT | CF_ARCHIVE, "r_glsl_deluxemapping", "1", "use per pixel lighting on deluxemap-compiled q3bsp maps (or a value of 2 forces deluxemap shading even without deluxemaps)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping

cvar_t r_glsl_offsetmapping
extern

Definition at line 172 of file gl_rmain.c.

172{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping", "0", "offset mapping effect (also known as parallax mapping or virtual displacement mapping)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_lod

cvar_t r_glsl_offsetmapping_lod
extern

Definition at line 178 of file gl_rmain.c.

178{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod", "0", "apply distance-based level-of-detail correction to number of offsetmappig steps, effectively making it render faster on large open-area maps"};

Referenced by GL_Main_Init(), and R_CompileShader_CheckStaticParms().

◆ r_glsl_offsetmapping_lod_distance

cvar_t r_glsl_offsetmapping_lod_distance
extern

Definition at line 179 of file gl_rmain.c.

179{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_lod_distance", "32", "first LOD level distance, second level (-50% steps) is 2x of this, third (33%) - 3x etc."};

Referenced by GL_Main_Init(), R_CompileShader_CheckStaticParms(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_reliefmapping

cvar_t r_glsl_offsetmapping_reliefmapping
extern

Definition at line 174 of file gl_rmain.c.

174{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_reliefmapping", "0", "relief mapping effect (higher quality)"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_glsl_offsetmapping_scale

cvar_t r_glsl_offsetmapping_scale
extern

Definition at line 177 of file gl_rmain.c.

177{CF_CLIENT | CF_ARCHIVE, "r_glsl_offsetmapping_scale", "0.04", "how deep the offset mapping effect is"};

Referenced by GL_Main_Init(), and R_SetupShader_Surface().

◆ r_lerplightstyles

cvar_t r_lerplightstyles
extern

Definition at line 205 of file gl_rmain.c.

205{CF_CLIENT | CF_ARCHIVE, "r_lerplightstyles", "0", "enable animation smoothing on flickering lights"};

Referenced by CL_RelinkLightFlashes(), GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), and M_Options_Effects_Draw().

◆ r_lerpmodels

cvar_t r_lerpmodels
extern

Definition at line 203 of file gl_rmain.c.

203{CF_CLIENT | CF_ARCHIVE, "r_lerpmodels", "1", "enables animation smoothing on models"};

Referenced by GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), and VM_FrameBlendFromFrameGroupBlend().

◆ r_lerpsprites

cvar_t r_lerpsprites
extern

Definition at line 202 of file gl_rmain.c.

202{CF_CLIENT | CF_ARCHIVE, "r_lerpsprites", "0", "enables animation smoothing on sprites"};

Referenced by GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), and VM_FrameBlendFromFrameGroupBlend().

◆ r_main_mempool

◆ r_maxqueries

unsigned int r_maxqueries
extern

◆ r_nearclip

cvar_t r_nearclip
extern

Definition at line 76 of file gl_rmain.c.

76{CF_CLIENT, "r_nearclip", "1", "distance from camera of nearclip plane" };

Referenced by GL_Main_Init(), R_UpdateVariables(), and R_View_WorldVisibility().

◆ r_novis

cvar_t r_novis
extern

Definition at line 31 of file model_brush.c.

31{CF_CLIENT, "r_novis", "0", "draws whole level, see also sv_cullentities_pvs 0"};

Referenced by Mod_BrushInit(), Mod_BSP_FatPVS(), R_GetCurrentTexture(), R_View_UpdateEntityVisible(), R_View_WorldVisibility(), and SV_MarkWriteEntityStateToClient().

◆ r_numqueries

unsigned int r_numqueries
extern

◆ r_q1bsp_lightmap_updates_combine

cvar_t r_q1bsp_lightmap_updates_combine
extern

Definition at line 258 of file gl_rmain.c.

258{CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_combine", "2", "combine lightmap texture updates to make fewer glTexSubImage2D calls, modes: 0 = immediately upload lightmaps (may be thousands of small 3x3 updates), 1 = combine to one call, 2 = combine to one full texture update (glTexImage2D) which tells the driver it does not need to lock the resource (faster on most drivers)"};

Referenced by GL_Main_Init(), R_BuildLightMap(), and R_DrawModelSurfaces().

◆ r_q1bsp_lightmap_updates_combine_full_texture

cvar_t r_q1bsp_lightmap_updates_combine_full_texture
extern

◆ r_q1bsp_lightmap_updates_enabled

cvar_t r_q1bsp_lightmap_updates_enabled
extern

Definition at line 257 of file gl_rmain.c.

257{CF_CLIENT, "r_q1bsp_lightmap_updates_enabled", "1", "allow lightmaps to be updated on Q1BSP maps (don't turn this off except for debugging)"};

Referenced by GL_Main_Init(), and R_DrawModelSurfaces().

◆ r_q1bsp_lightmap_updates_hidden_surfaces

cvar_t r_q1bsp_lightmap_updates_hidden_surfaces
extern

Definition at line 259 of file gl_rmain.c.

259{CF_CLIENT | CF_ARCHIVE, "r_q1bsp_lightmap_updates_hidden_surfaces", "0", "update lightmaps on surfaces that are not visible, so that updates only occur on frames where lightstyles changed value (animation or light switches), only makes sense with combine = 2"};

Referenced by GL_Main_Init(), and R_DrawModelSurfaces().

◆ r_q3bsp_renderskydepth

cvar_t r_q3bsp_renderskydepth
extern

Definition at line 41 of file gl_rsurf.c.

41{CF_CLIENT, "r_q3bsp_renderskydepth", "0", "draws sky depth masking in q3 maps (as in q1 maps), this means for example that sky polygons can hide other things"};

Referenced by GL_Surf_Init(), and R_DrawTextureSurfaceList_Sky().

◆ r_queries

unsigned int r_queries[MAX_OCCLUSION_QUERIES]
extern

◆ r_refdef

r_refdef_t r_refdef
extern

Definition at line 57 of file gl_rmain.c.

Referenced by CL_Beam_AddPolygons(), CL_Beam_CalculatePositions(), CL_ClearTempEntities(), CL_ExpandCSQCRenderEntities(), CL_Fog_f(), CL_Fog_HeightTexture_f(), CL_Frame(), CL_GetEntityMatrix(), CL_GetTagMatrix(), CL_Init(), CL_LinkNetworkEntity(), CL_Locs_RemoveNearest_f(), CL_MeshEntities_Scene_AddRenderEntity(), CL_NewParticlesFromEffectinfo(), CL_NewTempEntity(), CL_ParseEntityLump(), CL_ParticleEffect_Fallback(), CL_RelinkBeams(), CL_RelinkLightFlashes(), CL_RelinkStaticEntities(), CL_RelinkWorld(), CL_TimeRefresh_f(), CL_UpdateEntityShading(), CL_UpdateEntityShading_Entity(), CL_UpdatePrydonCursor(), CL_UpdateScreen(), CL_UpdateWorld(), CL_VM_UpdateView(), Collision_Cache_Lookup(), CSQC_AddRenderEdict(), CSQC_R_RecalcView(), DrawQ_Finish(), DrawQ_FlushUI(), DrawQ_RecalcView(), DrawQ_SetClipArea(), DrawQ_Start(), FOG_clear(), gl_main_start(), Mod_BSP_LightPoint_RecursiveBSPNode(), Mod_Mesh_Finalize(), MP_Draw(), R_AnimCache_CacheVisibleEntities(), R_AnimCache_ClearCache(), R_AnimCache_GetEntity(), R_BeginCoronaQuery(), R_BlendView(), R_BlendView_IsTrivial(), R_Bloom_MakeTexture(), R_Bloom_StartFrame(), R_BufferData_Store(), R_BuildFogHeightTexture(), R_BuildFogTexture(), R_BuildLightMap(), R_CalcBeam_Vertex3f(), R_CanSeeBox(), R_ClearScreen(), R_CompleteLightPoint(), R_CullFrustum(), R_DebugLine(), R_DecalSystem_ApplySplatEntities(), R_DrawBBoxMesh(), R_DrawBrushModelsSky(), R_DrawCorona(), R_DrawDebugModel(), R_DrawExplosion_TransparentCallback(), R_DrawLoc_Callback(), R_DrawModelDecals(), R_DrawModelDecals_Entity(), R_DrawModelDecals_FadeEntity(), R_DrawModels(), R_DrawModelsAddWaterPlanes(), R_DrawModelsDebug(), R_DrawModelsDepth(), R_DrawModelSurfaces(), R_DrawModelTextureSurfaceList(), R_DrawNoModel_TransparentCallback(), R_DrawParticle_TransparentCallback(), R_DrawParticles(), R_DrawPortal_Callback(), R_DrawPortals(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_Envmap_f(), R_FrameData_Alloc(), R_GetCurrentTexture(), R_GetScenePointer(), R_HDR_UpdateIrisAdaptation(), R_ListWorldTextures_f(), R_Main_FreeViewCache(), R_Main_ResizeViewCache(), R_Mesh_Draw(), R_Mesh_UpdateMeshBuffer(), R_MeshQueue_AddTransparent(), R_MeshQueue_BeginScene(), R_Mod_DrawAddWaterPlanes(), R_Mod_DrawDepth(), R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Mod_GetLightInfo(), R_Model_Sprite_Draw_TransparentCallback(), R_MotionBlurView(), R_ProcessTransparentTextureSurfaceList(), R_RenderScene(), R_RenderTarget_Get(), R_RenderView(), R_RenderView_UpdateViewVectors(), R_RenderWaterPlanes(), R_ReplaceWorldTexture_f(), R_ResetViewRendering2D_Common(), R_ResetViewRendering3D(), R_RTLight_Compile(), R_ScissorForBBox(), R_SelectScene(), R_SetupShader_DeferredLight(), R_SetupShader_Surface(), R_SetupView(), R_Shadow_BounceGrid_AssignPhotons_Task(), R_Shadow_BounceGrid_CheckEnable(), R_Shadow_BounceGrid_UpdateSpacing(), R_Shadow_ClearShadowMapTexture(), R_Shadow_ClearStencil(), R_Shadow_ComputeShadowCasterCullingPlanes(), R_Shadow_CullFrustumSides(), R_Shadow_DrawCoronas(), R_Shadow_DrawCursor_TransparentCallback(), R_Shadow_DrawLight(), R_Shadow_DrawLightShadowMaps(), R_Shadow_DrawLightSprite_TransparentCallback(), R_Shadow_DrawModelShadowMaps(), R_Shadow_DrawPrepass(), R_Shadow_DrawWorldLight(), R_Shadow_DrawWorldShadow_ShadowMap(), R_Shadow_PrepareLight(), R_Shadow_PrepareLights(), R_Shadow_PrepareModelShadows(), R_Shadow_RenderMode_Begin(), R_Shadow_RenderMode_DrawDeferredLight(), R_Shadow_RenderMode_End(), R_Shadow_RenderMode_Lighting(), R_Shadow_RenderMode_Reset(), R_Shadow_RenderMode_ShadowMap(), R_Shadow_RenderMode_VisibleLighting(), R_Shadow_ScissorForBBox(), R_Shadow_SelectLightInView(), R_Shadow_SetCursorLocationForView(), R_Shadow_UpdateBounceGridTexture(), R_Sky(), R_SkySphere(), R_SkyStartFrame(), R_SortEntities(), R_Stain(), R_TimeReport_BeginFrame(), R_TimeReport_EndFrame(), R_TrackSprite(), R_UpdateFog(), R_UpdateVariables(), R_View_SetFrustum(), R_View_Update(), R_View_UpdateEntityVisible(), R_View_WorldVisibility(), R_View_WorldVisibility_CullSurfaces(), R_Water_AddWaterPlane(), R_Water_ProcessPlanes(), RSurf_ActiveCustomEntity(), RSurf_ActiveModelEntity(), RSurf_DrawBatch(), RSurf_FogPoint(), RSurf_FogVertex(), RSurf_PrepareVerticesForBatch(), RSurf_SetupDepthAndCulling(), Sbar_ShowFPS(), SCR_DrawScreen(), V_CalcIntermissionRefdef(), V_CalcRefdef(), V_CalcRefdefUsing(), V_CalcViewBlend(), V_MakeViewIsometric(), VM_CL_getlight(), VM_CL_project(), VM_CL_R_AddDynamicLight(), VM_CL_R_ClearScene(), VM_CL_R_RenderScene(), VM_CL_R_SetView(), and VM_CL_unproject().

◆ r_render

cvar_t r_render
extern

Definition at line 11 of file gl_backend.c.

11{CF_CLIENT, "r_render", "1", "enables rendering 3D views (you want this on!)"};

Referenced by gl_backend_init(), and R_Mesh_Draw().

◆ r_renderview

cvar_t r_renderview
extern

Definition at line 12 of file gl_backend.c.

12{CF_CLIENT, "r_renderview", "1", "enables rendering 3D views (you want this on!)"};

Referenced by gl_backend_init(), and R_RenderView().

◆ r_screenvertex3f

const float r_screenvertex3f[12]
extern

vertex coordinates for a quad that covers the screen exactly

Definition at line 313 of file gl_rmain.c.

314{
315 0, 0, 0,
316 1, 0, 0,
317 1, 1, 0,
318 0, 1, 0
319};

Referenced by R_BlendView(), R_Bloom_MakeTexture(), and R_MotionBlurView().

◆ r_shadow_attenuation2dtexture

rtexture_t* r_shadow_attenuation2dtexture
extern

◆ r_shadow_attenuation3dtexture

rtexture_t* r_shadow_attenuation3dtexture
extern

◆ r_shadow_attenuationgradienttexture

rtexture_t* r_shadow_attenuationgradienttexture
extern

◆ r_shadow_lightshadowmap_parameters

float r_shadow_lightshadowmap_parameters[4]
extern

◆ r_shadow_lightshadowmap_texturescale

float r_shadow_lightshadowmap_texturescale[4]
extern

◆ r_shadow_modelshadowmap_parameters

float r_shadow_modelshadowmap_parameters[4]
extern

Definition at line 43 of file r_shadow.c.

Referenced by R_SetupShader_Surface(), and R_Shadow_DrawModelShadowMaps().

◆ r_shadow_modelshadowmap_texturescale

float r_shadow_modelshadowmap_texturescale[4]
extern

Definition at line 42 of file r_shadow.c.

Referenced by R_SetupShader_Surface(), and R_Shadow_DrawModelShadowMaps().

◆ r_shadow_prepass_height

int r_shadow_prepass_height
extern

Definition at line 118 of file r_shadow.c.

Referenced by R_Shadow_PrepareLights(), r_shadow_shutdown(), and r_shadow_start().

◆ r_shadow_prepass_width

int r_shadow_prepass_width
extern

Definition at line 117 of file r_shadow.c.

Referenced by R_Shadow_PrepareLights(), r_shadow_shutdown(), and r_shadow_start().

◆ r_shadow_prepassgeometrydepthbuffer

rtexture_t* r_shadow_prepassgeometrydepthbuffer
extern

Definition at line 119 of file r_shadow.c.

Referenced by R_Shadow_FreeDeferred(), and R_Shadow_PrepareLights().

◆ r_shadow_prepassgeometrynormalmaptexture

rtexture_t* r_shadow_prepassgeometrynormalmaptexture
extern

◆ r_shadow_prepasslightingdiffusetexture

rtexture_t* r_shadow_prepasslightingdiffusetexture
extern

Definition at line 121 of file r_shadow.c.

◆ r_shadow_prepasslightingspeculartexture

rtexture_t* r_shadow_prepasslightingspeculartexture
extern

Definition at line 122 of file r_shadow.c.

◆ r_shadow_shadowmap2ddepthbuffer

◆ r_shadow_shadowmap2ddepthtexture

◆ r_shadow_shadowmapmatrix

matrix4x4_t r_shadow_shadowmapmatrix
extern

Definition at line 62 of file r_shadow.c.

Referenced by R_SetupShader_Surface(), and R_Shadow_DrawModelShadowMaps().

◆ r_shadow_shadowmapvsdct

◆ r_shadow_shadowmapvsdcttexture

◆ r_shadow_usingdeferredprepass

qbool r_shadow_usingdeferredprepass
extern

Definition at line 64 of file r_shadow.c.

◆ r_shadow_usingshadowmap2d

◆ r_shadow_usingshadowmaportho

qbool r_shadow_usingshadowmaportho
extern

◆ r_shadow_viewcolortexture

rtexture_t* r_shadow_viewcolortexture
extern

Definition at line 126 of file r_shadow.c.

Referenced by R_RenderScene().

◆ r_shadow_viewdepthtexture

rtexture_t* r_shadow_viewdepthtexture
extern

Definition at line 125 of file r_shadow.c.

Referenced by R_RenderScene().

◆ r_shadow_viewfbo

int r_shadow_viewfbo
extern

Definition at line 124 of file r_shadow.c.

Referenced by R_RenderScene(), and R_Shadow_RenderMode_Reset().

◆ r_shadow_viewheight

int r_shadow_viewheight
extern

Definition at line 130 of file r_shadow.c.

Referenced by R_RenderScene().

◆ r_shadow_viewwidth

int r_shadow_viewwidth
extern

Definition at line 129 of file r_shadow.c.

Referenced by R_RenderScene().

◆ r_shadow_viewx

int r_shadow_viewx
extern

Definition at line 127 of file r_shadow.c.

Referenced by R_RenderScene().

◆ r_shadow_viewy

int r_shadow_viewy
extern

Definition at line 128 of file r_shadow.c.

Referenced by R_RenderScene().

◆ r_shadows

cvar_t r_shadows
extern

Definition at line 123 of file gl_rmain.c.

123{CF_CLIENT | CF_ARCHIVE, "r_shadows", "0", "casts fake stencil shadows from models onto the world (rtlights are unaffected by this); when set to 2, always cast the shadows in the direction set by r_shadows_throwdirection, otherwise use the model lighting."};

Referenced by GL_Main_Init(), R_Shadow_PrepareModelShadows(), and R_Water_ProcessPlanes().

◆ r_shadows_castfrombmodels

cvar_t r_shadows_castfrombmodels
extern

Definition at line 128 of file gl_rmain.c.

128{CF_CLIENT | CF_ARCHIVE, "r_shadows_castfrombmodels", "0", "do cast shadows from bmodels"};

Referenced by GL_Main_Init(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_darken

cvar_t r_shadows_darken
extern

Definition at line 124 of file gl_rmain.c.

124{CF_CLIENT | CF_ARCHIVE, "r_shadows_darken", "0.5", "how much shadowed areas will be darkened"};

Referenced by GL_Main_Init(), and R_Shadow_DrawModelShadowMaps().

◆ r_shadows_drawafterrtlighting

cvar_t r_shadows_drawafterrtlighting
extern

Definition at line 127 of file gl_rmain.c.

127{CF_CLIENT | CF_ARCHIVE, "r_shadows_drawafterrtlighting", "0", "draw fake shadows AFTER realtime lightning is drawn. May be useful for simulating fast sunlight on large outdoor maps with only one noshadow rtlight. The price is less realistic appearance of dynamic light shadows."};

Referenced by GL_Main_Init().

◆ r_shadows_focus

cvar_t r_shadows_focus
extern

Definition at line 129 of file gl_rmain.c.

129{CF_CLIENT | CF_ARCHIVE, "r_shadows_focus", "0 0 0", "offset the shadowed area focus"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_shadowmapbias

cvar_t r_shadows_shadowmapbias
extern

Definition at line 131 of file gl_rmain.c.

131{CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapbias", "-1", "sets shadowmap bias for fake shadows. -1 sets the value of r_shadow_shadowmapping_bias. Needs shadowmapping ON."};

Referenced by GL_Main_Init(), and R_Shadow_DrawModelShadowMaps().

◆ r_shadows_shadowmapscale

cvar_t r_shadows_shadowmapscale
extern

Definition at line 130 of file gl_rmain.c.

130{CF_CLIENT | CF_ARCHIVE, "r_shadows_shadowmapscale", "0.25", "higher values increase shadowmap quality at a cost of area covered (multiply global shadowmap precision) for fake shadows. Needs shadowmapping ON."};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_throwdirection

cvar_t r_shadows_throwdirection
extern

Definition at line 126 of file gl_rmain.c.

126{CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdirection", "0 0 -1", "override throwing direction for r_shadows 2"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_shadows_throwdistance

cvar_t r_shadows_throwdistance
extern

Definition at line 125 of file gl_rmain.c.

125{CF_CLIENT | CF_ARCHIVE, "r_shadows_throwdistance", "500", "how far to cast shadows from models"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and R_Shadow_PrepareModelShadows().

◆ r_showcollisionbrushes

cvar_t r_showcollisionbrushes
extern

Definition at line 89 of file gl_rmain.c.

89{CF_CLIENT, "r_showcollisionbrushes", "0", "draws collision brushes in quake3 maps (mode 1), mode 2 disables rendering of world (trippy!)"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_showcollisionbrushes_polygonfactor

cvar_t r_showcollisionbrushes_polygonfactor
extern

Definition at line 90 of file gl_rmain.c.

90{CF_CLIENT, "r_showcollisionbrushes_polygonfactor", "-1", "expands outward the brush polygons a little bit, used to make collision brushes appear infront of walls"};

Referenced by GL_Main_Init(), and R_DrawDebugModel().

◆ r_showcollisionbrushes_polygonoffset

cvar_t r_showcollisionbrushes_polygonoffset
extern

Definition at line 91 of file gl_rmain.c.

91{CF_CLIENT, "r_showcollisionbrushes_polygonoffset", "0", "nudges brush polygon depth in hardware depth units, used to make collision brushes appear infront of walls"};

Referenced by GL_Main_Init(), and R_DrawDebugModel().

◆ r_showdisabledepthtest

cvar_t r_showdisabledepthtest
extern

Definition at line 92 of file gl_rmain.c.

92{CF_CLIENT, "r_showdisabledepthtest", "0", "disables depth testing on r_show* cvars, allowing you to see what hidden geometry the graphics card is processing"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), R_DrawEntityBBoxes_Callback(), and R_Shadow_RenderLighting().

◆ r_showlighting

cvar_t r_showlighting
extern

Definition at line 88 of file gl_rmain.c.

88{CF_CLIENT, "r_showlighting", "0", "shows areas lit by lights, useful for finding out why some areas of a map render slowly (bright orange = lots of passes = slow), a value of 2 disables depth testing which can be interesting but not very useful"};

Referenced by GL_Main_Init(), R_Shadow_DrawLight(), and R_Shadow_RenderMode_VisibleLighting().

◆ r_shownormals

cvar_t r_shownormals
extern

Definition at line 87 of file gl_rmain.c.

87{CF_CLIENT, "r_shownormals", "0", "shows per-vertex surface normals and tangent vectors for bumpmapped lighting"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_showoverdraw

cvar_t r_showoverdraw
extern

Definition at line 82 of file gl_rmain.c.

82{CF_CLIENT, "r_showoverdraw", "0", "shows overlapping geometry"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_showparticleedges

cvar_t r_showparticleedges
extern

Definition at line 94 of file gl_rmain.c.

94{CF_CLIENT, "r_showparticleedges", "0", "renders a debug outline to show the polygon shape of each particle, for debugging rendering bugs with specific view types"};

Referenced by GL_Main_Init(), and R_DrawParticle_TransparentCallback().

◆ r_showspriteedges

cvar_t r_showspriteedges
extern

Definition at line 93 of file gl_rmain.c.

93{CF_CLIENT, "r_showspriteedges", "0", "renders a debug outline to show the polygon shape of each sprite frame rendered (may be 2 or more in case of interpolated animations), for debugging rendering bugs with specific view types"};

Referenced by GL_Main_Init(), and R_Model_Sprite_Draw_TransparentCallback().

◆ r_showtris

cvar_t r_showtris
extern

Definition at line 86 of file gl_rmain.c.

86{CF_CLIENT, "r_showtris", "0", "shows triangle outlines, value controls brightness (can be above 1)"};

Referenced by GL_Main_Init(), R_DrawDebugModel(), and R_RenderScene().

◆ r_sky

cvar_t r_sky
extern

Definition at line 6 of file r_sky.c.

6{CF_CLIENT | CF_ARCHIVE, "r_sky", "1", "enables sky rendering (black otherwise)"};

Referenced by R_Sky_Init(), and R_SkyStartFrame().

◆ r_sky_scissor

cvar_t r_sky_scissor
extern

Definition at line 9 of file r_sky.c.

9{CF_CLIENT, "r_sky_scissor", "1", "limit rendering of sky to approximately the area of the sky surfaces"};

Referenced by R_DrawTextureSurfaceList_Sky(), R_Sky(), and R_Sky_Init().

◆ r_skyscroll1

cvar_t r_skyscroll1
extern

Definition at line 7 of file r_sky.c.

7{CF_CLIENT | CF_ARCHIVE, "r_skyscroll1", "1", "speed at which upper clouds layer scrolls in quake sky"};

Referenced by M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), R_Sky_Init(), and R_SkySphere().

◆ r_skyscroll2

cvar_t r_skyscroll2
extern

Definition at line 8 of file r_sky.c.

8{CF_CLIENT | CF_ARCHIVE, "r_skyscroll2", "2", "speed at which lower clouds layer scrolls in quake sky"};

Referenced by M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), R_Sky_Init(), and R_SkySphere().

◆ r_smoothnormals_areaweighting

cvar_t r_smoothnormals_areaweighting
extern

Definition at line 229 of file gl_rmain.c.

229{CF_CLIENT, "r_smoothnormals_areaweighting", "1", "uses significantly faster (and supposedly higher quality) area-weighted vertex normals and tangent vectors rather than summing normalized triangle normals and tangents"};

Referenced by GL_Main_Init(), Mod_Alias_MorphMesh_CompileFrames(), Mod_DARKPLACESMODEL_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_OBJ_Load(), Mod_PSKMODEL_Load(), Mod_Q1BSP_LoadFaces(), Mod_Q3BSP_LoadFaces(), Mod_VBSP_LoadFaces(), Mod_ZYMOTICMODEL_Load(), RSurf_ActiveCustomEntity(), and RSurf_PrepareVerticesForBatch().

◆ r_speeds

cvar_t r_speeds
extern

Definition at line 111 of file gl_rmain.c.

111{CF_CLIENT, "r_speeds","0", "displays rendering statistics and per-subsystem timings"};

Referenced by GL_Main_Init(), R_DrawModelSurfaces(), R_TimeReport(), R_TimeReport_BeginFrame(), R_TimeReport_EndFrame(), and VID_Finish().

◆ r_svbsp

svbsp_t r_svbsp
extern

shadow volume bsp struct with automatically growing nodes buffer

Definition at line 268 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), R_Q1BSP_CallRecursiveGetLightInfo(), R_Q1BSP_RecursiveGetLightInfo_BIH(), and R_Q1BSP_RecursiveGetLightInfo_BSP().

◆ r_test

cvar_t r_test
extern

Definition at line 235 of file gl_rmain.c.

235{CF_CLIENT, "r_test", "0", "internal development use only, leave it alone (usually does nothing anyway)"};

Referenced by GL_Main_Init(), R_Shadow_DrawModelShadowMaps(), and RSurf_DrawBatch().

◆ r_texture_black

rtexture_t* r_texture_black
extern

◆ r_texture_blanknormalmap

◆ r_texture_fogattenuation

rtexture_t* r_texture_fogattenuation
extern

◆ r_texture_fogheighttexture

rtexture_t* r_texture_fogheighttexture
extern

◆ r_texture_grey128

rtexture_t* r_texture_grey128
extern

◆ r_texture_normalizationcube

rtexture_t* r_texture_normalizationcube
extern

Definition at line 278 of file gl_rmain.c.

Referenced by gl_main_shutdown(), gl_main_start(), and R_BuildNormalizationCube().

◆ r_texture_notexture

rtexture_t* r_texture_notexture
extern

Definition at line 276 of file gl_rmain.c.

Referenced by R_BuildNoTexture(), and R_GetCurrentTexture().

◆ r_texture_white

◆ r_texture_whitecube

◆ r_textureframe

int r_textureframe
extern

used only by R_GetCurrentTexture, incremented per view and per UI render

Definition at line 45 of file gl_rmain.c.

Referenced by DrawQ_FlushUI(), R_GetCurrentTexture(), and R_RenderView().

◆ r_timereport_active

◆ r_transparent_alphatocoverage

cvar_t r_transparent_alphatocoverage
extern

Definition at line 79 of file gl_rmain.c.

79{CF_CLIENT, "r_transparent_alphatocoverage", "1", "enables GL_ALPHA_TO_COVERAGE antialiasing technique on alphablend and alphatest surfaces when using vid_samples 2 or higher"};

Referenced by GL_Main_Init(), R_GetCurrentTexture(), and R_SetupShader_Surface().

◆ r_transparent_sortarraysize

cvar_t r_transparent_sortarraysize
extern

Definition at line 143 of file gl_rmain.c.

143{CF_CLIENT | CF_ARCHIVE, "r_transparent_sortarraysize", "4096", "number of distance-sorting layers"};

Referenced by GL_Main_Init(), and R_MeshQueue_RenderTransparent().

◆ r_transparent_sortmaxdist

cvar_t r_transparent_sortmaxdist
extern

Definition at line 142 of file gl_rmain.c.

142{CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmaxdist", "32768", "upper distance limit for transparent sorting"};

Referenced by GL_Main_Init(), and R_MeshQueue_RenderTransparent().

◆ r_transparent_sortmindist

cvar_t r_transparent_sortmindist
extern

Definition at line 141 of file gl_rmain.c.

141{CF_CLIENT | CF_ARCHIVE, "r_transparent_sortmindist", "0", "lower distance limit for transparent sorting"};

Referenced by GL_Main_Init(), and R_MeshQueue_RenderTransparent().

◆ r_transparent_sortsurfacesbynearest

cvar_t r_transparent_sortsurfacesbynearest
extern

Definition at line 80 of file gl_rmain.c.

80{CF_CLIENT, "r_transparent_sortsurfacesbynearest", "1", "sort entity and world surfaces by nearest point on bounding box instead of using the center of the bounding box, usually reduces sorting artifacts"};

Referenced by GL_Main_Init(), R_Mod_DrawLight(), and R_ProcessTransparentTextureSurfaceList().

◆ r_transparent_useplanardistance

cvar_t r_transparent_useplanardistance
extern

Definition at line 81 of file gl_rmain.c.

81{CF_CLIENT, "r_transparent_useplanardistance", "0", "sort transparent meshes by distance from view plane rather than spherical distance to the chosen point"};

Referenced by GL_Main_Init(), and R_MeshQueue_AddTransparent().

◆ r_trippy

◆ r_viewfbo

cvar_t r_viewfbo
extern

Definition at line 160 of file gl_rmain.c.

160{CF_CLIENT | CF_ARCHIVE, "r_viewfbo", "0", "enables use of an 8bit (1) or 16bit (2) or 32bit (3) per component float framebuffer render, which may be at a different resolution than the video mode; the default setting of 0 uses a framebuffer render when required, and renders directly to the screen otherwise"};

Referenced by GL_Main_Init(), R_BlendView_IsTrivial(), R_Bloom_StartFrame(), and VID_Mode().

◆ r_wateralpha

cvar_t r_wateralpha
extern

◆ r_waterscroll

cvar_t r_waterscroll
extern

Definition at line 206 of file gl_rmain.c.

206{CF_CLIENT | CF_ARCHIVE, "r_waterscroll", "1", "makes water scroll around, value controls how much"};

Referenced by GL_Main_Init(), M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), and R_RenderScene().

◆ r_waterwarp

cvar_t r_waterwarp
extern

Definition at line 13 of file gl_backend.c.

13{CF_CLIENT | CF_ARCHIVE, "r_waterwarp", "1", "warp view while underwater"};

Referenced by gl_backend_init(), M_Menu_Options_Effects_AdjustSliders(), M_Options_Effects_Draw(), and V_CalcViewBlend().

◆ rsurface

rsurfacestate_t rsurface
extern

Definition at line 6919 of file gl_rmain.c.

Referenced by R_DecalSystem_SplatEntity(), R_DecalSystem_SplatTriangle(), R_DrawCustomSurface_Texture(), R_DrawDebugModel(), R_DrawModelDecals_Entity(), R_DrawModelSurfaces(), R_DrawNoModel(), R_DrawNoModel_TransparentCallback(), R_DrawPortals(), R_DrawSurface_TransparentCallback(), R_DrawTextureSurfaceList_DepthOnly(), R_DrawTextureSurfaceList_GL20(), R_DrawTextureSurfaceList_ShowSurfaces(), R_DrawTextureSurfaceList_Sky(), R_EvaluateQ3WaveFunc(), R_GetCurrentTexture(), R_Mod_DrawAddWaterPlanes(), R_Mod_DrawLight(), R_Mod_DrawShadowMap(), R_Mod_GetLightInfo(), R_Model_Sprite_Draw(), R_Model_Sprite_Draw_TransparentCallback(), R_ProcessModelTextureSurfaceList(), R_ProcessTransparentTextureSurfaceList(), R_Q1BSP_DrawLight_TransparentCallback(), R_QueueModelSurfaceList(), R_RenderView(), R_SetupShader_DeferredLight(), R_SetupShader_DepthOrShadow(), R_SetupShader_Surface(), R_Shadow_DrawEntityLight(), R_Shadow_DrawEntityShadow(), R_Shadow_DrawModelShadowMaps(), R_Shadow_DrawWorldLight(), R_Shadow_DrawWorldShadow_ShadowMap(), R_Shadow_RenderLighting(), R_Shadow_RenderLighting_VisibleLighting(), R_Shadow_RenderMode_ActiveLight(), R_Shadow_RenderMode_DrawDeferredLight(), R_Shadow_RenderMode_ShadowMap(), R_Shadow_SetShadowmapParametersForLight(), R_Shadow_SetupEntityLight(), R_tcMod_ApplyToMatrix(), R_TestQ3WaveFunc(), R_Water_AddWaterPlane(), RSurf_ActiveCustomEntity(), RSurf_ActiveModelEntity(), RSurf_DrawBatch(), RSurf_FindWaterPlaneForSurface(), RSurf_FogVertex(), RSurf_PrepareVerticesForBatch(), RSurf_SetupDepthAndCulling(), and RSurf_UploadBuffersForBatch().

◆ skyrenderlater

int skyrenderlater
extern

Definition at line 10 of file r_sky.c.

Referenced by R_DrawTextureSurfaceList_Sky(), R_RenderScene(), and R_SkyStartFrame().

◆ skyrendermasked

int skyrendermasked

Definition at line 120 of file render.h.

◆ skyscissor

int skyscissor[4]
extern

Definition at line 12 of file r_sky.c.

Referenced by R_DrawTextureSurfaceList_Sky(), R_Sky(), and R_SkyStartFrame().