[SOLVED] How to draw texture with shader using drawQuadWithShader

Hello. So I really really want to use shader for texture blitting.

In previous topic here @mvaligursky explained that I can either do framebuffer blit, or a drawQuadWithShader.

Blitting was simple to reproduce, it worked fine. However, I’m not trying to draw with shader and failing.

I’ve looked at examples here and here, I’ve copied the original code with all the stuff it’s using.

What I’m trying to do is a simple test:

  • get render texture from camera
  • perform drawing with a shader using that render target
  • set resulting texture to fullscreen ui element to check results

and… I’m having no results. And no errors also.

can you please point me to what am i doing wrong here? Here is the test project I’ve thrown together for test:

in my ShaderBlit.update() I’m doing draw with shader routine, but I seem to have exact same color buffer that I’ve started with :frowning:

UPDATE: Since I was able to find what I was doing wrong, I’ve updated the project, so you can see how I did it exactly:

  • grab texture from camera and make it into render target
  • pass render target to post effect script
  • create global uniform handle for camera texture
  • on update, send camera texture to global ‘source’ uniform
  • on update, perform shader draw to another render target using simple shader that just multiplies color by red

oh I think I got it.

So this how this draw approach works.

  • Set up all the render targets and textures
  • Upload the texture I want to uniforms
  • Perform drawWithShader to desired render target using shader, which uses the uploaded uniform

Glad you worked it out!