Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/preview release/what's new.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- Fix an issue with keyboard control (re)attachment. ([#9411](https://github.com/BabylonJS/Babylon.js/issues/9411)) ([RaananW](https://github.com/RaananW))
- Fix issue where PBRSpecularGlossiness materials were excluded from export [#9423](https://github.com/BabylonJS/Babylon.js/issues/9423)([Drigax](https://github.com/drigax))
- Fix direct loading of a glTF string that has base64-encoded URI. ([bghgary](https://github.com/bghgary))
- Fix crash of some node materials using instances on iOS ([Popov72](https://github.com/Popov72))
- Fix the code generated for the NME gradient block ([Popov72](https://github.com/Popov72))
- Fix ssao2RenderingPipeline for orthographic cameras ([Kesshi](https://github.com/Kesshi))

Expand Down
2 changes: 2 additions & 0 deletions src/Engines/engineCapabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@ export interface EngineCapabilities {
maxMSAASamples: number;
/** Defines if the blend min max extension is supported */
blendMinMax: boolean;
/** In some iOS + WebGL1, gl_InstanceID (and gl_InstanceIDEXT) is undefined even if instancedArrays is true. So don't use gl_InstanceID in those cases */
canUseGLInstanceID: boolean;
}
3 changes: 2 additions & 1 deletion src/Engines/nativeEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,8 @@ export class NativeEngine extends Engine {
instancedArrays: false,
canUseTimestampForTimerQuery: false,
blendMinMax: false,
maxMSAASamples: 1
maxMSAASamples: 1,
canUseGLInstanceID: true,
};

this._features = {
Expand Down
3 changes: 2 additions & 1 deletion src/Engines/nullEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ export class NullEngine extends Engine {
instancedArrays: false,
canUseTimestampForTimerQuery: false,
maxMSAASamples: 1,
blendMinMax: false
blendMinMax: false,
canUseGLInstanceID: false,
};

this._features = {
Expand Down
3 changes: 2 additions & 1 deletion src/Engines/thinEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,8 @@ export class ThinEngine {
blendMinMax: false,
multiview: this._gl.getExtension('OVR_multiview2'),
oculusMultiview: this._gl.getExtension('OCULUS_multiview'),
depthTextureExtension: false
depthTextureExtension: false,
canUseGLInstanceID: !(this._badOS && this._webGLVersion <= 1),
};

// Infos
Expand Down
3 changes: 2 additions & 1 deletion src/Engines/webgpuEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ export class WebGPUEngine extends Engine {
oculusMultiview: false,
parallelShaderCompile: undefined,
blendMinMax: true,
maxMSAASamples: 4 // TODO WEBGPU what is the right value?
maxMSAASamples: 4,
canUseGLInstanceID: true,
};

this._caps.parallelShaderCompile = null as any;
Expand Down
8 changes: 7 additions & 1 deletion src/Materials/Node/Blocks/Vertex/instancesBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export class InstancesBlock extends NodeMaterialBlock {
protected _buildBlock(state: NodeMaterialBuildState) {
super._buildBlock(state);

const engine = state.sharedData.scene.getEngine();

// Register for defines
state.sharedData.blocksWithDefines.push(this);

Expand All @@ -175,7 +177,11 @@ export class InstancesBlock extends NodeMaterialBlock {
state.compilationString += `#ifdef THIN_INSTANCES\r\n`;
state.compilationString += `${output.associatedVariableName} = ${this.world.associatedVariableName} * ${output.associatedVariableName};\r\n`;
state.compilationString += `#endif\r\n`;
state.compilationString += this._declareOutput(instanceID, state) + ` = float(gl_InstanceID);\r\n`;
if (engine._caps.canUseGLInstanceID) {
state.compilationString += this._declareOutput(instanceID, state) + ` = 0.0;\r\n`;
} else {
state.compilationString += this._declareOutput(instanceID, state) + ` = float(gl_InstanceID);\r\n`;
}
state.compilationString += `#else\r\n`;
state.compilationString += this._declareOutput(output, state) + ` = ${this.world.associatedVariableName};\r\n`;
state.compilationString += this._declareOutput(instanceID, state) + ` = 0.0;\r\n`;
Expand Down