Gamestudio Links
Zorro Links
Newest Posts
New Zorro version 2.20
by AndrewAMD. 11/15/19 03:34
What are you working on?
by jumpman. 11/14/19 16:17
A9
by preacherX. 11/14/19 15:28
Idx calculated every tick
by jcl. 11/14/19 15:25
IG plugin initial release
by Dalla. 11/13/19 19:07
Login 0 IG ..
by Dalla. 11/13/19 19:03
Moving Average crossover
by gra9. 11/13/19 10:43
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
6 registered members (Iglarion, kvm, AndrewAMD, Dooley, 3run, 1 invisible), 675 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LaszloK, gra9, Dev_ill, Ryu, andrews825
18329 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[Processing shader] HELP me fixed bug PLZ! #478462
10/24/19 09:35
10/24/19 09:35
Joined: Feb 2003
Posts: 131
RP China
2
20BN Offline OP
Member
20BN  Offline OP
Member
2

Joined: Feb 2003
Posts: 131
RP China
This is camera processing shader, and replace sources: https://www.shadertoy.com/view/ldXfRj

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

texture mtlSkin1;
sampler2D randSrc = sampler_state{texture = (mtlSkin1); };

float4 vecSkill1;

float4 vecViewPort;

#define PI2 6.28318530717959

#define MAGIC_GRAD_THRESH 0.01

#define MAGIC_SENSITIVITY     10.0
#define MAGIC_COLOR           0.5

float4 getCol(float2 pos)
{
    float2 uv = pos / vecViewPort.xy;
    return tex2D(g_samSrcColor, uv);
}

float getVal(float2 pos)
{
    float4 c = getCol(pos);
    return dot(c.xyz, float3(0.2126, 0.7152, 0.0722));
}

float2 getGrad(float2 pos, float eps)
{
   	float2 d= float2(eps,0);
    return float2(
        getVal(pos+d.xy)-getVal(pos-d.xy),
        getVal(pos+d.yx)-getVal(pos-d.yx)
    )/eps/2.0;
}

void pR(inout float2 p, float a) {
	p = cos(a)*p + sin(a)* float2(p.y, -p.x);
}


float absCircular(float t)
{
    float a = floor(t + 0.5);
    return fmod(abs(a - t), 1.0);
}


float4 postprocessing_gameboy( float2 Tex : TEXCOORD0 ) : COLOR0 
{

    float2 pos = Tex;
    float weight = 1.0;
    for (int j = 0; j < 4; j += 1)
    {
        float2 dir = float2(1, 0);
        pR(dir, float(j) * PI2 / (2.0 * 4.0));
        
        float2 grad = float2(-dir.y, dir.x);
        for (int i = -16; i <= 16; i += 2)
        {
            float2 pos2 = pos + normalize(dir)*float(i);
            
            // video texture wrap can't be set to anything other than clamp  (-_-)
            if (pos2.y < 0.0 || pos2.x < 0.0 || pos2.x > vecViewPort.x || pos2.y > vecViewPort.y)
                continue;
            
            float2 g = getGrad(pos2, 1.);
            if (length(g) < MAGIC_GRAD_THRESH)
                continue;
            
            weight -= pow(abs(dot(normalize(grad), normalize(g))), MAGIC_SENSITIVITY) / floor((2.0 * 16.0 + 1.0) / 2.0) / 4.0;
        }
    }
    
#ifndef GRAYSCALE
    float4 col = getCol(pos);
#else
    float4 col = float4(getVal(pos), getVal(pos), getVal(pos), 1.0);
#endif
    
    float4 background = lerp(col, float4(1.0,1.0,1.0,1.0), MAGIC_COLOR);
    
    // I couldn't get this to look good, but I guess it's almost obligatory at this point...
    /*float distToLine = absCircular(fragCoord.y / (iResolution.y/8.));
    background = lerp(vec4(0.6,0.6,1,1), background, smoothstep(0., 0.03, distToLine));*/
    
    
    // because apparently all shaders need one of these. It's like a law or something.
    float r = length(pos - vecViewPort.xy*.5) / vecViewPort.x;
    float vign = 1. - r*r*r;
    
    float4 a = tex2D(randSrc, pos/vecViewPort.xy);
    
    float4 fragColor = vign * lerp(float4(0.0,0.0,0.0,0.0), background, weight) + a.xxxx/25.;
    //fragColor = getCol(pos);

      return fragColor;


 

}

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









THANKS!

Last edited by 20BN; 10/24/19 09:35.
Re: [Processing shader] HELP me fixed bug PLZ! [Re: 20BN] #478468
10/24/19 18:57
10/24/19 18:57
Joined: Jun 2007
Posts: 1,270
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,270
Hiporope and its pain
Hi,
I felt too lazy to setup a working test, but I would say that the shader spects as parameter the VPOS definition instead of the TEXCOORD0 one.


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