Hi i’m adapting custom GLSL shaders to TD, with the lastest 2022 Build Vulkan engine. I get
(i changed tdrDelay on regedit with no success)
When there is use of the texture function everything halts, it also happens with more simpler code and functions. I’m using a Nvidia GTX 1070 GPU, in version 2021 (based on OpenGL) everything runs fine
This is the the fragment i adapted:
layout (location = 0) out vec4 fragColor;
precision mediump float;
uniform sampler2D tex0;
uniform float time;
uniform vec2 resolution;
uniform sampler2D prevBuffer;
float _luminance(vec3 rgb){
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
return dot(rgb, W);
}
// Simplex 3D Noise
// by Ian McEwan, Ashima Arts
vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}
vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}
float _noise(vec3 v){
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
// First corner
vec3 i = floor(v + dot(v, C.yyy) );
vec3 x0 = v - i + dot(i, C.xxx) ;
// Other corners
vec3 g = step(x0.yzx, x0.xyz);
vec3 l = 1.0 - g;
vec3 i1 = min( g.xyz, l.zxy );
vec3 i2 = max( g.xyz, l.zxy );
// x0 = x0 - 0. + 0.0 * C
vec3 x1 = x0 - i1 + 1.0 * C.xxx;
vec3 x2 = x0 - i2 + 2.0 * C.xxx;
vec3 x3 = x0 - 1. + 3.0 * C.xxx;
// Permutations
i = mod(i, 289.0 );
vec4 p = permute( permute( permute(
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
// Gradients
// ( N*N points uniformly over a square, mapped onto an octahedron.)
float n_ = 1.0/7.0; // N=7
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N)
vec4 x_ = floor(j * ns.z);
vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
vec4 x = x_ *ns.x + ns.yyyy;
vec4 y = y_ *ns.x + ns.yyyy;
vec4 h = 1.0 - abs(x) - abs(y);
vec4 b0 = vec4( x.xy, y.xy );
vec4 b1 = vec4( x.zw, y.zw );
vec4 s0 = floor(b0)*2.0 + 1.0;
vec4 s1 = floor(b1)*2.0 + 1.0;
vec4 sh = -step(h, vec4(0.0));
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
vec3 p0 = vec3(a0.xy,h.x);
vec3 p1 = vec3(a0.zw,h.y);
vec3 p2 = vec3(a1.xy,h.z);
vec3 p3 = vec3(a1.zw,h.w);
//Normalise gradients
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
// Mix final noise value
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
m = m * m;
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
dot(p2,x2), dot(p3,x3) ) );
}
vec3 _rgbToHsv(vec3 c){
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 _hsvToRgb(vec3 c){
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
vec2 scale(vec2 _st, float amount, float xMult, float yMult, float offsetX, float offsetY) {
vec2 xy = _st - vec2(offsetX, offsetY);
xy*=(1.0/vec2(amount*xMult, amount*yMult));
xy+=vec2(offsetX, offsetY);
return xy;
}
vec4 noise(vec2 _st, float scale, float offset) {
return vec4(vec3(_noise(vec3(_st*scale, offset*time))), 1.0);
}
vec4 diff(vec4 _c0, vec4 _c1) {
return vec4(abs(_c0.rgb-_c1.rgb), max(_c0.a, _c1.a));
}
vec4 color(vec4 _c0, float r, float g, float b, float a) {
vec4 c = vec4(r, g, b, a);
vec4 pos = step(0.0, c); // detect whether negative
// if > 0, return r * _c0
// if < 0 return (1.0-r) * _c0
return vec4(mix((1.0-_c0)*abs(c), c*_c0, pos));
}
vec2 modulate(vec2 _st, vec4 _c0, float amount) {
// return fract(st+(_c0.xy-0.5)*amount);
return _st + _c0.xy*amount;
}
vec2 modulateScrollY(vec2 _st, vec4 _c0, float scrollY, float speed) {
_st.y += _c0.r*scrollY + time*speed;
return fract(_st);
}
vec4 osc(vec2 _st, float frequency, float sync, float offset) {
vec2 st = _st;
float r = sin((st.x-offset/frequency+time*sync)*frequency)*0.5 + 0.5;
float g = sin((st.x+time*sync)*frequency)*0.5 + 0.5;
float b = sin((st.x+offset/frequency+time*sync)*frequency)*0.5 + 0.5;
return vec4(r, g, b, 1.0);
}
vec2 rotate(vec2 _st, float angle, float speed) {
vec2 xy = _st - vec2(0.5);
float ang = angle + speed *time;
xy = mat2(cos(ang),-sin(ang), sin(ang),cos(ang))*xy;
xy += 0.5;
return xy;
}
vec4 src(vec2 _st, sampler2D tex) {
// vec2 uv = gl_FragCoord.xy/vec2(1280., 720.);
return texture(tex, _st);
}
void main () {
vec4 c = vec4(1, 0, 0, 1);
//vec2 st = fragColor.rg / resolution.xy;
fragColor = color(diff(osc(modulate(modulateScrollY(scale(vUV.st, 0.72, 1., 1., 0.5, 0.5), osc(modulate(scale(vUV.st, 0.72, 1., 1., 0.5, 0.5), osc(rotate(scale(vUV.st, 0.72, 1., 1., 0.5, 0.5), 10., 0.), 60., 0.1, 0.), 0.11), 2., 0.1, 0.), 0.5, 0.), noise(modulateScrollY(scale(vUV.st, 0.72, 1., 1., 0.5, 0.5), osc(modulate(scale(vUV.st, 0.72, 1., 1., 0.5, 0.5), osc(rotate(scale(vUV.st, 0.72, 1., 1., 0.5, 0.5), 10., 0.), 60., 0.1, 0.), 0.11), 2., 0.1, 0.), 0.5, 0.), 6., 0.1), 0.22), 5., 0.1, 0.), src(modulateScrollY(scale(vUV.st, 0.72, 1., 1., 0.5, 0.5), osc(modulate(scale(vUV.st, 0.72, 1., 1., 0.5, 0.5), osc(rotate(scale(vUV.st, 0.72, 1., 1., 0.5, 0.5), 10., 0.), 60., 0.1, 0.), 0.11), 2., 0.1, 0.), 0.5, 0.), sTD2DInputs[0])), 0.99, 1.014, 1., 1.);
// fragColor = src(vUV.st, sTD2DInputs[0] );
}