mirror of
https://github.com/RPCS3/ps3autotests.git
synced 2024-11-08 11:52:58 +01:00
Tests added: rsx/rsx_fp_static
The fragment shader draws something static on a fullscreen quad (two triangles). The results from a real PS3 are saved in *.expected.png. The source code of the fragment shader is saved in the *.cg files.
This commit is contained in:
parent
62b653e7d2
commit
763d903919
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,3 +15,7 @@
|
|||||||
# Uninteresting Log files
|
# Uninteresting Log files
|
||||||
*.ps3
|
*.ps3
|
||||||
*.rpcs3
|
*.rpcs3
|
||||||
|
|
||||||
|
# Uninteresting Source files
|
||||||
|
tests/rsx/rsx_fp_dynamic/*.cpp
|
||||||
|
tests/rsx/rsx_fp_static/*.cpp
|
22
tests/rsx/rsx_fp_static/rsx_fp_static_test1.cg
Normal file
22
tests/rsx/rsx_fp_static/rsx_fp_static_test1.cg
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
struct v2fConnector
|
||||||
|
{
|
||||||
|
float4 projCoord : POSITION;
|
||||||
|
float4 color : COLOR0;
|
||||||
|
float4 tex : TEX0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct f2fConnector
|
||||||
|
{
|
||||||
|
float4 COL0 : COLOR0;
|
||||||
|
};
|
||||||
|
|
||||||
|
f2fConnector main
|
||||||
|
(
|
||||||
|
v2fConnector v2f
|
||||||
|
)
|
||||||
|
{
|
||||||
|
f2fConnector f2f;
|
||||||
|
|
||||||
|
f2f.COL0 = float4(0.0f, v2f.tex.y, v2f.tex.x, 1.0f);
|
||||||
|
return f2f;
|
||||||
|
}
|
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test1.expected.png
Normal file
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test1.expected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 129 KiB |
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test1.ppu.elf
Normal file
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test1.ppu.elf
Normal file
Binary file not shown.
86
tests/rsx/rsx_fp_static/rsx_fp_static_test2.cg
Normal file
86
tests/rsx/rsx_fp_static/rsx_fp_static_test2.cg
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
// Shader: Translated to CG from: https://www.shadertoy.com/view/Xs2GDd ([SH2014] Cellular by vug)
|
||||||
|
|
||||||
|
struct v2fConnector
|
||||||
|
{
|
||||||
|
float4 projCoord : POSITION;
|
||||||
|
float4 color : COLOR0;
|
||||||
|
float4 tex : TEX0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct f2fConnector
|
||||||
|
{
|
||||||
|
float4 COL0 : COLOR0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Defines
|
||||||
|
#define PI 3.14159265359
|
||||||
|
|
||||||
|
// Globals
|
||||||
|
float3 col1 = float3(0.216, 0.471, 0.698); // blue
|
||||||
|
float3 col2 = float3(1.00, 0.329, 0.298); // yellow
|
||||||
|
float3 col3 = float3(0.867, 0.910, 0.247); // red
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
float disk(float2 r, float2 center, float radius)
|
||||||
|
{
|
||||||
|
return 1.0 - smoothstep(radius-0.008, radius+0.008, length(r-center));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main
|
||||||
|
f2fConnector main
|
||||||
|
(
|
||||||
|
v2fConnector v2f
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// GLSL variables
|
||||||
|
#define WIDTH 720.0
|
||||||
|
#define HEIGHT 480.0
|
||||||
|
float3 iResolution = float3(WIDTH, HEIGHT, 1.0);
|
||||||
|
float4 gl_FragCoord = float4(v2f.tex.x*WIDTH, v2f.tex.y*HEIGHT, 1.0, 0.0);
|
||||||
|
|
||||||
|
f2fConnector f2f;
|
||||||
|
|
||||||
|
// Shader: Translated to CG from: https://www.shadertoy.com/view/Xs2GDd ([SH2014] Cellular by vug)
|
||||||
|
float t = 1.0;
|
||||||
|
float2 r = (2.0*gl_FragCoord.xy - iResolution.xy) / 480.;
|
||||||
|
r *= 1.0 + 0.05*sin(r.x*5.) + 0.05*sin(r.y*3.);
|
||||||
|
r *= 1.0 + 0.2*length(r);
|
||||||
|
float side = 0.5;
|
||||||
|
float2 r2 = fmod(r, side);
|
||||||
|
float2 r3 = r2-side/2.;
|
||||||
|
float i = floor(r.x/side)+2.;
|
||||||
|
float j = floor(r.y/side)+4.;
|
||||||
|
float ii = r.x/side+2.;
|
||||||
|
float jj = r.y/side+4.;
|
||||||
|
|
||||||
|
float3 pix = float3(1.0);
|
||||||
|
|
||||||
|
float rad, disks;
|
||||||
|
|
||||||
|
rad = 0.15 + 0.05*sin(t+ii*jj);
|
||||||
|
disks = disk(r3, float2(0.,0.), rad);
|
||||||
|
pix = lerp(pix, col2, disks);
|
||||||
|
|
||||||
|
float speed = 2.0;
|
||||||
|
float tt = speed+0.1*i+0.08*j;
|
||||||
|
float stopEveryAngle = PI/2.0;
|
||||||
|
float stopRatio = 0.7;
|
||||||
|
float t1 = (floor(tt) + smoothstep(0.0, 1.0-stopRatio, frac(tt)) )*stopEveryAngle;
|
||||||
|
|
||||||
|
float x = -0.07*cos(t1+i);
|
||||||
|
float y = 0.055*(sin(t1+j)+cos(t1+i));
|
||||||
|
rad = 0.1 + 0.05*sin(t+i+j);
|
||||||
|
disks = disk(r3, float2(x,y), rad);
|
||||||
|
pix = lerp(pix, col1, disks);
|
||||||
|
|
||||||
|
rad = 0.2 + 0.05*sin(t*(1.0+0.01*i));
|
||||||
|
disks = disk(r3, float2(0.,0.), rad);
|
||||||
|
pix += 0.2*col3*disks * sin(t+i*j+i);
|
||||||
|
|
||||||
|
pix -= smoothstep(0.3, 5.5, length(r));
|
||||||
|
|
||||||
|
f2f.COL0 = float4(pix, 1.0f);
|
||||||
|
|
||||||
|
// Return
|
||||||
|
return f2f;
|
||||||
|
}
|
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test2.expected.png
Normal file
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test2.expected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 152 KiB |
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test2.ppu.elf
Normal file
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test2.ppu.elf
Normal file
Binary file not shown.
128
tests/rsx/rsx_fp_static/rsx_fp_static_test3.cg
Normal file
128
tests/rsx/rsx_fp_static/rsx_fp_static_test3.cg
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
// Shader: Translated to CG from: https://www.shadertoy.com/view/MdXGDr (Data Transfer by srtuss)
|
||||||
|
|
||||||
|
struct v2fConnector
|
||||||
|
{
|
||||||
|
float4 projCoord : POSITION;
|
||||||
|
float4 color : COLOR0;
|
||||||
|
float4 tex : TEX0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct f2fConnector
|
||||||
|
{
|
||||||
|
float4 COL0 : COLOR0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// GLSL variables
|
||||||
|
float iGlobalTime = 2.0;
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
float2 rotate(float2 k, float t)
|
||||||
|
{
|
||||||
|
return float2(cos(t) * k.x - sin(t) * k.y, sin(t) * k.x + cos(t) * k.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
float hexagon(float3 p, float2 h)
|
||||||
|
{
|
||||||
|
float3 q = abs(p);
|
||||||
|
return max(q.z - h.y, max(q.x + q.y * 0.57735, q.y * 1.1547) - h.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
float scene(float3 pi)
|
||||||
|
{
|
||||||
|
float slices = cos(iGlobalTime * 0.8) * 0.3 + 0.4;
|
||||||
|
|
||||||
|
// Twist the wires
|
||||||
|
float a = sin(pi.z * 0.3) * 2.0;
|
||||||
|
float3 pr = float3(rotate(pi.xy, a), pi.z);
|
||||||
|
|
||||||
|
// Move individual wires
|
||||||
|
float3 id = floor(pr);
|
||||||
|
pr.z += sin(id.x * 10.0 + id.y * 20.0) * iGlobalTime * 2.0;
|
||||||
|
|
||||||
|
// Calculate distance
|
||||||
|
float3 p = frac(pr);
|
||||||
|
p -= 0.5;
|
||||||
|
|
||||||
|
// This makes hollow wires
|
||||||
|
//return max(hexagon(p, vec2(0.3, slices)), -hexagon(p, vec2(0.2, slices + 0.05)));
|
||||||
|
|
||||||
|
return hexagon(p, float2(0.3, slices));
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 norm(float3 p)
|
||||||
|
{
|
||||||
|
// The normal is simply the gradient of the volume
|
||||||
|
float4 dim = float4(1, 1, 1, 0) * 0.01;
|
||||||
|
float3 n;
|
||||||
|
n.x = scene(p - dim.xww) - scene(p + dim.xww);
|
||||||
|
n.y = scene(p - dim.wyw) - scene(p + dim.wyw);
|
||||||
|
n.z = scene(p - dim.wwz) - scene(p + dim.wwz);
|
||||||
|
return normalize(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Main
|
||||||
|
f2fConnector main
|
||||||
|
(
|
||||||
|
v2fConnector v2f
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// GLSL variables
|
||||||
|
#define WIDTH 720.0
|
||||||
|
#define HEIGHT 480.0
|
||||||
|
float3 iResolution = float3(WIDTH, HEIGHT, 1.0);
|
||||||
|
float4 gl_FragCoord = float4(v2f.tex.x*WIDTH, v2f.tex.y*HEIGHT, 1.0, 0.0);
|
||||||
|
float4 gl_FragColor;
|
||||||
|
|
||||||
|
f2fConnector f2f;
|
||||||
|
|
||||||
|
// Shader: Translated to CG from: https://www.shadertoy.com/view/MdXGDr (Data Transfer by srtuss)
|
||||||
|
float slices = cos(iGlobalTime * 0.8) * 0.3 + 0.4;
|
||||||
|
float2 pos = gl_FragCoord.xy / iResolution.xy;
|
||||||
|
float2 p = -1.0 + 2.0 * pos;
|
||||||
|
float3 dir = normalize(float3(p * float2(1.77, 1.0), 1.0));
|
||||||
|
|
||||||
|
// Camera
|
||||||
|
dir.zx = rotate(dir.zx, sin(iGlobalTime * 0.5) * 0.4);
|
||||||
|
dir.xy = rotate(dir.xy, iGlobalTime * 0.2);
|
||||||
|
float3 ray = float3(0.0, 0.0, 0.0 - iGlobalTime * 0.9);
|
||||||
|
|
||||||
|
// Raymarching
|
||||||
|
float t = 0.0;
|
||||||
|
for(int i = 0; i < 90; i ++)
|
||||||
|
{
|
||||||
|
float k = scene(ray + dir * t);
|
||||||
|
t += k * 0.75;
|
||||||
|
}
|
||||||
|
float3 hit = ray + dir * t;
|
||||||
|
|
||||||
|
// Fog
|
||||||
|
float fogFact = clamp(exp(-distance(ray, hit) * 0.3), 0.0, 1.0);
|
||||||
|
|
||||||
|
if(fogFact < 0.05)
|
||||||
|
{
|
||||||
|
gl_FragColor = float4(0.0, 0.0, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Diffuse & specular light
|
||||||
|
float3 sun = normalize(float3(0.1, 1.0, 0.2));
|
||||||
|
float3 n = norm(hit);
|
||||||
|
float3 ref = reflect(normalize(hit - ray), n);
|
||||||
|
float diff = dot(n, sun);
|
||||||
|
float spec = pow(max(dot(ref, sun), 0.0), 32.0);
|
||||||
|
float3 col = lerp(float3(0.0, 0.7, 0.9), float3(0.0, 0.1, 0.2), diff);
|
||||||
|
|
||||||
|
// Enviroment map
|
||||||
|
col = fogFact * (col + spec);
|
||||||
|
|
||||||
|
// iq's vignetting
|
||||||
|
col *= 0.1 + 0.8 * pow(16.0 * pos.x * pos.y * (1.0 - pos.x) * (1.0 - pos.y), 0.1);
|
||||||
|
|
||||||
|
gl_FragColor = float4(col, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return
|
||||||
|
f2f.COL0 = gl_FragColor;
|
||||||
|
return f2f;
|
||||||
|
}
|
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test3.expected.png
Normal file
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test3.expected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 232 KiB |
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test3.ppu.elf
Normal file
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test3.ppu.elf
Normal file
Binary file not shown.
384
tests/rsx/rsx_fp_static/rsx_fp_static_test4.cg
Normal file
384
tests/rsx/rsx_fp_static/rsx_fp_static_test4.cg
Normal file
@ -0,0 +1,384 @@
|
|||||||
|
// Shader: Translated to CG from: https://www.shadertoy.com/view/lds3RX (Spheres/Plane by mu6k)
|
||||||
|
|
||||||
|
struct v2fConnector
|
||||||
|
{
|
||||||
|
float4 projCoord : POSITION;
|
||||||
|
float4 color : COLOR0;
|
||||||
|
float4 tex : TEX0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct f2fConnector
|
||||||
|
{
|
||||||
|
float4 COL0 : COLOR0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Defines
|
||||||
|
#define occlusion_enabled
|
||||||
|
#define occlusion_pass1_quality 40
|
||||||
|
#define occlusion_pass2_quality 8
|
||||||
|
#define noise2_use_smoothstep
|
||||||
|
#define object_count 8
|
||||||
|
#define object_speed_modifier 1.0
|
||||||
|
#define render_steps 128
|
||||||
|
|
||||||
|
// GLSL variables
|
||||||
|
float iGlobalTime = 2.0;
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
float hash(float x) // Decent hash for noise2 generation
|
||||||
|
{
|
||||||
|
return frac(sin(x*.0127863)*17143.321);
|
||||||
|
}
|
||||||
|
|
||||||
|
float hash(float2 x)
|
||||||
|
{
|
||||||
|
return frac(cos(dot(x.xy,float2(2.31,53.21))*124.123)*412.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
float hashlerp(float x0, float x1, float interp)
|
||||||
|
{
|
||||||
|
x0 = hash(x0);
|
||||||
|
x1 = hash(x1);
|
||||||
|
#ifdef noise2_use_smoothstep
|
||||||
|
interp = smoothstep(0.0,1.0,interp);
|
||||||
|
#endif
|
||||||
|
return lerp(x0,x1,interp);
|
||||||
|
}
|
||||||
|
|
||||||
|
float hashlerp(float2 p0, float2 p1, float2 interp)
|
||||||
|
{
|
||||||
|
float v0 = hashlerp(p0[0]+p0[1]*128.0,p1[0]+p0[1]*128.0,interp[0]);
|
||||||
|
float v1 = hashlerp(p0[0]+p1[1]*128.0,p1[0]+p1[1]*128.0,interp[0]);
|
||||||
|
#ifdef noise2_use_smoothstep
|
||||||
|
interp = smoothstep(float2(0.0),float2(1.0),interp);
|
||||||
|
#endif
|
||||||
|
return lerp(v0,v1,interp[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
float hashlerp(float3 p0, float3 p1, float3 interp)
|
||||||
|
{
|
||||||
|
float v0 = hashlerp(p0.xy+float2(p0.z*143.0,0.0),p1.xy+float2(p0.z*143.0,0.0),interp.xy);
|
||||||
|
float v1 = hashlerp(p0.xy+float2(p1.z*143.0,0.0),p1.xy+float2(p1.z*143.0,0.0),interp.xy);
|
||||||
|
#ifdef noise2_use_smoothstep
|
||||||
|
interp = smoothstep(float3(0.0),float3(1.0),interp);
|
||||||
|
#endif
|
||||||
|
return lerp(v0,v1,interp[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
float noise2(float3 p) // 3D noise2
|
||||||
|
{
|
||||||
|
float3 pm = fmod(p,1.0);
|
||||||
|
float3 pd = p-pm;
|
||||||
|
return hashlerp(pd,(pd+float3(1.0,1.0,1.0)), pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 cc(float3 color, float factor,float factor2) // Color modifier
|
||||||
|
{
|
||||||
|
float w = color.x+color.y+color.z;
|
||||||
|
return lerp(color,float3(w)*factor,w*factor2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float3 rotate_z(float3 v, float angle)
|
||||||
|
{
|
||||||
|
float ca = cos(angle); float sa = sin(angle);
|
||||||
|
return mul(v,float3x3(
|
||||||
|
+ca, -sa, +.0,
|
||||||
|
+sa, +ca, +.0,
|
||||||
|
+.0, +.0,+1.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 rotate_y(float3 v, float angle)
|
||||||
|
{
|
||||||
|
float ca = cos(angle); float sa = sin(angle);
|
||||||
|
return mul(v,float3x3(
|
||||||
|
+ca, +.0, -sa,
|
||||||
|
+.0,+1.0, +.0,
|
||||||
|
+sa, +.0, +ca));
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 rotate_x(float3 v, float angle)
|
||||||
|
{
|
||||||
|
float ca = cos(angle); float sa = sin(angle);
|
||||||
|
return mul(v,float3x3(
|
||||||
|
+1.0, +.0, +.0,
|
||||||
|
+.0, +ca, -sa,
|
||||||
|
+.0, +sa, +ca));
|
||||||
|
}
|
||||||
|
|
||||||
|
float spheres(float3 p)
|
||||||
|
{
|
||||||
|
p.xz += float2(2.0);
|
||||||
|
p.xz = fmod(p.xz,float2(4.0));
|
||||||
|
p.xz -= float2(2.0);
|
||||||
|
float d = length(p)-1.0;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
float flr(float3 p)
|
||||||
|
{
|
||||||
|
return p.y+1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float dist(float3 p) // Distance function
|
||||||
|
{
|
||||||
|
float t = iGlobalTime+4.0;
|
||||||
|
float d = 1000.0;
|
||||||
|
|
||||||
|
d = min(spheres(p),flr(p));
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
float amb_occ(float3 p)
|
||||||
|
{
|
||||||
|
float acc=0.0;
|
||||||
|
#define ambocce 0.2
|
||||||
|
|
||||||
|
acc+=dist(p+float3(-ambocce,-ambocce,-ambocce));
|
||||||
|
acc+=dist(p+float3(-ambocce,-ambocce,+ambocce));
|
||||||
|
acc+=dist(p+float3(-ambocce,+ambocce,-ambocce));
|
||||||
|
acc+=dist(p+float3(-ambocce,+ambocce,+ambocce));
|
||||||
|
acc+=dist(p+float3(+ambocce,-ambocce,-ambocce));
|
||||||
|
acc+=dist(p+float3(+ambocce,-ambocce,+ambocce));
|
||||||
|
acc+=dist(p+float3(+ambocce,+ambocce,-ambocce));
|
||||||
|
acc+=dist(p+float3(+ambocce,+ambocce,+ambocce));
|
||||||
|
return 0.5+acc /(16.0*ambocce);
|
||||||
|
}
|
||||||
|
|
||||||
|
float occ(float3 start, float3 light_pos, float size)
|
||||||
|
{
|
||||||
|
float3 dir = light_pos-start;
|
||||||
|
float total_dist = length(dir);
|
||||||
|
dir = dir/total_dist;
|
||||||
|
|
||||||
|
float travel = .1;
|
||||||
|
float o = 1.0;
|
||||||
|
float3 p=start;
|
||||||
|
|
||||||
|
float search_travel=.0;
|
||||||
|
float search_o=1.0;
|
||||||
|
float e = .5*total_dist/float(occlusion_pass1_quality);
|
||||||
|
|
||||||
|
// Pass 1 fixed step search
|
||||||
|
for (int i=0; i<occlusion_pass1_quality; i++)
|
||||||
|
{
|
||||||
|
travel = (float(i)+0.5)*total_dist/float(occlusion_pass1_quality);
|
||||||
|
float cd = dist(start+travel*dir);
|
||||||
|
float co = cd/travel*total_dist*size;
|
||||||
|
if (co<search_o)
|
||||||
|
{
|
||||||
|
search_o=co;
|
||||||
|
search_travel=travel;
|
||||||
|
if (co<.0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass 2 tries to find a better match in close proximity to the result from the previous pass
|
||||||
|
for (int i=0; i<occlusion_pass2_quality; i++)
|
||||||
|
{
|
||||||
|
float tr = search_travel+e;
|
||||||
|
float oc = dist(start+tr*dir)/tr*total_dist*size;
|
||||||
|
if (tr<.0||tr>total_dist)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (oc<search_o)
|
||||||
|
{
|
||||||
|
search_o = oc;
|
||||||
|
search_travel = tr;
|
||||||
|
}
|
||||||
|
e=e*-.75;
|
||||||
|
}
|
||||||
|
o=max(search_o,.0);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
float occ(float3 start, float3 light_pos, float size, float dist_to_scan)
|
||||||
|
{
|
||||||
|
float3 dir = light_pos-start;
|
||||||
|
float total_dist = length(dir);
|
||||||
|
dir = dir/total_dist;
|
||||||
|
|
||||||
|
float travel = .1;
|
||||||
|
float o = 1.0;
|
||||||
|
float3 p=start;
|
||||||
|
|
||||||
|
float search_travel=.0;
|
||||||
|
float search_o=1.0;
|
||||||
|
float e = .5*dist_to_scan/float(occlusion_pass1_quality);
|
||||||
|
|
||||||
|
// Pass 1 fixed step search
|
||||||
|
for (int i=0; i<occlusion_pass1_quality; i++)
|
||||||
|
{
|
||||||
|
travel = (float(i)+0.5)*dist_to_scan/float(occlusion_pass1_quality);
|
||||||
|
float cd = dist(start+travel*dir);
|
||||||
|
float co = cd/travel*total_dist*size;
|
||||||
|
if (co<search_o)
|
||||||
|
{
|
||||||
|
search_o=co;
|
||||||
|
search_travel=travel;
|
||||||
|
if (co<.0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass 2 tries to find a better match in close proximity to the result from the previous pass
|
||||||
|
for (int i=0; i<occlusion_pass2_quality; i++)
|
||||||
|
{
|
||||||
|
float tr = search_travel+e;
|
||||||
|
float oc = dist(start+tr*dir)/tr*total_dist*size;
|
||||||
|
if (tr<.0||tr>total_dist)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (oc<search_o)
|
||||||
|
{
|
||||||
|
search_o = oc;
|
||||||
|
search_travel = tr;
|
||||||
|
}
|
||||||
|
e = e*-.75;
|
||||||
|
}
|
||||||
|
|
||||||
|
o = max(search_o,.0);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 normal(float3 p,float e) // Returns the normal, uses the distance function
|
||||||
|
{
|
||||||
|
float d = dist(p);
|
||||||
|
return normalize(float3(dist(p+float3(e,0,0))-d,dist(p+float3(0,e,0))-d,dist(p+float3(0,0,e))-d));
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 background(float3 p,float3 d) // Render background
|
||||||
|
{
|
||||||
|
d=rotate_z(d,-1.0);
|
||||||
|
float3 color = lerp(float3(.9,.6,.2),float3(.1,.4,.8),d.y*.5+.5);
|
||||||
|
return color*(noise2(d)+.1*pow(noise2(d*4.0),4.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
float noise2(float p)
|
||||||
|
{
|
||||||
|
float pm = fmod(p,1.0);
|
||||||
|
float pd = p-pm;
|
||||||
|
return hashlerp(pd,pd+1.0,pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
float noise2(float2 p)
|
||||||
|
{
|
||||||
|
float2 pm = fmod(p,1.0);
|
||||||
|
float2 pd = p-pm;
|
||||||
|
return hashlerp(pd,(pd+float2(1.0,1.0)), pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 object_material(float3 p, float3 d) // Computes the material for the object
|
||||||
|
{
|
||||||
|
float3 n = normal(p,.02); // Normal vector
|
||||||
|
float3 r = reflect(d,n); // Reflect vector
|
||||||
|
float ao = amb_occ(p); // Fake ambient occlusion
|
||||||
|
float3 color = float3(.0,.0,.0); // Variable to hold the color
|
||||||
|
float reflectance = 1.0+dot(d,n);
|
||||||
|
|
||||||
|
float or = occ(p,p+r*10.0,0.5,10.0);
|
||||||
|
float3 diffuse_acc = float3(.0);
|
||||||
|
float t = iGlobalTime*.1;
|
||||||
|
|
||||||
|
for (int i=0; i<3; i++)
|
||||||
|
{
|
||||||
|
float fi = float(i);
|
||||||
|
float3 offs = float3(
|
||||||
|
-sin(5.0*(1.0+fi)*123.4+t),
|
||||||
|
-sin(4.0*(1.0+fi)*723.4+t),
|
||||||
|
-sin(3.0*(1.0+fi)*413.4+t));
|
||||||
|
|
||||||
|
float3 lp = offs*4.0;
|
||||||
|
float3 ld = normalize(lp-p);
|
||||||
|
|
||||||
|
float diffuse = dot(ld,n);
|
||||||
|
float od=.0;
|
||||||
|
if (diffuse>.0)
|
||||||
|
od = occ(p,lp,1.1);
|
||||||
|
|
||||||
|
float spec = pow(dot(r,ld)*.5+.5,100.0);
|
||||||
|
float3 icolor = float3(1.0)*diffuse*od + float3(spec)*od*reflectance;
|
||||||
|
diffuse_acc += icolor;
|
||||||
|
}
|
||||||
|
if(spheres(p)<flr(p))
|
||||||
|
{
|
||||||
|
float3 tex = float3(0.6, 0.0, 0.0);
|
||||||
|
tex *= float3(.5,.5,.7);
|
||||||
|
color = tex*diffuse_acc+background(p,r)*(.1+or*reflectance)*1.8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float3 tex = float3(0.6, 0.3, 0.1);
|
||||||
|
color = tex*diffuse_acc+background(p,r)*(.1+or*reflectance)*1.5;
|
||||||
|
}
|
||||||
|
return color*min(ao*1.9,1.0)*.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main
|
||||||
|
f2fConnector main
|
||||||
|
(
|
||||||
|
v2fConnector v2f
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// GLSL variables
|
||||||
|
#define WIDTH 720.0
|
||||||
|
#define HEIGHT 480.0
|
||||||
|
float3 iResolution = float3(WIDTH, HEIGHT, 1.0);
|
||||||
|
float4 gl_FragCoord = float4(v2f.tex.x*WIDTH, v2f.tex.y*HEIGHT, 1.0, 0.0);
|
||||||
|
float4 gl_FragColor;
|
||||||
|
|
||||||
|
f2fConnector f2f;
|
||||||
|
|
||||||
|
// Shader: Translated to CG from: https://www.shadertoy.com/view/lds3RX (Spheres/Plane by mu6k)
|
||||||
|
float2 uv = gl_FragCoord.xy / iResolution.xy - 0.5;
|
||||||
|
uv.x *= iResolution.x/iResolution.y; //fix aspect ratio
|
||||||
|
float3 mouse = float3(-0.5, -0.5, -0.5);
|
||||||
|
|
||||||
|
float t = iGlobalTime*.5*object_speed_modifier + 30.0;
|
||||||
|
mouse += float3(sin(t)*.05,sin(t)*.01,.0);
|
||||||
|
|
||||||
|
float offs0=5.0;
|
||||||
|
float offs1=1.0;
|
||||||
|
|
||||||
|
// Setup the camera
|
||||||
|
float3 p = float3(.0,0.0,-1.0);
|
||||||
|
p = rotate_x(p,mouse.y*9.0+offs0);
|
||||||
|
p = rotate_y(p,mouse.x*9.0+offs1);
|
||||||
|
p *= (abs(p.y*2.0+1.0)+1.0);
|
||||||
|
float3 d = float3(uv,1.0);
|
||||||
|
d.z -= length(d)*.6; // Lens distort
|
||||||
|
d = normalize(d);
|
||||||
|
d = rotate_x(d,mouse.y*9.0+offs0);
|
||||||
|
d = rotate_y(d,mouse.x*9.0+offs1);
|
||||||
|
|
||||||
|
float3 sp = p;
|
||||||
|
float3 color;
|
||||||
|
float dd,td;
|
||||||
|
|
||||||
|
// Raymarcing
|
||||||
|
for (int i=0; i<render_steps; i++)
|
||||||
|
{
|
||||||
|
dd = dist(p);
|
||||||
|
p+=d*dd;
|
||||||
|
td+=dd;
|
||||||
|
if (dd>5.0) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dd<0.1)
|
||||||
|
color = object_material(p,d);
|
||||||
|
else
|
||||||
|
color = background(p,d);
|
||||||
|
|
||||||
|
color = lerp(background(p,d),color,1.0/(td*.1+1.0));
|
||||||
|
color = lerp(color*color,color,1.4);
|
||||||
|
color *=.8;
|
||||||
|
color -= length(uv)*.1;
|
||||||
|
color = cc(color,.5,.5);
|
||||||
|
color += hash(uv.xy+color.xy)*.02;
|
||||||
|
gl_FragColor = float4(color,1.0);
|
||||||
|
|
||||||
|
// Return
|
||||||
|
f2f.COL0 = gl_FragColor;
|
||||||
|
return f2f;
|
||||||
|
}
|
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test4.expected.png
Normal file
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test4.expected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 104 KiB |
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test4.ppu.elf
Normal file
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test4.ppu.elf
Normal file
Binary file not shown.
85
tests/rsx/rsx_fp_static/rsx_fp_static_test5.cg
Normal file
85
tests/rsx/rsx_fp_static/rsx_fp_static_test5.cg
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// Shader: Translated to CG from: https://www.shadertoy.com/view/lss3Df (Circle pattern by iq)
|
||||||
|
|
||||||
|
struct v2fConnector
|
||||||
|
{
|
||||||
|
float4 projCoord : POSITION;
|
||||||
|
float4 color : COLOR0;
|
||||||
|
float4 tex : TEX0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct f2fConnector
|
||||||
|
{
|
||||||
|
float4 COL0 : COLOR0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Defines
|
||||||
|
#define NUM 9.0
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
float noise2( in float2 x )
|
||||||
|
{
|
||||||
|
float2 p = floor(x);
|
||||||
|
float2 f = frac(x);
|
||||||
|
float2 uv = p.xy + f.xy*f.xy*(3.0-2.0*f.xy);
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float map( in float2 x, float t )
|
||||||
|
{
|
||||||
|
return noise2( 2.5*x - 1.5*t*float2(1.0,0.0) );
|
||||||
|
}
|
||||||
|
|
||||||
|
float shapes( in float2 uv, in float r, in float e )
|
||||||
|
{
|
||||||
|
float p = pow( 32.0, r - 0.5 );
|
||||||
|
float l = pow( pow(abs(uv.x),p) + pow(abs(uv.y),p), 1.0/p );
|
||||||
|
float d = l - pow(r,0.6) - e*0.2 + 0.05;
|
||||||
|
float fw = fwidth( d )*0.5;
|
||||||
|
fw *= 1.0 + 10.0*e;
|
||||||
|
return (r)*smoothstep( fw, -fw, d ) * (1.0-0.2*e)*(0.4 + 0.6*smoothstep( -fw, fw, abs(l-r*0.8+0.05)-0.1 ));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main
|
||||||
|
f2fConnector main
|
||||||
|
(
|
||||||
|
v2fConnector v2f
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// GLSL variables
|
||||||
|
#define WIDTH 720.0
|
||||||
|
#define HEIGHT 480.0
|
||||||
|
float3 iResolution = float3(WIDTH, HEIGHT, 1.0);
|
||||||
|
float4 gl_FragCoord = float4(v2f.tex.x*WIDTH, v2f.tex.y*HEIGHT, 1.0, 0.0);
|
||||||
|
float4 gl_FragColor;
|
||||||
|
|
||||||
|
f2fConnector f2f;
|
||||||
|
|
||||||
|
// Shader: Translated to CG from: https://www.shadertoy.com/view/lss3Df (Circle pattern by iq)
|
||||||
|
float2 qq = gl_FragCoord.xy/iResolution.xy;
|
||||||
|
float2 uv = gl_FragCoord.xy/iResolution.xx;
|
||||||
|
float time = 11.0;
|
||||||
|
|
||||||
|
uv += 0.01*noise2( 2.0*uv + 0.2*time );
|
||||||
|
float3 col = 0.0*float3(1.0) * 0.15 * abs(qq.y-0.5);
|
||||||
|
float2 pq, st; float f; float3 coo;
|
||||||
|
|
||||||
|
// Grey
|
||||||
|
pq = floor( uv*NUM ) / NUM;
|
||||||
|
st = frac( uv*NUM )*2.0 - 1.0;
|
||||||
|
coo = (float3(0.5,0.7,0.7) + 0.3*sin(10.0*pq.x)*sin(13.0*pq.y))*0.6;
|
||||||
|
col += 1.0*coo*shapes( st, map(pq, time), 0.0 );
|
||||||
|
col += 0.6*coo*shapes( st, map(pq, time), 1.0 );
|
||||||
|
|
||||||
|
// Orange
|
||||||
|
pq = floor( uv*NUM+0.5 ) / NUM;
|
||||||
|
st = frac( uv*NUM+0.5 )*2.0 - 1.0;
|
||||||
|
coo = (float3(1.0,0.5,0.3) + 0.3*sin(10.0*pq.y)*cos(11.0*pq.x))*1.0;
|
||||||
|
col += 1.0*coo*shapes( st, 1.0-map(pq, time), 0.0 );
|
||||||
|
col += 0.4*coo*shapes( st, 1.0-map(pq, time), 1.0 );
|
||||||
|
col *= pow( 16.0*qq.x*qq.y*(1.0-qq.x)*(1.0-qq.y), 0.05 );
|
||||||
|
gl_FragColor = float4( col, 1.0 );
|
||||||
|
|
||||||
|
// Return
|
||||||
|
f2f.COL0 = gl_FragColor;
|
||||||
|
return f2f;
|
||||||
|
}
|
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test5.expected.png
Normal file
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test5.expected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 256 KiB |
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test5.ppu.elf
Normal file
BIN
tests/rsx/rsx_fp_static/rsx_fp_static_test5.ppu.elf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user