Hey I'm pretty new to Godot and was trying to implement an equivalent to a unity stencil shader for my project. I got most everything setup and it works in editor. However, whenever I play the game and try to reference the subviewport texture in a 3D object's shader the texture just show up as pink. If I restart the game engine then the texture shows up as pink in editor too (until I reset the ViewportTexture's local to scene checkbox). I'm wondering if there is anything I've missed and need to implement to get it to work. I've attached a copy of my debug project for convenience.

Zip File:

subviewport-test-2.zip
3MB

Screenshots:
In editor (everything's fine):

in game (suddenly broken: applies to 3D mesh objects, textureRect and sprite3D don't do this):

  • Tomcat replied to this.
  • knott11 in game (suddenly broken: applies to 3D mesh objects, textureRect and sprite3D don't do this):

    Try assigning a texture to the Surface Material Override:

    knott11 in game (suddenly broken: applies to 3D mesh objects, textureRect and sprite3D don't do this):

    Try assigning a texture to the Surface Material Override:

    That totally worked!!! Thank you so much!
    I tested it in my original project and it works there too!

    I greatly appreciate you taking the time to help me fix this bug. Your work definitely saved me a lot of time and headache.
    Thank you!