@galacean/engine-shaderlab 1.6.5 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -4960,7 +4960,9 @@ var PpUtils = /*#__PURE__*/ function() {
4960
4960
  generatedIdx = generatedIdxEnd;
4961
4961
  }
4962
4962
  ret.push(source.slice(startIdx));
4963
- return ret.join("");
4963
+ var result = ret.join("");
4964
+ // Replace multiple consecutive newlines with a single newline to clean up the output
4965
+ return result.replace(/\n\s*\n+/g, "\n");
4964
4966
  };
4965
4967
  return PpUtils;
4966
4968
  }();
@@ -7605,12 +7607,19 @@ SourceLexer._symbolLexemeTable = {
7605
7607
  for(var i = 0, n = shaderSource.subShaders.length; i < n; i++){
7606
7608
  var subShader = shaderSource.subShaders[i];
7607
7609
  var curSubShaderGlobalStatements = shaderPendingContents.concat(subShader.pendingContents);
7608
- var constMap = _extends({}, shaderRenderStates.constantMap, subShader.renderStates.constantMap);
7609
- var variableMap = _extends({}, shaderRenderStates.variableMap, subShader.renderStates.variableMap);
7610
+ var globalSubShaderStates = {
7611
+ constantMap: _extends({}, shaderRenderStates.constantMap),
7612
+ variableMap: _extends({}, shaderRenderStates.variableMap)
7613
+ };
7614
+ this._mergeRenderStates(globalSubShaderStates, subShader.renderStates);
7610
7615
  for(var j = 0, m = subShader.passes.length; j < m; j++){
7611
7616
  var pass = subShader.passes[j];
7612
- Object.assign(pass.renderStates.constantMap, constMap);
7613
- Object.assign(pass.renderStates.variableMap, variableMap);
7617
+ var globalPassRenderStates = {
7618
+ constantMap: _extends({}, globalSubShaderStates.constantMap),
7619
+ variableMap: _extends({}, globalSubShaderStates.variableMap)
7620
+ };
7621
+ this._mergeRenderStates(globalPassRenderStates, pass.renderStates);
7622
+ pass.renderStates = globalPassRenderStates;
7614
7623
  if (pass.isUsePass) continue;
7615
7624
  var passGlobalStatements = curSubShaderGlobalStatements.concat(pass.pendingContents);
7616
7625
  pass.contents = passGlobalStatements.map(function(item) {
@@ -7662,7 +7671,7 @@ SourceLexer._symbolLexemeTable = {
7662
7671
  }
7663
7672
  }
7664
7673
  };
7665
- ShaderSourceParser._parseRenderStateDeclarationOrAssignment = function _parseRenderStateDeclarationOrAssignment(renderStates, stateToken) {
7674
+ ShaderSourceParser._parseRenderStateDeclarationOrAssignment = function _parseRenderStateDeclarationOrAssignment(outRenderStates, stateToken) {
7666
7675
  var lexer = this._lexer;
7667
7676
  var token = lexer.scanToken();
7668
7677
  if (token.type === ETokenType.ID) {
@@ -7672,19 +7681,37 @@ SourceLexer._symbolLexemeTable = {
7672
7681
  var symbol = new ShaderSourceSymbol(token.lexeme, stateToken.type, renderState);
7673
7682
  this._symbolTableStack.insert(symbol);
7674
7683
  } else if (token.lexeme === "=") {
7675
- // Assignment
7676
- var variable = lexer.scanToken();
7677
- lexer.scanLexeme(";");
7678
- var lookupSymbol = this._lookupSymbol;
7679
- lookupSymbol.set(variable.lexeme, stateToken.type);
7680
- var sm = this._symbolTableStack.lookup(lookupSymbol);
7681
- if (!(sm == null ? void 0 : sm.value)) {
7682
- this._createCompileError('Invalid "' + stateToken.lexeme + '" variable: ' + variable.lexeme, variable.location);
7684
+ // Check if it's direct assignment syntax sugar or variable assignment
7685
+ var nextToken = lexer.scanToken();
7686
+ var renderState1;
7687
+ if (nextToken.lexeme === "{") {
7688
+ // Syntax: DepthState = { ... }
7689
+ renderState1 = this._parseRenderStateProperties(stateToken.lexeme);
7690
+ } else {
7691
+ // Syntax: DepthState = customDepthState;
7692
+ lexer.scanLexeme(";");
7693
+ var lookupSymbol = this._lookupSymbol;
7694
+ lookupSymbol.set(nextToken.lexeme, stateToken.type);
7695
+ var sm = this._symbolTableStack.lookup(lookupSymbol);
7696
+ if (!(sm == null ? void 0 : sm.value)) {
7697
+ this._createCompileError('Invalid "' + stateToken.lexeme + '" variable: ' + nextToken.lexeme, nextToken.location);
7698
+ }
7699
+ renderState1 = sm.value;
7683
7700
  }
7684
- var renderState1 = sm.value;
7685
- Object.assign(renderStates.constantMap, renderState1.constantMap);
7686
- Object.assign(renderStates.variableMap, renderState1.variableMap);
7687
- return;
7701
+ this._mergeRenderStates(outRenderStates, renderState1);
7702
+ }
7703
+ };
7704
+ ShaderSourceParser._mergeRenderStates = function _mergeRenderStates(outTarget, source) {
7705
+ // For each key in the source, remove it from the opposite map in target to ensure proper override
7706
+ var targetConstantMap = outTarget.constantMap, targetVariableMap = outTarget.variableMap;
7707
+ var sourceConstantMap = source.constantMap, sourceVariableMap = source.variableMap;
7708
+ for(var key in sourceConstantMap){
7709
+ delete targetVariableMap[key];
7710
+ targetConstantMap[key] = sourceConstantMap[key];
7711
+ }
7712
+ for(var key1 in sourceVariableMap){
7713
+ delete targetConstantMap[key1];
7714
+ targetVariableMap[key1] = sourceVariableMap[key1];
7688
7715
  }
7689
7716
  };
7690
7717
  ShaderSourceParser._parseVariableDeclaration = function _parseVariableDeclaration() {
@@ -8029,7 +8056,7 @@ ShaderLab._shaderPositionPool = ShaderLabUtils.createObjectPool(ShaderPosition);
8029
8056
  ShaderLab._shaderRangePool = ShaderLabUtils.createObjectPool(ShaderRange);
8030
8057
 
8031
8058
  //@ts-ignore
8032
- var version = "1.6.5";
8059
+ var version = "1.6.7";
8033
8060
  var mode = "Release";
8034
8061
  console.log("Galacean Engine ShaderLab Version: " + version + " | Mode: " + mode);
8035
8062