From 5072134f419f749b8b47021565dad3b0ee15c979 Mon Sep 17 00:00:00 2001 From: Saracen Date: Sat, 4 Jul 2015 00:59:03 +0100 Subject: [PATCH 1/4] Fixed canvas clipping on offscreen viewports. --- drivers/gles2/rasterizer_gles2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index d84ee5a7589..0bb58708eef 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -9349,7 +9349,7 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const int h = current_clip->final_clip_rect.size.y; */ int x = current_clip->final_clip_rect.pos.x; - int y = window_size.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.y); + int y = viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.y); int w = current_clip->final_clip_rect.size.x; int h = current_clip->final_clip_rect.size.y; From ff363c94db0d456e171aeacf10f11f5a51ca2ee3 Mon Sep 17 00:00:00 2001 From: Saracen Date: Sat, 31 Oct 2015 09:05:03 +0000 Subject: [PATCH 2/4] Another clipping fix: default back to using window size to calculate clipping on viewports which don't have a rendertarget which fixes clipping on the editor viewport. --- drivers/gles2/rasterizer_gles2.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 0bb58708eef..daac4123e0e 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -9348,10 +9348,23 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const int w = current_clip->final_clip_rect.size.x; int h = current_clip->final_clip_rect.size.y; */ - int x = current_clip->final_clip_rect.pos.x; - int y = viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.y); - int w = current_clip->final_clip_rect.size.x; - int h = current_clip->final_clip_rect.size.y; + int x; + int y; + int w; + int h; + + if (current_rt) { + x = current_clip->final_clip_rect.pos.x; + y = viewport.height - (current_clip->final_clip_rect.pos.y + current_clip->final_clip_rect.size.y); + w = current_clip->final_clip_rect.size.x; + h = current_clip->final_clip_rect.size.y; + } + else { + x = current_clip->final_clip_rect.pos.x; + y = window_size.height - (current_clip->final_clip_rect.pos.y + current_clip->final_clip_rect.size.y); + w = current_clip->final_clip_rect.size.x; + h = current_clip->final_clip_rect.size.y; + } glScissor(x,y,w,h); From 2cc52bc3ffde14dd7685588e9b4884bf7f8cfa4e Mon Sep 17 00:00:00 2001 From: Saracen Date: Thu, 19 Nov 2015 23:47:25 +0000 Subject: [PATCH 3/4] Modification to GUI in 3D demo to show resolved viewport clipping bug and small fix to bug causing viewport clipping to be inverted. --- demos/viewport/gui_in_3d/gui.scn | Bin 2270 -> 3267 bytes drivers/gles2/rasterizer_gles2.cpp | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/viewport/gui_in_3d/gui.scn b/demos/viewport/gui_in_3d/gui.scn index 4d665226b70ba79844e8c20a654a8e1068f75eb6..5e8c04754e8d6572215ef00407db124508e5b3fa 100644 GIT binary patch literal 3267 zcmXw64|o*i(VxA&%O<(}A@xaaxJ z?auz@oq1>Gz1i#R@_Hfp$pN^x7~r%3@R1dO1Bi2AiKlSDF&;7)pV=V?`jwupfD%?< zUlGeO>i~Gx1X+yFiYmG`7!4>jVR=A-G?pv)y9dKPA*Dx}ouUV#Y9v+@PhrLJJ&?|X z^pF;iLrZIFYT*paL@MHBmL#7hi1T2;EvNrVW6Dl{$L0 zz@T2E2E$rZ@egQ&x&pZ-%;fc$7BTW*Cd-?tt0RiPHzWu3nm#S6j%eYS9D+R4R%jhk zqA`_ilP(H=|9}#c{eJ1PwL=aoAt}wWO73Q9Vxh6$7E*d+U}tScHrpf@SYpa>{1O*Y z+s5fmSy4~*cwxCiopoUF8laq&~>i8_$zY;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`}E&-?8 z$b^IMBQNqqnnIXs<#CnR@gXfdoJ-EYxfinal_clip_rect.pos.x; - y = viewport.height - (current_clip->final_clip_rect.pos.y + current_clip->final_clip_rect.size.y); + y = current_clip->final_clip_rect.pos.y; w = current_clip->final_clip_rect.size.x; h = current_clip->final_clip_rect.size.y; } From 157b97b0872221224ba80099f4c11fd78123e576 Mon Sep 17 00:00:00 2001 From: Saracen Date: Mon, 7 Dec 2015 13:25:36 +0000 Subject: [PATCH 4/4] Extended clipping fix to missing clipping-related features. --- drivers/gles2/rasterizer_gles2.cpp | 42 ++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 8b70e7cfbfc..136e8162e92 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -9155,10 +9155,23 @@ void RasterizerGLES2::_canvas_item_render_commands(CanvasItem *p_item,CanvasItem //glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)), //current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height); - int x = current_clip->final_clip_rect.pos.x; - int y = window_size.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.y); - int w = current_clip->final_clip_rect.size.x; - int h = current_clip->final_clip_rect.size.y; + int x; + int y; + int w; + int h; + + if (current_rt) { + x = current_clip->final_clip_rect.pos.x; + y = current_clip->final_clip_rect.pos.y; + w = current_clip->final_clip_rect.size.x; + h = current_clip->final_clip_rect.size.y; + } + else { + x = current_clip->final_clip_rect.pos.x; + y = window_size.height - (current_clip->final_clip_rect.pos.y + current_clip->final_clip_rect.size.y); + w = current_clip->final_clip_rect.size.x; + h = current_clip->final_clip_rect.size.y; + } glScissor(x,y,w,h); @@ -9666,10 +9679,23 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const //glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)), //current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height); - int x = current_clip->final_clip_rect.pos.x; - int y = window_size.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.y); - int w = current_clip->final_clip_rect.size.x; - int h = current_clip->final_clip_rect.size.y; + int x; + int y; + int w; + int h; + + if (current_rt) { + x = current_clip->final_clip_rect.pos.x; + y = current_clip->final_clip_rect.pos.y; + w = current_clip->final_clip_rect.size.x; + h = current_clip->final_clip_rect.size.y; + } + else { + x = current_clip->final_clip_rect.pos.x; + y = window_size.height - (current_clip->final_clip_rect.pos.y + current_clip->final_clip_rect.size.y); + w = current_clip->final_clip_rect.size.x; + h = current_clip->final_clip_rect.size.y; + } glScissor(x,y,w,h);