Sampling second texture in GLSL shader


#1

Hi, I use HaxeFlixel for some game dev and am currently trying to port over a little lighting system that I wrote for an older version based on the blendmodes.
To do this, the only way seems to be with shaders, but I am having trouble passing in a second texture.

	#pragma header
	uniform sampler2D tex;

	void main()
	{
		vec4 source= flixel_texture2D(tex, openfl_TextureCoordv);
		vec4 other= texture2D(tex, openfl_TextureCoordv);
		gl_FragColor = vec4(source.r * other.r, source.g * other.g, source.b * other.b, source.a);
	}

Then, I create various HF things that are needed, including the shader and then pass in the bitmap data to the tex property of the shader.


#2

There’s a bug that I fixed on the OpenFL GIT version, could you give this a try?

Please let me know if it resolves your problem


#3

Looking good!
Even better when I change the sampler2D for source to bitmap

Now to change up the logic so it actually works.