[SOLVED] Stencil buffer and GLB-models

Hello, I found this nice project regarding ‘Stencils’ and visibility within certain masks:
(owner: @saadhaider )

  • works on fbx, but unfortunately it doesn’t seem to support glb-models (have tried different debug approaches)

Created an updated sample project of the original to work with render components



ok, thx - it works with .glb as well now

→ and now for the “Mr Annoying” follow-up (but still relevant):
The actual reason for me - to ask for GLB - was that I had a “Retro TV” GLB-model that could show a video-texture on a Screen (this Screen is part of the GLB-heirarchy).
Before going any further (example-wise): It seems like neither Plane or Model assets, can execute video-textures, for then to be a functional part of a/this Stencil-rendering above?

We have an example here where a model is loaded, and the video is played on the screen part of it. Is this what you’re after?



Seems to be okay in the example projects


ok, will re-fork to see which video format (might be the issue then)

back: both mp4 - so at first it looked like an issue in relation to size (youStar’s example 4 mb mine 159 mb), but then I compared the actual attached scripts

  1. My setup from another forked example (it works in other cases):

  2. yauStar’s - most recent - example:

  • not sure if I have ‘the nerd time’ to dig deep into the variation, but at least the last setup works with both video sizes now (namely while using the last forked)

Thx again to (you) yauStar

The issue for you is that in _setStencilForModel it creates a clone of the material per mesh instance for objects that render in/out of the stencil.

StencilSubject.prototype._setStencilForModel = function (stencil) {
    for (var i = 0; i < this._meshInstances.length; i++) {
        this._meshInstances[i].layer = this.app.scene.layers.getLayerByName('Before World');
        var mat = this._meshInstances[i].material.clone();
        mat.stencilBack = mat.stencilFront = stencil;
        this._meshInstances[i].material = mat;

In the default script for the video textures, the video texture is set on the original material, not the cloned one.

In my version of the video texture script that I tweaked to make it simpler to use for the example in this thread, I set the video texture before the clone, hence it works.


no, it was more like yauStar were pursuing - but thx anyway