]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
added r_viewfbo and r_viewscale cvars - the former allows use of
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 31 Mar 2011 13:17:15 +0000 (13:17 +0000)
committerRudolf Polzer <divVerent@xonotic.org>
Sun, 3 Apr 2011 20:48:25 +0000 (22:48 +0200)
GL_RGBA16F and GL_RGBA32F framebuffer rendering for 3D views (the main
refresh is not altered), the latter will allow scaling view rendering
resolution independently of video resolution, when implemented

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10989 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=3e38a6509b932ff0c1033f296737ba378bdc3214

cl_screen.c
dpsoftrast.h
gl_backend.h
gl_draw.c
gl_rmain.c
gl_textures.c
glquake.h
r_shadow.c
r_textures.h

index 9186a68ccc6c656905b2b2550309ad18cb3b302e..b8addbba81f690ceddc114aa990aa80478c1aad2 100644 (file)
@@ -2030,6 +2030,7 @@ static void SCR_DrawLoadingScreen_SharedSetup (qboolean clear)
 //     CHECKGLERROR
        r_refdef.draw2dstage = true;
        R_Viewport_InitOrtho(&viewport, &identitymatrix, 0, 0, vid.width, vid.height, 0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100, NULL);
+       R_Mesh_ResetRenderTargets();
        R_SetViewport(&viewport);
        GL_ColorMask(1,1,1,1);
        // when starting up a new video mode, make sure the screen is cleared to black
@@ -2291,6 +2292,7 @@ void CL_UpdateScreen(void)
        }
 
        R_Viewport_InitOrtho(&viewport, &identitymatrix, 0, 0, vid.width, vid.height, 0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100, NULL);
+       R_Mesh_ResetRenderTargets();
        R_SetViewport(&viewport);
        GL_ScissorTest(false);
        GL_ColorMask(1,1,1,1);
index a1b562e4d3da7107b59335a40a54c7339a945924..8ebb98d6a11a7a8318503a6718c6a8d1e5331c2a 100644 (file)
 #define DPSOFTRAST_TEXTURE_FORMAT_DEPTH 1
 #define DPSOFTRAST_TEXTURE_FORMAT_RGBA8 2
 #define DPSOFTRAST_TEXTURE_FORMAT_ALPHA8 3
-#define DPSOFTRAST_TEXTURE_FORMAT_COMPAREMASK 3
+#define DPSOFTRAST_TEXTURE_FORMAT_RGBA16F 4
+#define DPSOFTRAST_TEXTURE_FORMAT_RGBA32F 5
+#define DPSOFTRAST_TEXTURE_FORMAT_COMPAREMASK 0x0F
 
 // modifier flags for texture (can not be changed after creation)
-#define DPSOFTRAST_TEXTURE_FLAG_MIPMAP 4
-#define DPSOFTRAST_TEXTURE_FLAG_CUBEMAP 8
-#define DPSOFTRAST_TEXTURE_FLAG_USEALPHA 16
-#define DPSOFTRAST_TEXTURE_FLAG_CLAMPTOEDGE 32
+#define DPSOFTRAST_TEXTURE_FLAG_MIPMAP 0x10
+#define DPSOFTRAST_TEXTURE_FLAG_CUBEMAP 0x20
+#define DPSOFTRAST_TEXTURE_FLAG_USEALPHA 0x40
+#define DPSOFTRAST_TEXTURE_FLAG_CLAMPTOEDGE 0x80
 
 typedef enum DPSOFTRAST_TEXTURE_FILTER_e
 {
index 3997fa2643af15667e5864e25ab65bf25b54eddf..ad6b1dc389825c353f2d080b5ac26f8892d6fb5c 100644 (file)
@@ -50,6 +50,7 @@ void GL_ReadPixelsBGRA(int x, int y, int width, int height, unsigned char *outpi
 int R_Mesh_CreateFramebufferObject(rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4);
 void R_Mesh_DestroyFramebufferObject(int fbo);
 void R_Mesh_ResetRenderTargets(void);
+void R_Mesh_SetMainRenderTargets(void);
 void R_Mesh_SetRenderTargets(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4);
 
 unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **vertexstrings_list, int geometrystrings_count, const char **geometrystrings_list, int fragmentstrings_count, const char **fragmentstrings_list);
index 23eed34011f388008fc71b728cc7ca794f5cc6b7..50fcb81e35adfd2608e77379e85e270ec7746cbf 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -1015,6 +1015,7 @@ static void _DrawQ_Setup(void)
        r_refdef.draw2dstage = 1;
        CHECKGLERROR
        R_Viewport_InitOrtho(&viewport, &identitymatrix, r_refdef.view.x, vid.height - r_refdef.view.y - r_refdef.view.height, r_refdef.view.width, r_refdef.view.height, 0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100, NULL);
+       R_Mesh_ResetRenderTargets();
        R_SetViewport(&viewport);
        GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
        GL_DepthFunc(GL_LEQUAL);
index 8d6fd065b19310d013f7446594f8389f4563fcd8..caa7bbce785dfbff5eaf95a4e56669bf48a51064 100644 (file)
@@ -141,6 +141,9 @@ cvar_t r_textureunits = {0, "r_textureunits", "32", "number of texture units to
 static cvar_t gl_combine = {CVAR_READONLY, "gl_combine", "1", "indicates whether the OpenGL 1.3 rendering path is active"};
 static cvar_t r_glsl = {CVAR_READONLY, "r_glsl", "1", "indicates whether the OpenGL 2.0 rendering path is active"};
 
+cvar_t r_viewfbo = {CVAR_SAVE, "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"};
+cvar_t r_viewscale = {CVAR_SAVE, "r_viewscale", "1", "scaling factor for resolution of the fbo rendering method, must be > 0, can be above 1 for a costly antialiasing behavior, typical values are 0.5 for 1/4th as many pixels rendered, or 1 for normal rendering"};
+
 cvar_t r_glsl_deluxemapping = {CVAR_SAVE, "r_glsl_deluxemapping", "1", "use per pixel lighting on deluxemap-compiled q3bsp maps (or a value of 2 forces deluxemap shading even without deluxemaps)"};
 cvar_t r_glsl_offsetmapping = {CVAR_SAVE, "r_glsl_offsetmapping", "0", "offset mapping effect (also known as parallax mapping or virtual displacement mapping)"};
 cvar_t r_glsl_offsetmapping_steps = {CVAR_SAVE, "r_glsl_offsetmapping_steps", "2", "offset mapping steps (note: too high values may be not supported by your GPU)"};
@@ -222,6 +225,13 @@ static struct r_bloomstate_s
 
        int bloomwidth, bloomheight;
 
+       textype_t texturetype;
+       int viewfbo; // used to check if r_viewfbo cvar has changed
+
+       int fbo_framebuffer; // non-zero if r_viewfbo is enabled and working
+       rtexture_t *texture_framebuffercolor; // non-NULL if fbo_screen is non-zero
+       rtexture_t *texture_framebufferdepth; // non-NULL if fbo_screen is non-zero
+
        int screentexturewidth, screentextureheight;
        rtexture_t *texture_screen; /// \note also used for motion blur if enabled!
 
@@ -4084,6 +4094,8 @@ void GL_Main_Init(void)
        Cvar_RegisterVariable(&r_texture_convertsRGB_particles);
        Cvar_RegisterVariable(&r_textureunits);
        Cvar_RegisterVariable(&gl_combine);
+       Cvar_RegisterVariable(&r_viewfbo);
+       Cvar_RegisterVariable(&r_viewscale);
        Cvar_RegisterVariable(&r_glsl);
        Cvar_RegisterVariable(&r_glsl_deluxemapping);
        Cvar_RegisterVariable(&r_glsl_offsetmapping);
@@ -5101,6 +5113,14 @@ void R_View_Update(void)
        R_View_UpdateEntityLighting();
 }
 
+void R_Mesh_SetMainRenderTargets(void)
+{
+       if (r_bloomstate.fbo_framebuffer)
+               R_Mesh_SetRenderTargets(r_bloomstate.fbo_framebuffer, r_bloomstate.texture_framebufferdepth, r_bloomstate.texture_framebuffercolor, NULL, NULL, NULL);
+       else
+               R_Mesh_ResetRenderTargets();
+}
+
 void R_SetupView(qboolean allowwaterclippingplane)
 {
        const float *customclipplane = NULL;
@@ -5125,6 +5145,7 @@ void R_SetupView(qboolean allowwaterclippingplane)
                R_Viewport_InitPerspectiveInfinite(&r_refdef.view.viewport, &r_refdef.view.matrix, r_refdef.view.x, vid.height - r_refdef.view.height - r_refdef.view.y, r_refdef.view.width, r_refdef.view.height, r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, customclipplane);
        else
                R_Viewport_InitPerspective(&r_refdef.view.viewport, &r_refdef.view.matrix, r_refdef.view.x, vid.height - r_refdef.view.height - r_refdef.view.y, r_refdef.view.width, r_refdef.view.height, r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, r_refdef.farclip, customclipplane);
+       R_Mesh_SetMainRenderTargets();
        R_SetViewport(&r_refdef.view.viewport);
 }
 
@@ -5177,6 +5198,7 @@ void R_ResetViewRendering2D(void)
 
        // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom
        R_Viewport_InitOrtho(&viewport, &identitymatrix, r_refdef.view.x, vid.height - r_refdef.view.height - r_refdef.view.y, r_refdef.view.width, r_refdef.view.height, 0, 0, 1, 1, -10, 100, NULL);
+       R_Mesh_ResetRenderTargets();
        R_SetViewport(&viewport);
        GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
        GL_Color(1, 1, 1, 1);
@@ -5636,6 +5658,7 @@ error:
 void R_Bloom_StartFrame(void)
 {
        int bloomtexturewidth, bloomtextureheight, screentexturewidth, screentextureheight;
+       textype_t textype;
 
        switch(vid.renderpath)
        {
@@ -5683,31 +5706,82 @@ void R_Bloom_StartFrame(void)
                Cvar_SetValueQuick(&r_damageblur, 0);
        }
 
-       if (!(r_glsl_postprocess.integer || (!R_Stereo_ColorMasking() && r_glsl_saturation.value != 1) || (v_glslgamma.integer && !vid_gammatables_trivial)) && !r_bloom.integer && !r_hdr.integer && (R_Stereo_Active() || (r_motionblur.value <= 0 && r_damageblur.value <= 0)))
+       if (!(r_glsl_postprocess.integer || (!R_Stereo_ColorMasking() && r_glsl_saturation.value != 1) || (v_glslgamma.integer && !vid_gammatables_trivial)) && !r_bloom.integer && !r_hdr.integer && (R_Stereo_Active() || (r_motionblur.value <= 0 && r_damageblur.value <= 0)) && r_viewfbo.integer < 1 && r_viewscale.value == 1.0f)
                screentexturewidth = screentextureheight = 0;
        if (!r_hdr.integer && !r_bloom.integer)
                bloomtexturewidth = bloomtextureheight = 0;
 
+       textype = TEXTYPE_COLORBUFFER;
+       switch (vid.renderpath)
+       {
+       case RENDERPATH_GL20:
+       case RENDERPATH_GLES2:
+               if (vid.support.ext_framebuffer_object)
+               {
+                       if (r_viewfbo.integer == 2) textype = TEXTYPE_COLORBUFFER16F;
+                       if (r_viewfbo.integer == 3) textype = TEXTYPE_COLORBUFFER32F;
+               }
+               break;
+       case RENDERPATH_D3D9:
+       case RENDERPATH_D3D10:
+       case RENDERPATH_D3D11:
+       case RENDERPATH_SOFT:
+       case RENDERPATH_GL13:
+       case RENDERPATH_GL11:
+               break;
+       }
+
        // allocate textures as needed
-       if (r_bloomstate.screentexturewidth != screentexturewidth || r_bloomstate.screentextureheight != screentextureheight)
+       if (r_bloomstate.screentexturewidth != screentexturewidth
+        || r_bloomstate.screentextureheight != screentextureheight
+        || r_bloomstate.bloomtexturewidth != bloomtexturewidth
+        || r_bloomstate.bloomtextureheight != bloomtextureheight
+        || r_bloomstate.texturetype != textype
+        || r_bloomstate.viewfbo != r_viewfbo.integer)
        {
+               if (r_bloomstate.texture_bloom)
+                       R_FreeTexture(r_bloomstate.texture_bloom);
+               r_bloomstate.texture_bloom = NULL;
                if (r_bloomstate.texture_screen)
                        R_FreeTexture(r_bloomstate.texture_screen);
                r_bloomstate.texture_screen = NULL;
+               if (r_bloomstate.fbo_framebuffer)
+                       R_Mesh_DestroyFramebufferObject(r_bloomstate.fbo_framebuffer);
+               r_bloomstate.fbo_framebuffer = 0;
+               if (r_bloomstate.texture_framebuffercolor)
+                       R_FreeTexture(r_bloomstate.texture_framebuffercolor);
+               r_bloomstate.texture_framebuffercolor = NULL;
+               if (r_bloomstate.texture_framebufferdepth)
+                       R_FreeTexture(r_bloomstate.texture_framebufferdepth);
+               r_bloomstate.texture_framebufferdepth = NULL;
                r_bloomstate.screentexturewidth = screentexturewidth;
                r_bloomstate.screentextureheight = screentextureheight;
                if (r_bloomstate.screentexturewidth && r_bloomstate.screentextureheight)
-                       r_bloomstate.texture_screen = R_LoadTexture2D(r_main_texturepool, "screen", r_bloomstate.screentexturewidth, r_bloomstate.screentextureheight, NULL, TEXTYPE_COLORBUFFER, TEXF_RENDERTARGET | TEXF_FORCENEAREST | TEXF_CLAMP, -1, NULL);
-       }
-       if (r_bloomstate.bloomtexturewidth != bloomtexturewidth || r_bloomstate.bloomtextureheight != bloomtextureheight)
-       {
-               if (r_bloomstate.texture_bloom)
-                       R_FreeTexture(r_bloomstate.texture_bloom);
-               r_bloomstate.texture_bloom = NULL;
+                       r_bloomstate.texture_screen = R_LoadTexture2D(r_main_texturepool, "screen", r_bloomstate.screentexturewidth, r_bloomstate.screentextureheight, NULL, textype, TEXF_RENDERTARGET | TEXF_FORCENEAREST | TEXF_CLAMP, -1, NULL);
+               if (r_viewfbo.integer >= 1 && vid.support.ext_framebuffer_object)
+               {
+                       // FIXME: choose depth bits based on a cvar
+                       r_bloomstate.texture_framebufferdepth = R_LoadTextureShadowMap2D(r_main_texturepool, "framebufferdepth", r_bloomstate.screentexturewidth, r_bloomstate.screentextureheight, 24, false);
+                       r_bloomstate.texture_framebuffercolor = R_LoadTexture2D(r_main_texturepool, "framebuffercolor", r_bloomstate.screentexturewidth, r_bloomstate.screentextureheight, NULL, textype, TEXF_RENDERTARGET | TEXF_FORCENEAREST | TEXF_CLAMP, -1, NULL);
+                       r_bloomstate.fbo_framebuffer = R_Mesh_CreateFramebufferObject(r_bloomstate.texture_framebufferdepth, r_bloomstate.texture_framebuffercolor, NULL, NULL, NULL);
+                       R_Mesh_SetRenderTargets(r_bloomstate.fbo_framebuffer, r_bloomstate.texture_framebufferdepth, r_bloomstate.texture_framebuffercolor, NULL, NULL, NULL);
+                       // render depth into one texture and normalmap into the other
+                       if (qglDrawBuffer)
+                       {
+                               int status;
+                               qglDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);CHECKGLERROR
+                               qglReadBuffer(GL_COLOR_ATTACHMENT0_EXT);CHECKGLERROR
+                               status = qglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);CHECKGLERROR
+                               if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
+                                       Con_Printf("R_Bloom_StartFrame: glCheckFramebufferStatusEXT returned %i\n", status);
+                       }
+               }
                r_bloomstate.bloomtexturewidth = bloomtexturewidth;
                r_bloomstate.bloomtextureheight = bloomtextureheight;
                if (r_bloomstate.bloomtexturewidth && r_bloomstate.bloomtextureheight)
-                       r_bloomstate.texture_bloom = R_LoadTexture2D(r_main_texturepool, "bloom", r_bloomstate.bloomtexturewidth, r_bloomstate.bloomtextureheight, NULL, TEXTYPE_COLORBUFFER, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
+                       r_bloomstate.texture_bloom = R_LoadTexture2D(r_main_texturepool, "bloom", r_bloomstate.bloomtexturewidth, r_bloomstate.bloomtextureheight, NULL, textype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
+               r_bloomstate.viewfbo = r_viewfbo.integer;
+               r_bloomstate.texturetype = textype;
        }
 
        // when doing a reduced render (HDR) we want to use a smaller area
@@ -5770,6 +5844,9 @@ void R_Bloom_StartFrame(void)
        }
 
        R_Viewport_InitOrtho(&r_bloomstate.viewport, &identitymatrix, r_refdef.view.x, vid.height - r_bloomstate.bloomheight - r_refdef.view.y, r_bloomstate.bloomwidth, r_bloomstate.bloomheight, 0, 0, 1, 1, -10, 100, NULL);
+
+       if (r_bloomstate.fbo_framebuffer)
+               r_refdef.view.clear = true;
 }
 
 void R_Bloom_CopyBloomTexture(float colorscale)
@@ -5778,6 +5855,7 @@ void R_Bloom_CopyBloomTexture(float colorscale)
 
        // scale down screen texture to the bloom texture size
        CHECKGLERROR
+       R_Mesh_SetMainRenderTargets();
        R_SetViewport(&r_bloomstate.viewport);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_Color(colorscale, colorscale, colorscale, 1);
@@ -5980,6 +6058,7 @@ static void R_BlendView(void)
                        if (r_bloom_blur.value < 1) { Cvar_SetValueQuick(&r_bloom_blur, 1); }
 
                        R_ResetViewRendering2D();
+                       R_Mesh_SetMainRenderTargets();
 
                        if(!R_Stereo_Active() && (r_motionblur.value > 0 || r_damageblur.value > 0))
                        {
index 797ee9b11a2591374e9f42fc9241bb01532ff69c..d7729d55fcf0e626d1376b51f85feafc703b8bcf 100644 (file)
@@ -93,6 +93,8 @@ static textypeinfo_t textype_dxt1a                  = {TEXTYPE_DXT1A      , 4, 0
 static textypeinfo_t textype_dxt3                   = {TEXTYPE_DXT3       , 4, 0, 1.0f, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 0                 , 0                };
 static textypeinfo_t textype_dxt5                   = {TEXTYPE_DXT5       , 4, 0, 1.0f, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0                 , 0                };
 static textypeinfo_t textype_colorbuffer            = {TEXTYPE_COLORBUFFER, 4, 4, 4.0f, GL_RGBA                         , GL_BGRA           , GL_UNSIGNED_BYTE };
+static textypeinfo_t textype_colorbuffer16f         = {TEXTYPE_COLORBUFFER16F,8,8,8.0f, GL_RGBA16F_ARB                  , GL_RGBA           , GL_FLOAT         };
+static textypeinfo_t textype_colorbuffer32f         = {TEXTYPE_COLORBUFFER32F,16,16,16.0f,GL_RGBA32F_ARB                , GL_RGBA           , GL_FLOAT         };
 
 
 typedef enum gltexturetype_e
@@ -236,6 +238,10 @@ static textypeinfo_t *R_GetTexTypeInfo(textype_t textype, int flags)
                return (flags & TEXF_LOWPRECISION) ? &textype_shadowmap16 : &textype_shadowmap24;
        case TEXTYPE_COLORBUFFER:
                return &textype_colorbuffer;
+       case TEXTYPE_COLORBUFFER16F:
+               return &textype_colorbuffer16f;
+       case TEXTYPE_COLORBUFFER32F:
+               return &textype_colorbuffer32f;
        default:
                Host_Error("R_GetTexTypeInfo: unknown texture format");
                break;
@@ -1563,6 +1569,8 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden
                flags |= TEXF_ALPHA;
                break;
        case TEXTYPE_COLORBUFFER:
+       case TEXTYPE_COLORBUFFER16F:
+       case TEXTYPE_COLORBUFFER32F:
                flags |= TEXF_ALPHA;
                break;
        default:
@@ -1634,7 +1642,9 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden
                        case TEXTYPE_PALETTE: d3dformat = (flags & TEXF_ALPHA) ? D3DFMT_A8R8G8B8 : D3DFMT_X8R8G8B8;break;
                        case TEXTYPE_RGBA: d3dformat = (flags & TEXF_ALPHA) ? D3DFMT_A8B8G8R8 : D3DFMT_X8B8G8R8;break;
                        case TEXTYPE_BGRA: d3dformat = (flags & TEXF_ALPHA) ? D3DFMT_A8R8G8B8 : D3DFMT_X8R8G8B8;break;
-                       case TEXTYPE_COLORBUFFER: d3dformat = (flags & TEXF_ALPHA) ? D3DFMT_A8R8G8B8 : D3DFMT_X8R8G8B8;break;
+                       case TEXTYPE_COLORBUFFER: d3dformat = D3DFMT_A8R8G8B8;break;
+                       case TEXTYPE_COLORBUFFER16F: d3dformat = D3DFMT_A16B16G16R16F;break;
+                       case TEXTYPE_COLORBUFFER32F: d3dformat = D3DFMT_A32B32G32R32F;break;
                        case TEXTYPE_SHADOWMAP: d3dformat = D3DFMT_D16;d3dusage = D3DUSAGE_DEPTHSTENCIL;break; // note: can not use D3DUSAGE_RENDERTARGET here
                        case TEXTYPE_ALPHA: d3dformat = D3DFMT_A8;break;
                        default: d3dformat = D3DFMT_A8R8G8B8;Sys_Error("R_LoadTexture: unsupported texture type %i when picking D3DFMT", (int)textype);break;
@@ -1681,6 +1691,8 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden
                        case TEXTYPE_RGBA: tflags = DPSOFTRAST_TEXTURE_FORMAT_RGBA8;break;
                        case TEXTYPE_BGRA: tflags = DPSOFTRAST_TEXTURE_FORMAT_BGRA8;break;
                        case TEXTYPE_COLORBUFFER: tflags = DPSOFTRAST_TEXTURE_FORMAT_BGRA8;break;
+                       case TEXTYPE_COLORBUFFER16F: tflags = DPSOFTRAST_TEXTURE_FORMAT_RGBA16F;break;
+                       case TEXTYPE_COLORBUFFER32F: tflags = DPSOFTRAST_TEXTURE_FORMAT_RGBA32F;break;
                        case TEXTYPE_SHADOWMAP: tflags = DPSOFTRAST_TEXTURE_FORMAT_DEPTH;break;
                        case TEXTYPE_ALPHA: tflags = DPSOFTRAST_TEXTURE_FORMAT_ALPHA8;break;
                        default: Sys_Error("R_LoadTexture: unsupported texture type %i when picking DPSOFTRAST_TEXTURE_FLAGS", (int)textype);
index 04c71f113cb20464b344306bf75de848c4bbe489..c5b1b52968c745f2a8630dc480eb976ab04b48b6 100644 (file)
--- a/glquake.h
+++ b/glquake.h
@@ -598,6 +598,21 @@ extern void (GLAPIENTRY *qglGenerateMipmapEXT)(GLenum target);
 #endif
 extern void (GLAPIENTRY *qglDrawBuffersARB)(GLsizei n, const GLenum *bufs);
 
+// GL_ARB_texture_float
+#ifndef GL_RGBA32F_ARB
+#define GL_RGBA32F_ARB                                       0x8814
+#define GL_RGB32F_ARB                                        0x8815
+#define GL_ALPHA32F_ARB                                      0x8816
+#define GL_INTENSITY32F_ARB                                  0x8817
+#define GL_LUMINANCE32F_ARB                                  0x8818
+#define GL_LUMINANCE_ALPHA32F_ARB                            0x8819
+#define GL_RGBA16F_ARB                                       0x881A
+#define GL_RGB16F_ARB                                        0x881B
+#define GL_ALPHA16F_ARB                                      0x881C
+#define GL_INTENSITY16F_ARB                                  0x881D
+#define GL_LUMINANCE16F_ARB                                  0x881E
+#define GL_LUMINANCE_ALPHA16F_ARB                            0x881F
+#endif
 
 extern void (GLAPIENTRY *qglScissor)(GLint x, GLint y, GLsizei width, GLsizei height);
 
index 0afa3b3cd489d03c2f2d5756dcd97f23e20b2185..e3703f315fc2caa2cd1d62632c695e9937350228 100644 (file)
@@ -2010,7 +2010,7 @@ void R_Shadow_RenderMode_ActiveLight(const rtlight_t *rtlight)
 
 void R_Shadow_RenderMode_Reset(void)
 {
-       R_Mesh_ResetRenderTargets();
+       R_Mesh_SetMainRenderTargets();
        R_SetViewport(&r_refdef.view.viewport);
        GL_Scissor(r_shadow_lightscissor[0], r_shadow_lightscissor[1], r_shadow_lightscissor[2], r_shadow_lightscissor[3]);
        R_Mesh_ResetTextureState();
@@ -2157,15 +2157,9 @@ void R_Shadow_RenderMode_ShadowMap(int side, int clear, int size)
        r_shadow_rendermode = R_SHADOW_RENDERMODE_SHADOWMAP2D;
 
        R_Mesh_ResetTextureState();
-       R_Mesh_ResetRenderTargets();
        R_Shadow_RenderMode_Reset();
-       if (fbo)
-       {
-               R_Mesh_SetRenderTargets(fbo, r_shadow_shadowmap2dtexture, r_shadow_shadowmap2dcolortexture, NULL, NULL, NULL);
-               R_SetupShader_DepthOrShadow();
-       }
-       else
-               R_SetupShader_ShowDepth();
+       R_Mesh_SetRenderTargets(fbo, r_shadow_shadowmap2dtexture, r_shadow_shadowmap2dcolortexture, NULL, NULL, NULL);
+       R_SetupShader_DepthOrShadow();
        GL_PolygonOffset(r_shadow_shadowmapping_polygonfactor.value, r_shadow_shadowmapping_polygonoffset.value);
        GL_DepthMask(true);
        GL_DepthTest(true);
@@ -2227,7 +2221,7 @@ init_done:
 void R_Shadow_RenderMode_Lighting(qboolean stenciltest, qboolean transparent, qboolean shadowmapping)
 {
        R_Mesh_ResetTextureState();
-       R_Mesh_ResetRenderTargets();
+       R_Mesh_SetMainRenderTargets();
        if (transparent)
        {
                r_shadow_lightscissor[0] = r_refdef.view.viewport.x;
@@ -4527,7 +4521,7 @@ void R_Shadow_DrawPrepass(void)
                        if (r_refdef.scene.lights[lnum]->draw)
                                R_Shadow_DrawLight(r_refdef.scene.lights[lnum]);
 
-       R_Mesh_ResetRenderTargets();
+       R_Mesh_SetMainRenderTargets();
 
        R_Shadow_RenderMode_End();
 
@@ -4919,7 +4913,7 @@ void R_DrawModelShadowMaps(void)
 
 #if 0
        // debugging
-       R_Mesh_ResetRenderTargets();
+       R_Mesh_SetMainRenderTargets();
        R_SetupShader_ShowDepth();
        GL_ColorMask(1,1,1,1);
        GL_Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, clearcolor, 1.0f, 0);
index c89b27e873fdedcbea196b089a7415076f302ef7..b66201c49a9b597b73f12b30fe087e758d4beee6 100644 (file)
@@ -56,7 +56,11 @@ typedef enum textype_e
        // 4x4 block compressed 15bit color plus 8bit alpha (8 bits per pixel)
        TEXTYPE_DXT5,
        // this represents the same format as the framebuffer, for fast copies
-       TEXTYPE_COLORBUFFER
+       TEXTYPE_COLORBUFFER,
+       // this represents an RGBA half_float texture (4 16bit floats)
+       TEXTYPE_COLORBUFFER16F,
+       // this represents an RGBA float texture (4 32bit floats)
+       TEXTYPE_COLORBUFFER32F
 }
 textype_t;