X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=gl_rmain.c;h=8dc3369796969bf2889407bf3c6a89a0504ad90c;hb=bdb63282edaaa746a60ce4f9ddcdd914a4c4395f;hp=c613c66f57f452b1825fac67a82491b7ae321566;hpb=1c47ebbd998296306342310be858be14921aa084;p=xonotic%2Fdarkplaces.git diff --git a/gl_rmain.c b/gl_rmain.c index c613c66f..8dc33697 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -103,6 +103,9 @@ cvar_t r_bloom_intensity = {CVAR_SAVE, "r_bloom_intensity", "2"}; cvar_t r_bloom_blur = {CVAR_SAVE, "r_bloom_blur", "8"}; cvar_t r_bloom_resolution = {CVAR_SAVE, "r_bloom_resolution", "320"}; cvar_t r_bloom_power = {CVAR_SAVE, "r_bloom_power", "4"}; + +cvar_t developer_texturelogging = {0, "developer_texturelogging", "1"}; + rtexturepool_t *r_main_texturepool; rtexture_t *r_bloom_texture_screen; rtexture_t *r_bloom_texture_bloom; @@ -110,6 +113,10 @@ rtexture_t *r_texture_blanknormalmap; rtexture_t *r_texture_white; rtexture_t *r_texture_black; rtexture_t *r_texture_notexture; +rtexture_t *r_texture_whitecube; +rtexture_t *r_texture_normalizationcube; +rtexture_t *r_texture_detailtextures[NUM_DETAILTEXTURES]; +rtexture_t *r_texture_distorttexture[64]; void R_ModulateColors(float *in, float *out, int verts, float r, float g, float b) { @@ -209,14 +216,97 @@ void FOG_registercvars(void) } } -void gl_main_start(void) +static void R_BuildDetailTextures (void) +{ + int i, x, y, light; + float vc[3], vx[3], vy[3], vn[3], lightdir[3]; +#define DETAILRESOLUTION 256 + qbyte data[DETAILRESOLUTION][DETAILRESOLUTION][4], noise[DETAILRESOLUTION][DETAILRESOLUTION]; + lightdir[0] = 0.5; + lightdir[1] = 1; + lightdir[2] = -0.25; + VectorNormalize(lightdir); + for (i = 0;i < NUM_DETAILTEXTURES;i++) + { + fractalnoise(&noise[0][0], DETAILRESOLUTION, DETAILRESOLUTION >> 4); + for (y = 0;y < DETAILRESOLUTION;y++) + { + for (x = 0;x < DETAILRESOLUTION;x++) + { + vc[0] = x; + vc[1] = y; + vc[2] = noise[y][x] * (1.0f / 32.0f); + vx[0] = x + 1; + vx[1] = y; + vx[2] = noise[y][(x + 1) % DETAILRESOLUTION] * (1.0f / 32.0f); + vy[0] = x; + vy[1] = y + 1; + vy[2] = noise[(y + 1) % DETAILRESOLUTION][x] * (1.0f / 32.0f); + VectorSubtract(vx, vc, vx); + VectorSubtract(vy, vc, vy); + CrossProduct(vx, vy, vn); + VectorNormalize(vn); + light = 128 - DotProduct(vn, lightdir) * 128; + light = bound(0, light, 255); + data[y][x][0] = data[y][x][1] = data[y][x][2] = light; + data[y][x][3] = 255; + } + } + r_texture_detailtextures[i] = R_LoadTexture2D(r_main_texturepool, va("detailtexture%i", i), DETAILRESOLUTION, DETAILRESOLUTION, &data[0][0][0], TEXTYPE_RGBA, TEXF_MIPMAP | TEXF_PRECACHE, NULL); + } +} + +static qbyte R_MorphDistortTexture (double y0, double y1, double y2, double y3, double morph) +{ + int m = (int)(((y1 + y3 - (y0 + y2)) * morph * morph * morph) + + ((2 * (y0 - y1) + y2 - y3) * morph * morph) + + ((y2 - y0) * morph) + + (y1)); + return (qbyte)bound(0, m, 255); +} + +static void R_BuildDistortTexture (void) +{ + int x, y, i, j; +#define DISTORTRESOLUTION 32 + qbyte data[5][DISTORTRESOLUTION][DISTORTRESOLUTION][2]; + + for (i=0; i<4; i++) + { + for (y=0; yvisframe = r_framecount; renderimask = envmap ? (RENDER_EXTERIORMODEL | RENDER_VIEWMODEL) : (chase_active.integer ? 0 : RENDER_EXTERIORMODEL); if (r_refdef.worldmodel && r_refdef.worldmodel->brush.BoxTouchingVisibleLeafs) { @@ -661,14 +848,14 @@ static void R_BlendView(void) qglViewport(r_view_x, vid.realheight - (r_view_y + bloomheight), bloomwidth, bloomheight); GL_BlendFunc(GL_ONE, GL_ZERO); GL_Color(1, 1, 1, 1); - R_Mesh_Draw(4, 2, polygonelements); + R_Mesh_Draw(0, 4, 2, polygonelements); c_bloomdraws++; c_bloomdrawpixels += bloomwidth * bloomheight; // render multiple times with a multiply blendfunc to raise to a power GL_BlendFunc(GL_DST_COLOR, GL_ZERO); for (x = 1;x < r_bloom_power.integer;x++) { - R_Mesh_Draw(4, 2, polygonelements); + R_Mesh_Draw(0, 4, 2, polygonelements); c_bloomdraws++; c_bloomdrawpixels += bloomwidth * bloomheight; } @@ -707,7 +894,7 @@ static void R_BlendView(void) if (r < 0.01f) continue; GL_Color(r, r, r, 1); - R_Mesh_Draw(4, 2, polygonelements); + R_Mesh_Draw(0, 4, 2, polygonelements); c_bloomdraws++; c_bloomdrawpixels += bloomwidth * bloomheight; GL_BlendFunc(GL_ONE, GL_ONE); @@ -742,7 +929,7 @@ static void R_BlendView(void) if (r < 0.01f) continue; GL_Color(r, r, r, 1); - R_Mesh_Draw(4, 2, polygonelements); + R_Mesh_Draw(0, 4, 2, polygonelements); c_bloomdraws++; c_bloomdrawpixels += bloomwidth * bloomheight; GL_BlendFunc(GL_ONE, GL_ONE); @@ -777,7 +964,7 @@ static void R_BlendView(void) R_Mesh_State(&m); GL_BlendFunc(GL_ONE, GL_ZERO); GL_Color(1,1,1,1); - R_Mesh_Draw(4, 2, polygonelements); + R_Mesh_Draw(0, 4, 2, polygonelements); c_bloomdraws++; c_bloomdrawpixels += r_view_width * r_view_height; // now blend on the bloom texture if multipass @@ -790,7 +977,7 @@ static void R_BlendView(void) R_Mesh_State(&m); GL_BlendFunc(GL_ONE, GL_ONE); GL_Color(1,1,1,1); - R_Mesh_Draw(4, 2, polygonelements); + R_Mesh_Draw(0, 4, 2, polygonelements); c_bloomdraws++; c_bloomdrawpixels += r_view_width * r_view_height; } @@ -803,7 +990,7 @@ static void R_BlendView(void) R_Mesh_State(&m); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_Color(r_refdef.viewblend[0], r_refdef.viewblend[1], r_refdef.viewblend[2], r_refdef.viewblend[3]); - R_Mesh_Draw(4, 2, polygonelements); + R_Mesh_Draw(0, 4, 2, polygonelements); } } @@ -960,10 +1147,10 @@ void R_RenderScene(void) R_MeshQueue_Render(); R_MeshQueue_EndScene(); - if (r_shadow_visiblevolumes.integer && !r_showtrispass) + if ((r_shadow_visiblelighting.integer || r_shadow_visiblevolumes.integer) && !r_showtrispass) { R_ShadowVolumeLighting(true); - R_TimeReport("shadowvolume"); + R_TimeReport("visiblevolume"); } GL_ShowTrisColor(0.05, 0.05, 0.05, 1); @@ -1098,7 +1285,7 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2) else m.pointer_color = nomodelcolor4f; R_Mesh_State(&m); - R_Mesh_Draw(6, 8, nomodelelements); + R_Mesh_Draw(0, 6, 8, nomodelelements); } void R_DrawNoModel(entity_render_t *ent) @@ -1176,6 +1363,6 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, int depth m.pointer_vertex = varray_vertex3f; R_Mesh_State(&m); GL_Color(cr, cg, cb, ca); - R_Mesh_Draw(4, 2, polygonelements); + R_Mesh_Draw(0, 4, 2, polygonelements); }