1 registered members (rki),
405
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Postprocessing over panels
[Re: 3run]
#413206
12/10/12 08:39
12/10/12 08:39
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
It seems a good way to go when the process has nothing to do with the render/panels colors and so.
MATERIAL *mtlEffect = mtl_create ();
mtlEffect.effect = "myeffect.fx";
PANEL *panSource = pan_create ( "", 1 );
...
panSource.bmap = bmap_createblack ( panSource.size_x, panSource.size_y, 32 );
set ( panSource, SHOW );
...
while ( 1 )
{
bmap_process ( panSource.bmap, NULL, mtlEffect );
wait(1);
}
Otherway I know two other similar ways to go. If you want to process just the panels, render them over a render target and show it throught an other panel with a bmap_process.
MATERIAL *mtlEffect = mtl_create ();
mtlEffect.effect = "myeffect.fx";
PANEL *panSource = pan_create ( "", 99 );
...
panSource.render_target = bmap_createblack ( panSource.size_x, panSource.size_y, 32 );
set ( panSource, SHOW );
PANEL *panDestiny = pan_create ( "", 1 );
panSource.bmap = bmap_createblack ( panSource.size_x, panSource.size_y, 32 );
set ( panDestiny, SHOW );
...
while ( 1 )
{
bmap_process ( panDestiny.bmap, panSource.render_target, mtlEffect );
wait(1);
}
If you want process the camera too, you can go like in the example above and include the camera render target in a material skin, or you can enlarge the render chain with a process_target view.
PANEL *panSource = pan_create ( "", 1 );
...
panSource.render_target = bmap_createblack ( panSource.size_x, panSource.size_y, 32 );
set ( panSource, SHOW );
MATERIAL *mtlEffect = mtl_create ();
mtlEffect.effect = "myeffect.fx";
mtlEffect.skin1 = panSource.render_target;
VIEW *camFinal = view_create ( 1 );
camFinal.material = mtlEffect;
set ( camFinal, SHOW | PROCESS_TARGET | CHILD );
camera.stage = camFinal;
In both cases, you'll need to check the texture sampler sources of the shader. hope it helps, salud!
Last edited by txesmi; 12/10/12 08:46. Reason: ups, code error ;)
|
|
|
Re: Postprocessing over panels
[Re: 3dgs_snake]
#413211
12/10/12 12:53
12/10/12 12:53
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Hi snake, I tried to replace "render_target" with "target_map", but it crashes each frame from the while loop: bmap_process ( panDestiny.bmap, panSource.target_map, mtlEffect );
I guess problem was that bmap for "panDestiny" wasn't defined...
|
|
|
Re: Postprocessing over panels
[Re: 3dgs_snake]
#413212
12/10/12 13:00
12/10/12 13:00
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
ops, that is true target_map! You can render all the panels in the same render target, but I remember some troubles with alpha... edit___ the source panel should have a content, too
Last edited by txesmi; 12/10/12 13:02.
|
|
|
Re: Postprocessing over panels
[Re: txesmi]
#413213
12/10/12 13:03
12/10/12 13:03
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
In the same render target? You mean like this:
bmap_process(panel.bmap, panSource.target_map, mtlEffect);
I'm noob at rendering, shaders stuff, so please don't be confused Edit: "content" ?
|
|
|
Re: Postprocessing over panels
[Re: 3run]
#413214
12/10/12 13:09
12/10/12 13:09
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
i mean use same bmap as render target in all the panels.
BMAP *bmpRT = bmap_createblack ( screen_size.x, screen_size.y, 32 );
PANEL *pan1 = pan_create ( "", 1 );
pan1.target_map = bmpRT;
PANEL *pan2 = pan_create ( "", 2 );
pan2.target_map = bmpRT;
PANEL *pan3 = pan_create ( "", 3 );
pan3.target_map = bmpRT;
while (1)
{
bmap_process ( panVisible, bmpRT, mtlEffect );
wait(1);
}
whit content i mean, a background bmap, or a digit, or so. Something to render in the render target. edit__ sorry, I miss with the hurry in the code above...
MATERIAL *mtlEffect = mtl_create ();
mtlEffect.effect = "pp_oldMovie.fx";
PANEL *panSource = pan_create ( "", 99 );
panSource.size_x = 128; // Define the size, otherwise...
panSource.size_y = 128; //
panSource.bmap = bmap_createblack ( panSource.size_x, panSource.size_y, 32 ); // ir has 0 values!!
panSource.target_map = bmap_createblack ( panSource.size_x, panSource.size_y, 32 );
set ( panSource, SHOW );
PANEL *panDestiny = pan_create ( "", 1 );
panDestiny.bmap = bmap_createblack ( panSource.size_x, panSource.size_y, 32 ); // panDestiny bmap was pan Source, my fault...
set ( panDestiny, SHOW );
while(1){
bmap_process(panDestiny.bmap, panSource.target_map, mtlEffect);
wait(1);
}
Last edited by txesmi; 12/10/12 13:19.
|
|
|
Re: Postprocessing over panels
[Re: txesmi]
#413215
12/10/12 13:32
12/10/12 13:32
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
fucking shaders... I still can't get it...
MATERIAL* mtlEffect = mtl_create ();
mtlEffect.effect = "pp_oldMovie.fx";
PANEL* panSource = pan_create("", 99 );
panSource.size_x = 128; // Define the size, otherwise...
panSource.size_y = 128; //
panSource.bmap = bmap_createblack(panSource.size_x, panSource.size_y, 32); // ir has 0 values!!
panSource.target_map = bmap_createblack(panSource.size_x, panSource.size_y, 32);
set(panSource, SHOW);
PANEL* panDestiny = pan_create("", 1);
panDestiny.bmap = bmap_createblack(panSource.size_x, panSource.size_y, 32); // panDestiny bmap was pan Source, my fault...
set(panDestiny, SHOW);
PANEL* test_pan = pan_create("bmap = inv_temp.bmp;", 1);
test_pan.target_map = panSource.bmap;
set(test_pan, SHOW);
while(1){
bmap_process(panDestiny.bmap, panSource.target_map, mtlEffect);
bmap_process(test_pan.bmap, panSource.target_map, mtlEffect);
wait(1);
}
I've defined size as you've said (can I use screen size, or isn't that necessary?), I've set target map of a new panel to the bmap of the main (source) panel, all I can see, is that my (test pan) panel is smaller than it was (playing with the size of the source panel doesn't affect on it), and it's isn't affected by shader! What am I doing wrong?
|
|
|
Re: Postprocessing over panels
[Re: 3run]
#413223
12/10/12 14:40
12/10/12 14:40
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
try this. it is tested
#include <acknex.h>
MATERIAL *mtlEffect =
{
effect = "
float4 vecCycle;
texture TargetMap;
sampler ColorSampler = sampler_state { Texture = <TargetMap>; };
float4 PS ( in float2 inTex: TEXCOORD0 ) : COLOR0
{
float2 Coord = inTex.xy * vecCycle.y;
float4 Color1 = tex2D ( ColorSampler, Coord );
Color1.a = 1.0f;
return Color1;
}
technique blur
{
pass p0
{
VertexShader = null;
PixelShader = compile ps_2_0 PS();
}
}
";
}
function main ()
{
video_set(256,256,32,2);
wait(1);
FONT *fntArial = font_create ( "Arial#30" );
STRING *strText = str_create ( "ABCDEFGHIJKL" );
PANEL *panSource = pan_create ( "", 1 );
panSource.size_x = 256;
panSource.size_y = 256;
pan_setstring ( panSource, 0, 0, 0, fntArial, strText );
pan_setstring ( panSource, 0, 0, 30, fntArial, strText );
pan_setstring ( panSource, 0, 0, 60, fntArial, strText );
pan_setstring ( panSource, 0, 0, 90, fntArial, strText );
set ( panSource, SHOW );
panSource.target_map = bmap_createblack ( 256, 256, 32 );
PANEL *panDestiny = pan_create ( "", 1 );
panDestiny.bmap = bmap_createblack ( 256, 256, 32 );
set ( panDestiny, SHOW );
while ( !key_esc )
{
bmap_process ( panDestiny.bmap, panSource.target_map, mtlEffect );
wait(1);
}
sys_exit ( NULL );
}
|
|
|
|