Dad72 Posted March 15, 2017 Share Posted March 15, 2017 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. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 15, 2017 Author Share Posted March 15, 2017 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. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted March 15, 2017 Share Posted March 15, 2017 Could you create a PG for it ? it seems the alpha texture is missing the texture matrix which is weird. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted March 15, 2017 Share Posted March 15, 2017 BTW for the first issue your material is null so you do not reach the rest of the code http://www.babylonjs-playground.com/#1W1UYU#1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 15, 2017 Author Share Posted March 15, 2017 For the bug 1, ok, my bad For the bug for 2. I research what causes it. and you made a PG Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 15, 2017 Author Share Posted March 15, 2017 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) Quote Link to comment Share on other sites More sharing options...
Sebavan Posted March 15, 2017 Share Posted March 15, 2017 setPosition is not defined on your camera so exactly like for the first point it triggers an exception an does not go in the rest of the code, http://www.babylonjs-playground.com/#GA8XI#70 : here is a demo wrapping it in a try catch block Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 16, 2017 Author Share Posted March 16, 2017 @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. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted March 16, 2017 Share Posted March 16, 2017 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 :-) Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted March 17, 2017 Share Posted March 17, 2017 hi @Sebavan what exactly i need to do ? witch part? in code??? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 17, 2017 Author Share Posted March 17, 2017 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 Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted March 17, 2017 Share Posted March 17, 2017 http://www.babylonjs-playground.com/#GA8XI#79 Use .Transparency() and your Result Enable Alpha Parameter Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 17, 2017 Author Share Posted March 17, 2017 No, the error getTextureMatrix() is still present. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted March 17, 2017 Share Posted March 17, 2017 11 minutes ago, Dad72 said: No, the error getTextureMatrix() is still present. i don't see that error in chrome? and still result is fine Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 17, 2017 Author Share Posted March 17, 2017 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 ? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 17, 2017 Author Share Posted March 17, 2017 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. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 17, 2017 Author Share Posted March 17, 2017 To fix this problem manually, I did this: (I force needAlphaTesting be false) ground.material.needAlphaTesting = function () { return false; }; And it works. I think in ShaderBuillder, neddAphaTexting always returns true. http://www.babylonjs-playground.com/#GA8XI#81 Would you have a fix for it ? @NasimiAsl NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted March 17, 2017 Share Posted March 17, 2017 let me i make PR ok ? But What is default value ? Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 17, 2017 Author Share Posted March 17, 2017 Ok, for PR. The default value should be false Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 17, 2017 Author Share Posted March 17, 2017 In made, needAphadTesting must be true if alpha is used. it is true default with or without alpha. Well I think. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted March 17, 2017 Share Posted March 17, 2017 there is true always so?? when we need the false value? ** i make new function " DisableAlphaTesting() " in ShaderBuilder If you don't use that that return false else return true ? it is ok https://github.com/BabylonJS/Extensions/pull/38 http://www.babylonjs-playground.com/#GA8XI#85 and done Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 17, 2017 Author Share Posted March 17, 2017 Yes, it's ok Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted March 17, 2017 Share Posted March 17, 2017 3 minutes ago, Dad72 said: Yes, it's ok http://www.babylonjs-playground.com/#GA8XI#85 see this Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 17, 2017 Author Share Posted March 17, 2017 Thanks Nasimi, it's perfect Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.