8.23
60.0 fps
512 x 288
plots functions
Shader Inputs
uniform vec3 iResolution; // viewport resolution (in pixels)
uniform float iTime; // shader playback time (in seconds)
uniform float iTimeDelta; // render time (in seconds)
uniform float iFrameRate; // shader frame rate
uniform int iFrame; // shader playback frame
uniform float iChannelTime[4]; // channel playback time (in seconds)
uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube
uniform vec4 iDate; // (year, month, day, time in seconds)
uniform float iSampleRate; // sound sample rate (i.e., 44100)
xxxxxxxxxx bsp;
1
// I with this shader am trying to get familiar with glsl and the maths behind 2
// shaders.3
4
// plotting function: spent the most time on it. What I came up5
// with was computationally very fast but. It was not having a 6
// uniform thickness for only having y-thickness and no x-thickness.7
// Then I consulted GPT, it gave me shit. So I googled and found this:8
// https://www.shadertoy.com/view/slX3W2, I changed it's usage a bit 9
// so now it can be used with multiple functions.10
// I really like it now :)11
12
float lineWidth = 0.03;13
float DELTA = 0.005;14
15
float plot(vec2 uv, vec2 p, vec2 pDelta){16
vec2 delta = pDelta - p;17
float cosPhi = delta.x / length(delta); //cos(atan(delta.y, delta.x));18
float height = lineWidth / 2.0 / cosPhi;19
return abs(uv.y - p.y) - height;20
}21
22
float f1(float x) { return x * x; }23
float f2(float x) { return x * x * x; }24
float f3(float x) { return sin(x); }25
float f4(float x) { return cos(sinh(x)); }26
27
vec3 draw_grid(vec2 uv){28
// grid, I tried to make it work by seeing this shader: https://www.shadertoy.com/view/wdK3Dy.29
// Ultimately it was too much complicated for me and I 30
// decided to do it my own way. I just yanked the colours31
// from there.32
vec3 res = vec3(0.7);33
34
vec3 grid_colour = vec3(0.6);35
float grid_space = 0.5;36
float grid_thickness = 0.03;37
38
// the big grid39
if (mod(uv.y, grid_space) >gt; grid_space - grid_thickness)40
res = grid_colour;41
else if (mod(uv.x, grid_space) >gt; grid_space - grid_thickness)42
res = grid_colour;Filter
Wrap
iChannel0
Filter
Wrap
iChannel1
Filter
Wrap
iChannel2
Filter
Wrap
iChannel3
the changes were not online because I try not to upload broken shaders to public
I am working with the antialiasing, having some problems implementing it. But I will surely do it! rn this is what I am working with: float pixel_width = 1.0 / iResolution.x; col = mix(col, blue, smoothstep(pixel_width, -pixel_width, v1)); col = mix(col, red, smoothstep(pixel_width, -pixel_width, v2)); col = mix(col, green, smoothstep(pixel_width, -pixel_width, v3)); col = mix(col, white, smoothstep(pixel_width, -pixel_width, v4)); col = mix(col, pink, smoothstep(pixel_width, -pixel_width, v5)); I still can't wrap my head around antialiasing properly. While writing this comment, explaining what I have tried, I got a lot of ideas and tried those. The latest shader has those changes. This was supposed to surely work now. but fsr it doesn't. I am still looking what else I can do to remove the jaggies in lines with a steeper slopeeper slope
the constructor can construct from any type, that's all. What about implementing the antialiasing, now ? ;-))
:O wow! vec3(bool,int,float) & vec3(vec4) seems like black magic tbh, cool stuff!!!f!!!
vec() is also a caster. you can do vec3(bool,int,float) and even vec3(vec4) ;-)
OH MY GOD. DID I EVER DRAEM THAT THE ONE OF THE GODS OF SHADERS WILL PROVIDE ME HIS WISDOM. THANK YOU SO MUCH!! I ADMIRE YOUR SHADERS SOO MUCH!! anyway without getting to much derailed I will surely implement the changes you suggested! tysm for your help! idk how to react to the 2nd info. I am traumatized by not giving the .0 after floats and such assumed I should always have them. tysm for that info. It'll surely be helpful!! ul!!
antialiasing for free: replace if< with *step then smoothstep using blur = pixel width note that you can write vec3(0,1,0) 0) )