A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(cocos): the sprite texture is no parameter of a converted material, and a material blend state it does not set is the effect's
yhhadd61c329feb
diff --git a/pipeline/src/import/cocos/effectConvert.ts b/pipeline/src/import/cocos/effectConvert.tsindex bc0a69e53..423230580 100644--- a/pipeline/src/import/cocos/effectConvert.ts+++ b/pipeline/src/import/cocos/effectConvert.ts@@ -339,6 +339,8 @@ export function convertPass(effect: CocosEffect, pass: EffectPass, shaderName: s// Samplers: `uniform sampler2D name;` is a texture parameter, bound by the engine.const samplers = (text: string): string => text.replace(/(?:layout\s*\([^)]*\)\s*)?uniform\s+(?:highp\s+|mediump\s+|lowp\s+)?sampler(\w+)\s+(\w+)\s*;/g, (_m, dim: string, name: string) => {if (dim !== '2D') { approximations.push(`${name} is a sampler${dim}, which has no counterpart; it reads as a 2D texture`); }+ // The sprite's own texture is the engine's batch texture, not a parameter of the material.+ if (name === 'cc_spriteTexture') return '';if (!declared.has(name)) {declared.add(name);const def = props.get(name)?.value;diff --git a/pipeline/src/import/cocos/importProject.ts b/pipeline/src/import/cocos/importProject.tsindex 472a98983..bc7de7055 100644--- a/pipeline/src/import/cocos/importProject.ts+++ b/pipeline/src/import/cocos/importProject.ts@@ -30,7 +30,7 @@ import { convertEffect, isOutlinePass, type PassConversion } from './effectConve* importer that made less (or differently), and is brought up to date when it is opened. Raise it when the converted output changes in a* way an existing project needs to pick up: a new generated file, a field a document or a manifest now carries.*/-export const COCOS_IMPORT_REVISION = 3;+export const COCOS_IMPORT_REVISION = 4;/** Whether the project at @p projectRoot was written by an importer of this revision. A project that was not converted has nothing to bring up. */export function cocosImportIsCurrent(projectRoot: string): boolean {@@ -706,7 +706,7 @@ export async function importCocosProject(opts: CocosImportOptions): Promise<Impoconst state = json._states?.[passIndex] ?? json._states?.[0];const target = state?.blendState?.targets?.[0];let blendMode = pass.state.blendMode;- if (target) {+ if (target && target.blend !== undefined) {const src = FACTORS[target.blendSrc ?? 1], dst = FACTORS[target.blendDst ?? 0];blendMode = target.blend !== true ? 9 : src === 'src_alpha' && dst === 'one' ? 1 : src === 'one' && dst === 'one_minus_src_alpha' ? 4 : src === 'one' && dst === 'one' ? 5 : 0;}