2 registered members (TipmyPip, AndrewAMD),
911
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
draw_quad and bmap_rendertarget issue
#456843
12/12/15 13:11
12/12/15 13:11
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Just ran into this problem, pretty sure it's related to this one, posted by txesmi: when rendering into a bmap using bmap_rendertarget and draw_quad the quad does not get drawn if it's outside of the window's dimensions. what I mean by this is that draw_quad can draw on sections of a rendertarget that are outside of the screen's resolution - but only if some part of the quad is inside the rendertarget's dimensions. Looks like there's some culling going on that uses the dimensions of the engine window instead of the rendertarget's dimensions. Here's an example to test:
#include <acknex.h>
void main()
{
fps_max = 60;
wait(1);
video_set(256, 256, 0, 2);
wait(1);
//
BMAP * RenderTarget = bmap_createblack(512, 512, 8888); // create 512x512 bmap used as rendertarget -> bigger than the video resolution (256x256)
bmap_fill(RenderTarget, vector(40, 32, 30), 100); // fill it with some dark color
BMAP * SomeQuad = bmap_createblack(100, 75, 8888); // create a bmap to draw
bmap_fill(SomeQuad, vector(255, 255, 255), 100); // fill with white, this one is colored using draw_quad()'s color-parameter
//
bmap_rendertarget(RenderTarget, 0, 1); // render folowing stuff into bmap, keep the bmap's content
draw_quad(SomeQuad, vector( 0, 0, 0), NULL, NULL, NULL, vector(120, 240, 40), 100, 0); // GREEN: draw at position: 0, 0
draw_quad(SomeQuad, vector(150, 50, 0), NULL, NULL, NULL, vector( 30, 300, 240), 100, 0); // RED: draw at position: 300, 100
draw_quad(SomeQuad, vector(250, 250, 0), NULL, NULL, NULL, vector(240, 140, 40), 100, 0); // BLUE: partially outside, can draw outside
draw_quad(SomeQuad, vector(290, 325, 0), NULL, NULL, NULL, vector(240, 240, 240), 100, 0); // [ISSUE #1]: WHITE: fully outside, this one gets culled
bmap_rendertarget(NULL, 0, 0); // stop rendering into bmap
//
// [ISSUE #2]: without this the BMAP*'s content is lost when changing the video resolution or minimizing the game when running acknex in fullscreen
bmap_to_format(RenderTarget, bmap_format(RenderTarget)); // force bmap rewrite
video_set(512, 512, 0, 2); // set video resolution to the rendertarget's size
//
PANEL * test_pan = pan_create("flags = SHOW;", 0); // create panel to show the rendertarget's content
test_pan.bmap = RenderTarget;
}
It starts up with a resolution of 256x256 and creates a 512x512 BMAP*. Then it renders 4 rectangles into this BMAP* using draw_quad, a green one, a red one, a blue one and a white one. After this the resolution changes from 256x256 to 512x512 and the rendered image is being displayed using a panel. In the screenshot I also marked a purple and a white area: The purple area shows the application's initial dimensions. The green and red rectangle which are fully inside the window are rendered correctly as expected. The blue one which only intersects the window's resolution partially is also rendered completely. However, the white one - which is not inside the window - is not being rendered at all, it should appear where the white area is marked in the screenshot. The code example also addresses another issue (marked with '[ISSUE #2]' in the above code example): after using bmap_rendertarget on a BMAP*, it will lose it's content when changing the video resolution or minimizing the game when running acknex in fullscreen. You can test this by commenting out the line with bmap_to_format(); I suspect that the bmap somehow stays a rendertarget, but I'm not too sure about this. I sincerely hope that at least the first issue (the one related to draw_quad) can be solved somwhere in the near future since this is a crucial feature I need for my current project. kind regards, Alex
POTATO-MAN saves the day! - Random
|
|
|
Re: draw_quad and bmap_rendertarget issue
[Re: Kartoffel]
#456910
12/15/15 16:58
12/15/15 16:58
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Some feedback on whether or not this has been acknowledged would be nice...
POTATO-MAN saves the day! - Random
|
|
|
Re: draw_quad and bmap_rendertarget issue
[Re: jcl]
#456949
12/16/15 14:06
12/16/15 14:06
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Thanks for the answer, but does this mean that there's no way to fix this behaviour of draw_xxx functions and enable rendering into big rendertargets using draw_quad? Like I've said, being able to do so is quite important for what I'm planning to do and it would make things very complicated in that case. Edit: I'm sorry but shouldn't fixing this require just a really small change in the engine's code?
Last edited by Kartoffel; 12/17/15 10:50.
POTATO-MAN saves the day! - Random
|
|
|
Re: draw_quad and bmap_rendertarget issue
[Re: jcl]
#457048
12/21/15 16:18
12/21/15 16:18
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Thanks again, I'd really appreciate it if this could make it into an upcoming update.
POTATO-MAN saves the day! - Random
|
|
|
Re: draw_quad and bmap_rendertarget issue
[Re: Kartoffel]
#457137
12/29/15 10:07
12/29/15 10:07
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
I just ran into another problem using draw_quad and bmap_rendertarget. It seems like draw_quad performs incorrect alphablending: In this screenshot I'm drawing a title bar with a soft shadow onto an orange (100% opaque) bmap. It should look like the top image but the bottom one is the result. As you can see, the background (in this case a blue-green checker pattern) is clearly visible which means that draw_quad has lowered the alpha values of these pixels. Sadly, this behaviour renders alphablending useless and causes me a lot of trouble.
POTATO-MAN saves the day! - Random
|
|
|
Re: draw_quad and bmap_rendertarget issue
[Re: jcl]
#457139
12/29/15 11:02
12/29/15 11:02
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Well, bmap_blit/_blitpart is a function that overwrites the bmap's pixels (I guess it uses something like memcpy to copy the pixel's color values). draw_quad, however, seems to use some kind of blending. It has to, since it supports an 'alpha'-parameter as blending opacity and does produce correct results when rendering directly onto the screen.
In my example above, the rgb-channels are blended correctly but the alpha channel is not.
I'm not sure if draw_quad uses something similar to a shader, but I know that you get the same, incorrect blending when using the wrong values for DestBlend and SrcBlend in a shader's pass.
The problem is really just related to draw_quad in combination with bmap_rendertarget. When using panels with different layers, this problem does not occur. Neither does it when draw_quad is being used to draw an image directly onto the screen (without bmap_rendertarget).
Edit: Thinking about it, the reason why it works when rendering onto the screen is most likely because the screen's buffer doesn't use an alpha channel, so there's nothing to mess up. ...which means that bmap_rendertarget is probably not the culprit here, it's the blending-op that 2D-drawing-functions use.
POTATO-MAN saves the day! - Random
|
|
|
|