Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, degenerate_762), 642 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Combine shaders #431002
10/07/13 19:52
10/07/13 19:52
Joined: Jun 2008
Posts: 146
London
T
Truth Offline OP
Member
Truth  Offline OP
Member
T

Joined: Jun 2008
Posts: 146
London
Hi,
is it possible to combine shaders? can someone do this for me?

I have a Bloom shader and a blur shader but i cant seem to get them to work together. If anyone has a better blur shader please post.

Blur shader (pp_gaussian.fx)
Quote:

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

float4 vecViewPort;

float4 postprocessing_gaussian(float2 Tex : TEXCOORD0) : COLOR0
{
float4 sampleM = tex2D(g_samSrcColor, Tex.xy);
float4 sampleB0 = tex2D( g_samSrcColor, Tex.xy - vecViewPort.zw );
float4 sampleF0 = tex2D( g_samSrcColor, Tex.xy + vecViewPort.zw );
float4 sampleB1 = tex2D( g_samSrcColor, Tex.xy - vecViewPort.zw*2. );
float4 sampleF1 = tex2D( g_samSrcColor, Tex.xy + vecViewPort.zw*2. );
//float4 sampleB2 = tex2D( g_samSrcColor, Tex.xy - vecViewPort.zw*3. );
//float4 sampleF2 = tex2D( g_samSrcColor, Tex.xy + vecViewPort.zw*3. );

return 0.1752 * sampleM + 0.1658 * (sampleB0 + sampleF0) + 0.1403 * (sampleB1 + sampleF1);// + 0.1063 * (sampleB2 + sampleF2);
}

technique PostProcess
{
pass p1
{
AlphaBlendEnable = false;
VertexShader = null;
PixelShader = compile ps_2_0 postprocessing_gaussian();
}
}



Bloom shader (bloom.fx)

Quote:

float4 vecSkill1;

texture entSkin1;

sampler postTex = sampler_state
{
texture = (entSkin1);
MinFilter = linear;
MagFilter = linear;
MipFilter = linear;
AddressU = Clamp;
AddressV = Clamp;
};
;




float Luminance = 0.08f;
static const float fMiddleGray = 0.18f;
static const float fWhiteCutoff = 0.8f;

#define NUM 13 //13

float2 PixelOffsets[NUM] =
{
{ -0.006, -0.006 },
{ -0.005, -0.005 },
{ -0.004, -0.004 },
{ -0.003, -0.003 },
{ -0.002, -0.002 },
{ -0.001, -0.001 },
{ 0.000, 0.000 },
{ 0.001, 0.001 },
{ 0.002, 0.002 },
{ 0.003, 0.003 },
{ 0.004, 0.004 },
{ 0.005, 0.005 },
{ 0.006, 0.006 },
};

static const float BlurWeights[NUM] =
{
0.002216,
0.008764,
0.026995,
0.064759,
0.120985,
0.176033,
0.199471,
0.176033,
0.120985,
0.064759,
0.026995,
0.008764,
0.002216,
};





float4 Bloom_PS_3_0(float2 texcoord0 : TEXCOORD0) : COLOR
{
float3 pixel;
float3 Color = 0;

for(int i = 0; i < NUM; i++)
{
pixel = tex2D(postTex,texcoord0 + PixelOffsets[i] * 5.0f)+vecSkill1[1];

pixel *= fMiddleGray / (Luminance + 0.001f);
pixel *= (1.0f + (pixel / (fWhiteCutoff * fWhiteCutoff)));
pixel -= 5.0f;

pixel = max(pixel,0.0f);
pixel /= (10.0f + pixel);

Color += pixel * BlurWeights[i];
}

Color *= vecSkill1[0];

return float4(Color,1.0) + tex2D(postTex,texcoord0);
}

float4 Bloom_PS_2_0(float2 texcoord0 : TEXCOORD0) : COLOR
{
float3 pixel;
float3 Color = 0;

for(int i = 4; i < 9; i++)
{
pixel = tex2D(postTex,texcoord0 + PixelOffsets[i] * 5.0f)+vecSkill1[1];

pixel *= fMiddleGray / (Luminance + 0.001f);
pixel *= (1.0f + (pixel / (fWhiteCutoff * fWhiteCutoff)));
pixel -= 5.0f;

pixel = max(pixel,0.0f);
pixel /= (10.0f + pixel);

Color += pixel * BlurWeights[i];
}

Color *= vecSkill1[0];

return float4(Color,1.0) + tex2D(postTex,texcoord0);
}


/*
technique tech_00
{
pass pass_00
{
VertexShader = null;
PixelShader = compile ps_3_0 Bloom_PS_3_0();
}
}
*/


technique tech_01
{
pass pass_00
{

VertexShader = null;
PixelShader = compile ps_2_0 Bloom_PS_2_0();

}
}
/*
technique tech_02
{
pass pass_00
{
Texture[0] = <entSkin1>;
}
}
*/




Thank you!

Re: Combine shaders [Re: Truth] #431013
10/08/13 07:36
10/08/13 07:36
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
how do you use them?


POTATO-MAN saves the day! - Random
Re: Combine shaders [Re: Kartoffel] #431025
10/08/13 12:01
10/08/13 12:01
Joined: Jun 2008
Posts: 146
London
T
Truth Offline OP
Member
Truth  Offline OP
Member
T

Joined: Jun 2008
Posts: 146
London
Hi,
I use the pp_helper I got from wiki
Quote:

view PP_Cam{layer = -2;}

entity PP_Quad
{
type = <PPE_Quad.bmp>;
layer = 0;
view = PP_Cam;

x = 1060; //878
y = 0;
z = 0;

scale_x = 1.0;
scale_y = 1.0;
}


//
function PP_Init_Effect()
{
PP_Quad.material = Shader_mat; //Change this to the material you wish<---------------------------


Bloom_set_Value(2,0.3); //Call here the function to set the materials values<------------- 4,0.9


/*
while(1)
{
if(screen_size.x == 1920)
}

*/
}

//
function PP_Toggle_OnOff()
{
if(PP_Quad.visible == on)
{
camera.bmap = NULL;
PP_Quad.visible = off;

}else
{
PP_Quad.visible = on;

camera.bmap = bmap_for_entity(PP_Quad,0);

}
}



on_b = PP_Toggle_OnOff();



Thanks

Re: Combine shaders [Re: Truth] #431032
10/08/13 13:03
10/08/13 13:03
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
so, combining them shouldn't be a problem (right now I haven't got alot of time, maybe later) but you have to know how set the material-skins of the shader properly.


POTATO-MAN saves the day! - Random
Re: Combine shaders [Re: Kartoffel] #431053
10/08/13 18:58
10/08/13 18:58
Joined: Jun 2008
Posts: 146
London
T
Truth Offline OP
Member
Truth  Offline OP
Member
T

Joined: Jun 2008
Posts: 146
London
Okay cool, thanks laugh

Re: Combine shaders [Re: Truth] #431893
10/25/13 14:10
10/25/13 14:10
Joined: Aug 2008
Posts: 394
Germany
Benni003 Offline
Senior Member
Benni003  Offline
Senior Member

Joined: Aug 2008
Posts: 394
Germany
yes, hope you can help me a little. The main thing is that I want to make a building dirty looking with a shader.


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