Work on distortion shader
This commit is contained in:
+22
-13
@@ -1,18 +1,27 @@
|
||||
#version 450 core
|
||||
layout (location = 0) in vec2 pos;
|
||||
layout (location = 1) in vec2 rad1;
|
||||
layout (location = 2) in vec2 rad2;
|
||||
layout (location = 3) in float factor;
|
||||
struct DataS { vec2 pos; vec2 rad1; vec2 rad2; };
|
||||
layout (std430, binding = 9) readonly buffer Data { DataS data[]; };
|
||||
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
||||
out vec2 vCen;
|
||||
out vec2 vRad1;
|
||||
out vec2 vRad2;
|
||||
out float vFactor;
|
||||
out vec2 texPos;
|
||||
out vec2 distmask;
|
||||
const int ks[6] =
|
||||
{0,1,2 // 2--3
|
||||
,2,1,3 // | |
|
||||
}; // 0--1
|
||||
const vec2 cs[4] =
|
||||
{ vec2 (-1,-1)
|
||||
, vec2 ( 1,-1)
|
||||
, vec2 (-1, 1)
|
||||
, vec2 ( 1, 1)
|
||||
};
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(0,0,0,1);
|
||||
vCen = (theMat * vec4(pos,0,1)).xy;
|
||||
vRad1 = (theMat * vec4(rad1,0,1)).xy;
|
||||
vRad2 = (theMat * vec4(rad2,0,1)).xy;
|
||||
vFactor = factor;
|
||||
int k = ks[gl_VertexID];
|
||||
vec4 off = (theMat * vec4(data[gl_VertexID/6].pos, 0,1));
|
||||
float r = distance
|
||||
((theMat * vec4(data[gl_VertexID/6].rad1, 0,1)).xy
|
||||
,(theMat * vec4(0,0, 0,1)).xy);
|
||||
distmask = (cs[k] - off.xy)/r;
|
||||
texPos = 0.5 * (cs[k]+vec2(1,1));
|
||||
gl_Position = vec4 (cs[k],0,1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user