1
0
Fork 0

Follow the new shader guide style

This commit is contained in:
Erik Hofman 2023-04-13 08:25:07 +02:00
parent e77e5bad9c
commit 9e0211312e
4 changed files with 17 additions and 14 deletions

View file

@ -1,8 +1,9 @@
// -*-C++-*- // -*-C++-*-
#version 330 #version 330 core
out vec4 fragColor;
in vec4 interpolateColor; in vec4 interpolateColor;
out vec4 fragColor;
void main() void main()
{ {

View file

@ -1,9 +1,10 @@
// -*-C++-*- // -*-C++-*-
#version 330 #version 330 core
out vec4 interpolateColor;
in vec2 step; in vec2 step;
in vec4 stepColor; in vec4 stepColor;
out vec4 interpolateColor;
void main() void main()
{ {

View file

@ -16,16 +16,16 @@ in vec2 texImageCoord;
in vec2 paintCoord; in vec2 paintCoord;
uniform int drawMode; uniform int drawMode;
uniform sampler2D imageSampler;
uniform int imageMode; uniform int imageMode;
uniform int paintType; uniform int paintType;
uniform vec4 paintColor; uniform vec4 paintColor;
uniform vec2 paintParams[3]; uniform vec2 paintParams[3];
uniform vec4 scaleFactorBias[2];
uniform sampler2D imageSampler;
uniform sampler2D rampSampler; uniform sampler2D rampSampler;
uniform sampler2D patternSampler; uniform sampler2D patternSampler;
uniform vec4 scaleFactorBias[2];
float linearGradient(vec2 fragCoord, vec2 p0, vec2 p1){ float linear_gradient(vec2 fragCoord, vec2 p0, vec2 p1){
float x = fragCoord.x; float x = fragCoord.x;
float y = fragCoord.y; float y = fragCoord.y;
@ -41,7 +41,7 @@ float linearGradient(vec2 fragCoord, vec2 p0, vec2 p1){
/ ( dx*dx + dy*dy ); / ( dx*dx + dy*dy );
} }
float radialGradient(vec2 fragCoord, vec2 centerCoord, vec2 focalCoord, float r){ float radial_gradient(vec2 fragCoord, vec2 centerCoord, vec2 focalCoord, float r){
float x = fragCoord.x; float x = fragCoord.x;
float y = fragCoord.y; float y = fragCoord.y;
@ -68,7 +68,7 @@ void main()
{ {
vec2 x0 = paintParams[0]; vec2 x0 = paintParams[0];
vec2 x1 = paintParams[1]; vec2 x1 = paintParams[1];
float factor = linearGradient(paintCoord, x0, x1); float factor = linear_gradient(paintCoord, x0, x1);
col = texture(rampSampler, vec2(factor, 0.5)); col = texture(rampSampler, vec2(factor, 0.5));
} }
break; break;
@ -77,7 +77,7 @@ void main()
vec2 center = paintParams[0]; vec2 center = paintParams[0];
vec2 focal = paintParams[1]; vec2 focal = paintParams[1];
float radius = paintParams[2].x; float radius = paintParams[2].x;
float factor = radialGradient(paintCoord, center, focal, radius); float factor = radial_gradient(paintCoord, center, focal, radius);
col = texture(rampSampler, vec2(factor, 0.5)); col = texture(rampSampler, vec2(factor, 0.5));
} }
break; break;

View file

@ -1,15 +1,16 @@
// -*-C++-*- // -*-C++-*-
#version 330 core #version 330 core
out vec2 texImageCoord;
out vec2 paintCoord;
in vec2 pos; in vec2 pos;
in vec2 textureUV; in vec2 textureUV;
uniform mat4 sh_Model; uniform mat4 sh_Model;
uniform mat4 sh_Ortho; uniform mat4 sh_Ortho;
uniform mat3 paintInverted; uniform mat3 paintInverted;
out vec2 texImageCoord;
out vec2 paintCoord;
void main() void main()
{ {
gl_Position = vec4(pos, 0, 1); gl_Position = vec4(pos, 0, 1);