Using PShader and GLSL to make swaying grass

I’m trying to add swaying grass using both a vector and a fragment shader in a 2d game, and I’m up to the point where i need to add the image to the fragment shader. Right now I’m using image() to render the image, but the fragment shader isn’t receiving the texture, I’m not very sure how it works anymore as in the rework of the website they deleted the example of PShader :confused:


precision mediump float;
precision mediump int;


uniform sampler2D texture;
uniform vec2 texOffset;

varying vec4 vertColor;
varying vec4 vertTexCoord;

uniform float dW;
uniform float dH;

void main(void) {
    vec4 alpha = texture2D(texture,;
    gl_FragColor = vec4(, 1.0);


precision mediump float;

uniform float dW;
uniform float dH;

attribute vec4 vertex;
void main() {
    vec4 newVecSet = vec4((vertex.x/dW*2)-1.0, -((vertex.y/dH*2)-1.0), vertex.z, vertex.w);
    gl_Position = newVecSet;

Base code

image(Img, 0, 0);

Do you have the rest of the code please

That’s all you need, if you want the rest of the code i will have to port 8000 lines

I mean the draw method or is that long too?

Yeah lol, All of the image loading is fine, there are no issues in the base code, only in shader

It has been resolved by the discord lel, thanks for helping tho