Jump to content

HighlightLayer probleme with getTextureMatrix


Dad72
 Share

Recommended Posts

Hello,

I just noticed two bug HighlightLayer.

error 1) The first is when you use a emissiveColor on Import object. (On the playground, if I put in the comment line emissiveColor, it works, but else it does not work)

http://www.babylonjs-playground.com/#1W1UYU

error 2) The second mistake I fail to reproduce, I do not know what is this. This is when I add a HighlightLayer an object import : error getTextureMatrix . it is the scene.render () which crach and I get it in the console:

Uncaught TypeError: Cannot read property 'getTextureMatrix' of null
    at s (babylon.js:25)
    at _mainTexture.customRenderFunction (babylon.js:25)
    at t.render (babylon.js:11)
    at t.render (babylon.js:11)
    at i.renderToTarget (babylon.js:16)
    at i.render (babylon.js:15)
    at i._renderForCamera (babylon.js:12)
    at i._processSubCameras (babylon.js:12)
    at i.render (babylon.js:13)

For further information, I employs 2 cameras (multiview) and if Highlight.isEnabled = false; No error. but if Highlight.isEnabled = true; error getTextureMatrix.

Link to comment
Share on other sites

For error 2) I have a bit more precision using babylon.max.js

The error that is in

 // Custom render function
            var renderSubMesh = function (subMesh) {

...
...
// Alpha test
                    if (material && material.needAlphaTesting()) {
                        var alphaTexture = material.getAlphaTestTexture();
                        _this._glowMapGenerationEffect.setTexture("diffuseSampler", alphaTexture);
                        _this._glowMapGenerationEffect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
                    }

on line : _this._glowMapGenerationEffect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());

I think that is when we use objects with sub-object and there is a aphaTexture.

Link to comment
Share on other sites

I can find. If I use camera.setPosition the HighlightLayer does not work. I do not know if this is linked, but on my PC that make me error getTextureMatrix. in the playgroud, error TEXTURE_2D 

The model can be a long to load :

http://www.babylonjs-playground.com/#GA8XI#69 (Comment //Camera.setPosition and it works)

Error :

Uncaught TypeError: Cannot read property 'TEXTURE_2D' of null
    at r (babylon.js:4)
    at A (babylon.js:5)
    at babylon.js:5
    at XMLHttpRequest.e.onreadystatechange (babylon.js:3)

I guess it's because of the error setPosition (error getTextureMatrix()).

at i._renderForCamera (babylon.js:12)
at i._processSubCameras (babylon.js:12)

Link to comment
Share on other sites

@Sebavan Ok, It is a not easy to find this error. I finally managed to reproduce the bug getTextureMatrix() :

http://www.babylonjs-playground.com/#GA8XI#77

Uncaught TypeError: Cannot read property 'getTextureMatrix' of null
    at s (babylon.js:25)
    at _mainTexture.customRenderFunction (babylon.js:25)
    at t.render (babylon.js:11)
    at t.render (babylon.js:11)
    at i.renderToTarget (babylon.js:16)
    at i.render (babylon.js:16)
    at i._renderForCamera (babylon.js:12)
    at i._processSubCameras (babylon.js:12)
    at i.render (babylon.js:13)
    at index.js:194

I try to see the results of getTextureMatrix () and I have a result that is the same as if I do not use HightLightLayer. so it should not be null

var alphaTexture = mesh.material.getAlphaTestTexture();
console.log(alphaTexture.getTextureMatrix());

return Float32Array(16) with HightLightLayer and without

Thanks Sebavan and sorry for the loss of time previously.

 

 

Link to comment
Share on other sites

Hello,

It is all working with Standard Material : http://www.babylonjs-playground.com/#GA8XI#78

I guess in your case using ShaderBuilder returns true for needAlphaTesting but no texture for getAlphaTestTexture on the material implementation. I could add a check but would prefer for perf concern to return the related texture.

@NasimiAsl will probably fix this one :-)

Link to comment
Share on other sites

Hi @NasimiAsl,

I think you need to add in ShaderBuilder: needAlphaTesting false when no texture for getAlphaTestTexture.

If you have an error with getTextureMatrix in Babylon.

Here: http://www.babylonjs-playground.com/#GA8XI#77

Uncaught TypeError: Cannot read property 'getTextureMatrix' of null
    at s (babylon.js:25)
    at _mainTexture.customRenderFunction (babylon.js:25)
    at t.render (babylon.js:11)
    at t.render (babylon.js:11)
    at i.renderToTarget (babylon.js:16)
    at i.render (babylon.js:16)
    at i._renderForCamera (babylon.js:12)
    at i._processSubCameras (babylon.js:12)
    at i.render (babylon.js:13)
    at index.js:194

Thanks

Link to comment
Share on other sites

I'm also on Chrome. version 57.0

I looked at the code and ShaderBuilder I see here the relationship with needAlphaTesting which returned true

ShaderBuilder.prototype.PrepareMaterial = function (material, scene) {
            
            if (!this.Setting.Back)
                this.Setting.Back = false;
            material.needAlphaTesting = function () { return true; };

You see the character with HighLightLayer ?

Link to comment
Share on other sites

On FireFox too have the same error but with more precision in the console that can be help:

i.prototype.createTextureAndPostProcesses/s https://babylonjs.azurewebsites.net/babylon.js:25:26749
	i.prototype.createTextureAndPostProcesses/this._mainTexture.customRenderFunction https://babylonjs.azurewebsites.net/babylon.js:25:27499
	t.prototype.render https://babylonjs.azurewebsites.net/babylon.js:11:21002
	t.prototype.render https://babylonjs.azurewebsites.net/babylon.js:11:17917
	i.prototype.renderToTarget https://babylonjs.azurewebsites.net/babylon.js:16:7124
	i.prototype.render https://babylonjs.azurewebsites.net/babylon.js:16:6384
	r.prototype._renderForCamera https://babylonjs.azurewebsites.net/babylon.js:13:2823
	r.prototype._processSubCameras https://babylonjs.azurewebsites.net/babylon.js:13:4549
	r.prototype.render https://babylonjs.azurewebsites.net/babylon.js:13:8796
	run/compileAndRun/< http://www.babylonjs-playground.com/index.js:194:25
	n.prototype._renderLoop https://babylonjs.azurewebsites.net/babylon.js:4:29283
	bound 

n.prototype.createTexture/T https://babylonjs.azurewebsites.net/babylon.js:5:17068
	n.prototype.createTexture/< https://babylonjs.azurewebsites.net/babylon.js:5:17492
	t.LoadFile/h/e.onreadystatechange

Error: WebGL: texImage2D: Alpha-premult and y-flip are deprecated for non-DOM-Element uploads.  babylon.js:3:6815
Error: WebGL: texImage2D: Conversion requires y-flip.  babylon.js:3:6815
Error: WebGL: texImage2D: Alpha-premult and y-flip are deprecated for non-DOM-Element uploads.  babylon.js:3:6815
Error: WebGL: texImage2D: Conversion requires y-flip.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...