Shader issue when converted from Java

I converted a very simple Java example in to Python and I get a black screen instead. Just started tinkering with shaders so this is not a good start! Is there something obvious I’ve missed here? The shader seems to exist when I print myshader out.



def setup():

	global myshader
	size(640, 360, P2D)
	noStroke()

	# Load and compile shader
	myshader = loadShader("wood-1566731901444.frag")
	#print myshader
	

def draw():

	# Set uniforms
	myshader.set("u_resolution", width, height)
	#myshader.set("u_mouse", float(mouseX), float(mouseY))
	#myshader.set("u_time", millis() / 1000.0);

	# Replace the default pipeline programs with our shader
	shader(myshader)

	# Draw a billboard
	rect(0,0,width,height)


def keyPressed():
	print "keypressed"
	# Reload shader everytime a key is pressed
	myshader = loadShader("wood-1566731901444.frag");

1 Like

I needed to set width and height as floats.

2 Likes

Do you mean like this?:

myshader.set("u_resolution", float(width), float(height))

Did that change to your above sketch solve your problem?

2 Likes

That’s exactly right!