Posted By: Uhrwerk
Using target_map vs. post processing - 02/04/13 22:21
Hello Mr. Lotter,
here is another thing I stumbled over. The problem is that when you use a target_map for rendering a text or a panel certain bitmap sizes seem to influence the post processing. I made a small code sample so that you can reproduce the strange behavior.
First we need post processing shader. The following file is named "coords.fx" and renders the x texture coordinate in the red channel and the y coordinate in the blue channel:
Now we a need .c file:
The code is nothing too fancy so i won't describe it any further. Once you run the code and press space to activate the "post processing" you'll see this image:
It's pretty obvious that the coordinates are strangely stretched over the screen. If you change the resolution with F5 and change it back with shift + F5 you'll get correct results, like this:
For your comfort I created a difference image of the pictures above:
Looks as if only the x coordinates are wrong.
I tried to find a pattern in the dimension of the target_map that cause this effect but failed. At least I can say that all power of two sizes seem to work. Btw. I think you should issue a warning message when one tries to set a target_map does not match the requirements mentioned in the manual, i.e. the bitmap must be smaller than the camera view etc.
I hope this is of any help to you.
here is another thing I stumbled over. The problem is that when you use a target_map for rendering a text or a panel certain bitmap sizes seem to influence the post processing. I made a small code sample so that you can reproduce the strange behavior.
First we need post processing shader. The following file is named "coords.fx" and renders the x texture coordinate in the red channel and the y coordinate in the blue channel:
Code:
float4 PS (float2 texCoord : TEXCOORD0) : COLOR0 { return float4(texCoord.x,0,texCoord.y,1); } technique t0 { pass p0 { VertexShader = null; PixelShader = compile ps_1_1 PS(); } }
Now we a need .c file:
Code:
#include <default.c> VIEW* v = NULL; void on_space_event() { if (camera->stage) camera->stage = NULL; else camera->stage = v; } void main() { level_load(NULL); BMAP* b = bmap_createblack(256,640,8888); PANEL* p = pan_create(NULL,1); p->flags |= SHOW | LIGHT; p->target_map = b; // Commenting this line will "fix" the bug. MATERIAL* m = mtl_create(); effect_load(m,"coords.fx"); v = view_create(1); v->material = m; v->flags = PROCESS_TARGET | CHILD; }
The code is nothing too fancy so i won't describe it any further. Once you run the code and press space to activate the "post processing" you'll see this image:
It's pretty obvious that the coordinates are strangely stretched over the screen. If you change the resolution with F5 and change it back with shift + F5 you'll get correct results, like this:
For your comfort I created a difference image of the pictures above:
Looks as if only the x coordinates are wrong.
I tried to find a pattern in the dimension of the target_map that cause this effect but failed. At least I can say that all power of two sizes seem to work. Btw. I think you should issue a warning message when one tries to set a target_map does not match the requirements mentioned in the manual, i.e. the bitmap must be smaller than the camera view etc.
I hope this is of any help to you.