Quantcast
Channel: Bugs Latest Topics
Viewing all 760 articles
Browse latest View live

3D Textures and FLoat32

$
0
0

Hello all,

I've been working a bit with 3D textures lately, to display MRI which are sometimes (more often than not) encoded in Float32. So far, I was converting the data into uint8 on a single channel (LUMINANCE) but then thought it would be nice to have my data sent to the GPU directly as Float32 (single channel: gl.R32F ). And I found a bug! Or rather something that I suspect to have been overlooked because not a lot of people uses 3D textures and even less want to have floating point precision.

The guilty line of code lays in the Engine L5926 (link). When creating the 3D texture, something like that happens:

this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalFormat, texture.width, texture.height, texture.depth, 0, internalFormat, this._gl.UNSIGNED_BYTE, data);

and reading at the doc on MDN, we have a prototype like that (link😞

void gl.texImage3D(target, level, internalformat, width, height, depth, border, format, type, ImageData source);

The mistake is in the confusion between 'internalFormat' and 'format' and also in the fact that the type in the Engine is forced to UNSIGNED_INT. Somewhere in the middle of this page, we can find this table:

955885078_Capturedecran2018-05-23a12_09_28.thumb.png.81a135a81f0fff6611c9a4a77cf52bb0.png

In the case of a RGB or LUMINANCE image in UNSIGNED_BYTE, the piece of code in the Engine would work fine (and it's how I used it until now), but this is only because the 'type' and 'internal type' are the same. In the case or single channel float 32, 'internal format' and 'format' will take different values, respectively gl.R32F and gl.RED, while the type becomes gl.FLOAT .

So in my case, I replaced the line of code in the Engine by this dirty hardcoded version:

this._gl.texImage3D(this._gl.TEXTURE_3D, 0, this._gl.R32F, texture.width, texture.height, texture.depth, 0, this._gl.RED, this._gl.FLOAT, data);

As well as using that:

let myDummyTexture = new BABYLON.RawTexture3D( new Float32Array(1),1,1,1, BABYLON.Engine.TEXTUREFORMAT_R32F, this._scene);

And it works! (later on , I replaced that by an actual brain MRI texture, and it works too!)

In the method Engine._getInternalFormat() , the internalFormat returned for Engine.TEXTUREFORMAT_R32F is gl.RED but the thing is, it should be gl.R32F and we should have another lookup method called for example Engine._getFormat() that returns gl.RED when Engine.TEXTUREFORMAT_R32F is given and a third lookup method (say Engine._getType() ) that would return gl.FLOAT when Engine.TEXTUREFORMAT_R32F is given. Then we would have every possible settings available! Do you think it's an update you could add to the core?

Cheers :)


Serialize ground probleme

$
0
0

I have some problem when I serialize a terrain. then the serialized data is not reloaded with ImportMesh.

As soon as there is a texture on the ground, the serialization it passes bad. The only time it works is when a texture is not added. For exemple :

With no material :

If I take the case of a simple ground with CreateGround()  it will work (Because no textures are added here) . But if I create now with CreateGroundFromHeightMap() it will not work (Here we add a texture)

http://www.babylonjs-playground.com/#1SQFJP#16

With TerrainMaterial :

If I create a terrain and use TerrainMaterial, this time neither CreateGround() and CreateGroundFromHeightMap() will not work for serialization for reloading with ImportMesh (Here we add textures with the materials)

https://www.babylonjs-playground.com/#E6OZX#191

With MixMaterial :

Same thing if I use MixMaterial instead CreateGround() and CreateGroundFromHeightMap() will not work for serialization for reloading with ImportMesh  (Here also we add textures with the materials)

https://www.babylonjs-playground.com/#E6OZX#190

Thanks

SPS options, updatable/false will not work

$
0
0

This code will never change 'this._updatable' to false:

                if (options && options.updatable) {
                    this._updatable = options.updatable;

Line 162 in Particles/babylon.solidParticleSystem.ts

 

OimoJSPlugin's setLinearVelocity is incorrect

$
0
0

I tried to create a sample using OimoJSPlugin.

http://jsdo.it/cx20/IVHj

However, the following error occurred.

Uncaught TypeError: impostor.physicsBody.linearVelocity.init is not a function
    at OimoJSPlugin.setLinearVelocity (babylon.max.js:85118)
    at PhysicsImpostor.setLinearVelocity (babylon.max.js:83249)
    at IVHj:264
    at Array.forEach (<anonymous>)
    at Observer.callback (IVHj:260)
    at Observable.notifyObservers (babylon.max.js:8294)
    at Scene.render (babylon.max.js:27859)
    at IVHj:78
    at Engine._renderLoop (babylon.max.js:12784)

Perhaps linearVelocity and angularVelocity should use the set function, not the init function.

        public setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3) {
            //impostor.physicsBody.linearVelocity.init(velocity.x, velocity.y, velocity.z); // init() is undefined
            impostor.physicsBody.linearVelocity.set(velocity.x, velocity.y, velocity.z);
        }

        public setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3) {
            //impostor.physicsBody.angularVelocity.init(velocity.x, velocity.y, velocity.z); // init() is undefined
            impostor.physicsBody.angularVelocity.set(velocity.x, velocity.y, velocity.z);
        }

 

Assigning value to Abstractmesh._worldMatrix.m does not work with latest versions after babylonjs 2.5

$
0
0

Hi there,

After babylonjs v2.5 the assignment of _worldMatrix.m for an AbstractMesh doens't work.

For instance, myabstractmesh._worldMatrix.m = myMatrixValue. 

Any alternative solution of this assignment with the latest versions of BabylonJs.

 

Thanks..

mkaouri

Unity Exporter cannot be imported in Unity 2017.2.3p1

$
0
0

Hi,

I've tried importing the latest Unity package from: https://github.com/BabylonJS/Exporters/blob/master/Unity/EditorToolkit/Redist/Babylon Editor Toolkit.unitypackage

But it doesn't compile. Errors:

- Assets/Babylon/Shaders/Unity/Interface/StandardRoughnessShaderBJS.cs(272,34): error CS1501: No overload for method `TexturePropertyWithHDRColor' takes `4' arguments
- Assets/Babylon/Shaders/Unity/Interface/StandardShaderBJS.cs(297,88): error CS0117: `UnityEditorInternal.InternalEditorUtility' does not contain a definition for `IsMobilePlatform'
- Assets/Babylon/Shaders/Unity/Interface/StandardShaderBJS.cs(323,34): error CS1501: No overload for method `TexturePropertyWithHDRColor' takes `4' arguments

Which version of Unity should I use to test the exporter? I haven't seen it in the documentation.

Also, the GettingStarted video: http://www.babylontoolkit.com/videos/GettingStarted.mp4 is pointing to a 404

Pinging @MackeyK24

David

Lightmap issue with Unity3D Scene exporter

$
0
0

Hi, 

I tried to export my Unity project, following the "project setup" official guide here : http://doc.babylonjs.com/resources/projects.

I have got lightmaps on my textures that seems to break when I run the project with babylon.js as you can see :

Capturetex.thumb.JPG.795978eaff1aed5e9b3e05b55b023dad.JPG

 

Furthermore, when I try to interact with my game, nothing happens, the game is just stuck on the initial view.

The only issue that I've got from Unity during the export is "Material doesn't have a texture property '_MainTex'" as you can see here :1821590140_Capture.thumb.JPG.a10ba2ecc95dcd3741580a29480effe9.JPG

 

Did I do something wrong? It seems to be a Shader issue. Are the Unity lightmaps supposed to be supported?

Thanks!

Issues when using compressed Textures [using setTextureFormatToUse]

$
0
0

Hi,

Started using compressed textures in our projects. Came across three possible bugs, not sure about the last one. PG: https://www.babylonjs-playground.com/#RK0W5S#2

1 and 2 are demonstrated in the above PG. Comment line #5 to compare results when not using compressed textures.

1.) Incorrect texture returned when Engine is set to use a ktx format texture and Texture is made via Texture.CreateFromBase64String. Possibe fix: bypass textureFormatInUse when buffer is available in Engine.CreateTexture

2.) Callback passed to Texture is not fired when CreateTexture falls back to url passed on not finding its ktx counterparts. Need this to finish a "change texture" flow. Possible fix: Ignore fallback argument and create onLoadObserver in Engine.CreateTexture

3.) When engine is set to use ktx format , CubeTexture looks for one ktx file instead of 6. I don't know if the cubeTextures in ktx formats are to be composited into a single file. I use this gulp task to create compressed textures.

Got a work around for 1 and 2 but 3 is beyond me. Want this to support 360 tours on low spec devices.




 


flicker glTF mesh with doubleSided normals in DefaultEnvironment

Deterministic lockstep issue with high FPS

$
0
0

Hi,

I'm pretty new to Babylon.js, only started using it a few days ago, but really enjoy it, great work! :)

I encountered some odd behavior with using deterministic lockstep on my setup, when running the example from the Animation page (https://www.babylonjs-playground.com/index.html#DU4FPJ#3) on my laptop's display (120Hz) the animation is twice as fast as on my connected monitor (60Hz) - tried with both Latest and Stable version, with both Cannon and Oimo plugins. My first guess would be that the algorithm is only prepared to handle low FPS, and does not take into account possible higher values. Also tried to dig in to the project on GitHub, but since I'm not that familiar with the structure, sadly I did not find the sources responsible for the behavior. Could some expert please verify my finding?

Thank you, keep up the good work, cheers!

PBR, Reflection/Refraction glitch

AudioListener error when mouse is moved outside canvas

$
0
0

I'm not sure whether this qualifies as a babylon.js bug, but here's my scenario:

  • I'm embedding a babylon.js canvas in a WordPress page
  • there's some audio in the scene, but no positional audio
  • when the mouse is outside the canvas when the canvas loads, and the user moves the mouse, this error is thown, and the canvas crashes:
Uncaught TypeError: Failed to execute 'setPosition' on 'AudioListener': The provided float value is non-finite.
    at i._updateAudioParameters (babylon.custom.js:14)
    at i.render (babylon.custom.js:14)
    at main.js?v=201806111547:595
    at n._renderLoop (babylon.custom.js:6)

 

You can see it happen here: https://studio.rocketclowns.com/agnes/babylon-test/

Same result in Edge, Chrome and Firefox.

 

Help :)

 

Edit: I'm on Windows 10 and babylon.js is version 3.2.0.

 

The inspector has editing problems with meshes imported

$
0
0

Inspector Can not Change Mesh Values (vector3 and others). When we change the values, nothing happens on the mesh and in the inspector.

it does not work on all models imported. But it works on the primitive models of babylon (box, sphere ...)

I tested on this PG : http://www.babylonjs-playground.com/#QY1WYT#0

Export specular textures with 3ds max

$
0
0

Hi,

Specular textures are never exported with the export 3ds max (2017).

All my models are textures, diffuse, specular and bump. Diffuse and bump are correctly exported, but not the specular ones.

Thank you in advance.

ShadowGenerator usePercentageCloserFiltering breaks Android

$
0
0

https://playground.babylonjs.com/indexStable.html#MK6IZ7#1

Hi there,

if you use usePercentageCloserFiltering (Shadowgenerator) it will break Android and only Android (iOS, Safari, Chrome desktop works fine).

BJS - [10:25:40]: Unable to compile effect:

BJS - [10:25:40]: Uniforms:  world, view, viewProjection, vEyePosition, vLightsType, vAmbientColor, vDiffuseColor, vSpecularColor, vEmissiveColor, vFogInfos, vFogColor, pointSize, vDiffuseInfos, vAmbientInfos, vOpacityInfos, vReflectionInfos, vEmissiveInfos, vSpecularInfos, vBumpInfos, vLightmapInfos, vRefractionInfos, mBones, vClipPlane, diffuseMatrix, ambientMatrix, opacityMatrix, reflectionMatrix, emissiveMatrix, specularMatrix, bumpMatrix, normalMatrix, lightmapMatrix, refractionMatrix, diffuseLeftColor, diffuseRightColor, opacityParts, reflectionLeftColor, reflectionRightColor, emissiveLeftColor, emissiveRightColor, refractionLeftColor, refractionRightColor, vReflectionPosition, vReflectionSize, logarithmicDepthConstant, vTangentSpaceParams, alphaCutOff, vLightData0, vLightDiffuse0, vLightSpecular0, vLightDirection0, vLightGround0, lightMatrix0, shadowsInfo0, depthValues0, diffuseSampler, ambientSampler, opacitySampler, reflectionCubeSampler, reflection2DSampler, emissiveSampler, specularSampler, bumpSampler, lightmapSampler, refractionCubeSampler, refraction2DSampler, shadowSampler0, depthSampler0
t._ErrorEnabled @ babylon.js:4


BJS - [10:25:40]: Attributes:  position, normal

BJS - [10:25:40]: Vertex shader: default
1    #version 300 es
2    #define WEBGL2 
3    #define DIFFUSEDIRECTUV 0
4    #define AMBIENTDIRECTUV 0
5    #define OPACITYDIRECTUV 0
6    #define EMISSIVEDIRECTUV 0
7    #define SPECULARDIRECTUV 0
8    #define BUMPDIRECTUV 0
9    #define SPECULARTERM
10    #define NORMAL
11    #define NUM_BONE_INFLUENCERS 0
12    #define BonesPerMesh 0
13    #define LIGHTMAPDIRECTUV 0
14    #define SHADOWFLOAT
15    #define NUM_MORPH_INFLUENCERS 0
16    #define VIGNETTEBLENDMODEMULTIPLY
17    #define SAMPLER3DGREENDEPTH
18    #define SAMPLER3DBGRMAP
19    #define LIGHT0
20    #define DIRLIGHT0
21    #define SHADOW0
22    #define SHADOWPCF0
23    #define SHADOWS
24    
25    #define SHADER_NAME vertex:default
26    precision highp float;
27    layout(std140,column_major) uniform;
28    uniform Material
29    {
30    vec4 diffuseLeftColor;
31    vec4 diffuseRightColor;
32    vec4 opacityParts;
33    vec4 reflectionLeftColor;
34    vec4 reflectionRightColor;
35    vec4 refractionLeftColor;
36    vec4 refractionRightColor;
37    vec4 emissiveLeftColor; 
38    vec4 emissiveRightColor;
39    vec2 vDiffuseInfos;
40    vec2 vAmbientInfos;
41    vec2 vOpacityInfos;
42    vec2 vReflectionInfos;
43    vec3 vReflectionPosition;
44    vec3 vReflectionSize;
45    vec2 vEmissiveInfos;
46    vec2 vLightmapInfos;
47    vec2 vSpecularInfos;
48    vec3 vBumpInfos;
49    mat4 diffuseMatrix;
50    mat4 ambientMatrix;
51    mat4 opacityMatrix;
52    mat4 reflectionMatrix;
53    mat4 emissiveMatrix;
54    mat4 lightmapMatrix;
55    mat4 specularMatrix;
56    mat4 bumpMatrix; 
57    vec4 vTangentSpaceParams;
58    mat4 refractionMatrix;
59    vec4 vRefractionInfos;
60    vec4 vSpecularColor;
61    vec3 vEmissiveColor;
62    vec4 vDiffuseColor;
63    float pointSize; 
64    };
65    uniform Scene {
66    mat4 viewProjection;
67    mat4 view;
68    };
69    
70    #define CUSTOM_VERTEX_BEGIN
71    in vec3 position;
72    #ifdef NORMAL
73    in vec3 normal;
74    #endif
75    #ifdef TANGENT
76    in vec4 tangent;
77    #endif
78    #ifdef UV1
79    in vec2 uv;
80    #endif
81    #ifdef UV2
82    in vec2 uv2;
83    #endif
84    #ifdef VERTEXCOLOR
85    in vec4 color;
86    #endif
87    const float PI=3.1415926535897932384626433832795;
88    const float LinearEncodePowerApprox=2.2;
89    const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;
90    const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);
91    mat3 transposeMat3(mat3 inMatrix) {
92    vec3 i0=inMatrix[0];
93    vec3 i1=inMatrix[1];
94    vec3 i2=inMatrix[2];
95    mat3 outMatrix=mat3(
96    vec3(i0.x,i1.x,i2.x),
97    vec3(i0.y,i1.y,i2.y),
98    vec3(i0.z,i1.z,i2.z)
99    );
100    return outMatrix;
101    }
102    
103    mat3 inverseMat3(mat3 inMatrix) {
104    float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];
105    float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];
106    float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];
107    float b01=a22*a11-a12*a21;
108    float b11=-a22*a10+a12*a20;
109    float b21=a21*a10-a11*a20;
110    float det=a00*b01+a01*b11+a02*b21;
111    return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),
112    b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),
113    b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;
114    }
115    float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
116    {
117    float mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));
118    return mix(value,1.0,mask);
119    }
120    vec3 applyEaseInOut(vec3 x){
121    return x*x*(3.0-2.0*x);
122    }
123    vec3 toLinearSpace(vec3 color)
124    {
125    return pow(color,vec3(LinearEncodePowerApprox));
126    }
127    vec3 toGammaSpace(vec3 color)
128    {
129    return pow(color,vec3(GammaEncodePowerApprox));
130    }
131    float square(float value)
132    {
133    return value*value;
134    }
135    float getLuminance(vec3 color)
136    {
137    return clamp(dot(color,LuminanceEncodeApprox),0.,1.);
138    }
139    
140    float getRand(vec2 seed) {
141    return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);
142    }
143    float dither(vec2 seed,float varianceAmount) {
144    float rand=getRand(seed);
145    float dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);
146    return dither;
147    }
148    #if NUM_BONE_INFLUENCERS>0
149    uniform mat4 mBones[BonesPerMesh];
150    in vec4 matricesIndices;
151    in vec4 matricesWeights;
152    #if NUM_BONE_INFLUENCERS>4
153    in vec4 matricesIndicesExtra;
154    in vec4 matricesWeightsExtra;
155    #endif
156    #endif
157    
158    #ifdef INSTANCES
159    in vec4 world0;
160    in vec4 world1;
161    in vec4 world2;
162    in vec4 world3;
163    #else
164    uniform mat4 world;
165    #endif
166    #ifdef MAINUV1
167    out vec2 vMainUV1;
168    #endif
169    #ifdef MAINUV2
170    out vec2 vMainUV2;
171    #endif
172    #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
173    out vec2 vDiffuseUV;
174    #endif
175    #if defined(AMBIENT) && AMBIENTDIRECTUV == 0
176    out vec2 vAmbientUV;
177    #endif
178    #if defined(OPACITY) && OPACITYDIRECTUV == 0
179    out vec2 vOpacityUV;
180    #endif
181    #if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
182    out vec2 vEmissiveUV;
183    #endif
184    #if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
185    out vec2 vLightmapUV;
186    #endif
187    #if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0
188    out vec2 vSpecularUV;
189    #endif
190    #if defined(BUMP) && BUMPDIRECTUV == 0
191    out vec2 vBumpUV;
192    #endif
193    
194    out vec3 vPositionW;
195    #ifdef NORMAL
196    out vec3 vNormalW;
197    #endif
198    #ifdef VERTEXCOLOR
199    out vec4 vColor;
200    #endif
201    #if defined(BUMP) || defined(PARALLAX)
202    #if defined(TANGENT) && defined(NORMAL) 
203    out mat3 vTBN;
204    #endif
205    #endif
206    
207    #ifdef CLIPPLANE
208    uniform vec4 vClipPlane;
209    out float fClipDistance;
210    #endif
211    #ifdef FOG
212    out vec3 vFogDistance;
213    #endif
214    #ifdef LIGHT0
215    uniform Light0
216    {
217    vec4 vLightData;
218    vec4 vLightDiffuse;
219    vec3 vLightSpecular;
220    #ifdef SPOTLIGHT0
221    vec4 vLightDirection;
222    #endif
223    #ifdef HEMILIGHT0
224    vec3 vLightGround;
225    #endif
226    vec4 shadowsInfo;
227    vec2 depthValues;
228    } light0;
229    #ifdef PROJECTEDLIGHTTEXTURE0
230    uniform mat4 textureProjectionMatrix0;
231    uniform sampler2D projectionLightSampler0;
232    #endif
233    #ifdef SHADOW0
234    #if defined(SHADOWCUBE0)
235    uniform samplerCube shadowSampler0; 
236    #else
237    out vec4 vPositionFromLight0;
238    out float vDepthMetric0;
239    #if defined(SHADOWPCSS0)
240    uniform highp sampler2DShadow shadowSampler0;
241    uniform highp sampler2D depthSampler0;
242    #elif defined(SHADOWPCF0)
243    uniform highp sampler2DShadow shadowSampler0;
244    #else
245    uniform sampler2D shadowSampler0;
246    #endif
247    uniform mat4 lightMatrix0;
248    #endif
249    #endif
250    #endif
251    #ifdef LIGHT1
252    uniform Light1
253    {
254    vec4 vLightData;
255    vec4 vLightDiffuse;
256    vec3 vLightSpecular;
257    #ifdef SPOTLIGHT1
258    vec4 vLightDirection;
259    #endif
260    #ifdef HEMILIGHT1
261    vec3 vLightGround;
262    #endif
263    vec4 shadowsInfo;
264    vec2 depthValues;
265    } light1;
266    #ifdef PROJECTEDLIGHTTEXTURE1
267    uniform mat4 textureProjectionMatrix1;
268    uniform sampler2D projectionLightSampler1;
269    #endif
270    #ifdef SHADOW1
271    #if defined(SHADOWCUBE1)
272    uniform samplerCube shadowSampler1; 
273    #else
274    out vec4 vPositionFromLight1;
275    out float vDepthMetric1;
276    #if defined(SHADOWPCSS1)
277    uniform highp sampler2DShadow shadowSampler1;
278    uniform highp sampler2D depthSampler1;
279    #elif defined(SHADOWPCF1)
280    uniform highp sampler2DShadow shadowSampler1;
281    #else
282    uniform sampler2D shadowSampler1;
283    #endif
284    uniform mat4 lightMatrix1;
285    #endif
286    #endif
287    #endif
288    #ifdef LIGHT2
289    uniform Light2
290    {
291    vec4 vLightData;
292    vec4 vLightDiffuse;
293    vec3 vLightSpecular;
294    #ifdef SPOTLIGHT2
295    vec4 vLightDirection;
296    #endif
297    #ifdef HEMILIGHT2
298    vec3 vLightGround;
299    #endif
300    vec4 shadowsInfo;
301    vec2 depthValues;
302    } light2;
303    #ifdef PROJECTEDLIGHTTEXTURE2
304    uniform mat4 textureProjectionMatrix2;
305    uniform sampler2D projectionLightSampler2;
306    #endif
307    #ifdef SHADOW2
308    #if defined(SHADOWCUBE2)
309    uniform samplerCube shadowSampler2; 
310    #else
311    out vec4 vPositionFromLight2;
312    out float vDepthMetric2;
313    #if defined(SHADOWPCSS2)
314    uniform highp sampler2DShadow shadowSampler2;
315    uniform highp sampler2D depthSampler2;
316    #elif defined(SHADOWPCF2)
317    uniform highp sampler2DShadow shadowSampler2;
318    #else
319    uniform sampler2D shadowSampler2;
320    #endif
321    uniform mat4 lightMatrix2;
322    #endif
323    #endif
324    #endif
325    #ifdef LIGHT3
326    uniform Light3
327    {
328    vec4 vLightData;
329    vec4 vLightDiffuse;
330    vec3 vLightSpecular;
331    #ifdef SPOTLIGHT3
332    vec4 vLightDirection;
333    #endif
334    #ifdef HEMILIGHT3
335    vec3 vLightGround;
336    #endif
337    vec4 shadowsInfo;
338    vec2 depthValues;
339    } light3;
340    #ifdef PROJECTEDLIGHTTEXTURE3
341    uniform mat4 textureProjectionMatrix3;
342    uniform sampler2D projectionLightSampler3;
343    #endif
344    #ifdef SHADOW3
345    #if defined(SHADOWCUBE3)
346    uniform samplerCube shadowSampler3; 
347    #else
348    out vec4 vPositionFromLight3;
349    out float vDepthMetric3;
350    #if defined(SHADOWPCSS3)
351    uniform highp sampler2DShadow shadowSampler3;
352    uniform highp sampler2D depthSampler3;
353    #elif defined(SHADOWPCF3)
354    uniform highp sampler2DShadow shadowSampler3;
355    #else
356    uniform sampler2D shadowSampler3;
357    #endif
358    uniform mat4 lightMatrix3;
359    #endif
360    #endif
361    #endif
362    
363    #ifdef MORPHTARGETS
364    uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];
365    #endif
366    
367    #ifdef REFLECTIONMAP_SKYBOX
368    out vec3 vPositionUVW;
369    #endif
370    #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
371    out vec3 vDirectionW;
372    #endif
373    #ifdef LOGARITHMICDEPTH
374    uniform float logarithmicDepthConstant;
375    out float vFragmentDepth;
376    #endif
377    #define CUSTOM_VERTEX_DEFINITIONS
378    void main(void) {
379    #define CUSTOM_VERTEX_MAIN_BEGIN
380    vec3 positionUpdated=position;
381    #ifdef NORMAL 
382    vec3 normalUpdated=normal;
383    #endif
384    #ifdef TANGENT
385    vec4 tangentUpdated=tangent;
386    #endif
387    
388    #ifdef REFLECTIONMAP_SKYBOX
389    vPositionUVW=positionUpdated;
390    #endif 
391    #define CUSTOM_VERTEX_UPDATE_POSITION
392    #define CUSTOM_VERTEX_UPDATE_NORMAL
393    #ifdef INSTANCES
394    mat4 finalWorld=mat4(world0,world1,world2,world3);
395    #else
396    mat4 finalWorld=world;
397    #endif
398    #if NUM_BONE_INFLUENCERS>0
399    mat4 influence;
400    influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
401    #if NUM_BONE_INFLUENCERS>1
402    influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
403    #endif 
404    #if NUM_BONE_INFLUENCERS>2
405    influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
406    #endif 
407    #if NUM_BONE_INFLUENCERS>3
408    influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
409    #endif 
410    #if NUM_BONE_INFLUENCERS>4
411    influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
412    #endif 
413    #if NUM_BONE_INFLUENCERS>5
414    influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
415    #endif 
416    #if NUM_BONE_INFLUENCERS>6
417    influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
418    #endif 
419    #if NUM_BONE_INFLUENCERS>7
420    influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
421    #endif 
422    finalWorld=finalWorld*influence;
423    #endif
424    gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
425    vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
426    vPositionW=vec3(worldPos);
427    #ifdef NORMAL
428    mat3 normalWorld=mat3(finalWorld);
429    #ifdef NONUNIFORMSCALING
430    normalWorld=transposeMat3(inverseMat3(normalWorld));
431    #endif
432    vNormalW=normalize(normalWorld*normalUpdated);
433    #endif
434    #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
435    vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
436    #endif
437    
438    #ifndef UV1
439    vec2 uv=vec2(0.,0.);
440    #endif
441    #ifndef UV2
442    vec2 uv2=vec2(0.,0.);
443    #endif
444    #ifdef MAINUV1
445    vMainUV1=uv;
446    #endif
447    #ifdef MAINUV2
448    vMainUV2=uv2;
449    #endif
450    #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
451    if (vDiffuseInfos.x == 0.)
452    {
453    vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));
454    }
455    else
456    {
457    vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
458    }
459    #endif
460    #if defined(AMBIENT) && AMBIENTDIRECTUV == 0
461    if (vAmbientInfos.x == 0.)
462    {
463    vAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));
464    }
465    else
466    {
467    vAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));
468    }
469    #endif
470    #if defined(OPACITY) && OPACITYDIRECTUV == 0
471    if (vOpacityInfos.x == 0.)
472    {
473    vOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));
474    }
475    else
476    {
477    vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
478    }
479    #endif
480    #if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
481    if (vEmissiveInfos.x == 0.)
482    {
483    vEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));
484    }
485    else
486    {
487    vEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
488    }
489    #endif
490    #if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
491    if (vLightmapInfos.x == 0.)
492    {
493    vLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));
494    }
495    else
496    {
497    vLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));
498    }
499    #endif
500    #if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0
501    if (vSpecularInfos.x == 0.)
502    {
503    vSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));
504    }
505    else
506    {
507    vSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));
508    }
509    #endif
510    #if defined(BUMP) && BUMPDIRECTUV == 0
511    if (vBumpInfos.x == 0.)
512    {
513    vBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));
514    }
515    else
516    {
517    vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));
518    }
519    #endif
520    #if defined(BUMP) || defined(PARALLAX)
521    #if defined(TANGENT) && defined(NORMAL)
522    vec3 tbnNormal=normalize(normalUpdated);
523    vec3 tbnTangent=normalize(tangentUpdated.xyz);
524    vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;
525    vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);
526    #endif
527    #endif
528    #ifdef CLIPPLANE
529    fClipDistance=dot(worldPos,vClipPlane);
530    #endif
531    #ifdef FOG
532    vFogDistance=(view*worldPos).xyz;
533    #endif
534    #ifdef SHADOWS
535    #if defined(SHADOW0) && !defined(SHADOWCUBE0)
536    vPositionFromLight0=lightMatrix0*worldPos;
537    vDepthMetric0=((vPositionFromLight0.z+light0.depthValues.x)/(light0.depthValues.y));
538    #endif
539    #endif
540    #ifdef SHADOWS
541    #if defined(SHADOW1) && !defined(SHADOWCUBE1)
542    vPositionFromLight1=lightMatrix1*worldPos;
543    vDepthMetric1=((vPositionFromLight1.z+light1.depthValues.x)/(light1.depthValues.y));
544    #endif
545    #endif
546    #ifdef SHADOWS
547    #if defined(SHADOW2) && !defined(SHADOWCUBE2)
548    vPositionFromLight2=lightMatrix2*worldPos;
549    vDepthMetric2=((vPositionFromLight2.z+light2.depthValues.x)/(light2.depthValues.y));
550    #endif
551    #endif
552    #ifdef SHADOWS
553    #if defined(SHADOW3) && !defined(SHADOWCUBE3)
554    vPositionFromLight3=lightMatrix3*worldPos;
555    vDepthMetric3=((vPositionFromLight3.z+light3.depthValues.x)/(light3.depthValues.y));
556    #endif
557    #endif
558    
559    #ifdef VERTEXCOLOR
560    
561    vColor=color;
562    #endif
563    #ifdef POINTSIZE
564    gl_PointSize=pointSize;
565    #endif
566    #ifdef LOGARITHMICDEPTH
567    vFragmentDepth=1.0+gl_Position.w;
568    gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;
569    #endif
570    #define CUSTOM_VERTEX_MAIN_END
571    }
572    

kind reagards


Error for Specular Aliasing PG

$
0
0

Hi,

is it know issue about shader error on Specular Aliasing PG from Master Physically Based Rendering ?

BJS - [15:07:07]: Error: Validation Failed: Sampler error:
  Samplers of different types use the same texture image unit.
   - or -
  A sampler's texture unit is out of range (greater than max allowed or negative).

Can give more information if needed.

 

OS: Mac Desktop on chrome and safari.

sound and Artefact shadow because of SceneOptimizer

$
0
0

Hi,

When I activate the music on my scene (with a lot of object)  and if use SceneOptimizer, I get the ripples of the music on the ground in the form of a shadow.

It happens when I use:  mesh.material.freeze();

See screenshot.

2088143174_2018-06-3019_27_14-Greenshot.jpg.e75d5821858deb62b408472e17cb7ac1.jpg

The code is :

this.music = new BABYLON.Sound("musicZone", "myMP3.mp3", this.scene, null, { volume: 1.0, loop: true, autoplay: true, streaming: true, spatialSound: false }); 

   

BABYLON.SceneOptimizer.OptimizeAsync(scene, optionOptimizer());	

    function optionOptimizer()
	{
		var result = new BABYLON.SceneOptimizerOptions(60, 1000);
		result.optimizations.push(new BABYLON.ShadowsOptimization(0));
		result.optimizations.push(new BABYLON.LensFlaresOptimization(1));
		result.optimizations.push(new BABYLON.TextureOptimization(2, 256));
		result.optimizations.push(new BABYLON.PostProcessesOptimization(3));
		result.optimizations.push(new BABYLON.ParticlesOptimization(4));
		result.optimizations.push(new BABYLON.RenderTargetsOptimization(5));
		result.optimizations.push(new BABYLON.HardwareScalingOptimization(6, 4));
		return result;
	}

 

Maya .Babylon Export Changing Material with JS Breaks Animation

$
0
0

Firstly, sorry I don't have my code in front of me, but I'm wondering/thinking this is a bug.

I exported a skinned mesh avatar from Maya to *.babylon format with an animation. When I load the model into babylon.js it displays and the animation begins and loops as expected.

The bug is that when I change the material on any mesh from the imported skinned mesh consisting of multiple meshes (eyes, clothes, body etc) those particular meshes just stay in place. They no longer animate, but the rest of the meshes with the original imported material do animate just fine.

Any ideas?

In case it is relevant, I was replacing the imported material with a GLSL shader. Changing the material did work fine and in this case the avatars clothes became a GLSL texture that has some values which change over time, but again the cloth meshes just stay in place while the rest of my avatar animates.

Mesh normal issue!?

$
0
0

I am not sure why there is an issue with the material/shader for babylon format as shown in the image of the female. I also followed the instructions given on the babylon.js documentation site where they have mentioned to reset Xform of the mesh to solve the normal issue but its still giving me this issue on the babylon playground.

I am currently using 3ds max 2013. with an old version of babylon exporter plugin. I have tried to export this mesh using gltf and babylon format on 3ds max 2018 with an updated exporter but even then it's giving me the same normal issue. 

I have noticed in this file that any inset mesh is seen right through the top mesh for some reason. I can't really say its a normal issue per say, which is why I need help to understand what the actual problem is.

The image below is what it looks like once imported on the babylon playground.

material_female.thumb.JPG.b702fa904621190cb712b55443579625.JPG

The image below is what it looks like in 3ds max.

material_female_fromMax.thumb.JPG.c80056500b68ccafa586c603231c3a06.JPG

Playground saved scenes hosed

$
0
0

I wanted to go back to a scene, & drinking some on the 4th, but the Url reverted back to one without the stuff at the end.  At first, thought who deleted my fuckin scene:angry:.  After I calmed down, I tried others, ones in documentation, all the same result.  Think there be a problem not specific to me.  Can anyone get a saved scene?  Time for a nap.

Viewing all 760 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>