Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, ozgur), 1,240 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
squik, AemStones, LucasJoshua, Baklazhan, Hanky27
19060 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
How to use Multi Predefined Postprocessing Shaders together #374097
06/15/11 14:06
06/15/11 14:06
Joined: Jul 2008
Posts: 40
V
Vahid_PC_Games Offline OP
Newbie
Vahid_PC_Games  Offline OP
Newbie
V

Joined: Jul 2008
Posts: 40
hi guys.
How to use Multi Predefined Postprocessing Shaders together in a view?
for example:
Code:
pp_set(camera,mtl_hdr + mtl_erode + ...);

together?

tanks

Last edited by Vahid_PC_Games; 06/15/11 14:55.
Re: How to use Multi Predefined Postprocessing Shaders together [Re: Vahid_PC_Games] #374104
06/15/11 14:36
06/15/11 14:36
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany


no science involved
Re: How to use Multi Predefined Postprocessing Shaders together [Re: fogman] #374105
06/15/11 14:51
06/15/11 14:51
Joined: Jul 2008
Posts: 40
V
Vahid_PC_Games Offline OP
Newbie
Vahid_PC_Games  Offline OP
Newbie
V

Joined: Jul 2008
Posts: 40
Originally Posted By: fogman

tanks man. but i dont understand quite.
please show me in C Code.

Re: How to use Multi Predefined Postprocessing Shaders together [Re: Vahid_PC_Games] #374107
06/15/11 15:14
06/15/11 15:14
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
You actually have to create an extra view for each pp effect which have to be chained together using the stage member.
This helper functions written by Slin make it more comfortable:

Code:
//////////////////////////////////////////////////
//////////Postprocessing Helperfunctions//////////
//////////////////////////////////////////////////
////08.03.2008////////////////by Nils Daumann/////
/////////////slindev.wordpress.com////////////////
//////////////////////////////////////////////////


//temporary pointers
VIEW* PP_Temp_View;


//Add an effect to a views stage chain
VIEW* PP_Add(MATERIAL* Material,VIEW* View,BMAP* btarget0,BMAP* btarget1,BMAP* btarget2,BMAP* btarget3)
{
	//find the last view of "View"s effectchain and store its pointer
	PP_Temp_View = View;
	while(PP_Temp_View.stage != NULL)
	{
		PP_Temp_View = PP_Temp_View.stage;
	}
	
	//create a new view as the stored views stage
	PP_Temp_View.stage = view_create(0);
	set(PP_Temp_View.stage,PROCESS_TARGET);
	
	//assign "Material" to the just created view
	PP_Temp_View = PP_Temp_View.stage;
	PP_Temp_View.material = Material;
	
	//if a bmap is given, render the view into it
	if(btarget0 != NULL){	PP_Temp_View.bmap    = btarget0; }
	if(btarget1 != NULL){	PP_Temp_View.target1 = btarget1; }
	if(btarget2 != NULL){	PP_Temp_View.target2 = btarget2; }
	if(btarget3 != NULL){	PP_Temp_View.target3 = btarget3; }
	
	//return the pointer to the new view
	return(PP_Temp_View);
}

//remove an effect from a views stage chain
int PP_Remove(MATERIAL* Material,VIEW* View,VIEW* StageView)
{
	//find the view with the material selected or "StageView" and the previous view && ((StageView == NULL)+(PP_Temp_View.stage != NULL)) != 0
	PP_Temp_View = View;
	while(PP_Temp_View.material != Material)
	{
		View = PP_Temp_View;
		PP_Temp_View = PP_Temp_View.stage;
		
		//return one if the stage doesnīt exist
		if(PP_Temp_View == NULL){return(1);}
	}
	
	//pass the views stage to the previous view
	View.stage = PP_Temp_View.stage;
	
	//pass the render target
	View.bmap = PP_Temp_View.bmap;
	View.target1 = PP_Temp_View.target1;
	View.target2 = PP_Temp_View.target2;
	View.target3 = PP_Temp_View.target3;
	
	//reset the views bmap to null
	PP_Temp_View.bmap    = NULL;
	PP_Temp_View.target1 = NULL;
	PP_Temp_View.target2 = NULL;
	PP_Temp_View.target3 = NULL;
	
	//remove the view
	ptr_remove(PP_Temp_View);
	PP_Temp_View=NULL;
	
	//return null if everything worked
	return(0);
}


//remove all postprocessing from the view
void PP_Remove_All(VIEW* View)
{
	if(View.stage == NULL){return;}
	PP_Temp_View = View.stage;
	View.stage = NULL;
	View.bmap = NULL;
	while(PP_Temp_View.stage != NULL)
	{
		View = PP_Temp_View;
		PP_Temp_View = View.stage;
		
		//pass the views stage to the previous view
		View.stage = NULL;
		
		//reset the views bmap to null
		View.bmap = NULL;
		
		//remove the view
		ptr_remove(View);
	}
}



Then you can do something like:
Code:
...
camera->bmap=ColorTarget01_bmap;

vertical_blur_mtl->skin1=ColorTarget01_bmap;
PP_Add(vertical_blur_mtl,camera,ColorTarget02_bmap,NULL,NULL,NULL);

PP_Add(horizontal_blur_mtl,camera,NULL,NULL,NULL,NULL);//render to backbuffer
...



Re: How to use Multi Predefined Postprocessing Shaders together [Re: Hummel] #374116
06/15/11 16:14
06/15/11 16:14
Joined: Jul 2008
Posts: 40
V
Vahid_PC_Games Offline OP
Newbie
Vahid_PC_Games  Offline OP
Newbie
V

Joined: Jul 2008
Posts: 40
yeah man i like this place.
Tanks Hummel , its work.
but i have a problem.whene i use PP_ADD , and set mtl_hdr PPShader , my view size (x,y in game) is changed to small and i cant change it. i set video to "1280,720,32,0" but in the game window , my viewport is "320,240".
please help me.
tanks.



Last edited by Vahid_PC_Games; 06/15/11 16:22.
Re: How to use Multi Predefined Postprocessing Shaders together [Re: Vahid_PC_Games] #374118
06/15/11 16:23
06/15/11 16:23
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
Best is you post some source code so we can have a look at it.

Re: How to use Multi Predefined Postprocessing Shaders together [Re: Hummel] #374119
06/15/11 16:37
06/15/11 16:37
Joined: Jul 2008
Posts: 40
V
Vahid_PC_Games Offline OP
Newbie
Vahid_PC_Games  Offline OP
Newbie
V

Joined: Jul 2008
Posts: 40
Originally Posted By: Hummel
Best is you post some source code so we can have a look at it.

im working at Water.C
Code:
////////////////////////////////////////////////////////
// Water shader demo.
// Copyright 2010	by oP group Germany.							
// Commercial Edition or above required for shaders
////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#include <keys.c>
#include <level.c>
#include <entmove.c>
#include <mtlFx.c>
#include <mtlView.c>

#define PRAGMA_PATH "%EXE_DIR%\\templates\\levels";

////////////////////////////////////////////////////////
var water_height,water_ripple,water_scale,hdr_threshold;

FONT* fHelp = "Arial#16bi";

PANEL* pHelp = 
{
	digits(5,5,"[1]/[2] -> water level: %4.1f",fHelp,1,water_height);
	digits(5,20,"[3]/[4] -> wave height: %3.0f",fHelp,1,water_ripple);
	digits(5,35,"[5]/[6] -> wave scale: %3.0f",fHelp,1,water_scale);
	digits(5,50,"[7]/[8] -> HDR threshold: %3.0f",fHelp,1,hdr_threshold);
	digits(5,65,"Cursor,PgUp/Dn -> move camera",fHelp,0,0);
	flags = SHOW;
}

action on_f1_event() { toggle(pHelp,SHOW); }

action water()
{
	fx_mirrorWater();
	while(1) {
		if(key_hit("1")) terrain_raise(me,-0.5);
		if(key_hit("2")) terrain_raise(me,0.5);
// skills are defined as var, but shaders use float values 
// conversion is not automatic here, thus we need floatv/fixv
		if(key_hit("3")) my.skill43 = floatv(fixv(my.skill43)-5);
		if(key_hit("4")) my.skill43 = floatv(fixv(my.skill43)+5);
		if(key_hit("5")) my.skill44 = floatv(fixv(my.skill44)-5);
		if(key_hit("6")) my.skill44 = floatv(fixv(my.skill44)+5);
		if(key_hit("7")) mtl_hdr.skill2 = floatv(fixv(mtl_hdr.skill2)+1);
		if(key_hit("8")) mtl_hdr.skill2 = floatv(fixv(mtl_hdr.skill2)-1);
		water_height = terrain_get_z(my,1);
		water_ripple = fixv(my.skill43);
		water_scale = fixv(my.skill44);
		hdr_threshold = fixv(mtl_hdr.skill2);
		wait(1);
	}
}

action blob()
{
	my.skill42 = floatv(30); // texture influence
	fx_envBump();
	ent_rotate(me,2,1.5,0.5);
}
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////Postprocessing Helperfunctions//////////
//////////////////////////////////////////////////
////08.03.2008////////////////by Nils Daumann/////
/////////////slindev.wordpress.com////////////////
//////////////////////////////////////////////////


//temporary pointers
VIEW* PP_Temp_View;


//Add an effect to a views stage chain
VIEW* PP_Add(MATERIAL* Material,VIEW* View,BMAP* btarget0,BMAP* btarget1,BMAP* btarget2,BMAP* btarget3)
{
	//find the last view of "View"s effectchain and store its pointer
	PP_Temp_View = View;
	while(PP_Temp_View.stage != NULL)
	{
		PP_Temp_View = PP_Temp_View.stage;
	}
	
	//create a new view as the stored views stage
	PP_Temp_View.stage = view_create(0);
	set(PP_Temp_View.stage,PROCESS_TARGET);
	
	//assign "Material" to the just created view
	PP_Temp_View = PP_Temp_View.stage;
	PP_Temp_View.material = Material;
	
	//if a bmap is given, render the view into it
	if(btarget0 != NULL){	PP_Temp_View.bmap    = btarget0; }
	if(btarget1 != NULL){	PP_Temp_View.target1 = btarget1; }
	if(btarget2 != NULL){	PP_Temp_View.target2 = btarget2; }
	if(btarget3 != NULL){	PP_Temp_View.target3 = btarget3; }
	
	//return the pointer to the new view
	return(PP_Temp_View);
}

//remove an effect from a views stage chain
int PP_Remove(MATERIAL* Material,VIEW* View,VIEW* StageView)
{
	//find the view with the material selected or "StageView" and the previous view && ((StageView == NULL)+(PP_Temp_View.stage != NULL)) != 0
	PP_Temp_View = View;
	while(PP_Temp_View.material != Material)
	{
		View = PP_Temp_View;
		PP_Temp_View = PP_Temp_View.stage;
		
		//return one if the stage doesnīt exist
		if(PP_Temp_View == NULL){return(1);}
	}
	
	//pass the views stage to the previous view
	View.stage = PP_Temp_View.stage;
	
	//pass the render target
	View.bmap = PP_Temp_View.bmap;
	View.target1 = PP_Temp_View.target1;
	View.target2 = PP_Temp_View.target2;
	View.target3 = PP_Temp_View.target3;
	
	//reset the views bmap to null
	PP_Temp_View.bmap    = NULL;
	PP_Temp_View.target1 = NULL;
	PP_Temp_View.target2 = NULL;
	PP_Temp_View.target3 = NULL;
	
	//remove the view
	ptr_remove(PP_Temp_View);
	PP_Temp_View=NULL;
	
	//return null if everything worked
	return(0);
}


//remove all postprocessing from the view
void PP_Remove_All(VIEW* View)
{
	if(View.stage == NULL){return;}
	PP_Temp_View = View.stage;
	View.stage = NULL;
	View.bmap = NULL;
	while(PP_Temp_View.stage != NULL)
	{
		View = PP_Temp_View;
		PP_Temp_View = View.stage;
		
		//pass the views stage to the previous view
		View.stage = NULL;
		
		//reset the views bmap to null
		View.bmap = NULL;
		
		//remove the view
		ptr_remove(View);
	}
}
/////////////////////////////////////////////////////////////////////////

function main()
{
	if (d3d_shaderversion<2020)
		error("Shaders require Commercial Edition!");
	d3d_antialias = 4;
	//video_set(1920,1080,32,1);
	video_set(1280,720,32,0);
	fps_max = 60;
// load a level, and create sky, water, and a model :
	level_load("small.hmp");
	ent_createlayer("skycube+6.dds",SKY | CUBE | SHOW,1);
	//ent_createlayer("555.tga",SKY | CUBE | SHOW,1);
	
	//camera.fog_start   = 10                  ;
   //camera.fog_end     =  2000           ;
	//d3d_fogcolor1.red   = 255                     ;
	//d3d_fogcolor1.green = 180                   ;
   //d3d_fogcolor1.blue  = 20                    ; 
   //fog_color           = 1                    ; 

   
	ent_create("water.hmp",vector(0,0,-5),water);
	ent_create("blob.mdl",vector(0,0,30),blob);
	vec_set(sun_color,vector(200,240,240));	
	
// set up some parameters and a HDR effect for the camera	
	vec_set(camera.x,vector(-130,0,80));
	camera.tilt = -20;
	def_move(); // activate flythrough
	mtl_hdr.skill3 = floatv(50); // exposure compensation factor
	PP_Add(mtl_hdr,camera,NULL,NULL,NULL,NULL);
	PP_Add(mtl_erode,camera,NULL,NULL,NULL,NULL);

}


when i dont use "mtl_hdr" , its work normally.

Last edited by Vahid_PC_Games; 06/15/11 16:46.
Re: How to use Multi Predefined Postprocessing Shaders together [Re: Vahid_PC_Games] #374121
06/15/11 17:43
06/15/11 17:43
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
thatīs a bit strange, try to create the RT for the hdr_mtl on your own like this (btw standard antialiasing doesnt work with pp effects):
Click to reveal..

function main()
{
if (d3d_shaderversion<2020)
error("Shaders require Commercial Edition!");
//d3d_antialias = 4;
//video_set(1920,1080,32,1);
video_set(1280,720,32,0);
fps_max = 60;
// load a level, and create sky, water, and a model :
level_load("small.hmp");
ent_createlayer("skycube+6.dds",SKY | CUBE | SHOW,1);
//ent_createlayer("555.tga",SKY | CUBE | SHOW,1);

//camera.fog_start = 10 ;
//camera.fog_end = 2000 ;
//d3d_fogcolor1.red = 255 ;
//d3d_fogcolor1.green = 180 ;
//d3d_fogcolor1.blue = 20 ;
//fog_color = 1 ;


ent_create("water.hmp",vector(0,0,-5),water);
ent_create("blob.mdl",vector(0,0,30),blob);
vec_set(sun_color,vector(200,240,240));

// set up some parameters and a HDR effect for the camera
vec_set(camera.x,vector(-130,0,80));
camera.tilt = -20;
def_move(); // activate flythrough
mtl_hdr.skill3 = floatv(50); // exposure compensation factor
BMAP* HDR_RT = bmap_createblack(screen_size.x,screen_size.y,8888);
PP_Add(mtl_hdr,camera,HDR_RT,NULL,NULL,NULL);
mtl_erode->skin1=HDR_RT;
PP_Add(mtl_erode,camera,NULL,NULL,NULL,NULL);

}


Iīm not sure but you probably need another small modification in the pp_erode.fx file:

Click to reveal..

//Texture TargetMap;
texture mtlSkin1;
sampler2D g_samSrcColor = sampler_state { texture = <mtlSkin1>; MipFilter = Linear; };
...

Perhaps you only need to deactivate the AA, just try it.

Re: How to use Multi Predefined Postprocessing Shaders together [Re: Hummel] #374134
06/15/11 19:32
06/15/11 19:32
Joined: Jul 2008
Posts: 40
V
Vahid_PC_Games Offline OP
Newbie
Vahid_PC_Games  Offline OP
Newbie
V

Joined: Jul 2008
Posts: 40
Dear Hummel.i set all your changes.but its not work. frown
help me please.

Last edited by Vahid_PC_Games; 06/16/11 05:38.
Re: How to use Multi Predefined Postprocessing Shaders together [Re: Vahid_PC_Games] #374195
06/16/11 12:01
06/16/11 12:01
Joined: Jul 2008
Posts: 40
V
Vahid_PC_Games Offline OP
Newbie
Vahid_PC_Games  Offline OP
Newbie
V

Joined: Jul 2008
Posts: 40
F1 F1 F1 F1...Please!

Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1