IMaterial:SetTexture() Doesn't do a Thing

The result of the following code is the mat_mymaterial is rendered as a screen quad unmodified as if the SetTexture line does nothing.
I’ve pretty much ruled out any of the other lines being screwed up.
They should be correct, but I may be wrong.


local OldRT = render.GetRenderTarget()
local CRT= GetRenderTarget("customRenderTarget", ScrW(), ScrH())
render.SetRenderTarget( CRT)
render.SetMaterial( MaterialIWantToDraw )
render.DrawScreenQuad()
render.SetRenderTarget( OldRT )
mat_mymaterial:SetTexture( "$basetexture", CRT) -- I believe this is the problematic line
render.SetMaterial( mat_mymaterial)
render.DrawScreenQuad()

Yes, there is a reason why I can’t render it directly to the normal render target.
However, that isn’t relevant because this code as is doesn’t work so any of the things I want to do further with it won’t work either and will just make the code more confusing.

Seems to me the SetTexture function just isn’t doing it’s job and I can’t figure out why.
It works in render.DrawBloom() according to the source code.

Try setting the render target size to 512x512.

So I changed this:


local CRT= GetRenderTarget("customRenderTarget", ScrW(), ScrH())

To this:


local CRT= GetRenderTarget("customRenderTarget", 512, 512)

That’s what you meant, right?
I didn’t work :frowning:

bump