This position can be seen in the special handling of PPSSPP
File location
Look at these effects.
Non-special effects images for testing
Ppsspp
Legend Series Life Love---Yingjie legend
The Last Warrior
Aacolor
is about saturation, brightness, contrast, tonal adjustment,
The default parameter in PPSSPP is 1.2 times times greater in saturation, 1.25 times times more contrast, and in unity we can set the external variable to self-adjust
Key code:
FLOAT4 Frag (v2f i): color{float size = 1/_SIZE;FLOAT3 C10 = tex2d (_maintex, I.uv_maintex + float2 (0,-1) *size). Rgb;float 3 C01 = tex2d (_maintex, I.uv_maintex + float2 ( -1, 0) *size). Rgb;float3 C11 = tex2d (_maintex, I.uv_maintex). RGB;FLOAT3 C21 = Tex2d (_maintex, I.uv_maintex + float2 (1, 0) *size). Rgb;float3 C12 = tex2d (_maintex, I.uv_maintex + float2 (0, 1) *size). RGB; FLOAT3 dt = FLOAT3 (1.0, 1.0, 1.0); float K1 = dot (abs (C01-C21), DT), float k2 = dot (abs (C10-C12), DT); FLOAT3 color = (K1 * (C10 + C12) + k2* (C01 + c21) + 0.001*c11)/(2.0* (k1 + K2) + 0.001); float x = sqrt (dot (color)); COLOR.R = POW (color . R + 0.001, _a); color.g = POW (color.g + 0.001, _a); color.b = POW (color.b + 0.001, _a);//saturation, brightness, contrast, hue map return float4 (contr AST4 (x) *normalize (color*_c_ch) *_b,1);}
measured in PPSSPP
measured in Unity
Bloom
Glow Effect
The glow in PPSSPP is not good in unity, fuzzy processing is not enough, excessive brightness, sampling mode for grid sampling
I've written a detailed post about HDR (similar to bloom)
Key code:
FLOAT4 Frag (v2f i): color{float size = 1/_size;float2 UV = I.UV_MAINTEX;FLOAT3 COLOR = tex2d (_maintex, I.uv_maintex); Flo AT4 sum = 0;float3 bloom;for (int i =-3; i < 3; i++) {sum + = tex2d (_maintex, UV + FLOAT2 ( -1, i) *size) * _amount;sum + = tex2d (_maintex, UV + FLOAT2 (0, i) *size) * _amount;sum + = tex2d (_maintex, UV + FLOAT2 (1, i) *size) * _AMOUNT;} if (COLOR.R < 0.3 && COLOR.G < 0.3 && Color.b < 0.3) {bloom = sum.rgb*sum.rgb*0.012 + color;} Else{if (COLOR.R < 0.5 && Color.g < 0.5 && Color.b < 0.5) {bloom = sum.xyz*sum.xyz*0.009 + color;} Else{bloom = sum.xyz*sum.xyz*0.0075 + color;}} Bloom = Mix (color, bloom, _power); return Float4 (Bloom, 1);}
measured in PPSSPP
measured in Unity
Cartoon
Post processing for cartoon effect
The color is divided into four layers, the color gray level of the value of each segment plus the minimum number of decimal parts, resulting in some transition effect
Then use the resulting grayscale by the value of the primary color, retain the original colors are only four layers of light and shade, between the layers of excessive
With edge detection strokes, the coloring is like, but not identical to, a detailed post that was previously written.
Key code:
FLOAT4 Frag (v2f i): color{float size = 1/_SIZE;FLOAT3 c00 = tex2d (_maintex, I.uv_maintex + FLOAT2 ( -1,-1) *size). Rgb;floa T3 C10 = tex2d (_maintex, I.uv_maintex + float2 (0,-1) *size). RGB;FLOAT3 C20 = tex2d (_maintex, I.uv_maintex + FLOAT2 (1,-1) * Size). RGB;FLOAT3 C01 = tex2d (_maintex, I.uv_maintex + float2 ( -1, 0) *size). Rgb;float3 C11 = tex2d (_maintex, I.uv_maintex). RGB;FLOAT3 C21 = tex2d (_maintex, I.uv_maintex + float2 (1, 0) *size). Rgb;float3 C02 = tex2d (_maintex, I.uv_maintex + FLOAT2 ( -1, 1) *size). Rgb;float3 C12 = tex2d (_maintex, I.uv_maintex + float2 (0, 1) *size). RGB;FLOAT3 C22 = tex2d (_maintex, I.uv_main Tex + FLOAT2 (1, 1) *size). RGB;FLOAT3 dt = FLOAT3 (1.0, 1.0, 1.0), float D1 = dot (abs (C00-C22), DT), float d2 = dot (abs (C20- C02), dt), Float hl = dot (abs (C01-C21), DT), Float VL = dot (abs (C10-C12), DT), float d = _bb* (D1 + d2 + HL + VL)/(Dot ( C11, DT) + 0.15), float LC = 4.0*length (C11), float f = frac (LC); F *= f;lc = 0.25* (Floor (LC) + f*f) + 0.05;//color is divided into four layers, the color gray level of each segment value plus the minimum number of decimal parts, resulting in some transition effectFruit C11 = 4.0*normalize (C11); FLOAT3 frct = Frac (C11); FRCT *= frct;c11 = Floor (C11) + 0.05*dt + Frct*frct;return float4 (0.25*lc* (1.1-d*sqrt (d)) *c11,1);//re-use of the gray scale by the value of the primary color, preserving the original Yan The color is divided into four layers, between the layers have over//through the edge detection stroke, the coloring reason with a previous article like, but not exactly the same,}
measured in PPSSPP
measured in Unity
CRT
CRT is the simulation of the former Big Head computer CRT (cathode ray Tube) of the special effects, strobe and other effects, used to understand the big head.
Key code:
FLOAT4 Frag (v2f i): color{//scanlinesfloat vPOS = float ((i.uv_maintex.y + _time.z * 0.5) * 272.0); float j = 2;float Line_ intensity = MODF (float (vpos), j);//color shiftfloat off = line_intensity *0.00001;float2 shift = FLOAT2 (off, 0);//Shift R and G channels to simulate NTSC color bleedfloat2 colorshift = float2 (0.001, 0); float r = tex2d (_maintex, I.uv_maintex + Colorshift + Shift). X;float g = tex2d (_maintex, I.uv_maintex-colorshift + shift). Y;float B = tex2d (_maintex, I.uv_maint ex). Z;float4 C = float4 (R, G * 0.99, B, 1) * Clamp (line_intensity, 0.85, 1); Float Rollbar = sin ((i.uv_maintex.y + _time.z) * +); return C + (Rollbar * 0.02);}
measured in PPSSPP
measured in Unity
Fxaa
PPSSPP's FXAA anti-aliasing effect is exceptionally good on unity and consumes little,
Four sample points for edge detection (very coarse edge detection), blurring between two points at the Edge
Key code:
FLOAT4 Frag (v2f i): Color{floatu_texeldelta = 1/_size;float Fxaa_span_max = 8.0;float Fxaa_reduce_mul = 1.0/8.0;float Fxaa_reduce_min = (1.0/128.0); FLOAT3 rgbnw = tex2d (_maintex, I.uv_maintex + (FLOAT2 ( -1.0, -1.0) * U_texeldelta)). Xyz;flo AT3 rgbne = tex2d (_maintex, I.uv_maintex + (FLOAT2 (+1.0, -1.0) * U_texeldelta)). XYZ;FLOAT3 RGBSW = tex2d (_maintex, I.uv_ma InTex + (FLOAT2 ( -1.0, +1.0) * U_texeldelta)). XYZ;FLOAT3 rgbse = tex2d (_maintex, I.uv_maintex + (FLOAT2 (+1.0, +1.0) * U_tex Eldelta). XYZ;FLOAT3 RgbM = tex2d (_maintex, I.uv_maintex). Xyz;float3 Luma = FLOAT3 (0.299, 0.587, 0.114); float lumanw = dot (RGBNW, luma); float Lumane = dot (rgbne, luma); float LUMASW = dot (RGBSW, luma); float lumase = dot (rgbse, luma); float Lumam = Dot (RgbM, luma), Float lumamin = min (lumam, min (min (lumanw, Lumane), Min (LUMASW, lumase)), Float Lumamax = max (Lumam, Max (Max (LUMANW, Lumane), Max (LUMASW, lumase)); Float2 dir;dir.x =-((lumanw + lumane)-(LUMASW + lumase));d ir.y = ((Lumanw + LUMASW)-(Lumane + Lum)ASE); float dirreduce = max ((lumanw + lumane + LUMASW + lumase) * (0.25 * Fxaa_reduce_mul), fxaa_reduce_min); float rcpdirm in = 1.0/(min (ABS (dir.x), ABS (DIR.Y)) + dirreduce);d ir = min (float2 (Fxaa_span_max, Fxaa_span_max), MAX (FLOAT2 (-fxaa_ Span_max,-fxaa_span_max), dir * rcpdirmin) * U_TEXELDELTA;FLOAT3 RgbA = (1.0/2.0) * (tex2d (_maintex, I.uv_maintex + di R * (1.0/3.0-0.5)). XYZ +tex2d (_maintex, I.uv_maintex + dir * (2.0/3.0-0.5)). xyz); FLOAT3 RGBB = RgbA * (1.0/2.0) + (1.0/4.0) * (tex2d (_maintex, I.uv_maintex + dir * (0.0/3.0-0.5)). XYZ +tex2d (_maintex, I.uv_maintex + dir * (3.0/ 3.0-0.5)). Float lumab = dot (rgbb, luma); if (Lumab < lumamin) | | (Lumab > Lumamax)) {return float4 (rgba,1);} else {return float4 (RGBB, 1);} On the whole is an edge detection, sampling blur at the edges}
measured in PPSSPP
measured in Unity
Grayscale
Gray
The brightness of white light is indicated by Y, and it is related to the three colors of red, green and blue:
Y = 0.299r+0.587g+0.114b NTSC US TV format luminance formula
Y = 0.222r+0.707g+0.071b PAL (phase progressive alternating) TV format
PPSSPP uses NTSC us, and the luminance function in Unity uses the PAL format
Key code:
FLOAT4 Frag (v2f i): color{float3 RGB = tex2d (_maintex, I.uv_maintex). Rgb;float luma = dot (RGB, FLOAT3 (0.299, 0.587, 0.114) ); return luma;}
measured in PPSSPP
measured in Unity
inversecolors
Inverse color
Key code:
FLOAT4 Frag (v2f i): color{float3 RGB = tex2d (_maintex, I.uv_maintex). Rgb;float luma = dot (RGB, FLOAT3 (0.299, 0.587, 0.114) );//luma = luminance (RGB); Float3 Gray = Float3 (Luma, Luma, Luma)-0.5;rgb-= FLOAT3 (0.5, 0.5, 0.5); return FLOAT4 (Mix (RGB, Gray, 2.0) + 0.5, 1);}
measured in PPSSPP
measured in Unity
Natural
Make the color natural
Turn the color from RGB to Yiq color space to transform
Key code:
FLOAT4 Frag (v2f i): color{float3 val00 = FLOAT3 (1.2, 1.2, 1.2); float3x3 Rgbtoyiq = float3x3 (0.299, 0.596, 0.212, 0.587,-0. 275, -0.523,0.114, -0.321, 0.311); float3x3 Yiqtorgb = float3x3 (1.0, 1.0, 1.0, 0.95568806036115671171,- 0.27158179694405859326, -1.1081773266826619523,0.61985809445637075388,-0.64687381613840131330, 1.7050645599191817149); Float4 C = tex2d (_maintex, I.uv_maintex); FLOAT3 C1 =mul (RGBTOYIQ,C.RGB); c1 = FLOAT3 (Pow (c1.x, val00.x), C1.yz*val00.yz);//Convert to Yiq color space and strengthen GB color 1.2 times times return Float4 (Mul (YIQTORGB,C1), 1);}
measured in PPSSPP
measured in Unity
scanlines
The effect of the line on the screen
Key code:
FLOAT4 Frag (v2f i): color{float Pos0 = ((i.uv_maintex.y + 1.0) * 170.0*_amount); float pos1 = cos ((frac (POS0)-0.5) *3.1415 926*_inten) *1.5;FLOAT4 RGB = tex2d (_maintex, I.uv_maintex);//slight contrast curvefloat4 color = rgb*0.5 + 0.5*rgb*rgb*1. 2;//Color Tintcolor *= float4 (0.9, 1.0, 0.7, 0.0);//Vignettecolor *= 1.1-0.6 * (dot (i.uv_maintex-0.5, I.uv_maintex- 0.5) * 2.0); return Mix (float4 (0, 0, 0, 0), color, pos1);}
measured in PPSSPP
measured in Unity
Sharpen
Sharpening
Take the upper and lower two sample points, the greater the color difference between the sample points (edge, color difference, etc.), sharp more obvious
Key code:
FLOAT4 Frag (v2f i): color{float4 C = tex2d (_maintex, I.uv_maintex); c-= tex2d (_maintex, I.uv_maintex + _size) *7.0*_inten;c + = tex2d (_maintex, I.uv_maintex-_size) *7.0*_inten;//The higher the color difference between the sample points (edge, color difference, etc.), sharp more pronounced return c;
measured in PPSSPP
measured in Unity
Vignette
Vignette effect
Key code:
FLOAT4 Frag (v2f i): color{float vignette = 1.1-0.6 * (dot (i.uv_maintex-0.5, i.uv_maintex-0.5) * 2.0); FLOAT3 RGB = Te X2d (_maintex, I.uv_maintex). Rgb;return float4 (vignette * RGB, 1);}
measured in PPSSPP
measured in Unity
4XHQGLSL
Smoothing effect
measured in PPSSPP
Upscale_spline36
Zoom Filter
Spline-based scaling (Spline based resizers) has Spline16 spline36 spline64, respectively, based on the spline interpolation algorithm for the three zoom filters. The spline difference algorithm sharpens the image as much as possible to reduce distortion when zoomed in
The original author of the algorithm is the developer of Panorama Tools
For an introduction to the detailed algorithm, see forum.doom9.org/showthread.php?t=147117
measured in PPSSPP
Use a different diagram to test, in the case of 2X full-screen stretching, the image will be blurred, using the Zoom filter to zoom in, the effect is as clear as 4X
Not turned on
Open
All code has been uploaded to GitHub
--------by wolf96
The post processing shader in the Unity3d PPSSPP simulator is used in unity