diff --git a/@types/pal/input.d.ts b/@types/pal/input.d.ts
index 8b6bfba849..5dfb192bec 100644
--- a/@types/pal/input.d.ts
+++ b/@types/pal/input.d.ts
@@ -62,6 +62,7 @@ declare module 'pal/input' {
public static _on (eventType: import('cocos/input/types/event-enum').InputEventType, cb: GamepadCallback, target?: any);
public static all: GamepadInputDevice[];
+ public static xr: (GamepadInputDevice | null);
/**
* @en The gamepad device id
* @zh 手柄设备 id
@@ -159,6 +160,59 @@ declare module 'pal/input' {
* @zh 开始按键
*/
public get buttonStart (): InputSourceButton;
+
+ /**
+ * @en The grab Left Grip
+ * @zh 左手柄握住
+ */
+ public get gripLeft (): InputSourceButton;
+ /**
+ * @en The grab Right Grip
+ * @zh 右手柄握住
+ */
+ public get gripRight (): InputSourceButton;
+
+ /**
+ * @en The position Left hand
+ * @zh 左手位置
+ */
+ public get handLeftPosition (): InputSourcePosition;
+ /**
+ * @en The orientation Left hand
+ * @zh 左手方向
+ */
+ public get handLeftOrientation (): InputSourceOrientation;
+ /**
+ * @en The position Right hand
+ * @zh 右手位置
+ */
+ public get handRightPosition (): InputSourcePosition;
+ /**
+ * @en The orientation Right hand
+ * @zh 右手方向
+ */
+ public get handRightOrientation (): InputSourceOrientation;
+
+ /**
+ * @en The position Left aim
+ * @zh 左射线位置
+ */
+ public get aimLeftPosition (): InputSourcePosition;
+ /**
+ * @en The orientation Left aim
+ * @zh 左射线方向
+ */
+ public get aimLeftOrientation (): InputSourceOrientation;
+ /**
+ * @en The position Right aim
+ * @zh 右射线位置
+ */
+ public get aimRightPosition (): InputSourcePosition;
+ /**
+ * @en The orientation Right aim
+ * @zh 右射线方向
+ */
+ public get aimRightOrientation (): InputSourceOrientation;
}
type AccelerometerCallback = (res: import('cocos/input/types').EventAcceleration) => void;
@@ -374,7 +428,7 @@ declare module 'pal/input' {
/**
* Class designed for Handheld input.
*/
- export class HandheldInputDevice {
+ export class HandheldInputDevice {
/**
* Register the handheld event callback.
* @engineInternal
diff --git a/cocos/2d/assembler/label/bmfontUtils.ts b/cocos/2d/assembler/label/bmfontUtils.ts
index b6b879343a..c0b163bdb8 100644
--- a/cocos/2d/assembler/label/bmfontUtils.ts
+++ b/cocos/2d/assembler/label/bmfontUtils.ts
@@ -319,7 +319,7 @@ export const bmfontUtils = {
this._recordLetterInfo(letterPosition, character, letterIndex, lineIndex);
if (letterIndex + 1 < _horizontalKerning.length && letterIndex < textLen - 1) {
- nextLetterX += _horizontalKerning[letterIndex + 1];
+ nextLetterX += _horizontalKerning[letterIndex + 1] * _bmfontScale;
}
nextLetterX += letterDef.xAdvance * _bmfontScale + _spacingX;
diff --git a/cocos/2d/components/mask.ts b/cocos/2d/components/mask.ts
index 3afad72002..19ff7976b4 100644
--- a/cocos/2d/components/mask.ts
+++ b/cocos/2d/components/mask.ts
@@ -618,7 +618,7 @@ export class Mask extends Component {
public getMaterial (idx: number): any {
warnID(9007);
if (this.subComp) {
- return this.subComp.getMaterial(idx);
+ return this.subComp.getSharedMaterial(idx);
}
return null;
}
diff --git a/cocos/2d/components/rich-text.ts b/cocos/2d/components/rich-text.ts
index 8bd1e2e37c..51b78664c9 100644
--- a/cocos/2d/components/rich-text.ts
+++ b/cocos/2d/components/rich-text.ts
@@ -27,7 +27,7 @@ import { ccclass, executeInEditMode, executionOrder, help, menu, tooltip, multil
import { DEBUG, DEV, EDITOR } from 'internal:constants';
import { Font, SpriteAtlas, TTFFont, SpriteFrame } from '../assets';
import { EventTouch } from '../../input/types';
-import { assert, warnID, Color, Vec2, CCObject, cclegacy, js } from '../../core';
+import { assert, warnID, Color, Vec2, CCObject, cclegacy, js, Size } from '../../core';
import { BASELINE_RATIO, fragmentText, isUnicodeCJK, isUnicodeSpace, getEnglishWordPartAtFirst, getEnglishWordPartAtLast } from '../utils/text-utils';
import { HtmlTextParser, IHtmlTextParserResultObj, IHtmlTextParserStack } from '../utils/html-text-parser';
import { Node } from '../../scene-graph';
@@ -42,6 +42,9 @@ const _htmlTextParser = new HtmlTextParser();
const RichTextChildName = 'RICHTEXT_CHILD';
const RichTextChildImageName = 'RICHTEXT_Image_CHILD';
+const _tempSize = new Vec2();
+const _tempSizeLeft = new Vec2();
+
/**
* 富文本池。
*/
@@ -582,14 +585,14 @@ export class RichText extends Component {
return partStringArr;
}
- const labelSize = this._calculateSize(styleIndex, text);
- if (labelSize.x < 2048) {
+ this._calculateSize(_tempSize, styleIndex, text);
+ if (_tempSize.x < 2048) {
partStringArr.push(text);
} else {
const multilineTexts = text.split('\n');
for (let i = 0; i < multilineTexts.length; i++) {
- const thisPartSize = this._calculateSize(styleIndex, multilineTexts[i]);
- if (thisPartSize.x < 2048) {
+ this._calculateSize(_tempSize, styleIndex, multilineTexts[i]);
+ if (_tempSize.x < 2048) {
partStringArr.push(multilineTexts[i]);
} else {
const thisPartSplitResultArr = this.splitLongStringOver2048(multilineTexts[i], styleIndex);
@@ -611,12 +614,16 @@ export class RichText extends Component {
let curEnd = longStr.length / 2;
let curString = longStr.substring(curStart, curEnd);
let leftString = longStr.substring(curEnd);
- let curStringSize = this._calculateSize(styleIndex, curString);
- let leftStringSize = this._calculateSize(styleIndex, leftString);
+ const curStringSize = this._calculateSize(_tempSize, styleIndex, curString);
+ const leftStringSize = this._calculateSize(_tempSizeLeft, styleIndex, leftString);
+ let maxWidth = this._maxWidth;
+ if (this._maxWidth === 0) {
+ maxWidth = 2047.9; // Callback when maxWidth is 0
+ }
// a line should be an unit to split long string
const lineCountForOnePart = 1;
- const sizeForOnePart = lineCountForOnePart * this.maxWidth;
+ const sizeForOnePart = lineCountForOnePart * maxWidth;
// divide text into some pieces of which the size is less than sizeForOnePart
while (curStringSize.x > sizeForOnePart) {
@@ -629,7 +636,7 @@ export class RichText extends Component {
curString = curString.substring(curStart, curEnd);
leftString = longStr.substring(curEnd);
- curStringSize = this._calculateSize(styleIndex, curString);
+ this._calculateSize(curStringSize, styleIndex, curString);
}
// avoid too many loops
@@ -647,7 +654,7 @@ export class RichText extends Component {
curString = longStr.substring(curStart, curEnd);
leftString = longStr.substring(curEnd);
- curStringSize = this._calculateSize(styleIndex, curString);
+ this._calculateSize(curStringSize, styleIndex, curString);
leftTryTimes--;
}
@@ -656,7 +663,7 @@ export class RichText extends Component {
while (leftTryTimes && curString.length >= 2 && curStringSize.x > sizeForOnePart) {
curEnd -= curWordStep;
curString = longStr.substring(curStart, curEnd);
- curStringSize = this._calculateSize(styleIndex, curString);
+ this._calculateSize(curStringSize, styleIndex, curString);
// after the first reduction, the step should be 1.
curWordStep = 1;
@@ -684,19 +691,21 @@ export class RichText extends Component {
curString = longStr.substring(curStart, curEnd);
leftString = longStr.substring(curEnd);
- leftStringSize = this._calculateSize(styleIndex, leftString);
+ this._calculateSize(leftStringSize, styleIndex, leftString);
+ this._calculateSize(curStringSize, styleIndex, curString);
leftTryTimes--;
// Exit: If the left part string size is less than 2048, the method will finish.
- if (leftStringSize.x < 2048) {
+ if (leftStringSize.x < 2048 && curStringSize.x < sizeForOnePart) {
+ partStringArr.push(curString);
curStart = text.length;
curEnd = text.length;
curString = leftString;
- partStringArr.push(curString);
+ if (leftString !== '') {
+ partStringArr.push(curString);
+ }
break;
- } else {
- curStringSize = this._calculateSize(styleIndex, curString);
}
}
@@ -705,8 +714,8 @@ export class RichText extends Component {
protected _measureText (styleIndex: number, string?: string) {
const func = (s: string) => {
- const labelSize = this._calculateSize(styleIndex, s);
- return labelSize.width;
+ const width = this._calculateSize(_tempSize, styleIndex, s).x;
+ return width;
};
if (string) {
return func(string);
@@ -718,7 +727,7 @@ export class RichText extends Component {
/**
* @engineInternal
*/
- protected _calculateSize (styleIndex: number, s: string) {
+ protected _calculateSize (out: Vec2, styleIndex: number, s: string) {
let label: ISegment;
if (this._labelSegmentsCache.length === 0) {
label = this._createFontLabel(s);
@@ -729,8 +738,9 @@ export class RichText extends Component {
}
label.styleIndex = styleIndex;
this._applyTextAttribute(label);
- const labelSize = label.node._uiProps.uiTransformComp!.contentSize;
- return labelSize;
+ const size = label.node._uiProps.uiTransformComp!.contentSize;
+ Vec2.set(out, size.x, size.y);
+ return out;
}
protected _onTouchEnded (event: EventTouch) {
diff --git a/cocos/2d/framework/sprite-renderer.ts b/cocos/2d/framework/sprite-renderer.ts
index 539af1ecbd..fadc96c5fe 100644
--- a/cocos/2d/framework/sprite-renderer.ts
+++ b/cocos/2d/framework/sprite-renderer.ts
@@ -119,6 +119,7 @@ export class SpriteRenderer extends ModelRenderer {
}
public onEnable () {
+ super.onEnable();
if (!this._model) {
this._updateModels();
}
diff --git a/cocos/2d/framework/ui-renderer.ts b/cocos/2d/framework/ui-renderer.ts
index 6d8aec173a..f19e13caad 100644
--- a/cocos/2d/framework/ui-renderer.ts
+++ b/cocos/2d/framework/ui-renderer.ts
@@ -30,7 +30,7 @@ import {
import { Color, assert, ccenum, cclegacy } from '../../core';
import { builtinResMgr } from '../../asset/asset-manager';
import { Material } from '../../asset/assets';
-import { BlendFactor } from '../../gfx';
+import { BlendFactor, BlendOp, ColorMask } from '../../gfx';
import { IAssembler, IAssemblerManager } from '../renderer/base';
import { RenderData } from '../renderer/render-data';
import { IBatcher } from '../renderer/i-batcher';
@@ -47,6 +47,8 @@ import { director } from '../../game';
// hack
ccenum(BlendFactor);
+ccenum(BlendOp);
+ccenum(ColorMask);
/**
* @en
@@ -434,7 +436,7 @@ export class UIRenderer extends Renderer {
if (DEBUG) {
assert(this.isValid, 'this component should not be invalid!');
}
- return this.getMaterial(0) !== null
+ return this.getSharedMaterial(0) !== null
&& this._enabled
&& this._color.a > 0;
}
@@ -446,7 +448,7 @@ export class UIRenderer extends Renderer {
*/
public updateMaterial () {
if (this._customMaterial) {
- if (this.getMaterial(0) !== this._customMaterial) {
+ if (this.getSharedMaterial(0) !== this._customMaterial) {
this.setMaterial(this._customMaterial, 0);
}
return;
diff --git a/cocos/2d/renderer/batcher-2d.ts b/cocos/2d/renderer/batcher-2d.ts
index 3102398e47..97f3d84a59 100644
--- a/cocos/2d/renderer/batcher-2d.ts
+++ b/cocos/2d/renderer/batcher-2d.ts
@@ -53,10 +53,8 @@ const _dsInfo = new DescriptorSetInfo(null!);
const m4_1 = new Mat4();
/**
- * @en
- * UI render flow
- * @zh
- * UI 渲染流程
+ * @en UI rendering process
+ * @zh UI 渲染流程
*/
export class Batcher2D implements IBatcher {
protected declare _nativeObj: NativeBatcher2d;
diff --git a/cocos/2d/utils/dynamic-atlas/atlas-manager.ts b/cocos/2d/utils/dynamic-atlas/atlas-manager.ts
index 7affddb9f7..61d150847f 100644
--- a/cocos/2d/utils/dynamic-atlas/atlas-manager.ts
+++ b/cocos/2d/utils/dynamic-atlas/atlas-manager.ts
@@ -28,6 +28,17 @@ import { Filter } from '../../../asset/assets/asset-enum';
import { Atlas } from './atlas';
import { director } from '../../../game';
+/**
+ * @en The dynamic atlas manager which manages all runtime dynamic packed atlas texture for UI rendering.
+ * It generates a maximum of [[maxAtlasCount]] atlas texture, all atlas texture have the size of [[textureSize]].
+ * Normally the [[Root.batcher2D]] is in charge of submitting sprite frames to the dynamic atlas manager, the process is transparent to user.
+ * Note that the first committed sprite frame will define the filter settings of the atlas textures,
+ * only sprite frame with the same setting will be accepted afterward.
+ * @zh 动态合图的管理器,管理所有运行时动态合成的图集,主要用于 UI 渲染。
+ * 该管理器支持生成 [[maxAtlasCount]] 张动态合图,并且所有合图都有同样的 [[textureSize]] 像素尺寸。
+ * 一般来说 [[Root.batcher2D]] 负责提交 [[SpriteFrame]] 到动态合图管理器中,这个过程对于开发者是透明的。
+ * 需要注意的是,第一个提交的 [[SpriteFrame]] 会决定图集的过滤器参数,在此之后只有同样参数的贴图才会被管理器接受。
+ */
export class DynamicAtlasManager extends System {
public static instance: DynamicAtlasManager;
@@ -274,8 +285,9 @@ export class DynamicAtlasManager extends System {
}
/**
- * @en Dynamic Atlas Manager,use to auto merge sprite frame.
- * @zh 动态合图管理器,用于引擎的自动合图功能。
+ * @en The singleton instance of [[DynamicAtlasManager]], please use [[DynamicAtlasManager.instance]] instead.
+ * @zh [[DynamicAtlasManager]] 的单例对象,请直接使用 [[DynamicAtlasManager.instance]]。
+ * @deprecated since v3.7
*/
export const dynamicAtlasManager: DynamicAtlasManager = DynamicAtlasManager.instance = new DynamicAtlasManager();
diff --git a/cocos/2d/utils/index.ts b/cocos/2d/utils/index.ts
index 4f0ef61268..9088895db8 100644
--- a/cocos/2d/utils/index.ts
+++ b/cocos/2d/utils/index.ts
@@ -26,4 +26,4 @@ import './font-loader';
export * from './html-text-parser';
export * from './text-utils';
-export { dynamicAtlasManager } from './dynamic-atlas/atlas-manager';
+export * from './dynamic-atlas/atlas-manager';
diff --git a/cocos/3d/models/baked-skinning-model.jsb.ts b/cocos/3d/models/baked-skinning-model.jsb.ts
index ac18716c6d..58cceff65f 100644
--- a/cocos/3d/models/baked-skinning-model.jsb.ts
+++ b/cocos/3d/models/baked-skinning-model.jsb.ts
@@ -48,6 +48,7 @@ bakedSkinningModelProto._ctor = function () {
this._jointsMedium = { buffer: null, jointTextureInfo, animInfo, texture: null, boundsInfo: null };
this._skeleton = null;
this._mesh = null;
+ this._registerOnDestroy();
};
const oldDestroy = bakedSkinningModelProto.destroy;
@@ -59,6 +60,11 @@ bakedSkinningModelProto.destroy = function () {
oldDestroy.call(this);
};
+// tips:for native platform need call jointTexturePool.releaseHandle(oldTex)
+bakedSkinningModelProto._onDestroy = function () {
+ this._applyJointTexture();
+}
+
const oldBindSkeleton = bakedSkinningModelProto.bindSkeleton;
bakedSkinningModelProto.bindSkeleton = function (skeleton: Skeleton | null = null, skinningRoot: Node | null = null, mesh: Mesh | null = null) {
this._skeleton = skeleton;
diff --git a/cocos/3d/reflection-probe/reflection-probe-component.ts b/cocos/3d/reflection-probe/reflection-probe-component.ts
index 95607e61d3..af4afa0d78 100644
--- a/cocos/3d/reflection-probe/reflection-probe-component.ts
+++ b/cocos/3d/reflection-probe/reflection-probe-component.ts
@@ -248,6 +248,7 @@ export class ReflectionProbe extends Component {
* @en fast bake no convolution.
* @zh 快速烘焙不会进行卷积。
*/
+ @visible(function (this: ReflectionProbe) { return this.probeType === ProbeType.CUBE; })
@type(CCBoolean)
@tooltip('i18n:reflection_probe.fastBake')
get fastBake () {
diff --git a/cocos/3d/skeletal-animation/skeletal-animation-state.ts b/cocos/3d/skeletal-animation/skeletal-animation-state.ts
index 2492a96d3c..463188cd86 100644
--- a/cocos/3d/skeletal-animation/skeletal-animation-state.ts
+++ b/cocos/3d/skeletal-animation/skeletal-animation-state.ts
@@ -183,6 +183,7 @@ export class SkeletalAnimationState extends AnimationState {
users.forEach((user) => {
user.uploadAnimation(clip);
});
+ info.data[0] = -1; // reset frame index to -1. sampleCurves will calculate frame to 0.
}
const curFrame = (ratio * this._frames + 0.5) | 0;
diff --git a/cocos/3d/skeletal-animation/skeletal-animation-utils.ts b/cocos/3d/skeletal-animation/skeletal-animation-utils.ts
index c61fb079c8..d9a41f0757 100644
--- a/cocos/3d/skeletal-animation/skeletal-animation-utils.ts
+++ b/cocos/3d/skeletal-animation/skeletal-animation-utils.ts
@@ -179,7 +179,11 @@ export class JointTexturePool {
public registerCustomTextureLayouts (layouts: ICustomJointTextureLayout[]) {
for (let i = 0; i < layouts.length; i++) {
const layout = layouts[i];
- const chunkIdx = this._customPool.createChunk(layout.textureLength);
+ let textureLength = layout.textureLength;
+ if (!(this._device.getFormatFeatures(Format.RGBA32F) & FormatFeatureBit.SAMPLED_TEXTURE)) {
+ textureLength *= 2; // RGBA8 format textures need 4 times the memory.
+ }
+ const chunkIdx = this._customPool.createChunk(textureLength);
for (let j = 0; j < layout.contents.length; j++) {
const content = layout.contents[j];
const { skeleton } = content;
@@ -489,7 +493,6 @@ export class JointAnimationInfo {
info.currentClip = clip;
info.data[0] = 0; // reset default frame 0
info.buffer.update(info.data);
- info.data[0] = -1; // reset frame index to -1. sampleCurves will calculate frame to 0.
info.dirty = false;
if (JSB) {
info.dirtyForJSB[0] = 0;
diff --git a/cocos/3d/skinned-mesh-renderer/skinned-mesh-batch-renderer.ts b/cocos/3d/skinned-mesh-renderer/skinned-mesh-batch-renderer.ts
index 62cd981b16..bf8f4a08bb 100644
--- a/cocos/3d/skinned-mesh-renderer/skinned-mesh-batch-renderer.ts
+++ b/cocos/3d/skinned-mesh-renderer/skinned-mesh-batch-renderer.ts
@@ -114,7 +114,7 @@ export class SkinnedMeshUnit {
if (!comp) { return; }
this.mesh = comp.mesh;
this.skeleton = comp.skeleton;
- this.material = comp.getMaterial(0);
+ this.material = comp.getSharedMaterial(0);
if (comp.skinningRoot) { getWorldTransformUntilRoot(comp.node, comp.skinningRoot, this._localTransform); }
}
@@ -223,7 +223,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
public cookMaterials () {
if (!this._batchMaterial) {
- this._batchMaterial = this.getMaterial(0);
+ this._batchMaterial = this.getSharedMaterial(0);
}
const mat = this.getMaterialInstance(0);
if (!mat || !this._batchMaterial || !this._batchMaterial.effectAsset) {
diff --git a/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts b/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts
index 408dc2ccac..53fc8c2fb8 100644
--- a/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts
+++ b/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts
@@ -80,9 +80,9 @@ export class SkinnedMeshRenderer extends MeshRenderer {
}
set skinningRoot (value) {
+ if (value === this._skinningRoot) { return; }
this._skinningRoot = value;
this._tryBindAnimation();
- if (value === this._skinningRoot) { return; }
this._update();
}
diff --git a/cocos/asset/asset-manager/config.ts b/cocos/asset/asset-manager/config.ts
index 6f76b0c702..adb275aa25 100644
--- a/cocos/asset/asset-manager/config.ts
+++ b/cocos/asset/asset-manager/config.ts
@@ -26,6 +26,7 @@ import { Asset } from '../assets';
import { js, cclegacy } from '../../core';
import Cache from './cache';
import { decodeUuid, normalize } from './helper';
+import { legacyCC } from '../../core/global-exports';
export interface IConfigOption {
importBase: string;
@@ -147,7 +148,7 @@ const isMatchByWord = (path: string, test: string): boolean => {
};
const processOptions = (options: IConfigOption) => {
- if (EDITOR || TEST) { return; }
+ if ((EDITOR && !legacyCC.GAME_VIEW) || TEST) { return; }
let uuids = options.uuids;
const paths = options.paths;
const types = options.types;
diff --git a/cocos/asset/asset-manager/downloader.ts b/cocos/asset/asset-manager/downloader.ts
index a8f69c594f..21e1093cad 100644
--- a/cocos/asset/asset-manager/downloader.ts
+++ b/cocos/asset/asset-manager/downloader.ts
@@ -32,6 +32,7 @@ import { files } from './shared';
import { retry, RetryFunction, urlAppendTimestamp } from './utilities';
import { IConfigOption } from './config';
import { CCON, parseCCONJson, decodeCCONBinary } from '../../serialization/ccon';
+import { legacyCC } from '../../core/global-exports';
export type DownloadHandler = (url: string, options: Record, onComplete: ((err: Error | null, data?: any | null) => void)) => void;
@@ -122,7 +123,7 @@ const downloadBundle = (nameOrUrl: string, options: Record, onCompl
url = `assets/${bundleName}`;
}
}
- const version = options.version || downloader.bundleVers![bundleName];
+ const version = options.version || downloader.bundleVers[bundleName];
let count = 0;
const config = `${url}/config.${version ? `${version}.` : ''}json`;
let out: IConfigOption | null = null;
@@ -213,12 +214,12 @@ export class Downloader {
* You don't need to change it at runtime.
* @internal
*/
- public appendTimeStamp = !!EDITOR;
+ public appendTimeStamp = !!(EDITOR && !legacyCC.GAME_VIEW);
/**
* @engineInternal
*/
- public limited = !EDITOR;
+ public limited = !(EDITOR && !legacyCC.GAME_VIEW);
/**
* @en
@@ -231,14 +232,14 @@ export class Downloader {
public retryInterval = 2000;
/**
- * Version information of all bundles.
- * @engineInternal
+ * @en Version information of all bundles.
+ * @zh 所有包的版本信息。
*/
- public bundleVers: Record | null = null;
+ public bundleVers: Record = {};
/**
- * Remote bundle list.
- * @engineInternal
+ * @en The names of remote bundles.
+ * @zh 远程包名列表。
*/
public remoteBundles: ReadonlyArray = [];
diff --git a/cocos/asset/assets/render-texture.ts b/cocos/asset/assets/render-texture.ts
index d18846da0b..9ca06bf965 100644
--- a/cocos/asset/assets/render-texture.ts
+++ b/cocos/asset/assets/render-texture.ts
@@ -25,7 +25,8 @@
import { ccclass } from 'cc.decorator';
import { EDITOR, TEST } from 'internal:constants';
import { clamp, cclegacy, errorID } from '../../core';
-import { Texture, ColorAttachment, DepthStencilAttachment, GeneralBarrierInfo, AccessFlagBit, RenderPassInfo, Format, deviceManager, BufferTextureCopy } from '../../gfx';
+import { Texture, ColorAttachment, DepthStencilAttachment, GeneralBarrierInfo, AccessFlagBit, RenderPassInfo, Format, deviceManager,
+ BufferTextureCopy, TextureFlags, TextureFlagBit } from '../../gfx';
import { RenderWindow, IRenderWindowInfo } from '../../render-scene/core/render-window';
import { Root } from '../../root';
import { TextureBase } from './texture-base';
@@ -35,6 +36,9 @@ export interface IRenderTextureCreateInfo {
width: number;
height: number;
passInfo?: RenderPassInfo;
+ externalResLow?: number; // for vulkan vkImage/opengl es texture created from external
+ externalResHigh?: number; // for vulkan vkImage created from external
+ externalFlag?: TextureFlags; // external texture type normal or oes
}
const _colorAttachment = new ColorAttachment();
@@ -168,6 +172,9 @@ export class RenderTexture extends TextureBase {
_windowInfo.width = this._width;
_windowInfo.height = this._height;
_windowInfo.renderPassInfo = info && info.passInfo ? info.passInfo : passInfo;
+ _windowInfo.externalResLow = info && info.externalResLow ? info.externalResLow : 0;
+ _windowInfo.externalResHigh = info && info.externalResHigh ? info.externalResHigh : 0;
+ _windowInfo.externalFlag = info && info.externalFlag ? info.externalFlag : TextureFlagBit.NONE;
_colorAttachment.barrier = deviceManager.gfxDevice.getGeneralBarrier(new GeneralBarrierInfo(
AccessFlagBit.FRAGMENT_SHADER_READ_TEXTURE,
diff --git a/cocos/asset/assets/texture-cube.ts b/cocos/asset/assets/texture-cube.ts
index da22a7099b..782c089a4d 100644
--- a/cocos/asset/assets/texture-cube.ts
+++ b/cocos/asset/assets/texture-cube.ts
@@ -22,7 +22,7 @@
THE SOFTWARE.
*/
-import { EDITOR, TEST, VIVO, WECHAT, WECHAT_MINI_PROGRAM } from 'internal:constants';
+import { EDITOR, OPPO, TEST, VIVO, WECHAT, WECHAT_MINI_PROGRAM } from 'internal:constants';
import { ccclass, serializable } from 'cc.decorator';
import { TextureType, TextureInfo, TextureViewInfo, BufferTextureCopy } from '../../gfx';
import { ImageAsset } from './image-asset';
@@ -190,7 +190,7 @@ export class TextureCube extends SimpleTexture {
}
//In ios wechat mini-game platform drawImage and getImageData can not get correct data,so upload to gfxTexture than use readPixels to get data
//The performance of upload to gfxTexture and readPixels is not good, so only use this way in the ios wechat mini-game platform
- if (((WECHAT || WECHAT_MINI_PROGRAM) && sys.os === OS.IOS) || VIVO) {
+ if (((WECHAT || WECHAT_MINI_PROGRAM) && sys.os === OS.IOS) || VIVO || OPPO) {
this._uploadAtlas();
return;
}
diff --git a/cocos/core/utils/misc.ts b/cocos/core/utils/misc.ts
index 7648639fdd..81b28b250d 100644
--- a/cocos/core/utils/misc.ts
+++ b/cocos/core/utils/misc.ts
@@ -30,6 +30,7 @@ import { getClassName, getset, isEmptyObject } from './js';
import { legacyCC } from '../global-exports';
import { warnID } from '../platform/debug';
import { macro } from '../platform/macro';
+import { setTimeoutRAF } from '../../../pal/utils';
export const BUILTIN_CLASSID_RE = /^(?:cc|dragonBones|sp|ccsg)\..+/;
@@ -163,7 +164,7 @@ export function isDomNode (node) {
*/
export function callInNextTick (callback, p1?: any, p2?: any) {
if (callback) {
- setTimeout(() => {
+ setTimeoutRAF(() => {
callback(p1, p2);
}, 0);
}
diff --git a/cocos/core/value-types/bitmask.ts b/cocos/core/value-types/bitmask.ts
index 24fa654792..50385421d6 100644
--- a/cocos/core/value-types/bitmask.ts
+++ b/cocos/core/value-types/bitmask.ts
@@ -107,16 +107,35 @@ BitMask.getList = (BitMaskDef) => {
return BitMaskDef.__bitmask__;
}
- const bitlist: any[] = BitMaskDef.__bitmask__ = [];
+ return BitMask.update(BitMaskDef);
+};
+
+/**
+ * @en
+ * Update BitMask object properties.
+ * @zh
+ * 更新 BitMask 对象的属性列表。
+ *
+ * @param BitMaskDef
+ * @returns @en A sorted array with integer values. @zh 存储整型属性值的数组。该数组已排序。
+ */
+BitMask.update = (BitMaskDef) => {
+ if (!Array.isArray(BitMaskDef.__bitmask__)) {
+ BitMaskDef.__bitmask__ = [];
+ }
+
+ const bitList = BitMaskDef.__bitmask__;
+ bitList.length = 0;
for (const name in BitMaskDef) {
const v = BitMaskDef[name];
if (Number.isInteger(v)) {
- bitlist.push({ name, value: v });
+ bitList.push({ name, value: v });
}
}
- bitlist.sort((a, b) => a.value - b.value);
- return bitlist;
+ bitList.sort((a, b) => a.value - b.value);
+
+ return bitList;
};
/**
diff --git a/cocos/dragon-bones/CCFactory.ts b/cocos/dragon-bones/CCFactory.ts
index ef07e54485..b8e541d85a 100644
--- a/cocos/dragon-bones/CCFactory.ts
+++ b/cocos/dragon-bones/CCFactory.ts
@@ -39,7 +39,6 @@ const { ccclass } = _decorator;
* DragonBones factory
* @class CCFactory
* @extends BaseFactory
- * @engineInternal
* @en Usually only one global factory instance is needed. The factory creates
* Armature object by parsing DragonBonesData and TextureAtlasData instances,
* and is responsible for global updating the Dragonbones component animation
diff --git a/cocos/game/splash-screen.ts b/cocos/game/splash-screen.ts
index 1dd356b60c..0bc847b3a2 100644
--- a/cocos/game/splash-screen.ts
+++ b/cocos/game/splash-screen.ts
@@ -32,7 +32,7 @@ import {
} from '../gfx';
import { PipelineStateManager } from '../rendering';
import { SetIndex } from '../rendering/define';
-import { ccwindow } from '../core/global-exports';
+import { ccwindow, legacyCC } from '../core/global-exports';
import { XREye } from '../xr/xr-enums';
const v2_0 = new Vec2();
@@ -502,7 +502,7 @@ export class SplashScreen {
device.flushCommands([cmdBuff]);
device.queue.submit([cmdBuff]);
device.present();
- device.enableAutoBarrier(false);
+ device.enableAutoBarrier(!legacyCC.rendering);
if (sys.isXR) {
xr.entry.renderLoopEnd(xrEye);
diff --git a/cocos/gfx/base/define.ts b/cocos/gfx/base/define.ts
index 2f99290d7c..d756533edf 100644
--- a/cocos/gfx/base/define.ts
+++ b/cocos/gfx/base/define.ts
@@ -400,6 +400,8 @@ export enum TextureFlagBit {
NONE = 0,
GEN_MIPMAP = 0x1, // Generate mipmaps using bilinear filter
GENERAL_LAYOUT = 0x2, // For inout framebuffer attachments
+ EXTERNAL_OES = 0x4, // External oes texture
+ EXTERNAL_NORMAL = 0x8, // External normal texture
}
export enum FormatFeatureBit {
diff --git a/cocos/gfx/webgl2/webgl2-commands.ts b/cocos/gfx/webgl2/webgl2-commands.ts
index f9a4f2c830..26657fc6b4 100644
--- a/cocos/gfx/webgl2/webgl2-commands.ts
+++ b/cocos/gfx/webgl2/webgl2-commands.ts
@@ -2756,6 +2756,20 @@ export function WebGL2CmdFuncExecuteCmds (device: WebGL2Device, cmdPackage: WebG
} // for
}
+function toUseTexImage2D (texImages: Readonly, regions: Readonly) {
+ if (texImages.length > 1 || regions.length > 1) return false;
+ const isVideoElement = texImages[0] instanceof HTMLVideoElement;
+ if (isVideoElement) {
+ const videoElement = texImages[0] as HTMLVideoElement;
+ const isSameSize = regions[0].texOffset.x === 0
+ && regions[0].texOffset.y === 0
+ && regions[0].texExtent.width === videoElement.videoWidth
+ && regions[0].texExtent.height === videoElement.videoHeight;
+ return isSameSize;
+ }
+ return false;
+}
+
export function WebGL2CmdFuncCopyTexImagesToTexture (
device: WebGL2Device,
texImages: Readonly,
@@ -2774,11 +2788,16 @@ export function WebGL2CmdFuncCopyTexImagesToTexture (
switch (gpuTexture.glTarget) {
case gl.TEXTURE_2D: {
- for (let k = 0; k < regions.length; k++) {
- const region = regions[k];
- gl.texSubImage2D(gl.TEXTURE_2D, region.texSubres.mipLevel,
- region.texOffset.x, region.texOffset.y,
- gpuTexture.glFormat, gpuTexture.glType, texImages[n++]);
+ if (toUseTexImage2D(texImages, regions)) {
+ gl.texImage2D(gl.TEXTURE_2D, regions[0].texSubres.mipLevel, gpuTexture.glInternalFmt, regions[0].texExtent.width,
+ regions[0].texExtent.height, 0, gpuTexture.glFormat, gpuTexture.glType, texImages[0]);
+ } else {
+ for (let k = 0; k < regions.length; k++) {
+ const region = regions[k];
+ gl.texSubImage2D(gl.TEXTURE_2D, region.texSubres.mipLevel,
+ region.texOffset.x, region.texOffset.y,
+ gpuTexture.glFormat, gpuTexture.glType, texImages[n++]);
+ }
}
break;
}
diff --git a/cocos/gfx/webgl2/webgl2-swapchain.ts b/cocos/gfx/webgl2/webgl2-swapchain.ts
index fac8c5ba90..83b9ff4329 100644
--- a/cocos/gfx/webgl2/webgl2-swapchain.ts
+++ b/cocos/gfx/webgl2/webgl2-swapchain.ts
@@ -120,7 +120,7 @@ export function getExtensions (gl: WebGL2RenderingContext) {
export function getContext (canvas: HTMLCanvasElement): WebGL2RenderingContext | null {
let context: WebGL2RenderingContext | null = null;
try {
- if (globalThis.__globalXR.webxrCompatible) {
+ if (globalThis.__globalXR?.webxrCompatible) {
const glAttribs = {
alpha: macro.ENABLE_TRANSPARENT_CANVAS,
antialias: EDITOR || macro.ENABLE_WEBGL_ANTIALIAS,
diff --git a/cocos/input/input.ts b/cocos/input/input.ts
index 21266351fa..d0ca4c8f1c 100644
--- a/cocos/input/input.ts
+++ b/cocos/input/input.ts
@@ -347,6 +347,7 @@ export class Input {
const eventGamepadList = this._eventGamepadList;
GamepadInputDevice._on(InputEventType.GAMEPAD_CHANGE, (event) => { this._dispatchOrPushEvent(event, eventGamepadList); });
GamepadInputDevice._on(InputEventType.GAMEPAD_INPUT, (event) => { this._dispatchOrPushEvent(event, eventGamepadList); });
+ GamepadInputDevice._on(InputEventType.HANDLE_POSE_INPUT, (event) => { this._dispatchOrPushEvent(event, eventGamepadList); });
}
if (sys.hasFeature(sys.Feature.EVENT_HANDLE)) {
diff --git a/cocos/misc/deprecated.ts b/cocos/misc/deprecated.ts
index 9d7f7c3b5c..2e6580ab35 100644
--- a/cocos/misc/deprecated.ts
+++ b/cocos/misc/deprecated.ts
@@ -26,8 +26,9 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { Camera } from './camera-component';
-import { replaceProperty, cclegacy, js } from '../core';
+import { replaceProperty, cclegacy, js, markAsWarning } from '../core';
import { ModelRenderer } from './model-renderer';
+import { Renderer } from './renderer';
replaceProperty(Camera, 'Camera', [
{
@@ -51,6 +52,14 @@ replaceProperty(Camera.prototype, 'Camera.prototype', [
},
]);
+// deprecate Renderer API
+markAsWarning(Renderer.prototype, 'Renderer.prototype', [
+ {
+ name: 'getMaterial',
+ suggest: 'please use renderer.getSharedMaterial instead.',
+ },
+]);
+
/**
* Alias of [[Camera]]
* @deprecated Since v1.2
diff --git a/cocos/misc/renderer.ts b/cocos/misc/renderer.ts
index 03451cb5a8..94600d2434 100644
--- a/cocos/misc/renderer.ts
+++ b/cocos/misc/renderer.ts
@@ -60,7 +60,7 @@ export class Renderer extends Component {
* @zh 获取默认的共享材质
*/
get sharedMaterial () {
- return this.getMaterial(0);
+ return this.getSharedMaterial(0);
}
/**
@@ -138,11 +138,18 @@ export class Renderer extends Component {
protected _materialInstances: (MaterialInstance | null)[] = [];
+ /**
+ * @deprecated Since v3.7.3, please use [[getSharedMaterial]] instead.
+ */
+ public getMaterial (idx: number): Material | null {
+ return this.getSharedMaterial(idx);
+ }
+
/**
* @en Get the shared material asset of the specified sub-model.
* @zh 获取指定子模型的共享材质资源。
*/
- public getMaterial (idx: number): Material | null {
+ public getSharedMaterial (idx: number): Material | null {
if (idx < 0 || idx >= this._materials.length) {
return null;
}
diff --git a/cocos/particle/animator/gradient-range.ts b/cocos/particle/animator/gradient-range.ts
index c4b3f5c299..7f2ed92469 100644
--- a/cocos/particle/animator/gradient-range.ts
+++ b/cocos/particle/animator/gradient-range.ts
@@ -219,7 +219,7 @@ export function packGradientRange (tex: Texture2D | null, data: Uint8Array | nul
if (data === null || data.length !== len) {
data = new Uint8Array(samples * height * 4);
}
- const interval = 1.0 / (samples);
+ const interval = 1.0 / (samples - 1);
let offset = 0;
for (let h = 0; h < height; h++) {
diff --git a/cocos/particle/animator/gradient.ts b/cocos/particle/animator/gradient.ts
index acb5d1468d..5be0f04b78 100644
--- a/cocos/particle/animator/gradient.ts
+++ b/cocos/particle/animator/gradient.ts
@@ -22,7 +22,7 @@
THE SOFTWARE.
*/
-import { CCClass, Color, lerp, repeat, Enum } from '../../core';
+import { CCClass, Color, lerp, repeat, Enum, EPSILON, approx } from '../../core';
const Mode = Enum({
Blend: 0,
@@ -161,7 +161,7 @@ export default class Gradient {
private getRGB (time: number) {
if (this.colorKeys.length > 1) {
- time = repeat(time, 1);
+ time = repeat(time, 1.0 + EPSILON);
for (let i = 1; i < this.colorKeys.length; ++i) {
const preTime = this.colorKeys[i - 1].time;
const curTime = this.colorKeys[i].time;
@@ -175,7 +175,9 @@ export default class Gradient {
}
}
const lastIndex = this.colorKeys.length - 1;
- if (time < this.colorKeys[0].time) {
+ if (approx(time, this.colorKeys[lastIndex].time, EPSILON)) {
+ this._color.set(this.colorKeys[lastIndex].color);
+ } else if (time < this.colorKeys[0].time) {
Color.lerp(this._color, Color.BLACK, this.colorKeys[0].color, time / this.colorKeys[0].time);
} else if (time > this.colorKeys[lastIndex].time) {
Color.lerp(this._color, this.colorKeys[lastIndex].color, Color.BLACK, (time - this.colorKeys[lastIndex].time) / (1 - this.colorKeys[lastIndex].time));
@@ -194,7 +196,7 @@ export default class Gradient {
private getAlpha (time: number) {
const basicAlpha = 0; // default alpha is 0
if (this.alphaKeys.length > 1) {
- time = repeat(time, 1);
+ time = repeat(time, 1.0 + EPSILON);
for (let i = 1; i < this.alphaKeys.length; ++i) {
const preTime = this.alphaKeys[i - 1].time;
const curTime = this.alphaKeys[i].time;
@@ -207,7 +209,9 @@ export default class Gradient {
}
}
const lastIndex = this.alphaKeys.length - 1;
- if (time < this.alphaKeys[0].time) {
+ if (approx(time, this.alphaKeys[lastIndex].time, EPSILON)) {
+ return this.alphaKeys[lastIndex].alpha;
+ } else if (time < this.alphaKeys[0].time) {
return lerp(basicAlpha, this.alphaKeys[0].alpha, time / this.alphaKeys[0].time);
} else if (time > this.alphaKeys[lastIndex].time) {
return lerp(this.alphaKeys[lastIndex].alpha, basicAlpha, (time - this.alphaKeys[lastIndex].time) / (1 - this.alphaKeys[lastIndex].time));
diff --git a/cocos/particle/line.ts b/cocos/particle/line.ts
index 23125a6774..58f8ea6284 100644
--- a/cocos/particle/line.ts
+++ b/cocos/particle/line.ts
@@ -69,7 +69,7 @@ export class Line extends ModelRenderer {
@tooltip('i18n:line.material')
@displayName('Material')
get lineMaterial () {
- return this.getMaterial(0);
+ return this.getSharedMaterial(0);
}
set lineMaterial (val) {
diff --git a/cocos/particle/particle-system.ts b/cocos/particle/particle-system.ts
index 9071e26f25..747aa61a5d 100644
--- a/cocos/particle/particle-system.ts
+++ b/cocos/particle/particle-system.ts
@@ -1041,7 +1041,11 @@ export class ParticleSystem extends ModelRenderer {
* @zh 获取当前粒子数量。
*/
public getParticleCount () {
- return this.processor.getParticleCount();
+ if (this.processor) {
+ return this.processor.getParticleCount();
+ } else {
+ return 0;
+ }
}
/**
diff --git a/cocos/particle/renderer/particle-system-renderer-data.ts b/cocos/particle/renderer/particle-system-renderer-data.ts
index dc038c5fe4..54644d0090 100644
--- a/cocos/particle/renderer/particle-system-renderer-data.ts
+++ b/cocos/particle/renderer/particle-system-renderer-data.ts
@@ -141,7 +141,7 @@ export default class ParticleSystemRenderer {
if (!this._particleSystem) {
return null;
}
- return this._particleSystem.getMaterial(0) as Material;
+ return this._particleSystem.getSharedMaterial(0) as Material;
}
public set particleMaterial (val: Material | null) {
@@ -221,7 +221,7 @@ export default class ParticleSystemRenderer {
if (!this._particleSystem) {
return null;
}
- return this._particleSystem.getMaterial(1) as Material;
+ return this._particleSystem.getSharedMaterial(1) as Material;
}
public set trailMaterial (val: Material | null) {
diff --git a/cocos/physics-2d/builtin/builtin-world.ts b/cocos/physics-2d/builtin/builtin-world.ts
index d1429b976a..0bd42dfc65 100644
--- a/cocos/physics-2d/builtin/builtin-world.ts
+++ b/cocos/physics-2d/builtin/builtin-world.ts
@@ -94,9 +94,16 @@ export class BuiltinPhysicsWorld implements IPhysicsWorld {
}
js.array.fastRemoveAt(contacts, i);
+
+ const other = contact.shape1 === shape ? contact.shape2 : contact.shape1;
+ const contactIndex = other!._contacts.indexOf(contact);
+ if (contactIndex >= 0) {
+ js.array.fastRemoveAt(other!._contacts, contactIndex);
+ }
}
}
}
+ shape._contacts.length = 0;
}
updateShapeGroup (shape: BuiltinShape2D) {
diff --git a/cocos/render-scene/core/render-window.ts b/cocos/render-scene/core/render-window.ts
index 970b56f156..b59384d657 100644
--- a/cocos/render-scene/core/render-window.ts
+++ b/cocos/render-scene/core/render-window.ts
@@ -25,7 +25,7 @@ import { screenAdapter } from 'pal/screen-adapter';
import { Orientation } from '../../../pal/screen-adapter/enum-type';
import {
TextureType, TextureUsageBit, Format, RenderPass, Texture, Framebuffer,
- RenderPassInfo, Device, TextureInfo, FramebufferInfo, Swapchain, SurfaceTransform,
+ RenderPassInfo, Device, TextureInfo, FramebufferInfo, Swapchain, SurfaceTransform, TextureFlagBit, TextureFlags,
} from '../../gfx';
import { Root } from '../../root';
import { Camera } from '../scene';
@@ -36,6 +36,9 @@ export interface IRenderWindowInfo {
height: number;
renderPassInfo: RenderPassInfo;
swapchain?: Swapchain;
+ externalResLow?: number; // for vulkan vkImage/opengl es texture created from external
+ externalResHigh?: number; // for vulkan vkImage created from external
+ externalFlag?: TextureFlags; // external texture type normal or oes
}
const orientationMap: Record = {
@@ -130,13 +133,19 @@ export class RenderWindow {
this._depthStencilTexture = info.swapchain.depthStencilTexture;
} else {
for (let i = 0; i < info.renderPassInfo.colorAttachments.length; i++) {
- this._colorTextures.push(device.createTexture(new TextureInfo(
+ const textureInfo = new TextureInfo(
TextureType.TEX2D,
TextureUsageBit.COLOR_ATTACHMENT | TextureUsageBit.SAMPLED | TextureUsageBit.TRANSFER_SRC,
info.renderPassInfo.colorAttachments[i].format,
this._width,
this._height,
- )));
+ );
+
+ if (info.externalFlag && (info.externalFlag & TextureFlagBit.EXTERNAL_NORMAL || info.externalFlag & TextureFlagBit.EXTERNAL_OES)) {
+ textureInfo.flags |= info.externalFlag;
+ textureInfo.externalRes = info.externalResLow ? info.externalResLow : 0;
+ }
+ this._colorTextures.push(device.createTexture(textureInfo));
}
if (info.renderPassInfo.depthStencilAttachment.format !== Format.UNKNOWN) {
this._depthStencilTexture = device.createTexture(new TextureInfo(
diff --git a/cocos/render-scene/scene/camera.ts b/cocos/render-scene/scene/camera.ts
index c5305b3e90..fe2e13b1f5 100644
--- a/cocos/render-scene/scene/camera.ts
+++ b/cocos/render-scene/scene/camera.ts
@@ -996,6 +996,12 @@ export class Camera {
if (!this._node) return;
let viewProjDirty = false;
+ const xr = globalThis.__globalXR;
+ if (xr && xr.isWebXR && xr.webXRWindowMap && xr.webXRMatProjs) {
+ const wndXREye = xr.webXRWindowMap.get(this._window);
+ const x = 1 / xr.webXRMatProjs.length;
+ this.setViewportInOrientedSpace(new Rect(x * wndXREye, 0, x, 1));
+ }
// view matrix
if (this._node.hasChangedFlags || forceUpdate) {
Mat4.invert(this._matView, this._node.worldMatrix);
@@ -1016,8 +1022,13 @@ export class Camera {
const projectionSignY = this._device.capabilities.clipSpaceSignY;
// Only for rendertexture processing
if (this._proj === CameraProjection.PERSPECTIVE) {
- Mat4.perspective(this._matProj, this._fov, this._aspect, this._nearClip, this._farClip,
- this._fovAxis === CameraFOVAxis.VERTICAL, this._device.capabilities.clipSpaceMinZ, projectionSignY, orientation);
+ if (xr && xr.isWebXR && xr.webXRWindowMap && xr.webXRMatProjs && xr.webXRMatProjs.length === 2) {
+ const wndXREye = xr.webXRWindowMap.get(this._window);
+ this._matProj.set(xr.webXRMatProjs[wndXREye]);
+ } else {
+ Mat4.perspective(this._matProj, this._fov, this._aspect, this._nearClip, this._farClip,
+ this._fovAxis === CameraFOVAxis.VERTICAL, this._device.capabilities.clipSpaceMinZ, projectionSignY, orientation);
+ }
} else {
const x = this._orthoHeight * this._aspect;
const y = this._orthoHeight;
diff --git a/cocos/rendering/custom/define.ts b/cocos/rendering/custom/define.ts
index f0e17c4039..5bbfb28b34 100644
--- a/cocos/rendering/custom/define.ts
+++ b/cocos/rendering/custom/define.ts
@@ -234,16 +234,9 @@ export function buildFxaaPass (camera: Camera,
fxaaPass.name = `CameraFxaaPass${cameraID}`;
fxaaPass.setViewport(new Viewport(area.x, area.y, width, height));
if (ppl.containsResource(inputRT)) {
- const computeView = new ComputeView();
- computeView.name = 'sceneColorMap';
- fxaaPass.addComputeView(inputRT, computeView);
+ fxaaPass.addTexture(inputRT, 'sceneColorMap');
}
- const fxaaPassView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- LoadOp.CLEAR, StoreOp.STORE,
- camera.clearFlag,
- clearColor);
- fxaaPass.addRasterView(fxaaPassRTName, fxaaPassView);
+ fxaaPass.addRenderTarget(fxaaPassRTName, '_', LoadOp.CLEAR, StoreOp.STORE, clearColor);
fxaaData.fxaaMaterial.setProperty('texSize', new Vec4(width, height, 1.0 / width, 1.0 / height), fxaaPassIdx);
fxaaPass.addQueue(QueueHint.RENDER_TRANSPARENT).addCameraQuad(
camera, fxaaData.fxaaMaterial, fxaaPassIdx,
@@ -345,16 +338,9 @@ export function buildBloomPass (camera: Camera,
bloomPrefilterPass.name = `CameraBloomPrefilterPass${cameraID}`;
bloomPrefilterPass.setViewport(new Viewport(area.x, area.y, width, height));
if (ppl.containsResource(inputRT)) {
- const computeView = new ComputeView();
- computeView.name = 'outputResultMap';
- bloomPrefilterPass.addComputeView(inputRT, computeView);
+ bloomPrefilterPass.addTexture(inputRT, 'outputResultMap');
}
- const prefilterPassView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- LoadOp.CLEAR, StoreOp.STORE,
- camera.clearFlag,
- bloomClearColor);
- bloomPrefilterPass.addRasterView(bloomPassPrefilterRTName, prefilterPassView);
+ bloomPrefilterPass.addRenderTarget(bloomPassPrefilterRTName, '_', LoadOp.CLEAR, StoreOp.STORE, bloomClearColor);
bloomData.bloomMaterial.setProperty('texSize', new Vec4(0, 0, bloomData.threshold, 0), 0);
bloomPrefilterPass.addQueue(QueueHint.RENDER_TRANSPARENT).addCameraQuad(
camera, bloomData.bloomMaterial, 0,
@@ -376,19 +362,12 @@ export function buildBloomPass (camera: Camera,
const bloomDownSamplePass = ppl.addRasterPass(width, height, `bloom-downsample${i}`);
bloomDownSamplePass.name = `CameraBloomDownSamplePass${cameraID}${i}`;
bloomDownSamplePass.setViewport(new Viewport(area.x, area.y, width, height));
- const computeView = new ComputeView();
- computeView.name = 'bloomTexture';
if (i === 0) {
- bloomDownSamplePass.addComputeView(bloomPassPrefilterRTName, computeView);
+ bloomDownSamplePass.addTexture(bloomPassPrefilterRTName, 'bloomTexture');
} else {
- bloomDownSamplePass.addComputeView(`dsBloomPassDownSampleColor${cameraName}${i - 1}`, computeView);
+ bloomDownSamplePass.addTexture(`dsBloomPassDownSampleColor${cameraName}${i - 1}`, 'bloomTexture');
}
- const downSamplePassView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- LoadOp.CLEAR, StoreOp.STORE,
- camera.clearFlag,
- bloomClearColor);
- bloomDownSamplePass.addRasterView(bloomPassDownSampleRTName, downSamplePassView);
+ bloomDownSamplePass.addRenderTarget(bloomPassDownSampleRTName, '_', LoadOp.CLEAR, StoreOp.STORE, bloomClearColor);
bloomData.bloomMaterial.setProperty('texSize', texSize, BLOOM_DOWNSAMPLEPASS_INDEX + i);
bloomDownSamplePass.addQueue(QueueHint.RENDER_TRANSPARENT).addCameraQuad(
camera, bloomData.bloomMaterial, BLOOM_DOWNSAMPLEPASS_INDEX + i,
@@ -411,19 +390,12 @@ export function buildBloomPass (camera: Camera,
const bloomUpSamplePass = ppl.addRasterPass(width, height, `bloom-upsample${i}`);
bloomUpSamplePass.name = `CameraBloomUpSamplePass${cameraID}${bloomData.iterations - 1 - i}`;
bloomUpSamplePass.setViewport(new Viewport(area.x, area.y, width, height));
- const computeView = new ComputeView();
- computeView.name = 'bloomTexture';
if (i === 0) {
- bloomUpSamplePass.addComputeView(`dsBloomPassDownSampleColor${cameraName}${bloomData.iterations - 1}`, computeView);
+ bloomUpSamplePass.addTexture(`dsBloomPassDownSampleColor${cameraName}${bloomData.iterations - 1}`, 'bloomTexture');
} else {
- bloomUpSamplePass.addComputeView(`dsBloomPassUpSampleColor${cameraName}${bloomData.iterations - i}`, computeView);
+ bloomUpSamplePass.addTexture(`dsBloomPassUpSampleColor${cameraName}${bloomData.iterations - i}`, 'bloomTexture');
}
- const upSamplePassView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- LoadOp.CLEAR, StoreOp.STORE,
- camera.clearFlag,
- bloomClearColor);
- bloomUpSamplePass.addRasterView(bloomPassUpSampleRTName, upSamplePassView);
+ bloomUpSamplePass.addRenderTarget(bloomPassUpSampleRTName, '_', LoadOp.CLEAR, StoreOp.STORE, bloomClearColor);
bloomData.bloomMaterial.setProperty('texSize', texSize, BLOOM_UPSAMPLEPASS_INDEX + i);
bloomUpSamplePass.addQueue(QueueHint.RENDER_TRANSPARENT).addCameraQuad(
camera, bloomData.bloomMaterial, BLOOM_UPSAMPLEPASS_INDEX + i,
@@ -445,18 +417,9 @@ export function buildBloomPass (camera: Camera,
const bloomCombinePass = ppl.addRasterPass(width, height, 'bloom-combine');
bloomCombinePass.name = `CameraBloomCombinePass${cameraID}`;
bloomCombinePass.setViewport(new Viewport(area.x, area.y, width, height));
- const computeViewOut = new ComputeView();
- computeViewOut.name = 'outputResultMap';
- bloomCombinePass.addComputeView(inputRT, computeViewOut);
- const computeViewBt = new ComputeView();
- computeViewBt.name = 'bloomTexture';
- bloomCombinePass.addComputeView(`dsBloomPassUpSampleColor${cameraName}${0}`, computeViewBt);
- const combinePassView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- LoadOp.CLEAR, StoreOp.STORE,
- camera.clearFlag,
- bloomClearColor);
- bloomCombinePass.addRasterView(bloomPassCombineRTName, combinePassView);
+ bloomCombinePass.addTexture(inputRT, 'outputResultMap');
+ bloomCombinePass.addTexture(`dsBloomPassUpSampleColor${cameraName}${0}`, 'bloomTexture');
+ bloomCombinePass.addRenderTarget(bloomPassCombineRTName, '_', LoadOp.CLEAR, StoreOp.STORE, bloomClearColor);
bloomData.bloomMaterial.setProperty('texSize', new Vec4(0, 0, 0, bloomData.intensity), BLOOM_COMBINEPASS_INDEX);
bloomCombinePass.addQueue(QueueHint.RENDER_TRANSPARENT).addCameraQuad(
camera, bloomData.bloomMaterial, BLOOM_COMBINEPASS_INDEX,
@@ -507,7 +470,7 @@ export function buildPostprocessPass (camera: Camera,
const postprocessPassRTName = `postprocessPassRTName${cameraID}`;
const postprocessPassDS = `postprocessPassDS${cameraID}`;
if (!ppl.containsResource(postprocessPassRTName)) {
- ppl.addRenderTexture(postprocessPassRTName, Format.BGRA8, width, height, camera.window);
+ ppl.addRenderWindow(postprocessPassRTName, Format.BGRA8, width, height, camera.window);
ppl.addDepthStencil(postprocessPassDS, Format.DEPTH_STENCIL, width, height, ResourceResidency.MANAGED);
}
ppl.updateRenderWindow(postprocessPassRTName, camera.window);
@@ -516,9 +479,7 @@ export function buildPostprocessPass (camera: Camera,
postprocessPass.name = `CameraPostprocessPass${cameraID}`;
postprocessPass.setViewport(new Viewport(area.x, area.y, area.width, area.height));
if (ppl.containsResource(inputTex)) {
- const computeView = new ComputeView();
- computeView.name = 'outputResultMap';
- postprocessPass.addComputeView(inputTex, computeView);
+ postprocessPass.addTexture(inputTex, 'outputResultMap');
}
const postClearColor = new Color(0, 0, 0, camera.clearColor.w);
if (camera.clearFlag & ClearFlagBit.COLOR) {
@@ -526,25 +487,14 @@ export function buildPostprocessPass (camera: Camera,
postClearColor.y = camera.clearColor.y;
postClearColor.z = camera.clearColor.z;
}
- const postprocessPassView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.RENDER_TARGET),
- StoreOp.STORE,
- camera.clearFlag,
- postClearColor);
- const postprocessPassDSView = new RasterView('_',
- AccessType.WRITE, AttachmentType.DEPTH_STENCIL,
+ postprocessPass.addRenderTarget(postprocessPassRTName, '_',
+ getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.RENDER_TARGET), StoreOp.STORE, postClearColor);
+ postprocessPass.addDepthStencil(postprocessPassDS, '_',
getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.DEPTH_STENCIL),
- StoreOp.STORE,
- camera.clearFlag,
- new Color(camera.clearDepth, camera.clearStencil, 0, 0));
- postprocessPass.addRasterView(postprocessPassRTName, postprocessPassView);
- postprocessPass.addRasterView(postprocessPassDS, postprocessPassDSView);
+ StoreOp.STORE, camera.clearDepth, camera.clearStencil, camera.clearFlag);
postprocessPass.addQueue(QueueHint.NONE).addFullscreenQuad(
postInfo.postMaterial, 0, SceneFlags.NONE,
);
- postprocessPass.addQueue(QueueHint.RENDER_TRANSPARENT).addSceneOfCamera(camera, new LightInfo(),
- SceneFlags.UI);
if (getProfilerCamera() === camera) {
postprocessPass.showStatistics = true;
}
@@ -568,7 +518,7 @@ export function buildForwardPass (camera: Camera,
const forwardPassDSName = `dsForwardPassDS${cameraName}`;
if (!ppl.containsResource(forwardPassRTName)) {
if (!isOffScreen) {
- ppl.addRenderTexture(forwardPassRTName, Format.BGRA8, width, height, camera.window);
+ ppl.addRenderWindow(forwardPassRTName, Format.BGRA8, width, height, camera.window);
} else {
ppl.addRenderTarget(forwardPassRTName, Format.RGBA16F, width, height, ResourceResidency.MANAGED);
}
@@ -586,30 +536,24 @@ export function buildForwardPass (camera: Camera,
forwardPass.setViewport(new Viewport(area.x, area.y, width, height));
for (const dirShadowName of cameraInfo.mainLightShadowNames) {
if (ppl.containsResource(dirShadowName)) {
- const computeView = new ComputeView('cc_shadowMap');
- forwardPass.addComputeView(dirShadowName, computeView);
+ forwardPass.addTexture(dirShadowName, 'cc_shadowMap');
}
}
for (const spotShadowName of cameraInfo.spotLightShadowNames) {
if (ppl.containsResource(spotShadowName)) {
- const computeView = new ComputeView('cc_spotShadowMap');
- forwardPass.addComputeView(spotShadowName, computeView);
+ forwardPass.addTexture(spotShadowName, 'cc_spotShadowMap');
}
}
- const passView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
+ forwardPass.addRenderTarget(forwardPassRTName, '_',
isOffScreen ? LoadOp.CLEAR : getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.RENDER_TARGET),
StoreOp.STORE,
- camera.clearFlag,
new Color(camera.clearColor.x, camera.clearColor.y, camera.clearColor.z, camera.clearColor.w));
- const passDSView = new RasterView('_',
- AccessType.WRITE, AttachmentType.DEPTH_STENCIL,
+ forwardPass.addDepthStencil(forwardPassDSName, '_',
isOffScreen ? LoadOp.CLEAR : getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.DEPTH_STENCIL),
StoreOp.STORE,
- camera.clearFlag,
- new Color(camera.clearDepth, camera.clearStencil, 0, 0));
- forwardPass.addRasterView(forwardPassRTName, passView);
- forwardPass.addRasterView(forwardPassDSName, passDSView);
+ camera.clearDepth,
+ camera.clearStencil,
+ camera.clearFlag);
forwardPass
.addQueue(QueueHint.RENDER_OPAQUE)
.addSceneOfCamera(camera, new LightInfo(),
@@ -647,16 +591,9 @@ export function buildShadowPass (passName: Readonly,
const pass = ppl.addRasterPass(width, height, 'default');
pass.name = passName;
pass.setViewport(new Viewport(area.x, area.y, area.width, area.height));
- pass.addRasterView(shadowMapName, new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- LoadOp.CLEAR, StoreOp.STORE,
- ClearFlagBit.COLOR,
- new Color(1, 1, 1, camera.clearColor.w)));
- pass.addRasterView(`${shadowMapName}Depth`, new RasterView('_',
- AccessType.WRITE, AttachmentType.DEPTH_STENCIL,
- LoadOp.CLEAR, StoreOp.DISCARD,
- ClearFlagBit.DEPTH_STENCIL,
- new Color(camera.clearDepth, camera.clearStencil, 0, 0)));
+ pass.addRenderTarget(shadowMapName, '_', LoadOp.CLEAR, StoreOp.STORE, new Color(1, 1, 1, camera.clearColor.w));
+ pass.addDepthStencil(`${shadowMapName}Depth`, '_', LoadOp.CLEAR, StoreOp.DISCARD,
+ camera.clearDepth, camera.clearStencil, ClearFlagBit.DEPTH_STENCIL);
const queue = pass.addQueue(QueueHint.RENDER_OPAQUE);
queue.addSceneOfCamera(camera, new LightInfo(light, level),
SceneFlags.SHADOW_CASTER);
@@ -694,7 +631,7 @@ export function buildReflectionProbePass (camera: Camera,
probe.updateCameraDir(faceIdx);
if (!ppl.containsResource(probePassRTName)) {
- ppl.addRenderTexture(probePassRTName, Format.RGBA8, width, height, renderWindow);
+ ppl.addRenderWindow(probePassRTName, Format.RGBA8, width, height, renderWindow);
ppl.addDepthStencil(probePassDSName, Format.DEPTH_STENCIL, width, height, ResourceResidency.MANAGED);
}
ppl.updateRenderWindow(probePassRTName, renderWindow);
@@ -703,21 +640,10 @@ export function buildReflectionProbePass (camera: Camera,
const probePass = ppl.addRasterPass(width, height, 'default');
probePass.name = `ReflectionProbePass${faceIdx}`;
probePass.setViewport(new Viewport(0, 0, width, height));
-
- const passView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- getLoadOpOfClearFlag(probeCamera.clearFlag, AttachmentType.RENDER_TARGET),
- StoreOp.STORE,
- probeCamera.clearFlag,
- new Color(probeCamera.clearColor.x, probeCamera.clearColor.y, probeCamera.clearColor.z, probeCamera.clearColor.w));
- const passDSView = new RasterView('_',
- AccessType.WRITE, AttachmentType.DEPTH_STENCIL,
- getLoadOpOfClearFlag(probeCamera.clearFlag, AttachmentType.DEPTH_STENCIL),
- StoreOp.STORE,
- probeCamera.clearFlag,
- new Color(probeCamera.clearDepth, probeCamera.clearStencil, 0, 0));
- probePass.addRasterView(probePassRTName, passView);
- probePass.addRasterView(probePassDSName, passDSView);
+ probePass.addRenderTarget(probePassRTName, '_', getLoadOpOfClearFlag(probeCamera.clearFlag, AttachmentType.RENDER_TARGET),
+ StoreOp.STORE, new Color(probeCamera.clearColor.x, probeCamera.clearColor.y, probeCamera.clearColor.z, probeCamera.clearColor.w));
+ probePass.addDepthStencil(probePassDSName, '_', getLoadOpOfClearFlag(probeCamera.clearFlag, AttachmentType.DEPTH_STENCIL),
+ StoreOp.STORE, probeCamera.clearDepth, probeCamera.clearStencil, probeCamera.clearFlag);
const passBuilder = probePass.addQueue(QueueHint.RENDER_OPAQUE);
passBuilder.addSceneOfCamera(camera, new LightInfo(), SceneFlags.REFLECTION_PROBE);
updateCameraUBO(passBuilder as unknown as any, probeCamera, ppl);
@@ -824,30 +750,10 @@ export function buildGBufferPass (camera: Camera,
rtColor.z = camera.clearColor.z;
}
}
- const passColorView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- LoadOp.CLEAR, StoreOp.STORE,
- camera.clearFlag,
- rtColor);
- const passNormalView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- LoadOp.CLEAR, StoreOp.STORE,
- camera.clearFlag,
- new Color(0, 0, 0, 0));
- const passEmissiveView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- LoadOp.CLEAR, StoreOp.STORE,
- camera.clearFlag,
- new Color(0, 0, 0, 0));
- const passDSView = new RasterView('_',
- AccessType.WRITE, AttachmentType.DEPTH_STENCIL,
- LoadOp.CLEAR, StoreOp.STORE,
- camera.clearFlag,
- new Color(camera.clearDepth, camera.clearStencil, 0, 0));
- gBufferPass.addRasterView(gBufferPassRTName, passColorView);
- gBufferPass.addRasterView(gBufferPassNormal, passNormalView);
- gBufferPass.addRasterView(gBufferPassEmissive, passEmissiveView);
- gBufferPass.addRasterView(gBufferPassDSName, passDSView);
+ gBufferPass.addRenderTarget(gBufferPassRTName, '_', LoadOp.CLEAR, StoreOp.STORE, rtColor);
+ gBufferPass.addRenderTarget(gBufferPassNormal, '_', LoadOp.CLEAR, StoreOp.STORE, new Color(0, 0, 0, 0));
+ gBufferPass.addRenderTarget(gBufferPassEmissive, '_', LoadOp.CLEAR, StoreOp.STORE, new Color(0, 0, 0, 0));
+ gBufferPass.addDepthStencil(gBufferPassDSName, '_', LoadOp.CLEAR, StoreOp.STORE, camera.clearDepth, camera.clearStencil, camera.clearFlag);
gBufferPass
.addQueue(QueueHint.RENDER_OPAQUE)
.addSceneOfCamera(camera, new LightInfo(), SceneFlags.OPAQUE_OBJECT | SceneFlags.CUTOUT_OBJECT);
@@ -905,32 +811,19 @@ export function buildLightingPass (camera: Camera, ppl: Pipeline, gBuffer: GBuff
lightingPass.setViewport(new Viewport(area.x, area.y, width, height));
for (const dirShadowName of cameraInfo.mainLightShadowNames) {
if (ppl.containsResource(dirShadowName)) {
- const computeView = new ComputeView('cc_shadowMap');
- lightingPass.addComputeView(dirShadowName, computeView);
+ lightingPass.addTexture(dirShadowName, 'cc_shadowMap');
}
}
for (const spotShadowName of cameraInfo.spotLightShadowNames) {
if (ppl.containsResource(spotShadowName)) {
- const computeView = new ComputeView('cc_spotShadowMap');
- lightingPass.addComputeView(spotShadowName, computeView);
+ lightingPass.addTexture(spotShadowName, 'cc_spotShadowMap');
}
}
if (ppl.containsResource(gBuffer.color)) {
- const computeView = new ComputeView();
- computeView.name = 'gbuffer_albedoMap';
- lightingPass.addComputeView(gBuffer.color, computeView);
-
- const computeNormalView = new ComputeView();
- computeNormalView.name = 'gbuffer_normalMap';
- lightingPass.addComputeView(gBuffer.normal, computeNormalView);
-
- const computeEmissiveView = new ComputeView();
- computeEmissiveView.name = 'gbuffer_emissiveMap';
- lightingPass.addComputeView(gBuffer.emissive, computeEmissiveView);
-
- const computeDepthView = new ComputeView();
- computeDepthView.name = 'depth_stencil';
- lightingPass.addComputeView(gBuffer.ds, computeDepthView);
+ lightingPass.addTexture(gBuffer.color, 'gbuffer_albedoMap');
+ lightingPass.addTexture(gBuffer.normal, 'gbuffer_normalMap');
+ lightingPass.addTexture(gBuffer.emissive, 'gbuffer_emissiveMap');
+ lightingPass.addTexture(gBuffer.ds, 'depth_stencil');
}
const lightingClearColor = new Color(0, 0, 0, 0);
if (camera.clearFlag & ClearFlagBit.COLOR) {
@@ -939,12 +832,7 @@ export function buildLightingPass (camera: Camera, ppl: Pipeline, gBuffer: GBuff
lightingClearColor.z = camera.clearColor.z;
}
lightingClearColor.w = 0;
- const lightingPassView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
- LoadOp.CLEAR, StoreOp.STORE,
- camera.clearFlag,
- lightingClearColor);
- lightingPass.addRasterView(deferredLightingPassRTName, lightingPassView);
+ lightingPass.addRenderTarget(deferredLightingPassRTName, '_', LoadOp.CLEAR, StoreOp.STORE, lightingClearColor);
lightingPass.addQueue(QueueHint.RENDER_TRANSPARENT).addCameraQuad(
camera, lightingInfo.deferredLightingMaterial, 0,
SceneFlags.VOLUMETRIC_LIGHTING,
@@ -987,34 +875,28 @@ export function buildUIPass (camera: Camera,
const dsUIAndProfilerPassRTName = `dsUIAndProfilerPassColor${cameraName}`;
const dsUIAndProfilerPassDSName = `dsUIAndProfilerPassDS${cameraName}`;
if (!ppl.containsResource(dsUIAndProfilerPassRTName)) {
- ppl.addRenderTexture(dsUIAndProfilerPassRTName, Format.BGRA8, width, height, camera.window);
+ ppl.addRenderWindow(dsUIAndProfilerPassRTName, Format.BGRA8, width, height, camera.window);
ppl.addDepthStencil(dsUIAndProfilerPassDSName, Format.DEPTH_STENCIL, width, height, ResourceResidency.MANAGED);
}
ppl.updateRenderWindow(dsUIAndProfilerPassRTName, camera.window);
ppl.updateDepthStencil(dsUIAndProfilerPassDSName, width, height);
- const uIAndProfilerPass = ppl.addRasterPass(width, height, 'default');
- uIAndProfilerPass.name = `CameraUIAndProfilerPass${cameraID}`;
- uIAndProfilerPass.setViewport(new Viewport(area.x, area.y, width, height));
- const passView = new RasterView('_',
- AccessType.WRITE, AttachmentType.RENDER_TARGET,
+ const uiAndProfilerPass = ppl.addRasterPass(width, height, 'default');
+ uiAndProfilerPass.name = `CameraUIAndProfilerPass${cameraID}`;
+ uiAndProfilerPass.setViewport(new Viewport(area.x, area.y, width, height));
+ uiAndProfilerPass.addRenderTarget(dsUIAndProfilerPassRTName, '_',
getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.RENDER_TARGET),
StoreOp.STORE,
- camera.clearFlag,
new Color(camera.clearColor.x, camera.clearColor.y, camera.clearColor.z, camera.clearColor.w));
- const passDSView = new RasterView('_',
- AccessType.WRITE, AttachmentType.DEPTH_STENCIL,
+ uiAndProfilerPass.addDepthStencil(dsUIAndProfilerPassDSName, '_',
getLoadOpOfClearFlag(camera.clearFlag, AttachmentType.DEPTH_STENCIL),
StoreOp.STORE,
- camera.clearFlag,
- new Color(camera.clearDepth, camera.clearStencil, 0, 0));
- uIAndProfilerPass.addRasterView(dsUIAndProfilerPassRTName, passView);
- uIAndProfilerPass.addRasterView(dsUIAndProfilerPassDSName, passDSView);
+ camera.clearDepth, camera.clearStencil, camera.clearFlag);
const sceneFlags = SceneFlags.UI;
- uIAndProfilerPass
+ uiAndProfilerPass
.addQueue(QueueHint.RENDER_TRANSPARENT)
.addSceneOfCamera(camera, new LightInfo(), sceneFlags);
if (getProfilerCamera() === camera) {
- uIAndProfilerPass.showStatistics = true;
+ uiAndProfilerPass.showStatistics = true;
}
}
diff --git a/cocos/rendering/custom/executor.ts b/cocos/rendering/custom/executor.ts
index 50e6c0f068..d1cf26be1d 100644
--- a/cocos/rendering/custom/executor.ts
+++ b/cocos/rendering/custom/executor.ts
@@ -93,11 +93,26 @@ class DeviceTexture extends DeviceResource {
get description () { return this._desc; }
get trait () { return this._trait; }
get swapchain () { return this._swapchain; }
+ private _setDesc (desc: ResourceDesc) {
+ if (!this._desc) {
+ this._desc = new ResourceDesc();
+ }
+ this._desc.alignment = desc.alignment;
+ this._desc.depthOrArraySize = desc.depthOrArraySize;
+ this._desc.dimension = desc.dimension;
+ this._desc.flags = desc.flags;
+ this._desc.format = desc.format;
+ this._desc.height = desc.height;
+ this._desc.mipLevels = desc.mipLevels;
+ this._desc.sampleCount = desc.sampleCount;
+ this._desc.textureFlags = desc.textureFlags;
+ this._desc.width = desc.width;
+ }
constructor (name: string, tex: Texture | Framebuffer | RenderSwapchain | ManagedResource) {
super(name);
const resGraph = context.resourceGraph;
const verID = resGraph.vertex(name);
- this._desc = resGraph.getDesc(verID);
+ this._setDesc(resGraph.getDesc(verID));
this._trait = resGraph.getTraits(verID);
if (tex instanceof Texture) {
this._texture = tex;
@@ -112,7 +127,7 @@ class DeviceTexture extends DeviceResource {
return;
}
- const info = this._desc;
+ const info = this._desc!;
let type = TextureType.TEX2D;
switch (info.dimension) {
@@ -441,7 +456,7 @@ class DeviceRenderQueue {
this.queueHint = queueHint;
this.queueId = id;
this._devicePass = devicePass;
- if (isEnableEffect()) this._phaseID = cclegacy.rendering.getPhaseID(devicePass.passID, 'default');
+ if (isEnableEffect()) this._phaseID = cclegacy.rendering.getPhaseID(devicePass.passID, context.renderGraph.getLayout(id) || 'default');
if (!this._sceneVisitor) {
this._sceneVisitor = new WebSceneVisitor(context.commandBuffer,
context.pipeline.pipelineSceneData);
@@ -514,11 +529,7 @@ class SubmitInfo {
public shadowMap: RenderShadowMapBatchedQueue | null = null;
public additiveLight: RenderAdditiveLightQueue | null = null;
public reflectionProbe: RenderReflectionProbeQueue | null = null;
- private _isInit = false;
- get isInit () { return this._isInit; }
- set isInit (val: boolean) { this._isInit = val; }
reset () {
- this._isInit = false;
this.instances.clear();
this.renderInstanceQueue.length = 0;
this.batches.clear();
@@ -649,13 +660,15 @@ class DeviceRenderPass {
protected _clearDepth = 1;
protected _clearStencil = 0;
protected _passID: number;
+ protected _layoutName: string;
protected _viewport: Viewport | null = null;
private _rasterInfo: RasterPassInfo;
private _layout: RenderPassLayoutInfo | null = null;
constructor (passInfo: RasterPassInfo) {
this._rasterInfo = passInfo;
const device = context.device;
- this._passID = cclegacy.rendering.getPassID(context.renderGraph.getLayout(passInfo.id));
+ this._layoutName = context.renderGraph.getLayout(passInfo.id);
+ this._passID = cclegacy.rendering.getPassID(this._layoutName);
const depthStencilAttachment = new DepthStencilAttachment();
depthStencilAttachment.format = Format.DEPTH_STENCIL;
depthStencilAttachment.depthLoadOp = LoadOp.DISCARD;
@@ -752,6 +765,7 @@ class DeviceRenderPass {
swapchain ? [swapchain.colorTexture] : colorTexs,
swapchain ? swapchain.depthStencilTexture : depthTex));
}
+ get layoutName (): string { return this._layoutName; }
get passID (): number { return this._passID; }
get renderLayout () { return this._layout; }
get renderPass () { return this._renderPass; }
@@ -852,15 +866,17 @@ class DeviceRenderPass {
}
private _clear () {
- for (const [cam, info] of context.submitMap) {
- info.additiveLight?.clear();
- const it = info.instances.values(); let res = it.next();
- while (!res.done) {
- res.value.clear();
- res = it.next();
+ for (const [cam, infoMap] of context.submitMap) {
+ for (const [id, info] of infoMap) {
+ info.additiveLight?.clear();
+ const it = info.instances.values(); let res = it.next();
+ while (!res.done) {
+ res.value.clear();
+ res = it.next();
+ }
+ info.renderInstanceQueue = [];
+ info.instances.clear();
}
- info.renderInstanceQueue = [];
- info.instances.clear();
}
}
@@ -1038,15 +1054,23 @@ class DevicePreSceneTask extends WebSceneTask {
}
const devicePass = this._currentQueue.devicePass;
const submitMap = context.submitMap;
- if (submitMap.has(this.camera)) {
- this._submitInfo = submitMap.get(this.camera)!;
+ let submitInfoMap = submitMap.get(this.camera);
+ if (submitInfoMap && submitInfoMap.has(this._currentQueue.phaseID)) {
+ this._submitInfo = submitInfoMap.get(this._currentQueue.phaseID)!;
} else {
+ if (!submitInfoMap) {
+ submitInfoMap = new Map();
+ submitMap.set(this.camera, submitInfoMap);
+ }
this._submitInfo = new SubmitInfo();
- submitMap.set(this.camera, this._submitInfo);
+ submitInfoMap.set(this._currentQueue.phaseID, this._submitInfo);
}
// culling
if ((!this._isShadowMap() || (this._isShadowMap() && this.graphScene.scene!.light.level === 0))
- && !this._submitInfo.isInit) { super.start(); this._submitInfo.isInit = true; }
+ && this.camera !== context.cullCamera) {
+ super.start();
+ context.cullCamera = this.camera;
+ }
// shadowmap
if (this._isShadowMap()) {
@@ -1078,7 +1102,6 @@ class DevicePreSceneTask extends WebSceneTask {
&& !this._submitInfo.instances.size
&& !this._submitInfo.batches.size;
if (isEmpty) {
- context.pools.resetPassInfo();
for (const ro of this.sceneData.renderObjects) {
const subModels = ro.model.subModels;
for (const subModel of subModels) {
@@ -1105,7 +1128,7 @@ class DevicePreSceneTask extends WebSceneTask {
}
if (sceneFlag & SceneFlags.DEFAULT_LIGHTING) {
this._submitInfo.additiveLight = context.additiveLight;
- this._submitInfo.additiveLight.gatherLightPasses(this.camera, this._cmdBuff);
+ this._submitInfo.additiveLight.gatherLightPasses(this.camera, this._cmdBuff, this._currentQueue.devicePass.layoutName);
}
if (sceneFlag & SceneFlags.PLANAR_SHADOW) {
this._submitInfo.planarQueue = context.planarShadow;
@@ -1141,7 +1164,7 @@ class DevicePreSceneTask extends WebSceneTask {
const currTransparent = pass.blendState.targets[0].blend;
const devicePass = this._currentQueue.devicePass;
const passId = devicePass.passID;
- const phase = isEnableEffect() ? cclegacy.rendering.getPhaseID(passId, 'default') | cclegacy.rendering.getPhaseID(passId, 'planarShadow')
+ const phase = isEnableEffect() ? this._currentQueue.phaseID // | cclegacy.rendering.getPhaseID(passId, 'planarShadow')
: getPhaseID('default') | getPhaseID('planarShadow');
if (currTransparent !== isTransparent || !(pass.phaseID & (isTransparent ? phase : this._currentQueue.phaseID))) {
return;
@@ -1294,7 +1317,9 @@ class DeviceSceneTask extends WebSceneTask {
public start () {}
protected _recordRenderList (isTransparent: boolean) {
const submitMap = context.submitMap;
- const renderList = isTransparent ? submitMap.get(this.camera!)!.transparentList : submitMap.get(this.camera!)!.opaqueList;
+ const currSubmitInfo = submitMap.get(this.camera!)!.get(this._currentQueue.phaseID)!;
+ const renderList = isTransparent ? currSubmitInfo.transparentList
+ : currSubmitInfo.opaqueList;
for (let i = 0; i < renderList.length; ++i) {
const { subModel, passIdx } = renderList[i];
const { inputAssembler } = subModel;
@@ -1314,9 +1339,10 @@ class DeviceSceneTask extends WebSceneTask {
}
protected _recordInstences () {
const submitMap = context.submitMap;
- const it = submitMap.get(this.camera!)!.renderInstanceQueue.length === 0
- ? submitMap.get(this.camera!)!.instances.values()
- : submitMap.get(this.camera!)!.renderInstanceQueue.values();
+ const currSubmitInfo = submitMap.get(this.camera!)!.get(this._currentQueue.phaseID)!;
+ const it = currSubmitInfo.renderInstanceQueue.length === 0
+ ? currSubmitInfo.instances.values()
+ : currSubmitInfo.renderInstanceQueue.values();
let res = it.next();
while (!res.done) {
const { instances, pass, hasPendingModels } = res.value;
@@ -1344,7 +1370,8 @@ class DeviceSceneTask extends WebSceneTask {
}
protected _recordBatches () {
const submitMap = context.submitMap;
- const it = submitMap.get(this.camera!)!.batches.values(); let res = it.next();
+ const currSubmitInfo = submitMap.get(this.camera!)!.get(this._currentQueue.phaseID)!;
+ const it = currSubmitInfo.batches.values(); let res = it.next();
while (!res.done) {
let boundPSO = false;
for (let b = 0; b < res.value.batches.length; ++b) {
@@ -1398,12 +1425,14 @@ class DeviceSceneTask extends WebSceneTask {
}
protected _recordShadowMap () {
const submitMap = context.submitMap;
- submitMap.get(this.camera!)?.shadowMap?.recordCommandBuffer(context.device,
+ const currSubmitInfo = submitMap.get(this.camera!)!.get(this._currentQueue.phaseID)!;
+ currSubmitInfo.shadowMap?.recordCommandBuffer(context.device,
this._renderPass, context.commandBuffer);
}
protected _recordReflectionProbe () {
const submitMap = context.submitMap;
- submitMap.get(this.camera!)?.reflectionProbe?.recordCommandBuffer(context.device,
+ const currSubmitInfo = submitMap.get(this.camera!)!.get(this._currentQueue.phaseID)!;
+ currSubmitInfo.reflectionProbe?.recordCommandBuffer(context.device,
this._renderPass, context.commandBuffer);
}
private _isShadowMap () {
@@ -1462,7 +1491,8 @@ class DeviceSceneTask extends WebSceneTask {
private _recordAdditiveLights () {
const devicePass = this._currentQueue.devicePass;
const submitMap = context.submitMap;
- submitMap.get(this.camera!)?.additiveLight?.recordCommandBuffer(context.device,
+ const currSubmitInfo = submitMap.get(this.camera!)!.get(this._currentQueue.phaseID)!;
+ currSubmitInfo.additiveLight?.recordCommandBuffer(context.device,
this._renderPass,
context.commandBuffer);
}
@@ -1470,7 +1500,8 @@ class DeviceSceneTask extends WebSceneTask {
private _recordPlanarShadows () {
const devicePass = this._currentQueue.devicePass;
const submitMap = context.submitMap;
- submitMap.get(this.camera!)?.planarQueue?.recordCommandBuffer(context.device,
+ const currSubmitInfo = submitMap.get(this.camera!)!.get(this._currentQueue.phaseID)!;
+ currSubmitInfo.planarQueue?.recordCommandBuffer(context.device,
this._renderPass,
context.commandBuffer);
}
@@ -1572,6 +1603,7 @@ class ExecutorPools {
this.deviceQueuePool.reset();
this.graphScenePool.reset();
this.reflectionProbe.reset();
+ this.resetPassInfo();
}
readonly deviceQueuePool: RecyclePool;
readonly graphScenePool: RecyclePool;
@@ -1784,8 +1816,9 @@ class ExecutorContext {
}
reset () {
this.pools.reset();
- for (const info of this.submitMap) {
- info[1].reset();
+ this.cullCamera = null;
+ for (const infoMap of this.submitMap) {
+ for (const info of infoMap[1]) info[1].reset();
}
}
resize (width: number, height: number) {
@@ -1806,12 +1839,13 @@ class ExecutorContext {
readonly additiveLight: RenderAdditiveLightQueue;
readonly shadowMapBatched: RenderShadowMapBatchedQueue;
readonly planarShadow: PlanarShadowQueue;
- readonly submitMap: Map = new Map();
+ readonly submitMap: Map> = new Map>();
readonly pools: ExecutorPools;
readonly blit: BlitInfo;
renderGraph: RenderGraph;
width: number;
height: number;
+ cullCamera;
}
class ResourceVisitor implements ResourceGraphVisitor {
name: string;
diff --git a/cocos/rendering/custom/pipeline.ts b/cocos/rendering/custom/pipeline.ts
index 84593ad9f8..481d302957 100644
--- a/cocos/rendering/custom/pipeline.ts
+++ b/cocos/rendering/custom/pipeline.ts
@@ -31,12 +31,12 @@
import { Material } from '../../asset/assets';
import { Camera } from '../../render-scene/scene/camera';
import { GeometryRenderer } from '../geometry-renderer';
-import { Buffer, Color, CommandBuffer, DescriptorSet, DescriptorSetLayout, Device, DrawInfo, Format, InputAssembler, PipelineState, Rect, Sampler, Swapchain, Texture, Viewport } from '../../gfx';
+import { Buffer, ClearFlagBit, Color, CommandBuffer, DescriptorSet, DescriptorSetLayout, Device, DrawInfo, Format, InputAssembler, LoadOp, PipelineState, Rect, Sampler, StoreOp, Swapchain, Texture, Viewport } from '../../gfx';
import { GlobalDSManager } from '../global-descriptor-set-manager';
import { Mat4, Quat, Vec2, Vec4 } from '../../core/math';
import { MacroRecord } from '../../render-scene/core/pass-utils';
import { PipelineSceneData } from '../pipeline-scene-data';
-import { ComputeView, CopyPair, LightInfo, MovePair, QueueHint, RasterView, ResourceResidency, SceneFlags, TaskType, UpdateFrequency } from './types';
+import { AccessType, ComputeView, CopyPair, LightInfo, MovePair, QueueHint, RasterView, ResourceResidency, SceneFlags, TaskType, UpdateFrequency } from './types';
import { RenderScene } from '../../render-scene/core/render-scene';
import { RenderWindow } from '../../render-scene/core/render-window';
import { Model } from '../../render-scene/scene';
@@ -67,6 +67,10 @@ export interface PipelineRuntime {
export interface RenderNode {
name: string;
+ /**
+ * @beta method's name might change
+ */
+ setCustomBehavior (name: string): void;
}
export interface Setter extends RenderNode {
@@ -76,6 +80,7 @@ export interface Setter extends RenderNode {
setVec4 (name: string, vec: Vec4): void;
setVec2 (name: string, vec: Vec2): void;
setFloat (name: string, v: number): void;
+ setArrayBuffer (name: string, arrayBuffer: ArrayBuffer): void;
setBuffer (name: string, buffer: Buffer): void;
setTexture (name: string, texture: Texture): void;
setReadWriteBuffer (name: string, buffer: Buffer): void;
@@ -95,10 +100,68 @@ export interface RasterQueueBuilder extends Setter {
clearRenderTarget (name: string, color: Color): void;
clearRenderTarget (name: string/*, new Color()*/): void;
setViewport (viewport: Viewport): void;
+ /**
+ * @beta method's name might change
+ */
+ addCustomCommand (customBehavior: string): void;
}
export interface RasterSubpassBuilder extends Setter {
- addRasterView (name: string, view: RasterView): void;
+ /**
+ * @beta method's name might change
+ */
+ addRenderTarget (name: string, accessType: AccessType, slotName: string, loadOp: LoadOp, storeOp: StoreOp, color: Color): void;
+ /**
+ * @beta method's name might change
+ */
+ addRenderTarget (name: string, accessType: AccessType, slotName: string, loadOp: LoadOp, storeOp: StoreOp/*, new Color()*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addRenderTarget (name: string, accessType: AccessType, slotName: string, loadOp: LoadOp/*, StoreOp.STORE, new Color()*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addRenderTarget (name: string, accessType: AccessType, slotName: string/*, LoadOp.CLEAR, StoreOp.STORE, new Color()*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, accessType: AccessType, slotName: string, loadOp: LoadOp, storeOp: StoreOp, depth: number, stencil: number, clearFlags: ClearFlagBit): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, accessType: AccessType, slotName: string, loadOp: LoadOp, storeOp: StoreOp, depth: number, stencil: number/*, ClearFlagBit.DEPTH_STENCIL*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, accessType: AccessType, slotName: string, loadOp: LoadOp, storeOp: StoreOp, depth: number/*, 0, ClearFlagBit.DEPTH_STENCIL*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, accessType: AccessType, slotName: string, loadOp: LoadOp, storeOp: StoreOp/*, 1, 0, ClearFlagBit.DEPTH_STENCIL*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, accessType: AccessType, slotName: string, loadOp: LoadOp/*, StoreOp.STORE, 1, 0, ClearFlagBit.DEPTH_STENCIL*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, accessType: AccessType, slotName: string/*, LoadOp.CLEAR, StoreOp.STORE, 1, 0, ClearFlagBit.DEPTH_STENCIL*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addTexture (name: string, slotName: string): void;
+ /**
+ * @beta method's name might change
+ */
+ addStorageBuffer (name: string, accessType: AccessType, slotName: string): void;
+ /**
+ * @beta method's name might change
+ */
+ addStorageImage (name: string, accessType: AccessType, slotName: string): void;
+ /**
+ * @deprecated method will be removed in 3.8.0
+ */
addComputeView (name: string, view: ComputeView): void;
setViewport (viewport: Viewport): void;
addQueue (hint: QueueHint, layoutName: string): RasterQueueBuilder;
@@ -114,14 +177,90 @@ export interface ComputeQueueBuilder extends Setter {
}
export interface ComputeSubpassBuilder extends Setter {
- addRasterView (name: string, view: RasterView): void;
+ /**
+ * @beta method's name might change
+ */
+ addRenderTarget (name: string, slotName: string): void;
+ /**
+ * @beta method's name might change
+ */
+ addTexture (name: string, slotName: string): void;
+ /**
+ * @beta method's name might change
+ */
+ addStorageBuffer (name: string, accessType: AccessType, slotName: string): void;
+ /**
+ * @beta method's name might change
+ */
+ addStorageImage (name: string, accessType: AccessType, slotName: string): void;
+ /**
+ * @deprecated method will be removed in 3.8.0
+ */
addComputeView (name: string, view: ComputeView): void;
addQueue (layoutName: string): ComputeQueueBuilder;
addQueue (/*''*/): ComputeQueueBuilder;
}
export interface RasterPassBuilder extends Setter {
+ /**
+ * @beta method's name might change
+ */
+ addRenderTarget (name: string, slotName: string, loadOp: LoadOp, storeOp: StoreOp, color: Color): void;
+ /**
+ * @beta method's name might change
+ */
+ addRenderTarget (name: string, slotName: string, loadOp: LoadOp, storeOp: StoreOp/*, new Color()*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addRenderTarget (name: string, slotName: string, loadOp: LoadOp/*, StoreOp.STORE, new Color()*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addRenderTarget (name: string, slotName: string/*, LoadOp.CLEAR, StoreOp.STORE, new Color()*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, slotName: string, loadOp: LoadOp, storeOp: StoreOp, depth: number, stencil: number, clearFlags: ClearFlagBit): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, slotName: string, loadOp: LoadOp, storeOp: StoreOp, depth: number, stencil: number/*, ClearFlagBit.DEPTH_STENCIL*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, slotName: string, loadOp: LoadOp, storeOp: StoreOp, depth: number/*, 0, ClearFlagBit.DEPTH_STENCIL*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, slotName: string, loadOp: LoadOp, storeOp: StoreOp/*, 1, 0, ClearFlagBit.DEPTH_STENCIL*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, slotName: string, loadOp: LoadOp/*, StoreOp.STORE, 1, 0, ClearFlagBit.DEPTH_STENCIL*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addDepthStencil (name: string, slotName: string/*, LoadOp.CLEAR, StoreOp.STORE, 1, 0, ClearFlagBit.DEPTH_STENCIL*/): void;
+ /**
+ * @beta method's name might change
+ */
+ addTexture (name: string, slotName: string): void;
+ /**
+ * @beta method's name might change
+ */
+ addStorageBuffer (name: string, accessType: AccessType, slotName: string): void;
+ /**
+ * @beta method's name might change
+ */
+ addStorageImage (name: string, accessType: AccessType, slotName: string): void;
+ /**
+ * @deprecated method will be removed in 3.8.0
+ */
addRasterView (name: string, view: RasterView): void;
+ /**
+ * @deprecated method will be removed in 3.8.0
+ */
addComputeView (name: string, view: ComputeView): void;
addQueue (hint: QueueHint, layoutName: string): RasterQueueBuilder;
addQueue (hint: QueueHint/*, ''*/): RasterQueueBuilder;
@@ -136,6 +275,21 @@ export interface RasterPassBuilder extends Setter {
}
export interface ComputePassBuilder extends Setter {
+ /**
+ * @beta method's name might change
+ */
+ addTexture (name: string, slotName: string): void;
+ /**
+ * @beta method's name might change
+ */
+ addStorageBuffer (name: string, accessType: AccessType, slotName: string): void;
+ /**
+ * @beta method's name might change
+ */
+ addStorageImage (name: string, accessType: AccessType, slotName: string): void;
+ /**
+ * @deprecated method will be removed in 3.8.0
+ */
addComputeView (name: string, view: ComputeView): void;
addQueue (layoutName: string): ComputeQueueBuilder;
addQueue (/*''*/): ComputeQueueBuilder;
@@ -176,7 +330,11 @@ export interface Pipeline extends PipelineRuntime {
beginSetup (): void;
endSetup (): void;
containsResource (name: string): boolean;
+ /**
+ * @deprecated method will be removed in 3.8.0
+ */
addRenderTexture (name: string, format: Format, width: number, height: number, renderWindow: RenderWindow): number;
+ addRenderWindow (name: string, format: Format, width: number, height: number, renderWindow: RenderWindow): number;
updateRenderWindow (name: string, renderWindow: RenderWindow): void;
addStorageBuffer (name: string, format: Format, size: number, residency: ResourceResidency): number;
addStorageBuffer (name: string, format: Format, size: number/*, ResourceResidency.MANAGED*/): number;
@@ -189,13 +347,13 @@ export interface Pipeline extends PipelineRuntime {
addShadingRateTexture (name: string, width: number, height: number, residency: ResourceResidency): number;
addShadingRateTexture (name: string, width: number, height: number/*, ResourceResidency.MANAGED*/): number;
updateStorageBuffer (name: string, size: number, format: Format): void;
- updateStorageBuffer (name: string, size: number/*, gfx.Format.UNKNOWN*/): void;
+ updateStorageBuffer (name: string, size: number/*, Format.UNKNOWN*/): void;
updateRenderTarget (name: string, width: number, height: number, format: Format): void;
- updateRenderTarget (name: string, width: number, height: number/*, gfx.Format.UNKNOWN*/): void;
+ updateRenderTarget (name: string, width: number, height: number/*, Format.UNKNOWN*/): void;
updateDepthStencil (name: string, width: number, height: number, format: Format): void;
- updateDepthStencil (name: string, width: number, height: number/*, gfx.Format.UNKNOWN*/): void;
+ updateDepthStencil (name: string, width: number, height: number/*, Format.UNKNOWN*/): void;
updateStorageTexture (name: string, width: number, height: number, format: Format): void;
- updateStorageTexture (name: string, width: number, height: number/*, gfx.Format.UNKNOWN*/): void;
+ updateStorageTexture (name: string, width: number, height: number/*, Format.UNKNOWN*/): void;
updateShadingRateTexture (name: string, width: number, height: number): void;
beginFrame (): void;
endFrame (): void;
@@ -204,6 +362,9 @@ export interface Pipeline extends PipelineRuntime {
addComputePass (layoutName: string): ComputePassBuilder;
addMovePass (): MovePassBuilder;
addCopyPass (): CopyPassBuilder;
+ /**
+ * @deprecated method will be removed in 3.8.0
+ */
createSceneTransversal (camera: Camera, scene: RenderScene): SceneTransversal;
getDescriptorSetLayout (shaderName: string, freq: UpdateFrequency): DescriptorSetLayout | null;
}
diff --git a/cocos/rendering/custom/render-graph.ts b/cocos/rendering/custom/render-graph.ts
index d6e63cdb2d..2877c91aea 100644
--- a/cocos/rendering/custom/render-graph.ts
+++ b/cocos/rendering/custom/render-graph.ts
@@ -1081,7 +1081,7 @@ export class RaytracePass {
}
export class ClearView {
- constructor (slotName = '', clearFlags: ClearFlagBit = gfx.ClearFlagBit.ALL, clearColor: Color = new Color()) {
+ constructor (slotName = '', clearFlags: ClearFlagBit = ClearFlagBit.ALL, clearColor: Color = new Color()) {
this.slotName = slotName;
this.clearFlags = clearFlags;
this.clearColor = clearColor;
@@ -1152,6 +1152,7 @@ export class RenderData {
readonly buffers: Map = new Map();
readonly textures: Map = new Map();
readonly samplers: Map = new Map();
+ custom = '';
}
//=================================================================
diff --git a/cocos/rendering/custom/web-pipeline.ts b/cocos/rendering/custom/web-pipeline.ts
index 1fe683a481..fb97d29bc7 100644
--- a/cocos/rendering/custom/web-pipeline.ts
+++ b/cocos/rendering/custom/web-pipeline.ts
@@ -24,9 +24,10 @@
/* eslint-disable max-len */
import { systemInfo } from 'pal/system-info';
-import { Color, Buffer, DescriptorSetLayout, Device, Feature, Format, FormatFeatureBit, Sampler, Swapchain, Texture, ClearFlagBit, DescriptorSet, deviceManager, Viewport, API, CommandBuffer, Type, SamplerInfo, Filter, Address, DescriptorSetInfo } from '../../gfx';
+import { DEBUG } from 'internal:constants';
+import { Color, Buffer, DescriptorSetLayout, Device, Feature, Format, FormatFeatureBit, Sampler, Swapchain, Texture, ClearFlagBit, DescriptorSet, deviceManager, Viewport, API, CommandBuffer, Type, SamplerInfo, Filter, Address, DescriptorSetInfo, LoadOp, StoreOp } from '../../gfx';
import { Mat4, Quat, toRadian, Vec2, Vec3, Vec4, assert, macro, cclegacy } from '../../core';
-import { ComputeView, CopyPair, LightInfo, LightingMode, MovePair, QueueHint, RasterView, ResourceDimension, ResourceFlags, ResourceResidency, SceneFlags, UpdateFrequency } from './types';
+import { AccessType, AttachmentType, ComputeView, CopyPair, LightInfo, LightingMode, MovePair, QueueHint, RasterView, ResourceDimension, ResourceFlags, ResourceResidency, SceneFlags, UpdateFrequency } from './types';
import { Blit, ClearView, ComputePass, CopyPass, Dispatch, ManagedBuffer, ManagedResource, MovePass, RasterPass, RasterSubpass, RenderData, RenderGraph, RenderGraphComponent, RenderGraphValue, RenderQueue, RenderSwapchain, ResourceDesc, ResourceGraph, ResourceGraphValue, ResourceStates, ResourceTraits, SceneData, Subpass } from './render-graph';
import { ComputePassBuilder, ComputeQueueBuilder, ComputeSubpassBuilder, CopyPassBuilder, MovePassBuilder, Pipeline, PipelineBuilder, RasterPassBuilder, RasterQueueBuilder, RasterSubpassBuilder, SceneTransversal } from './pipeline';
import { PipelineSceneData } from '../pipeline-scene-data';
@@ -53,13 +54,27 @@ import { getUBOTypeCount } from './utils';
import { initGlobalDescBinding } from './define';
import { createGfxDescriptorSetsAndPipelines } from './layout-graph-utils';
+const _uboVec = new Vec4();
+const _uboVec3 = new Vec3();
+const _uboCol = new Color();
+const _matView = new Mat4();
+const _mulMatView = new Mat4();
+let uniformOffset = -1;
+const _samplerPointInfo = new SamplerInfo(
+ Filter.POINT,
+ Filter.POINT,
+ Filter.NONE,
+ Address.CLAMP,
+ Address.CLAMP,
+ Address.CLAMP,
+);
export class WebSetter {
constructor (data: RenderData, lg: LayoutGraphData) {
this._data = data;
this._lg = lg;
}
- protected _applyCurrConstantBuffer (name: string, target: any, type: Type, idx = 0) {
- const offset = this._getUniformOffset(name, type, idx);
+
+ protected _copyToBuffer (target: any, offset: number, type: Type) {
assert(offset !== -1);
const arr = this.getCurrConstant();
switch (type) {
@@ -77,13 +92,23 @@ export class WebSetter {
case Type.TEXTURE2D:
break;
case Type.FLOAT2:
- Vec2.toArray(arr, new Vec2(target.x, target.y), offset);
+ arr[offset + 0] = target.x;
+ arr[offset + 1] = target.y;
break;
default:
}
}
- protected _getUniformOffset (name: string, type: Type, idx = 0) {
+ protected _applyCurrConstantBuffer (name: string, target: any, type: Type, idx = 0) {
+ const offset = this.getUniformOffset(name, type, idx);
+ this._copyToBuffer(target, offset, type);
+ }
+
+ public hasUniform (offset: number) {
+ return offset !== -1;
+ }
+
+ public getUniformOffset (name: string, type: Type, idx = 0) {
const currBlock = this._getCurrUniformBlock();
if (!currBlock) return -1;
let offset = 0;
@@ -98,7 +123,7 @@ export class WebSetter {
} else if (typeCount < currCount * uniform.count) {
return offset + idx;
}
- assert(false);
+ if (DEBUG) assert(false);
}
offset += currCount * uniform.count;
}
@@ -168,21 +193,39 @@ export class WebSetter {
public setMat4 (name: string, mat: Mat4, idx = 0): void {
this._applyCurrConstantBuffer(name, mat, Type.MAT4, idx);
}
+ public offsetMat4 (mat: Mat4, offset: number): void {
+ this._copyToBuffer(mat, offset, Type.MAT4);
+ }
public setQuaternion (name: string, quat: Quat, idx = 0): void {
- this._applyCurrConstantBuffer(name, new Vec4(quat.x, quat.y, quat.z, quat.w), Type.FLOAT4, idx);
+ this._applyCurrConstantBuffer(name, quat, Type.FLOAT4, idx);
+ }
+ public offsetQuaternion (quat: Quat, offset: number): void {
+ this._copyToBuffer(quat, offset, Type.FLOAT4);
}
public setColor (name: string, color: Color, idx = 0): void {
- this._applyCurrConstantBuffer(name, new Vec4(color.x, color.y, color.z, color.w), Type.FLOAT4, idx);
+ this._applyCurrConstantBuffer(name, color, Type.FLOAT4, idx);
+ }
+ public offsetColor (color: Color, offset: number): void {
+ this._copyToBuffer(color, offset, Type.FLOAT4);
}
public setVec4 (name: string, vec: Vec4, idx = 0): void {
this._applyCurrConstantBuffer(name, vec, Type.FLOAT4, idx);
}
+ public offsetVec4 (vec: Vec4, offset: number): void {
+ this._copyToBuffer(vec, offset, Type.FLOAT4);
+ }
public setVec2 (name: string, vec: Vec2, idx = 0): void {
this._applyCurrConstantBuffer(name, vec, Type.FLOAT2, idx);
}
+ public offsetVec2 (vec: Vec2, offset: number): void {
+ this._copyToBuffer(vec, offset, Type.FLOAT2);
+ }
public setFloat (name: string, v: number, idx = 0): void {
this._applyCurrConstantBuffer(name, v, Type.FLOAT, idx);
}
+ public offsetFloat (v: number, offset: number): void {
+ this._copyToBuffer(v, offset, Type.FLOAT);
+ }
public setBuffer (name: string, buffer: Buffer): void {}
public setTexture (name: string, texture: Texture): void {
if (this._getCurrDescriptorBlock(name) === -1) {
@@ -214,10 +257,13 @@ export class WebSetter {
}
return this._data.textures.has(id);
}
+ public setCustomBehavior (name: string): void {
+ throw new Error('Method not implemented.');
+ }
// protected
- protected readonly _data: RenderData;
- protected readonly _lg: LayoutGraphData;
+ protected _data: RenderData;
+ protected _lg: LayoutGraphData;
protected _currBlock;
protected _currStage;
protected _currCount;
@@ -237,7 +283,6 @@ function setShadowUBOLightView (setter: WebSetter,
const csmLayers = sceneData.csmLayers;
const packing = supportsR32FloatTexture(device) ? 0.0 : 1.0;
const cap = pipeline.device.capabilities;
- const _vec4ShadowInfo = new Vec4();
setter.addConstant('CCCSM', layout);
// ShadowMap
if (!setter.addConstant('CCShadow', layout)) return;
@@ -273,8 +318,11 @@ function setShadowUBOLightView (setter: WebSetter,
far = csmLayers.specialLayer.shadowCameraFar;
levelCount = 1;
}
- _vec4ShadowInfo.set(0.0, packing, mainLight.shadowNormalBias, 0);
- setter.setVec4('cc_shadowLPNNInfo', _vec4ShadowInfo);
+ uniformOffset = setter.getUniformOffset('cc_shadowLPNNInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(0.0, packing, mainLight.shadowNormalBias, 0);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
} else {
const layer = csmLayers.layers[level];
matShadowView = layer.matShadowView;
@@ -285,52 +333,83 @@ function setShadowUBOLightView (setter: WebSetter,
far = layer.splitCameraFar;
levelCount = mainLight.csmLevel;
}
- setter.setMat4('cc_matLightView', matShadowView);
- setter.setVec4('cc_shadowProjDepthInfo', new Vec4(matShadowProj.m10, matShadowProj.m14,
- matShadowProj.m11, matShadowProj.m15));
- setter.setVec4('cc_shadowProjInfo', new Vec4(matShadowProj.m00, matShadowProj.m05,
- 1.0 / matShadowProj.m00, 1.0 / matShadowProj.m05));
- setter.setMat4('cc_matLightViewProj', matShadowViewProj);
- _vec4ShadowInfo.set(near, far, 0, 1.0 - mainLight.shadowSaturation);
- setter.setVec4('cc_shadowNFLSInfo', _vec4ShadowInfo);
- _vec4ShadowInfo.set(0.0, packing, mainLight.shadowNormalBias, levelCount);
- setter.setVec4('cc_shadowLPNNInfo', _vec4ShadowInfo);
- _vec4ShadowInfo.set(shadowInfo.size.x, shadowInfo.size.y, mainLight.shadowPcf, mainLight.shadowBias);
- setter.setVec4('cc_shadowWHPBInfo', _vec4ShadowInfo);
+ uniformOffset = setter.getUniformOffset('cc_matLightView', Type.MAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetMat4(matShadowView, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowProjDepthInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(matShadowProj.m10, matShadowProj.m14, matShadowProj.m11, matShadowProj.m15);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowProjInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(matShadowProj.m00, matShadowProj.m05, 1.0 / matShadowProj.m00, 1.0 / matShadowProj.m05);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_matLightViewProj', Type.MAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetMat4(matShadowViewProj, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowNFLSInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(near, far, 0, 1.0 - mainLight.shadowSaturation);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowLPNNInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(0.0, packing, mainLight.shadowNormalBias, levelCount);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowWHPBInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(shadowInfo.size.x, shadowInfo.size.y, mainLight.shadowPcf, mainLight.shadowBias);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
}
}
break;
}
case LightType.SPOT: {
const spotLight = light as SpotLight;
- const _matShadowView = new Mat4();
- const _matShadowProj = new Mat4();
- const _matShadowViewProj = new Mat4();
if (shadowInfo.enabled && spotLight && spotLight.shadowEnabled) {
- Mat4.invert(_matShadowView, (light as any).node.getWorldMatrix());
- setter.setMat4('cc_matLightView', _matShadowView);
-
- Mat4.perspective(_matShadowProj, (light as any).angle, 1.0, 0.001, (light as any).range,
- true, cap.clipSpaceMinZ, cap.clipSpaceSignY, 0);
-
- Mat4.multiply(_matShadowViewProj, _matShadowProj, _matShadowView);
- setter.setMat4('cc_matLightViewProj', _matShadowViewProj);
-
- _vec4ShadowInfo.set(0.01, (light as SpotLight).range, 0.0, 0.0);
- setter.setVec4('cc_shadowNFLSInfo', _vec4ShadowInfo);
-
- _vec4ShadowInfo.set(shadowInfo.size.x, shadowInfo.size.y, spotLight.shadowPcf, spotLight.shadowBias);
- setter.setVec4('cc_shadowWHPBInfo', _vec4ShadowInfo);
-
- _vec4ShadowInfo.set(1.0, packing, spotLight.shadowNormalBias, 0.0);
- setter.setVec4('cc_shadowLPNNInfo', _vec4ShadowInfo);
+ const matViewOffset = setter.getUniformOffset('cc_matLightView', Type.MAT4);
+ const matViewProOffset = setter.getUniformOffset('cc_matLightViewProj', Type.MAT4);
+ if (setter.hasUniform(matViewOffset) || setter.hasUniform(matViewProOffset)) {
+ Mat4.invert(_matView, (light as any).node.getWorldMatrix());
+ }
+ if (setter.hasUniform(matViewOffset)) setter.offsetMat4(_matView, matViewOffset);
+ if (setter.hasUniform(matViewProOffset)) {
+ Mat4.perspective(_mulMatView, (light as any).angle, 1.0, 0.001, (light as any).range,
+ true, cap.clipSpaceMinZ, cap.clipSpaceSignY, 0);
+ Mat4.multiply(_matView, _mulMatView, _matView);
+ setter.offsetMat4(_matView, matViewProOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowNFLSInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(0.01, (light as SpotLight).range, 0.0, 0.0);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowWHPBInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(shadowInfo.size.x, shadowInfo.size.y, spotLight.shadowPcf, spotLight.shadowBias);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowLPNNInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(1.0, packing, spotLight.shadowNormalBias, 0.0);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
}
break;
}
default:
}
- setter.setColor('cc_shadowColor', new Color(shadowInfo.shadowColor.x, shadowInfo.shadowColor.y,
- shadowInfo.shadowColor.z, shadowInfo.shadowColor.w));
+ uniformOffset = setter.getUniformOffset('cc_shadowColor', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboCol.copy(shadowInfo.shadowColor);
+ setter.offsetColor(_uboCol, uniformOffset);
+ }
}
function getPCFRadius (shadowInfo: Shadows, mainLight: DirectionalLight): number {
@@ -349,17 +428,17 @@ function getPCFRadius (shadowInfo: Shadows, mainLight: DirectionalLight): number
return 0.0;
}
-function setShadowUBOView (setter: WebSetter, camera: Camera, layout = 'default') {
+function setShadowUBOView (setter: WebSetter, camera: Camera | null, layout = 'default') {
const director = cclegacy.director;
const pipeline = director.root.pipeline;
const device = pipeline.device;
- const mainLight = camera.scene!.mainLight;
+ const scene = cclegacy.director.getScene().renderScene;
+ const mainLight = camera && camera.scene ? camera.scene.mainLight : scene.mainLight;
const sceneData = pipeline.pipelineSceneData;
const shadowInfo = sceneData.shadows;
const csmLayers = sceneData.csmLayers;
const csmSupported = sceneData.csmSupported;
const packing = supportsR32FloatTexture(device) ? 0.0 : 1.0;
- const _vec4ShadowInfo = new Vec4();
const hasCCShadow = setter.addConstant('CCShadow', layout);
const hasCCCSM = setter.addConstant('CCCSM', layout);
if (mainLight && shadowInfo.enabled) {
@@ -373,18 +452,34 @@ function setShadowUBOView (setter: WebSetter, camera: Camera, layout = 'default'
const matShadowViewProj = csmLayers.specialLayer.matShadowViewProj;
const near = mainLight.shadowNear;
const far = mainLight.shadowFar;
-
- setter.setMat4('cc_matLightView', matShadowView);
- setter.setVec4('cc_shadowProjDepthInfo', new Vec4(matShadowProj.m10, matShadowProj.m14,
- matShadowProj.m11, matShadowProj.m15));
-
- setter.setVec4('cc_shadowProjInfo', new Vec4(matShadowProj.m00, matShadowProj.m05,
- 1.0 / matShadowProj.m00, 1.0 / matShadowProj.m05));
- setter.setMat4('cc_matLightViewProj', matShadowViewProj);
- _vec4ShadowInfo.set(near, far, 0, 1.0 - mainLight.shadowSaturation);
- setter.setVec4('cc_shadowNFLSInfo', _vec4ShadowInfo);
- _vec4ShadowInfo.set(0.0, packing, mainLight.shadowNormalBias, 0);
- setter.setVec4('cc_shadowLPNNInfo', _vec4ShadowInfo);
+ uniformOffset = setter.getUniformOffset('cc_matLightView', Type.MAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetMat4(matShadowView, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowProjDepthInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(matShadowProj.m10, matShadowProj.m14, matShadowProj.m11, matShadowProj.m15);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowProjInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(matShadowProj.m00, matShadowProj.m05, 1.0 / matShadowProj.m00, 1.0 / matShadowProj.m05);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_matLightViewProj', Type.MAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetMat4(matShadowViewProj, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowNFLSInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(near, far, 0, 1.0 - mainLight.shadowSaturation);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowLPNNInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(0.0, packing, mainLight.shadowNormalBias, 0);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
}
} else {
if (hasCCCSM) {
@@ -392,57 +487,92 @@ function setShadowUBOView (setter: WebSetter, camera: Camera, layout = 'default'
setter.setCurrConstant('CCCSM', layout);
for (let i = 0; i < mainLight.csmLevel; i++) {
const matShadowView = csmLayers.layers[i].matShadowView;
- _vec4ShadowInfo.set(matShadowView.m00, matShadowView.m04, matShadowView.m08, layerThreshold);
- setter.setVec4('cc_csmViewDir0', _vec4ShadowInfo, i);
- _vec4ShadowInfo.set(matShadowView.m01, matShadowView.m05, matShadowView.m09, 0.0);
- setter.setVec4('cc_csmViewDir1', _vec4ShadowInfo, i);
- _vec4ShadowInfo.set(matShadowView.m02, matShadowView.m06, matShadowView.m10, 0.0);
- setter.setVec4('cc_csmViewDir2', _vec4ShadowInfo, i);
-
- const csmAtlas = csmLayers.layers[i].csmAtlas;
- setter.setVec4('cc_csmAtlas', csmAtlas, i);
-
- setter.setFloat('cc_csmSplitsInfo', csmLayers.layers[i].splitCameraFar / mainLight.shadowDistance, i);
- const matShadowViewProj = csmLayers.layers[i].matShadowViewProj;
- setter.setMat4('cc_matCSMViewProj', matShadowViewProj, i);
-
+ uniformOffset = setter.getUniformOffset('cc_csmViewDir0', Type.FLOAT4, i);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(matShadowView.m00, matShadowView.m04, matShadowView.m08, layerThreshold);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_csmViewDir1', Type.FLOAT4, i);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(matShadowView.m01, matShadowView.m05, matShadowView.m09, 0.0);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_csmViewDir2', Type.FLOAT4, i);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(matShadowView.m02, matShadowView.m06, matShadowView.m10, 0.0);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_csmAtlas', Type.FLOAT4, i);
+ if (setter.hasUniform(uniformOffset)) {
+ const csmAtlas = csmLayers.layers[i].csmAtlas;
+ setter.offsetVec4(csmAtlas, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_csmSplitsInfo', Type.FLOAT, i);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetFloat(csmLayers.layers[i].splitCameraFar / mainLight.shadowDistance, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_matCSMViewProj', Type.MAT4, i);
+ if (setter.hasUniform(uniformOffset)) {
+ const matShadowViewProj = csmLayers.layers[i].matShadowViewProj;
+ setter.offsetMat4(matShadowViewProj, uniformOffset);
+ }
const matShadowProj = csmLayers.layers[i].matShadowProj;
- setter.setVec4('cc_csmProjDepthInfo', new Vec4(matShadowProj.m10,
- matShadowProj.m14, matShadowProj.m11, matShadowProj.m15), i);
-
- setter.setVec4('cc_csmProjInfo', new Vec4(matShadowProj.m00,
- matShadowProj.m05, 1.0 / matShadowProj.m00, 1.0 / matShadowProj.m05), i);
+ uniformOffset = setter.getUniformOffset('cc_csmProjDepthInfo', Type.FLOAT4, i);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(matShadowProj.m10, matShadowProj.m14, matShadowProj.m11, matShadowProj.m15);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_csmProjInfo', Type.FLOAT4, i);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(matShadowProj.m00, matShadowProj.m05, 1.0 / matShadowProj.m00, 1.0 / matShadowProj.m05);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
}
}
if (hasCCShadow) {
setter.setCurrConstant('CCShadow', layout);
- _vec4ShadowInfo.set(0, 0, 0, 1.0 - mainLight.shadowSaturation);
- setter.setVec4('cc_shadowNFLSInfo', _vec4ShadowInfo);
- _vec4ShadowInfo.set(0.0, packing, mainLight.shadowNormalBias, mainLight.csmLevel);
- setter.setVec4('cc_shadowLPNNInfo', _vec4ShadowInfo);
+ uniformOffset = setter.getUniformOffset('cc_shadowNFLSInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(0, 0, 0, 1.0 - mainLight.shadowSaturation);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_shadowLPNNInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(0.0, packing, mainLight.shadowNormalBias, mainLight.csmLevel);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
}
}
if (hasCCShadow) {
setter.setCurrConstant('CCShadow', layout);
- _vec4ShadowInfo.set(shadowInfo.size.x, shadowInfo.size.y, mainLight.shadowPcf, mainLight.shadowBias);
- setter.setVec4('cc_shadowWHPBInfo', _vec4ShadowInfo);
+ uniformOffset = setter.getUniformOffset('cc_shadowWHPBInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(shadowInfo.size.x, shadowInfo.size.y, mainLight.shadowPcf, mainLight.shadowBias);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
}
}
} else if (hasCCShadow) {
setter.setCurrConstant('CCShadow', layout);
- const _tempVec3 = new Vec3();
- Vec3.normalize(_tempVec3, shadowInfo.normal);
- setter.setVec4('cc_planarNDInfo', new Vec4(_tempVec3.x, _tempVec3.y, _tempVec3.z, -shadowInfo.distance));
+ uniformOffset = setter.getUniformOffset('cc_planarNDInfo', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ Vec3.normalize(_uboVec3, shadowInfo.normal);
+ _uboVec.set(_uboVec3.x, _uboVec3.y, _uboVec3.z, -shadowInfo.distance);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
}
if (hasCCShadow) {
setter.setCurrConstant('CCShadow', layout);
- setter.setColor('cc_shadowColor', shadowInfo.shadowColor);
+ uniformOffset = setter.getUniformOffset('cc_shadowColor', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetColor(shadowInfo.shadowColor, uniformOffset);
+ }
}
}
}
function setCameraUBOValues (setter: WebSetter,
- camera: Readonly, cfg: Readonly,
+ camera: Readonly | null, cfg: Readonly,
scene: Readonly,
layoutName = 'default') {
const director = cclegacy.director;
@@ -453,59 +583,139 @@ function setCameraUBOValues (setter: WebSetter,
const shadingScale = cfg.shadingScale;
// Camera
if (!setter.addConstant('CCCamera', layoutName)) return;
- setter.setMat4('cc_matView', camera.matView);
- setter.setMat4('cc_matViewInv', camera.node.worldMatrix);
- setter.setMat4('cc_matProj', camera.matProj);
- setter.setMat4('cc_matProjInv', camera.matProjInv);
- setter.setMat4('cc_matViewProj', camera.matViewProj);
- setter.setMat4('cc_matViewProjInv', camera.matViewProjInv);
- setter.setVec4('cc_cameraPos', new Vec4(camera.position.x, camera.position.y, camera.position.z, pipeline.getCombineSignY()));
- setter.setVec4('cc_surfaceTransform', new Vec4(camera.surfaceTransform, 0.0, Math.cos(toRadian(skybox.getRotationAngle())), Math.sin(toRadian(skybox.getRotationAngle()))));
- setter.setVec4('cc_screenScale', new Vec4(cfg.shadingScale, cfg.shadingScale, 1.0 / cfg.shadingScale, 1.0 / cfg.shadingScale));
- setter.setVec4('cc_exposure', new Vec4(camera.exposure, 1.0 / camera.exposure, cfg.isHDR ? 1.0 : 0.0, 1.0 / Camera.standardExposureValue));
-
+ if (camera) {
+ uniformOffset = setter.getUniformOffset('cc_matView', Type.MAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetMat4(camera.matView, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_matViewInv', Type.MAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetMat4(camera.node.worldMatrix, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_matProj', Type.MAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetMat4(camera.matProj, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_matProjInv', Type.MAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetMat4(camera.matProjInv, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_matViewProj', Type.MAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetMat4(camera.matViewProj, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_matViewProjInv', Type.MAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ setter.offsetMat4(camera.matViewProjInv, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_surfaceTransform', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(camera.surfaceTransform, 0.0, Math.cos(toRadian(skybox.getRotationAngle())), Math.sin(toRadian(skybox.getRotationAngle())));
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_exposure', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(camera.exposure, 1.0 / camera.exposure, cfg.isHDR ? 1.0 : 0.0, 1.0 / Camera.standardExposureValue);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ }
+ uniformOffset = setter.getUniformOffset('cc_cameraPos', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ if (camera) { _uboVec.set(camera.position.x, camera.position.y, camera.position.z, pipeline.getCombineSignY()); } else { _uboVec.set(0, 0, 0, pipeline.getCombineSignY()); }
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_screenScale', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(cfg.shadingScale, cfg.shadingScale, 1.0 / cfg.shadingScale, 1.0 / cfg.shadingScale);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
const mainLight = scene.mainLight;
if (mainLight) {
- const shadowEnable = (mainLight.shadowEnabled && shadowInfo.type === ShadowType.ShadowMap) ? 1.0 : 0.0;
- setter.setVec4('cc_mainLitDir', new Vec4(mainLight.direction.x, mainLight.direction.y, mainLight.direction.z, shadowEnable));
- let r = mainLight.color.x;
- let g = mainLight.color.y;
- let b = mainLight.color.z;
- if (mainLight.useColorTemperature) {
- r *= mainLight.colorTemperatureRGB.x;
- g *= mainLight.colorTemperatureRGB.y;
- b *= mainLight.colorTemperatureRGB.z;
+ uniformOffset = setter.getUniformOffset('cc_mainLitDir', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ const shadowEnable = (mainLight.shadowEnabled && shadowInfo.type === ShadowType.ShadowMap) ? 1.0 : 0.0;
+ _uboVec.set(mainLight.direction.x, mainLight.direction.y, mainLight.direction.z, shadowEnable);
+ setter.offsetVec4(_uboVec, uniformOffset);
}
- let w = mainLight.illuminance;
- if (cfg.isHDR) {
- w *= camera.exposure;
+ uniformOffset = setter.getUniformOffset('cc_mainLitColor', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ let r = mainLight.color.x;
+ let g = mainLight.color.y;
+ let b = mainLight.color.z;
+ if (mainLight.useColorTemperature) {
+ r *= mainLight.colorTemperatureRGB.x;
+ g *= mainLight.colorTemperatureRGB.y;
+ b *= mainLight.colorTemperatureRGB.z;
+ }
+ let w = mainLight.illuminance;
+ if (cfg.isHDR && camera) {
+ w *= camera.exposure;
+ }
+ _uboVec.set(r, g, b, w);
+ setter.offsetVec4(_uboVec, uniformOffset);
}
- setter.setVec4('cc_mainLitColor', new Vec4(r, g, b, w));
} else {
- setter.setVec4('cc_mainLitDir', new Vec4(0, 0, 1, 0));
- setter.setVec4('cc_mainLitColor', new Vec4(0, 0, 0, 0));
+ uniformOffset = setter.getUniformOffset('cc_mainLitDir', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(0, 0, 1, 0);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_mainLitColor', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(0, 0, 0, 0);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
}
const ambient = cfg.ambient;
- const skyColor = ambient.skyColor;
- if (cfg.isHDR) {
- skyColor.w = ambient.skyIllum * camera.exposure;
- } else {
- skyColor.w = ambient.skyIllum;
+ uniformOffset = setter.getUniformOffset('cc_ambientSky', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ const skyColor = ambient.skyColor;
+ if (cfg.isHDR) {
+ skyColor.w = ambient.skyIllum * (camera ? camera.exposure : 1);
+ } else {
+ skyColor.w = ambient.skyIllum;
+ }
+ _uboVec.set(skyColor.x, skyColor.y, skyColor.z, skyColor.w);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_ambientGround', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(ambient.groundAlbedo.x, ambient.groundAlbedo.y, ambient.groundAlbedo.z, skybox.envmap ? skybox.envmap?.mipmapLevel : 1.0);
+ setter.offsetVec4(_uboVec, uniformOffset);
}
- setter.setVec4('cc_ambientSky', new Vec4(skyColor.x, skyColor.y, skyColor.z, skyColor.w));
- setter.setVec4('cc_ambientGround', new Vec4(ambient.groundAlbedo.x, ambient.groundAlbedo.y, ambient.groundAlbedo.z, skybox.envmap ? skybox.envmap?.mipmapLevel : 1.0));
-
const fog = cfg.fog;
- const colorTempRGB = fog.colorArray;
- setter.setVec4('cc_fogColor', new Vec4(colorTempRGB.x, colorTempRGB.y, colorTempRGB.z, colorTempRGB.z));
- setter.setVec4('cc_fogBase', new Vec4(fog.fogStart, fog.fogEnd, fog.fogDensity, 0.0));
- setter.setVec4('cc_fogAdd', new Vec4(fog.fogTop, fog.fogRange, fog.fogAtten, 0.0));
- setter.setVec4('cc_nearFar', new Vec4(camera.nearClip, camera.farClip, 0.0, 0.0));
- setter.setVec4('cc_viewPort', new Vec4(camera.viewport.x, camera.viewport.y, shadingScale * camera.window.width * camera.viewport.z, shadingScale * camera.window.height * camera.viewport.w));
+ uniformOffset = setter.getUniformOffset('cc_fogColor', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ const colorTempRGB = fog.colorArray;
+ _uboVec.set(colorTempRGB.x, colorTempRGB.y, colorTempRGB.z, colorTempRGB.z);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_fogBase', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(fog.fogStart, fog.fogEnd, fog.fogDensity, 0.0);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_fogAdd', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(fog.fogTop, fog.fogRange, fog.fogAtten, 0.0);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ if (camera) {
+ uniformOffset = setter.getUniformOffset('cc_nearFar', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(camera.nearClip, camera.farClip, 0.0, 0.0);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_viewPort', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(camera.viewport.x, camera.viewport.y, shadingScale * camera.window.width * camera.viewport.z, shadingScale * camera.window.height * camera.viewport.w);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ }
}
-function setTextureUBOView (setter: WebSetter, camera: Camera, cfg: Readonly, layout = 'default') {
+function setTextureUBOView (setter: WebSetter, camera: Camera | null, cfg: Readonly, layout = 'default') {
const skybox = cfg.skybox;
const director = cclegacy.director;
const root = director.root;
@@ -530,15 +740,6 @@ function setTextureUBOView (setter: WebSetter, camera: Camera, cfg: Readonly(
@@ -644,10 +858,13 @@ export class WebRasterQueueBuilder extends WebSetter implements RasterQueueBuild
'Viewport', '', new RenderData(), false, this._vertID,
);
}
- private readonly _renderGraph: RenderGraph;
- private readonly _vertID: number;
- private readonly _queue: RenderQueue;
- private readonly _pipeline: PipelineSceneData;
+ addCustomCommand (customBehavior: string): void {
+ throw new Error('Method not implemented.');
+ }
+ private _renderGraph: RenderGraph;
+ private _vertID: number;
+ private _queue: RenderQueue;
+ private _pipeline: PipelineSceneData;
}
export class WebRasterSubpassBuilder extends WebSetter implements RasterSubpassBuilder {
@@ -665,26 +882,48 @@ export class WebRasterSubpassBuilder extends WebSetter implements RasterSubpassB
);
this._layoutID = layoutGraph.locateChild(layoutGraph.nullVertex(), layoutName);
}
+ setArrayBuffer (name: string, arrayBuffer: ArrayBuffer): void {
+ throw new Error('Method not implemented.');
+ }
get name () {
return this._renderGraph.getName(this._vertID);
}
set name (name: string) {
this._renderGraph.setName(this._vertID, name);
}
+ addRenderTarget (name: string, accessType: AccessType, slotName: string, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, clearColor = new Color()) {
+ throw new Error('Method not implemented.');
+ }
+ addDepthStencil (name: string, accessType: AccessType, slotName: string, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, depth = 1, stencil = 0, clearFlag = ClearFlagBit.DEPTH_STENCIL): void {
+ throw new Error('Method not implemented.');
+ }
+ addTexture (name: string, slotName: string): void {
+ throw new Error('Method not implemented.');
+ }
+ addStorageBuffer (name: string, accessType: AccessType, slotName: string): void {
+ throw new Error('Method not implemented.');
+ }
+ addStorageImage (name: string, accessType: AccessType, slotName: string): void {
+ throw new Error('Method not implemented.');
+ }
addRasterView (name: string, view: RasterView): void {
-
+ throw new Error('Method not implemented.');
}
addComputeView (name: string, view: ComputeView): void {
-
+ throw new Error('Method not implemented.');
}
setViewport (viewport: Viewport): void {
-
+ throw new Error('Method not implemented.');
}
- addQueue (hint: QueueHint = QueueHint.RENDER_OPAQUE, name = 'Queue'): RasterQueueBuilder {
+ addQueue (hint: QueueHint = QueueHint.RENDER_OPAQUE, layoutName = 'default'): RasterQueueBuilder {
+ if (DEBUG) {
+ const layoutId = this._layoutGraph.locateChild(this._layoutID, layoutName);
+ assert(layoutId !== 0xFFFFFFFF);
+ }
const queue = new RenderQueue(hint);
const data = new RenderData();
const queueID = this._renderGraph.addVertex(
- RenderGraphValue.Queue, queue, name, '', data, false, this._vertID,
+ RenderGraphValue.Queue, queue, '', layoutName, data, false, this._vertID,
);
return new WebRasterQueueBuilder(data, this._renderGraph, this._layoutGraph, queueID, queue, this._pipeline);
}
@@ -704,10 +943,11 @@ export class WebRasterSubpassBuilder extends WebSetter implements RasterSubpassB
}
export class WebRasterPassBuilder extends WebSetter implements RasterPassBuilder {
- constructor (data: RenderData, renderGraph: RenderGraph, layoutGraph: LayoutGraphData, vertID: number, pass: RasterPass, pipeline: PipelineSceneData) {
+ constructor (data: RenderData, renderGraph: RenderGraph, layoutGraph: LayoutGraphData, resourceGraph: ResourceGraph, vertID: number, pass: RasterPass, pipeline: PipelineSceneData) {
super(data, layoutGraph);
this._renderGraph = renderGraph;
this._layoutGraph = layoutGraph;
+ this._resourceGraph = resourceGraph;
this._vertID = vertID;
this._pass = pass;
this._pipeline = pipeline;
@@ -717,6 +957,26 @@ export class WebRasterPassBuilder extends WebSetter implements RasterPassBuilder
);
this._layoutID = layoutGraph.locateChild(layoutGraph.nullVertex(), layoutName);
}
+ addRasterView (name: string, view: RasterView) {
+ this._pass.rasterViews.set(name, view);
+ }
+ addComputeView (name: string, view: ComputeView) {
+ if (DEBUG) {
+ assert(view.name);
+ assert(name && this._resourceGraph.contains(name));
+ const descriptorName = view.name;
+ const descriptorID = this._layoutGraph.attributeIndex.get(descriptorName);
+ assert(descriptorID !== undefined);
+ }
+ if (this._pass.computeViews.has(name)) {
+ this._pass.computeViews.get(name)?.push(view);
+ } else {
+ this._pass.computeViews.set(name, [view]);
+ }
+ }
+ setArrayBuffer (name: string, arrayBuffer: ArrayBuffer): void {
+ throw new Error('Method not implemented.');
+ }
setVersion (name: string, version: number): void {
this._pass.versionName = name;
this._pass.version = version;
@@ -727,16 +987,59 @@ export class WebRasterPassBuilder extends WebSetter implements RasterPassBuilder
set name (name: string) {
this._renderGraph.setName(this._vertID, name);
}
- addRasterView (name: string, view: RasterView) {
+ addRenderTarget (name: string, slotName: string, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, clearColor = new Color()) {
+ if (DEBUG) {
+ assert(name && this._resourceGraph.contains(name));
+ }
+ let clearFlag = ClearFlagBit.COLOR;
+ if (loadOp === LoadOp.LOAD) {
+ clearFlag = ClearFlagBit.NONE;
+ }
+ const view = new RasterView(slotName,
+ AccessType.WRITE, AttachmentType.RENDER_TARGET,
+ loadOp,
+ storeOp,
+ clearFlag,
+ clearColor);
this._pass.rasterViews.set(name, view);
}
- addComputeView (name: string, view: ComputeView) {
+ addDepthStencil (name: string, slotName: string, loadOp = LoadOp.CLEAR, storeOp = StoreOp.STORE, depth = 1, stencil = 0, clearFlag = ClearFlagBit.DEPTH_STENCIL): void {
+ if (DEBUG) {
+ assert(name && this._resourceGraph.contains(name));
+ }
+ const view = new RasterView(slotName,
+ AccessType.WRITE, AttachmentType.DEPTH_STENCIL,
+ loadOp,
+ storeOp,
+ clearFlag,
+ new Color(depth, stencil, 0, 0));
+ this._pass.rasterViews.set(name, view);
+ }
+ private _addComputeResource (name: string, accessType: AccessType, slotName: string) {
+ const view = new ComputeView(slotName);
+ view.accessType = accessType;
+ if (DEBUG) {
+ assert(view.name);
+ assert(name && this._resourceGraph.contains(name));
+ const descriptorName = view.name;
+ const descriptorID = this._layoutGraph.attributeIndex.get(descriptorName);
+ assert(descriptorID !== undefined);
+ }
if (this._pass.computeViews.has(name)) {
this._pass.computeViews.get(name)?.push(view);
} else {
this._pass.computeViews.set(name, [view]);
}
}
+ addTexture (name: string, slotName: string): void {
+ this._addComputeResource(name, AccessType.READ, slotName);
+ }
+ addStorageBuffer (name: string, accessType: AccessType, slotName: string): void {
+ this._addComputeResource(name, accessType, slotName);
+ }
+ addStorageImage (name: string, accessType: AccessType, slotName: string): void {
+ this._addComputeResource(name, accessType, slotName);
+ }
addRasterSubpass (layoutName = ''): RasterSubpassBuilder {
const name = 'Raster';
const subpassID = this._pass.subpassGraph.numVertices();
@@ -752,11 +1055,15 @@ export class WebRasterPassBuilder extends WebSetter implements RasterPassBuilder
addComputeSubpass (layoutName = ''): ComputeSubpassBuilder {
throw new Error('Method not implemented.');
}
- addQueue (hint: QueueHint = QueueHint.RENDER_OPAQUE, name = 'Queue') {
+ addQueue (hint: QueueHint = QueueHint.RENDER_OPAQUE, layoutName = 'default') {
+ if (DEBUG) {
+ const layoutId = this._layoutGraph.locateChild(this._layoutID, layoutName);
+ assert(layoutId !== 0xFFFFFFFF);
+ }
const queue = new RenderQueue(hint);
const data = new RenderData();
const queueID = this._renderGraph.addVertex(
- RenderGraphValue.Queue, queue, name, '', data, false, this._vertID,
+ RenderGraphValue.Queue, queue, '', layoutName, data, false, this._vertID,
);
return new WebRasterQueueBuilder(data, this._renderGraph, this._layoutGraph, queueID, queue, this._pipeline);
}
@@ -800,6 +1107,7 @@ export class WebRasterPassBuilder extends WebSetter implements RasterPassBuilder
private readonly _pass: RasterPass;
private readonly _pipeline: PipelineSceneData;
private readonly _layoutGraph: LayoutGraphData;
+ private readonly _resourceGraph: ResourceGraph;
}
export class WebComputeQueueBuilder extends WebSetter implements ComputeQueueBuilder {
@@ -810,6 +1118,9 @@ export class WebComputeQueueBuilder extends WebSetter implements ComputeQueueBui
this._queue = queue;
this._pipeline = pipeline;
}
+ setArrayBuffer (name: string, arrayBuffer: ArrayBuffer): void {
+ throw new Error('Method not implemented.');
+ }
get name () {
return this._renderGraph.getName(this._vertID);
}
@@ -837,10 +1148,11 @@ export class WebComputeQueueBuilder extends WebSetter implements ComputeQueueBui
}
export class WebComputePassBuilder extends WebSetter implements ComputePassBuilder {
- constructor (data: RenderData, renderGraph: RenderGraph, layoutGraph: LayoutGraphData, vertID: number, pass: ComputePass, pipeline: PipelineSceneData) {
+ constructor (data: RenderData, renderGraph: RenderGraph, layoutGraph: LayoutGraphData, resourceGraph: ResourceGraph, vertID: number, pass: ComputePass, pipeline: PipelineSceneData) {
super(data, layoutGraph);
this._renderGraph = renderGraph;
this._layoutGraph = layoutGraph;
+ this._resourceGraph = resourceGraph;
this._vertID = vertID;
this._pass = pass;
this._pipeline = pipeline;
@@ -850,29 +1162,49 @@ export class WebComputePassBuilder extends WebSetter implements ComputePassBuild
);
this._layoutID = layoutGraph.locateChild(layoutGraph.nullVertex(), layoutName);
}
+ setArrayBuffer (name: string, arrayBuffer: ArrayBuffer): void {
+ throw new Error('Method not implemented.');
+ }
get name () {
return this._renderGraph.getName(this._vertID);
}
set name (name: string) {
this._renderGraph.setName(this._vertID, name);
}
+ addTexture (name: string, slotName: string): void {
+ throw new Error('Method not implemented.');
+ }
+ addStorageBuffer (name: string, accessType: AccessType, slotName: string): void {
+ throw new Error('Method not implemented.');
+ }
+ addStorageImage (name: string, accessType: AccessType, slotName: string): void {
+ throw new Error('Method not implemented.');
+ }
addComputeView (name: string, view: ComputeView) {
+ if (DEBUG) {
+ assert(name && this._resourceGraph.contains(name));
+ }
if (this._pass.computeViews.has(name)) {
this._pass.computeViews.get(name)?.push(view);
} else {
this._pass.computeViews.set(name, [view]);
}
}
- addQueue (name = 'Queue') {
+ addQueue (layoutName = 'default') {
+ if (DEBUG) {
+ const layoutId = this._layoutGraph.locateChild(this._layoutID, layoutName);
+ assert(layoutId !== 0xFFFFFFFF);
+ }
const queue = new RenderQueue();
const data = new RenderData();
const queueID = this._renderGraph.addVertex(
- RenderGraphValue.Queue, queue, name, '', data, false, this._vertID,
+ RenderGraphValue.Queue, queue, '', layoutName, data, false, this._vertID,
);
return new WebComputeQueueBuilder(data, this._renderGraph, this._layoutGraph, queueID, queue, this._pipeline);
}
private readonly _renderGraph: RenderGraph;
private readonly _layoutGraph: LayoutGraphData;
+ private readonly _resourceGraph: ResourceGraph;
private readonly _vertID: number;
private readonly _layoutID: number;
private readonly _pass: ComputePass;
@@ -885,6 +1217,9 @@ export class WebMovePassBuilder implements MovePassBuilder {
this._vertID = vertID;
this._pass = pass;
}
+ setCustomBehavior (name: string): void {
+ throw new Error('Method not implemented.');
+ }
get name () {
return this._renderGraph.getName(this._vertID);
}
@@ -905,6 +1240,9 @@ export class WebCopyPassBuilder implements CopyPassBuilder {
this._vertID = vertID;
this._pass = pass;
}
+ setCustomBehavior (name: string): void {
+ throw new Error('Method not implemented.');
+ }
get name () {
return this._renderGraph.getName(this._vertID);
}
@@ -928,6 +1266,41 @@ export class WebPipeline implements Pipeline {
constructor (layoutGraph: LayoutGraphData) {
this._layoutGraph = layoutGraph;
}
+ addRenderTexture (name: string, format: Format, width: number, height: number, renderWindow: RenderWindow): number {
+ return this.addRenderWindow(name, format, width, height, renderWindow);
+ }
+ addRenderWindow (name: string, format: Format, width: number, height: number, renderWindow: RenderWindow): number {
+ const desc = new ResourceDesc();
+ desc.dimension = ResourceDimension.TEXTURE2D;
+ desc.width = width;
+ desc.height = height;
+ desc.depthOrArraySize = 1;
+ desc.mipLevels = 1;
+ desc.format = format;
+ desc.flags = ResourceFlags.COLOR_ATTACHMENT;
+
+ if (renderWindow.swapchain === null) {
+ assert(renderWindow.framebuffer.colorTextures.length === 1
+ && renderWindow.framebuffer.colorTextures[0] !== null);
+ return this._resourceGraph.addVertex(
+ ResourceGraphValue.Framebuffer,
+ renderWindow.framebuffer,
+ name, desc,
+ new ResourceTraits(ResourceResidency.EXTERNAL),
+ new ResourceStates(),
+ new SamplerInfo(),
+ );
+ } else {
+ return this._resourceGraph.addVertex(
+ ResourceGraphValue.Swapchain,
+ new RenderSwapchain(renderWindow.swapchain),
+ name, desc,
+ new ResourceTraits(ResourceResidency.BACKBUFFER),
+ new ResourceStates(),
+ new SamplerInfo(),
+ );
+ }
+ }
updateRenderWindow (name: string, renderWindow: RenderWindow): void {
const resId = this.resourceGraph.vertex(name);
const currFbo = this.resourceGraph._vertices[resId]._object;
@@ -1156,6 +1529,13 @@ export class WebPipeline implements Pipeline {
}
return value as boolean;
}
+ public getSamplerInfo (name: string): SamplerInfo | null {
+ if (this.containsResource(name)) {
+ const verId = this._resourceGraph.vertex(name);
+ return this._resourceGraph.getSampler(verId);
+ }
+ return null;
+ }
public setMacroString (name: string, value: string): void {
this._macros[name] = value;
}
@@ -1170,43 +1550,10 @@ export class WebPipeline implements Pipeline {
}
beginSetup (): void {
if (!this._renderGraph) this._renderGraph = new RenderGraph();
- // this.renderGraph!.clear();
}
endSetup (): void {
this.compile();
}
- addRenderTexture (name: string, format: Format, width: number, height: number, renderWindow: RenderWindow) {
- const desc = new ResourceDesc();
- desc.dimension = ResourceDimension.TEXTURE2D;
- desc.width = width;
- desc.height = height;
- desc.depthOrArraySize = 1;
- desc.mipLevels = 1;
- desc.format = format;
- desc.flags = ResourceFlags.COLOR_ATTACHMENT;
-
- if (renderWindow.swapchain === null) {
- assert(renderWindow.framebuffer.colorTextures.length === 1
- && renderWindow.framebuffer.colorTextures[0] !== null);
- return this._resourceGraph.addVertex(
- ResourceGraphValue.Framebuffer,
- renderWindow.framebuffer,
- name, desc,
- new ResourceTraits(ResourceResidency.EXTERNAL),
- new ResourceStates(),
- new SamplerInfo(),
- );
- } else {
- return this._resourceGraph.addVertex(
- ResourceGraphValue.Swapchain,
- new RenderSwapchain(renderWindow.swapchain),
- name, desc,
- new ResourceTraits(ResourceResidency.BACKBUFFER),
- new ResourceStates(),
- new SamplerInfo(),
- );
- }
- }
addStorageBuffer (name: string, format: Format, size: number, residency = ResourceResidency.MANAGED): number {
const desc = new ResourceDesc();
desc.dimension = ResourceDimension.BUFFER;
@@ -1363,6 +1710,13 @@ export class WebPipeline implements Pipeline {
}
addRasterPass (width: number, height: number, layoutName = 'default'): RasterPassBuilder {
+ if (DEBUG) {
+ const stageId = this.layoutGraph.locateChild(this.layoutGraph.nullVertex(), layoutName);
+ assert(stageId !== 0xFFFFFFFF);
+ const layout = this.layoutGraph.getLayout(stageId);
+ assert(layout);
+ assert(layout.descriptorSets.get(UpdateFrequency.PER_PASS));
+ }
const name = 'Raster';
const pass = new RasterPass();
pass.viewport.width = width;
@@ -1372,7 +1726,7 @@ export class WebPipeline implements Pipeline {
const vertID = this._renderGraph!.addVertex(
RenderGraphValue.RasterPass, pass, name, layoutName, data, false,
);
- const result = new WebRasterPassBuilder(data, this._renderGraph!, this._layoutGraph, vertID, pass, this._pipelineSceneData);
+ const result = new WebRasterPassBuilder(data, this._renderGraph!, this._layoutGraph, this._resourceGraph, vertID, pass, this._pipelineSceneData);
this._updateRasterPassConstants(result, width, height, isEnableEffect() ? layoutName : 'default');
initGlobalDescBinding(data, layoutName);
return result;
@@ -1403,23 +1757,39 @@ export class WebPipeline implements Pipeline {
const layoutGraph = pipeline.layoutGraph;
// Global
if (!setter.addConstant('CCGlobal', layoutName)) return;
- setter.setVec4('cc_time', new Vec4(root.cumulativeTime, root.frameTime, director.getTotalFrames()));
- setter.setVec4('cc_screenSize', new Vec4(shadingWidth, shadingHeight, 1.0 / shadingWidth, 1.0 / shadingHeight));
- setter.setVec4('cc_nativeSize', new Vec4(shadingWidth, shadingHeight, 1.0 / shadingWidth, 1.0 / shadingHeight));
+ uniformOffset = setter.getUniformOffset('cc_time', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(root.cumulativeTime, root.frameTime, director.getTotalFrames());
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_screenSize', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(shadingWidth, shadingHeight, 1.0 / shadingWidth, 1.0 / shadingHeight);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
+ uniformOffset = setter.getUniformOffset('cc_nativeSize', Type.FLOAT4);
+ if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(shadingWidth, shadingHeight, 1.0 / shadingWidth, 1.0 / shadingHeight);
+ setter.offsetVec4(_uboVec, uniformOffset);
+ }
const debugView = root.debugView;
+ uniformOffset = setter.getUniformOffset('cc_debug_view_mode', Type.FLOAT4);
if (debugView) {
- const debugPackVec: number[] = [debugView.singleMode as number, 0.0, 0.0, 0.0];
- for (let i = DebugViewCompositeType.DIRECT_DIFFUSE as number; i < DebugViewCompositeType.MAX_BIT_COUNT; i++) {
- const idx = i >> 3;
- const bit = i % 8;
- debugPackVec[idx + 1] += (debugView.isCompositeModeEnabled(i) ? 1.0 : 0.0) * (10.0 ** bit);
+ if (setter.hasUniform(uniformOffset)) {
+ const debugPackVec: number[] = [debugView.singleMode as number, 0.0, 0.0, 0.0];
+ for (let i = DebugViewCompositeType.DIRECT_DIFFUSE as number; i < DebugViewCompositeType.MAX_BIT_COUNT; i++) {
+ const idx = i >> 3;
+ const bit = i % 8;
+ debugPackVec[idx + 1] += (debugView.isCompositeModeEnabled(i) ? 1.0 : 0.0) * (10.0 ** bit);
+ }
+ debugPackVec[3] += (debugView.lightingWithAlbedo ? 1.0 : 0.0) * (10.0 ** 6.0);
+ debugPackVec[3] += (debugView.csmLayerColoration ? 1.0 : 0.0) * (10.0 ** 7.0);
+ _uboVec.set(debugPackVec[0], debugPackVec[1], debugPackVec[2], debugPackVec[3]);
+ setter.offsetVec4(_uboVec, uniformOffset);
}
- debugPackVec[3] += (debugView.lightingWithAlbedo ? 1.0 : 0.0) * (10.0 ** 6.0);
- debugPackVec[3] += (debugView.csmLayerColoration ? 1.0 : 0.0) * (10.0 ** 7.0);
-
- setter.setVec4('cc_debug_view_mode', new Vec4(debugPackVec[0], debugPackVec[1], debugPackVec[2], debugPackVec[3]));
- } else {
- setter.setVec4('cc_debug_view_mode', new Vec4(0.0, 0.0, 0.0, 0.0));
+ } else if (setter.hasUniform(uniformOffset)) {
+ _uboVec.set(0.0, 0.0, 0.0, 0.0);
+ setter.offsetVec4(_uboVec, uniformOffset);
}
}
diff --git a/cocos/rendering/render-additive-light-queue.ts b/cocos/rendering/render-additive-light-queue.ts
index f8d0c99bbb..3b2bb64695 100644
--- a/cocos/rendering/render-additive-light-queue.ts
+++ b/cocos/rendering/render-additive-light-queue.ts
@@ -86,10 +86,10 @@ function cullRangedDirLight (light: RangedDirectionalLight, model: Model) {
const phaseName = 'forward-add';
let _phaseID = getPhaseID(phaseName);
const _lightPassIndices: number[] = [];
-function getLightPassIndices (subModels: SubModel[], lightPassIndices: number[]) {
+function getLightPassIndices (subModels: SubModel[], lightPassIndices: number[], passLayout = 'default') {
const r = cclegacy.rendering;
if (isEnableEffect()) {
- _phaseID = r.getPhaseID(r.getPassID('default'), phaseName);
+ _phaseID = r.getPhaseID(r.getPassID(passLayout), phaseName);
}
lightPassIndices.length = 0;
let hasValidLightPass = false;
@@ -191,26 +191,19 @@ export class RenderAdditiveLightQueue {
}
}
- public gatherLightPasses (camera: Camera, cmdBuff: CommandBuffer) {
- this.clear();
-
- const validPunctualLights = this._pipeline.pipelineSceneData.validPunctualLights;
- if (!validPunctualLights.length) { return; }
-
- this._updateUBOs(camera, cmdBuff);
- this._updateLightDescriptorSet(camera, cmdBuff);
+ private _bindForwardAddLight (validPunctualLights, passLayout = 'default') {
const renderObjects = this._pipeline.pipelineSceneData.renderObjects;
for (let i = 0; i < renderObjects.length; i++) {
const ro = renderObjects[i];
const { model } = ro;
const { subModels } = model;
- if (!getLightPassIndices(subModels, _lightPassIndices)) { continue; }
+ if (!getLightPassIndices(subModels, _lightPassIndices, passLayout)) { continue; }
_lightIndices.length = 0;
this._lightCulling(model, validPunctualLights);
- if (!_lightIndices.length) { continue; }
+ if (!_lightIndices.length && validPunctualLights.length > 0) { continue; }
for (let j = 0; j < subModels.length; j++) {
const lightPassIdx = _lightPassIndices[j];
@@ -229,7 +222,20 @@ export class RenderAdditiveLightQueue {
this._addRenderQueue(pass, subModel, model, lightPassIdx);
}
}
+ }
+ public gatherLightPasses (camera: Camera, cmdBuff: CommandBuffer, passLayout = 'default') {
+ this.clear();
+
+ const validPunctualLights = this._pipeline.pipelineSceneData.validPunctualLights;
+ if (!validPunctualLights.length) {
+ this._bindForwardAddLight(validPunctualLights, passLayout);
+ return;
+ }
+
+ this._updateUBOs(camera, cmdBuff);
+ this._updateLightDescriptorSet(camera, cmdBuff);
+ this._bindForwardAddLight(validPunctualLights, passLayout);
// only for instanced and batched, no light culling applied
for (let l = 0; l < validPunctualLights.length; l++) {
const light = validPunctualLights[l];
diff --git a/cocos/root.ts b/cocos/root.ts
index 4c6158d630..006327bfc3 100644
--- a/cocos/root.ts
+++ b/cocos/root.ts
@@ -25,7 +25,7 @@
import { Pool, cclegacy, warnID, settings, Settings, macro } from './core';
import { RenderPipeline, createDefaultPipeline, DeferredPipeline } from './rendering';
import { DebugView } from './rendering/debug-view';
-import { Camera, Light, Model } from './render-scene/scene';
+import { Camera, CameraType, Light, Model, TrackingType } from './render-scene/scene';
import type { DataPoolManager } from './3d/skeletal-animation/data-pool-manager';
import { LightType } from './render-scene/scene/light';
import { IRenderSceneInfo, RenderScene } from './render-scene/core/render-scene';
@@ -40,6 +40,7 @@ import { Pipeline, PipelineRuntime } from './rendering/custom/pipeline';
import { Batcher2D } from './2d/renderer/batcher-2d';
import { IPipelineEvent } from './rendering/pipeline-event';
import { localDescriptorSetLayout_ResizeMaxJoints, UBOCamera, UBOGlobal, UBOLocal, UBOShadow, UBOWorldBound } from './rendering/define';
+import { XREye, XRPoseType } from './xr/xr-enums';
/**
* @en Initialization information for the Root
@@ -469,7 +470,6 @@ export class Root {
* @param deltaTime @en The delta time since last update. @zh 距离上一帧间隔时间
*/
public frameMove (deltaTime: number) {
- const { director, Director } = cclegacy;
this._frameTime = deltaTime;
/*
@@ -491,46 +491,14 @@ export class Root {
this._frameCount = 0;
this._fpsTime = 0.0;
}
- for (let i = 0; i < this._scenes.length; ++i) {
- this._scenes[i].removeBatches();
+
+ if (globalThis.__globalXR?.isWebXR) {
+ this._doWebXRFrameMove();
+ } else {
+ this._frameMoveBegin();
+ this._frameMoveProcess();
+ this._frameMoveEnd();
}
-
- const windows = this._windows;
- const cameraList = this._cameraList;
- cameraList.length = 0;
-
- for (let i = 0; i < windows.length; i++) {
- const window = windows[i];
- window.extractRenderCameras(cameraList);
- }
-
- if (this._pipeline && cameraList.length > 0) {
- this._device.acquire([deviceManager.swapchain]);
- const scenes = this._scenes;
- const stamp = director.getTotalFrames();
-
- if (this._batcher) {
- this._batcher.update();
- this._batcher.uploadBuffers();
- }
-
- for (let i = 0; i < scenes.length; i++) {
- scenes[i].update(stamp);
- }
-
- director.emit(Director.EVENT_BEFORE_COMMIT);
- cameraList.sort((a: Camera, b: Camera) => a.priority - b.priority);
-
- for (let i = 0; i < cameraList.length; ++i) {
- cameraList[i].geometryRenderer?.update();
- }
- director.emit(Director.EVENT_BEFORE_RENDER);
- this._pipeline.render(cameraList);
- director.emit(Director.EVENT_AFTER_RENDER);
- this._device.present();
- }
-
- if (this._batcher) this._batcher.reset();
}
/**
@@ -733,6 +701,121 @@ export class Root {
}
}
+ private _doWebXRFrameMove () {
+ const xr = globalThis.__globalXR;
+ if (!xr || !xr.webXRMatProjs) {
+ return;
+ }
+
+ const windows = this._windows;
+ const cameraList = this._cameraList;
+ const viewCount = xr.webXRMatProjs.length;
+ if (!xr.webXRWindowMap) {
+ xr.webXRWindowMap = new Map();
+ }
+
+ let allcameras: Camera[] = [];
+ const webxrHmdPoseInfos = xr.webxrHmdPoseInfos;
+ for (let xrEye = 0; xrEye < viewCount; xrEye++) {
+ for (const window of windows) {
+ allcameras = allcameras.concat(window.cameras);
+ if (window.swapchain) {
+ xr.webXRWindowMap.set(window, xrEye);
+ }
+ }
+
+ if (webxrHmdPoseInfos) {
+ const cameraPosition: number[] = [];
+ for (let i = 0; i < webxrHmdPoseInfos.length; i++) {
+ const info = webxrHmdPoseInfos[i];
+ if ((info.code === XRPoseType.VIEW_LEFT && xrEye === XREye.LEFT)
+ || (info.code === XRPoseType.VIEW_RIGHT && xrEye === XREye.RIGHT)) {
+ cameraPosition[0] = info.position.x;
+ cameraPosition[1] = info.position.y;
+ cameraPosition[2] = info.position.z;
+ break;
+ }
+ }
+
+ for (const cam of allcameras) {
+ if (cam.trackingType !== TrackingType.NO_TRACKING && cam.node) {
+ cam.node.setPosition(cameraPosition[0], cameraPosition[1], cameraPosition[2]);
+ }
+ }
+ }
+ allcameras.length = 0;
+
+ this._frameMoveBegin();
+
+ this._frameMoveProcess();
+
+ for (let i = cameraList.length - 1; i >= 0; i--) {
+ const camera = cameraList[i];
+ const isMismatchedCam = (xrEye === XREye.LEFT && camera.cameraType === CameraType.RIGHT_EYE)
+ || (xrEye === XREye.RIGHT && camera.cameraType === CameraType.LEFT_EYE);
+ if (isMismatchedCam) {
+ // currently is left eye loop, so right camera do not need active
+ cameraList.splice(i, 1);
+ }
+ }
+
+ this._frameMoveEnd();
+ }
+ }
+
+ private _frameMoveBegin () {
+ for (let i = 0; i < this._scenes.length; ++i) {
+ this._scenes[i].removeBatches();
+ }
+
+ this._cameraList.length = 0;
+ }
+
+ private _frameMoveProcess () {
+ const { director } = cclegacy;
+ const windows = this._windows;
+ const cameraList = this._cameraList;
+
+ for (let i = 0; i < windows.length; i++) {
+ const window = windows[i];
+ window.extractRenderCameras(cameraList);
+ }
+
+ if (this._pipeline && cameraList.length > 0) {
+ this._device.acquire([deviceManager.swapchain]);
+ const scenes = this._scenes;
+ const stamp = director.getTotalFrames();
+
+ if (this._batcher) {
+ this._batcher.update();
+ this._batcher.uploadBuffers();
+ }
+
+ for (let i = 0; i < scenes.length; i++) {
+ scenes[i].update(stamp);
+ }
+ }
+ }
+
+ private _frameMoveEnd () {
+ const { director, Director } = cclegacy;
+ const cameraList = this._cameraList;
+ if (this._pipeline && cameraList.length > 0) {
+ director.emit(Director.EVENT_BEFORE_COMMIT);
+ cameraList.sort((a: Camera, b: Camera) => a.priority - b.priority);
+
+ for (let i = 0; i < cameraList.length; ++i) {
+ cameraList[i].geometryRenderer?.update();
+ }
+ director.emit(Director.EVENT_BEFORE_RENDER);
+ this._pipeline.render(cameraList);
+ director.emit(Director.EVENT_AFTER_RENDER);
+ this._device.present();
+ }
+
+ if (this._batcher) this._batcher.reset();
+ }
+
private _resizeMaxJointForDS () {
const usedUBOVectorCount = (UBOGlobal.COUNT + UBOCamera.COUNT + UBOShadow.COUNT + UBOLocal.COUNT + UBOWorldBound.COUNT) / 4;
let maxJoints = Math.floor((deviceManager.gfxDevice.capabilities.maxVertexUniformVectors - usedUBOVectorCount) / 3);
diff --git a/cocos/scene-graph/layers.ts b/cocos/scene-graph/layers.ts
index 5e95be58cd..b63696c0a4 100644
--- a/cocos/scene-graph/layers.ts
+++ b/cocos/scene-graph/layers.ts
@@ -131,6 +131,9 @@ export class Layers {
js.value(Layers.Enum, String(val), name);
Layers.BitMask[name] = val;
js.value(Layers.BitMask, String(val), name);
+
+ BitMask.update(Layers.BitMask);
+ Enum.update(Layers.Enum);
}
/**
@@ -148,6 +151,9 @@ export class Layers {
delete Layers.Enum[val];
delete Layers.BitMask[Layers.BitMask[val]];
delete Layers.BitMask[val];
+
+ BitMask.update(Layers.BitMask);
+ Enum.update(Layers.Enum);
}
/**
diff --git a/cocos/scene-graph/node.jsb.ts b/cocos/scene-graph/node.jsb.ts
index ae65c404ea..9ef8ab2a2b 100644
--- a/cocos/scene-graph/node.jsb.ts
+++ b/cocos/scene-graph/node.jsb.ts
@@ -190,9 +190,16 @@ nodeProto.addComponent = function (typeOrClassName) {
// check requirement
// TODO: `_requireComponent` is injected properties
- const ReqComp = (constructor as any)._requireComponent;
- if (ReqComp && !this.getComponent(ReqComp)) {
- this.addComponent(ReqComp);
+ const reqComps = (constructor as any)._requireComponent;
+ if (reqComps) {
+ const tryAdd = (c: Component) => {
+ if (!this.getComponent(c)) { this.addComponent(c); }
+ };
+ if (Array.isArray(reqComps)) {
+ reqComps.forEach((c) => tryAdd(c));
+ } else {
+ tryAdd(reqComps);
+ }
}
/// / check conflict
@@ -802,7 +809,7 @@ nodeProto.getWorldRS = function getWorldRS(out?: Mat4): Mat4 {
return out;
};
-nodeProto.isTransformDirty = function(): Boolean {
+nodeProto.isTransformDirty = function (): Boolean {
return this._transformFlags !== TransformBit.NONE;
};
diff --git a/cocos/scene-graph/scene-globals.ts b/cocos/scene-graph/scene-globals.ts
index c581dc0598..25b0b33e0f 100644
--- a/cocos/scene-graph/scene-globals.ts
+++ b/cocos/scene-graph/scene-globals.ts
@@ -565,6 +565,27 @@ export class SkyboxInfo {
this._resource.setRotationAngle(this._rotationAngle);
this._resource.activate(); // update global DS first
}
+
+ /**
+ * @en When the environment map changed will call this function to update scene.
+ * @zh 环境贴图发生变化时,会调用此函数更新场景。
+ * @param val environment map
+ */
+ public updateEnvMap (val: TextureCube) {
+ if (!val) {
+ this.applyDiffuseMap = false;
+ this.useIBL = false;
+ this.envLightingType = EnvironmentLightingType.HEMISPHERE_DIFFUSE;
+ warnID(15001);
+ }
+ if (this._resource) {
+ this._resource.setEnvMaps(this._envmapHDR, this._envmapLDR);
+ this._resource.setDiffuseMaps(this._diffuseMapHDR, this._diffuseMapLDR);
+ this._resource.setReflectionMaps(this._reflectionHDR, this._reflectionLDR);
+ this._resource.useDiffuseMap = this.applyDiffuseMap;
+ this._resource.envmap = val;
+ }
+ }
}
legacyCC.SkyboxInfo = SkyboxInfo;
diff --git a/cocos/spine/skeleton.ts b/cocos/spine/skeleton.ts
index d5af79e4c5..9a86dc3acb 100644
--- a/cocos/spine/skeleton.ts
+++ b/cocos/spine/skeleton.ts
@@ -280,9 +280,8 @@ export class Skeleton extends UIRenderer {
if (value) {
this.setAnimation(0, value, this.loop);
this.markForUpdateRenderData();
- } else if (!this.isAnimationCached()) {
- this.clearTrack(0);
- this.setToSetupPose();
+ } else {
+ this.clearAnimation();
}
}
@@ -737,7 +736,7 @@ export class Skeleton extends UIRenderer {
*/
public setSkeletonData (skeletonData: spine.SkeletonData) {
const uiTrans = this.node._uiProps.uiTransformComp!;
- uiTrans.setContentSize(skeletonData.width, skeletonData.height);
+ if (skeletonData.width && skeletonData.height) uiTrans.setContentSize(skeletonData.width, skeletonData.height);
if (skeletonData.width !== 0) uiTrans.anchorX = Math.abs(skeletonData.x) / skeletonData.width;
if (skeletonData.height !== 0) uiTrans.anchorY = Math.abs(skeletonData.y) / skeletonData.height;
@@ -1121,7 +1120,6 @@ export class Skeleton extends UIRenderer {
*/
public setAnimation (trackIndex: number, name: string, loop: boolean) {
this._playTimes = loop ? 0 : 1;
- this._animationName = name;
if (this.isAnimationCached()) {
if (trackIndex !== 0) {
@@ -1133,6 +1131,7 @@ export class Skeleton extends UIRenderer {
cache = this._skeletonCache.initAnimationCache(this._skeletonData!._uuid, name);
}
if (cache) {
+ this._animationName = name;
this._isAniComplete = false;
this._accTime = 0;
this._playCount = 0;
@@ -1149,6 +1148,7 @@ export class Skeleton extends UIRenderer {
logID(7509, name);
return null;
}
+ this._animationName = name;
const res = this._state!.setAnimationWith(trackIndex, animation, loop);
this._state!.apply(this._skeleton);
return res;
@@ -1200,6 +1200,17 @@ export class Skeleton extends UIRenderer {
return null;
}
+ /**
+ * @en Clear animation and set to setup pose.
+ * @zh 清除动画并还原到初始姿势。
+ */
+ public clearAnimation () {
+ if (!this.isAnimationCached()) {
+ this.clearTrack(0);
+ this.setToSetupPose();
+ }
+ }
+
/**
* @en Returns track entry by trackIndex.
* Returns a {{#crossLinkModule "sp.spine"}}sp.spine{{/crossLinkModule}}.TrackEntry object.
diff --git a/cocos/xr/xr-enums.ts b/cocos/xr/xr-enums.ts
index 2e68809b8e..44e8c6f561 100644
--- a/cocos/xr/xr-enums.ts
+++ b/cocos/xr/xr-enums.ts
@@ -80,3 +80,45 @@ export enum XRConfigKey {
*/
SPLIT_AR_GLASSES = 42
}
+
+/**
+ * @en XR Pose Type Enum.
+ * @zh XR姿态类型枚举。
+ */
+export enum XRPoseType {
+ /**
+ * @en The pose for left eye.
+ * @zh 左眼姿态。
+ */
+ VIEW_LEFT = 0,
+ /**
+ * @en The pose for left controller.
+ * @zh 左手柄姿态。
+ */
+ HAND_LEFT = 1,
+ /**
+ * @en The pose for left controller's aim.
+ * @zh 左手柄瞄准方向姿态。
+ */
+ AIM_LEFT = 2,
+ /**
+ * @en The pose for right eye.
+ * @zh 右眼姿态。
+ */
+ VIEW_RIGHT = 3,
+ /**
+ * @en The pose for right controller.
+ * @zh 右手柄姿态。
+ */
+ HAND_RIGHT = 4,
+ /**
+ * @en The pose for right controller's aim.
+ * @zh 右手柄瞄准方向姿态。
+ */
+ AIM_RIGHT = 5,
+ /**
+ * @en The pose for head.
+ * @zh 头部姿态。
+ */
+ HEAD_MIDDLE = 6,
+}
diff --git a/editor/assets/chunks/builtin/internal/particle-vs-gpu.chunk b/editor/assets/chunks/builtin/internal/particle-vs-gpu.chunk
index bd886efdc5..16e06edc48 100644
--- a/editor/assets/chunks/builtin/internal/particle-vs-gpu.chunk
+++ b/editor/assets/chunks/builtin/internal/particle-vs-gpu.chunk
@@ -380,7 +380,8 @@ vec4 gpvs_main () {
frameInfo = mix(frameInfo0, frameInfo1, factor_t);
}
startFrame = frameInfo.x / u_anim_info.y;
- frameIndex = repeat(u_anim_info.z * (frameInfo.y + startFrame), 1.);
+ float EPSILON = 1e-6;
+ frameIndex = repeat(u_anim_info.z * (frameInfo.y + startFrame), 1. + EPSILON);
#endif
uv = computeUV(frameIndex, vertIdx, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;
diff --git a/editor/assets/chunks/common/color/gamma.chunk b/editor/assets/chunks/common/color/gamma.chunk
index 2247c5c852..74c91cb1bc 100644
--- a/editor/assets/chunks/common/color/gamma.chunk
+++ b/editor/assets/chunks/common/color/gamma.chunk
@@ -5,7 +5,7 @@
// #pragma define SRGBToLinear(gamma) pow(gamma, vec3(2.2))
vec3 SRGBToLinear (vec3 gamma) {
#ifdef CC_USE_SURFACE_SHADER
- #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
+ #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW
if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {
return gamma;
}
@@ -18,7 +18,7 @@ vec3 SRGBToLinear (vec3 gamma) {
// #pragma define LinearToSRGB(linear) pow(linear, vec3(0.454545))
vec3 LinearToSRGB(vec3 linear) {
#ifdef CC_USE_SURFACE_SHADER
- #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
+ #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW
if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {
return linear;
}
diff --git a/editor/assets/chunks/common/color/tone-mapping.chunk b/editor/assets/chunks/common/color/tone-mapping.chunk
new file mode 100644
index 0000000000..5f35af77b0
--- /dev/null
+++ b/editor/assets/chunks/common/color/tone-mapping.chunk
@@ -0,0 +1,18 @@
+// Copyright (c) 2017-2023 Xiamen Yaji Software Co., Ltd.
+
+#include
+
+vec3 HDRToLDR(vec3 color)
+{
+ #if CC_USE_HDR
+ #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW
+ if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING)
+ #endif
+ // linear exposure has already applied to light intensity
+ #if CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES
+ color.rgb = ACESToneMap(color.rgb);
+ #endif
+ #endif
+
+ return color;
+}
diff --git a/editor/assets/chunks/common/color/tone-mapping.chunk.meta b/editor/assets/chunks/common/color/tone-mapping.chunk.meta
new file mode 100644
index 0000000000..e3e2c6d2c5
--- /dev/null
+++ b/editor/assets/chunks/common/color/tone-mapping.chunk.meta
@@ -0,0 +1,9 @@
+{
+ "ver": "1.0.7",
+ "importer": "effect-header",
+ "imported": true,
+ "uuid": "077c9168-e907-405b-b7f6-b4d5f68ced4a",
+ "files": [],
+ "subMetas": {},
+ "userData": {}
+}
diff --git a/editor/assets/chunks/common/common-define.chunk b/editor/assets/chunks/common/common-define.chunk
index 107aa6d21a..db65a1fed8 100644
--- a/editor/assets/chunks/common/common-define.chunk
+++ b/editor/assets/chunks/common/common-define.chunk
@@ -29,6 +29,7 @@
#pragma define equalf_lowp(data1, data2) (abs(float(data1) - float(data2)) < EPSILON_LOWP)
#pragma define equalf_epsilon(data1, data2, epsilonValue) (abs(float(data1) - float(data2)) < epsilonValue)
#pragma define clip(value) if(value < 0.0) discard;
+#pragma define lerp(value1, value2, value2Multiplier) mix(value1, value2, value2Multiplier)
// runtime constants
#pragma define-meta CC_DEVICE_SUPPORT_FLOAT_TEXTURE default(1)
@@ -72,5 +73,9 @@
#define IS_POINT_LIGHT(light_type) equalf_lowp(light_type, LIGHT_TYPE_POINT)
#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) equalf_lowp(light_type, LIGHT_TYPE_RANGED_DIRECTIONAL)
+// CC_TONE_MAPPING_TYPE Values
+#define TONE_MAPPING_ACES 0
+#define TONE_MAPPING_LINEAR 1
+
// Material
#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0
diff --git a/editor/assets/chunks/common/debug/debug-view-define.chunk b/editor/assets/chunks/common/debug/debug-view-define.chunk
index 2b3ccf299a..78447e8f7a 100644
--- a/editor/assets/chunks/common/debug/debug-view-define.chunk
+++ b/editor/assets/chunks/common/debug/debug-view-define.chunk
@@ -43,12 +43,12 @@
#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1
#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1
#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1
-#define CC_SURFACES_DEBUG_VIEW_TRT_DIRECT CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1
-#define CC_SURFACES_DEBUG_VIEW_TRT_ENVIRONMENT CC_SURFACES_DEBUG_VIEW_TRT_DIRECT + 1
-#define CC_SURFACES_DEBUG_VIEW_TRT_ALL CC_SURFACES_DEBUG_VIEW_TRT_ENVIRONMENT + 1
+#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1
+#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1
+#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1
// misc data
-#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_TRT_ALL + 1
+#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1
// Debug view UI and macros
// #pragma define-meta CC_USE_DEBUG_VIEW range([0, 2])
@@ -76,5 +76,5 @@
#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)
#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)
#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)
-#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRT (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)
+#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)
#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)
diff --git a/editor/assets/chunks/common/effect/special-effects.chunk b/editor/assets/chunks/common/effect/special-effects.chunk
index 55dea8cc08..b01cc492e5 100644
--- a/editor/assets/chunks/common/effect/special-effects.chunk
+++ b/editor/assets/chunks/common/effect/special-effects.chunk
@@ -10,3 +10,32 @@ void DitheredAlphaClip(vec4 clipPos, vec2 screen_resolution, float transparency)
float dither = ( dither5 * 5.0 + noiseValue ) * (1.0 / 6.0);
if( transparency + dither < 0.833333333 ) discard;
}
+
+// NormalFromMap is: texture(normalmap) - 0.5
+vec3 BlendDetailedNormalMap(vec3 baseNormalFromMap, vec3 detailedNormalFromMap, float detailedIntensity)
+{
+ return normalize(vec3(baseNormalFromMap.xy + detailedNormalFromMap.xy * detailedIntensity, baseNormalFromMap.z));
+}
+
+
+float BlendDetailedColorMap(float baseColor, float detailedColor)
+{
+ float s = baseColor, d = detailedColor;
+ if (s < 0.5)
+ {
+ return 2.0 * s * d;
+ }
+ else
+ {
+ if (d >= 0.5)
+ return 1.0 - 2.0 * (1.0 - s) * (1.0 - d);
+ else
+ return mix(2.0 * s * d, s, (2.0 * s - 1.0) * (2.0 * s - 1.0));
+ }
+}
+vec3 BlendDetailedColorMap(vec3 baseColor, vec3 detailedColor)
+{
+ return vec3(BlendDetailedColorMap(baseColor.r, detailedColor.r),
+ BlendDetailedColorMap(baseColor.g, detailedColor.g),
+ BlendDetailedColorMap(baseColor.b, detailedColor.b));
+}
diff --git a/editor/assets/chunks/common/graph-expression.meta b/editor/assets/chunks/common/graph-expression.meta
new file mode 100644
index 0000000000..71a30219d7
--- /dev/null
+++ b/editor/assets/chunks/common/graph-expression.meta
@@ -0,0 +1,12 @@
+{
+ "ver": "1.1.0",
+ "importer": "directory",
+ "imported": true,
+ "uuid": "8cab82a8-3634-48c2-8853-021f200cf799",
+ "files": [],
+ "subMetas": {},
+ "userData": {
+ "compressionType": {},
+ "isRemoteBundle": {}
+ }
+}
diff --git a/editor/assets/chunks/common/graph-expression/base.chunk b/editor/assets/chunks/common/graph-expression/base.chunk
new file mode 100644
index 0000000000..c3ef49a59d
--- /dev/null
+++ b/editor/assets/chunks/common/graph-expression/base.chunk
@@ -0,0 +1,47 @@
+// base coordinates & color expressions for shader-graph
+
+
+// fraction is saturation percentage, 0 means gray
+vec3 Desaturation(vec3 color, float fraction)
+{
+ vec3 gray = vec3(dot(color, GRAY_VECTOR));
+ return mix(color, gray, fraction);
+}
+
+vec2 Rotator(vec2 uv, vec2 centerUV, float time, float speed)
+{
+ uv -= centerUV;
+ vec3 dir = vec3(uv.x, 0.0, uv.y);
+ float dirLength = length(dir);
+ dir /= dirLength + EPSILON;
+ dir = RotationVecFromAxisY(dir, time * speed) * dirLength;
+ return vec2(dir.x, dir.z) + centerUV;
+}
+
+// tangent space -> world space
+// same as TransformVector
+vec3 TransformNormalMap(vec3 vectorFromNormalMap)
+{
+ vec3 vectorTS = normalize(vectorFromNormalMap - vec3(0.5));
+ vec3 normal = normalize(FSInput_worldNormal);
+ vec3 tangent = normalize(FSInput_worldTangent);
+ vec3 binormal = CalculateBinormal(normal, tangent, FSInput_mirrorNormal);
+ vec3 vecWS = vectorTS.x * tangent + vectorTS.y * binormal + vectorTS.z * normal;
+ return vecWS * vec3(1.0, 1.0, -1.0); // inverse Z for RH
+}
+
+
+// return 0.0 when out of range
+// hardness: 0 - 1
+float SphereMask(vec2 center, vec2 point, float radius, float hardness)
+{
+ float length = length(center - point);
+ float coef = pow(saturate(length / radius), 1.0 / (1.0 - saturate(sqrt(hardness)) + EPSILON));
+ return length > radius ? 0.0 : 1.0 - coef;
+}
+float SphereMask(vec3 center, vec3 point, float radius, float hardness)
+{
+ float length = length(center - point);
+ float coef = pow(saturate(length / radius), 1.0 / (1.0 - saturate(sqrt(hardness)) + EPSILON));
+ return length > radius ? 0.0 : 1.0 - coef;
+}
diff --git a/editor/assets/chunks/common/graph-expression/base.chunk.meta b/editor/assets/chunks/common/graph-expression/base.chunk.meta
new file mode 100644
index 0000000000..753111e53c
--- /dev/null
+++ b/editor/assets/chunks/common/graph-expression/base.chunk.meta
@@ -0,0 +1,9 @@
+{
+ "ver": "1.0.7",
+ "importer": "effect-header",
+ "imported": true,
+ "uuid": "4b4d0c0f-1d50-4d50-84e7-226c8d0dbd6f",
+ "files": [],
+ "subMetas": {},
+ "userData": {}
+}
diff --git a/editor/assets/chunks/common/lighting/functions.chunk b/editor/assets/chunks/common/lighting/functions.chunk
index 18f478f2bb..9672ae2bd2 100644
--- a/editor/assets/chunks/common/lighting/functions.chunk
+++ b/editor/assets/chunks/common/lighting/functions.chunk
@@ -4,17 +4,34 @@
// V from pixel to camera
vec3 CalculateRefractDirection(vec3 N, vec3 V, float NoV, float ior)
{
- float NoVAbs = abs(NoV);
// two sided
float sideSign = NoV < 0.0 ? -1.0 : 1.0;
N *= sideSign;
- NoV *= sideSign;
- float sinB = sqrt(1.0 - NoVAbs*NoVAbs) / ior;
- vec3 X = normalize(-V + N * NoVAbs);
- vec3 R = -N + X * sinB;
+
+ // A: NV B:NR
+ float cosA = abs(NoV);
+ float sinA = sqrt(1.0 - cosA * cosA);
+ float sinB = saturate(sinA / ior);
+ float cosB = sqrt(1.0 - sinB * sinB);
+
+ vec3 edgeA = -V + N * cosA;
+ vec3 edgeB = normalize(edgeA) * sinB;
+ vec3 R = edgeB - N * cosB;
return R;
}
+vec3 CalculateRefractDirectionFast(vec3 N, vec3 V, float NoV, float ior)
+{
+ // two sided
+ float sideSign = NoV < 0.0 ? -1.0 : 1.0;
+ N *= sideSign;
+
+ float w = ior * NoV;
+ float k = sqrt(1.0 + (w - ior) * (w + ior)); // 1 + ior2 * (NoV2 - 1)
+ vec3 R = (w - k) * N - ior * V;
+ return -R;
+}
+
vec3 CalculateReflectDirection(vec3 N, vec3 V, float NoV)
{
// two sided
diff --git a/editor/assets/chunks/common/math/coordinates.chunk b/editor/assets/chunks/common/math/coordinates.chunk
index aaa71d054b..e78714070c 100644
--- a/editor/assets/chunks/common/math/coordinates.chunk
+++ b/editor/assets/chunks/common/math/coordinates.chunk
@@ -27,7 +27,8 @@ vec2 GetPlanarReflectScreenUV(vec3 worldPos, mat4 matVirtualCameraViewProj, floa
return screenUV;
}
-// depthHS = ndc depth(-1 ~ +1)
+// depthHS (Z) = ndc depth(-1 ~ +1)
+// return camera depth (W), negative in RH
float GetCameraDepthRH(float depthHS, mat4 matProj)
{
return -matProj[3][2] / (depthHS + matProj[2][2]);
@@ -55,10 +56,18 @@ float GetLinearDepthFromViewSpace(vec3 viewPos, float near, float far) {
return (dist - near) / (far - near);
}
-// params must be normalized
+// for right-hand coordinates, params must be normalized
vec3 CalculateBinormal(vec3 normal, vec3 tangent, float mirrorNormal)
{
- return cross(normal.xyz, tangent) * mirrorNormal;
+ return cross(normal, tangent) * mirrorNormal;
+}
+vec3 CalculateTangent(vec3 normal, vec3 binormal)
+{
+ return cross(binormal, normal);
+}
+vec3 CalculateNormal(vec3 tangent, vec3 binormal)
+{
+ return cross(tangent, binormal);
}
@@ -81,6 +90,11 @@ vec3 RotationVecFromAxisY(vec3 v, float cosTheta, float sinTheta)
return result;
}
+vec3 RotationVecFromAxisY(vec3 v, float rotateAngleArc)
+{
+ return RotationVecFromAxisY(v, cos(rotateAngleArc), sin(rotateAngleArc));
+}
+
// rotationAngle: radians, 0-2Pi
void RotateTangentAndBinormal(inout vec3 tangent, inout vec3 binormal, vec3 normal, float rotationAngle)
{
@@ -94,14 +108,22 @@ void RotateTangentAndBinormal(inout vec3 tangent, inout vec3 binormal, vec3 norm
tangentNew = T.x * binormal + T.y * normal + T.z * tangent;
tangent = normalize(tangentNew);
- // tangent = cross(binormal, normal);
}
// fast rotation for anisotropic offset
// rotationAngle: -1 - +1
-void RotateNormalAndBinormal(inout vec3 binormal, inout vec3 normal, in vec3 tangent, float rotationAngle)
+void RotateNormalAndBinormal(inout vec3 binormal, inout vec3 normal, in vec3 tangent, float rotationAngle, float mirrorNormal)
{
- normal += (binormal - normal) * rotationAngle;
- normal = normalize(normal);
- binormal = normalize(cross(tangent, normal));
+ if(rotationAngle > 0.0)
+ {
+ normal += (binormal - normal) * rotationAngle;
+ normal = normalize(normal);
+ binormal = CalculateBinormal(normal, tangent, mirrorNormal);
+ }
+ else if(rotationAngle < 0.0)
+ {
+ binormal += (binormal - normal) * rotationAngle;
+ binormal = normalize(binormal);
+ normal = CalculateNormal(tangent, binormal);
+ }
}
diff --git a/editor/assets/chunks/legacy/output-standard.chunk b/editor/assets/chunks/legacy/output-standard.chunk
index f8472da6c6..6ed9b3dd12 100644
--- a/editor/assets/chunks/legacy/output-standard.chunk
+++ b/editor/assets/chunks/legacy/output-standard.chunk
@@ -1,13 +1,17 @@
// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
#include
#include
+#include
vec4 CCFragOutput (vec4 color) {
- #if !CC_USE_RGBE_OUTPUT
- #if CC_USE_HDR
+ #if CC_USE_RGBE_OUTPUT
+ color = packRGBE(color.rgb);
+ #elif !CC_USE_FLOAT_OUTPUT
+ #if CC_USE_HDR && CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES
color.rgb = ACESToneMap(color.rgb);
#endif
color.rgb = LinearToSRGB(color.rgb);
#endif
+
return color;
}
diff --git a/editor/assets/chunks/legacy/shading-standard-base.chunk b/editor/assets/chunks/legacy/shading-standard-base.chunk
index 226fa074e3..856e023f17 100644
--- a/editor/assets/chunks/legacy/shading-standard-base.chunk
+++ b/editor/assets/chunks/legacy/shading-standard-base.chunk
@@ -157,11 +157,11 @@ vec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {
#endif
#if CC_USE_LIGHTMAP == LIGHT_MAP_TYPE_INDIRECT_OCCLUSION
shadow *= s.lightmap.a; // apply baked shadows for real-time lighting
- s.occlusion *= s.lightmap_test;
finalColor += diffuse * lightmap.rgb;
#else
finalColor += diffuse * lightmap.rgb * shadow; // apply real-time shadows for baked color
#endif
+ s.occlusion *= s.lightmap_test;
#endif
#if !CC_DISABLE_DIRECTIONAL_LIGHT
diff --git a/editor/assets/chunks/legacy/standard-surface-entry.chunk b/editor/assets/chunks/legacy/standard-surface-entry.chunk
index b42a39c459..5abc13073b 100644
--- a/editor/assets/chunks/legacy/standard-surface-entry.chunk
+++ b/editor/assets/chunks/legacy/standard-surface-entry.chunk
@@ -31,14 +31,11 @@
\
void main () { \
StandardSurface s; surf(s); \
- vec4 color = CCFragOutput(CCStandardShadingBase(s, CC_SHADOW_POSITION)); \
+ vec4 color = CCStandardShadingBase(s, CC_SHADOW_POSITION); \
#if CC_USE_FOG != CC_FOG_NONE \
CC_APPLY_FOG(color, s.position.xyz); \
#endif \
- #if CC_USE_RGBE_OUTPUT \
- color = packRGBE(color.rgb); \
- #endif \
- fragColorX = color; \
+ fragColorX = CCFragOutput(color); \
} \
\
#elif CC_PIPELINE_TYPE == CC_PIPELINE_TYPE_DEFERRED \
diff --git a/editor/assets/chunks/lighting-models/data-structures/lighting-intermediate-data.chunk b/editor/assets/chunks/lighting-models/data-structures/lighting-intermediate-data.chunk
index ee4763104b..7a4b39bd1a 100644
--- a/editor/assets/chunks/lighting-models/data-structures/lighting-intermediate-data.chunk
+++ b/editor/assets/chunks/lighting-models/data-structures/lighting-intermediate-data.chunk
@@ -34,9 +34,6 @@ struct LightingIntermediateData
vec3 baseColorTT;
float ttIntensity, ttScatterCoef;
#endif
- // #if CC_SURFACES_LIGHTING_CLEAR_COAT
- // float roughnessClearCoat; // for clear coat or multi-layer pbr
- // #endif
};
// add overrided functions for difference shading-models in
diff --git a/editor/assets/chunks/lighting-models/data-structures/lighting-result.chunk b/editor/assets/chunks/lighting-models/data-structures/lighting-result.chunk
index dce1af2420..6ab96c09d3 100644
--- a/editor/assets/chunks/lighting-models/data-structures/lighting-result.chunk
+++ b/editor/assets/chunks/lighting-models/data-structures/lighting-result.chunk
@@ -1,7 +1,7 @@
struct LightingResult
{
// material-dependent lighting data
- vec3 diffuseColorWithLighting, specularColorWithLighting;
+ vec3 diffuseColorWithLighting, specularColorWithLighting, specularColorWithEnvLighting;
// pure lighting
vec3 directDiffuse, directSpecular;
@@ -21,9 +21,9 @@ struct LightingResult
#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE
vec3 directTransmitDiffuse, environmentTransmitDiffuse;
#endif
-#if CC_SURFACES_LIGHTING_TRT
- vec3 directTRT, environmentTRT;
- vec3 specularColorWithLightingTRT;
+#if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ vec3 direct2ndSpecular, environment2ndSpecular;
+ vec3 specularColorWithLighting2ndSpecular, specularColorWithEnvLighting2ndSpecular;
#endif
#if CC_SURFACES_LIGHTING_TT
vec3 directTT;
diff --git a/editor/assets/chunks/lighting-models/default-functions/simple-skin.chunk b/editor/assets/chunks/lighting-models/default-functions/simple-skin.chunk
index 069d515750..77ba5e675a 100644
--- a/editor/assets/chunks/lighting-models/default-functions/simple-skin.chunk
+++ b/editor/assets/chunks/lighting-models/default-functions/simple-skin.chunk
@@ -10,13 +10,13 @@
{
#if CC_SURFACES_LIGHTING_SSS
float sssIntensity = surfaceData.sssParams.x;
+ // curvature needs pre-generating in vertex or texture data, otherwise disable pre-integrated skin
float sssCurvature = surfaceData.sssParams.y;
float sssColoration = surfaceData.sssParams.z;
- float cavity = surfaceData.sssParams.w;
// update lighting data for diffuse calculations
LightingIntermediateData lightingData3S = lightingData;
- lightingData3S.N = FSInput_worldNormal;
+ lightingData3S.N = normalize(FSInput_worldNormal);
lightingData3S.NoL = dot(lightingData3S.N, -miscData.lightDir);
lightingData3S.NoL = mix(lightingData.NoL, lightingData3S.NoL, sssIntensity);
lightingData3S.NoLSat = saturate(lightingData3S.NoL);
@@ -31,11 +31,8 @@
result.directDiffuse = CalculateDirectDiffuse(lightingData3S, miscData.lightColorAndIntensity) * multiplier;
#endif
- result.directSpecular *= cavity;
-
#if !CC_FORWARD_ADD
result.environmentDiffuse = CalculateEnvironmentDiffuse(lightingData3S, cc_ambientSky.w);
- result.environmentSpecular *= cavity;
#endif
#endif
}
diff --git a/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk b/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk
index 6f8a29b894..d1166ed9a9 100644
--- a/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk
+++ b/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk
@@ -11,24 +11,24 @@
CCSurfacesInitializeLightingIntermediateData(lightingData, surfaceData);
LightingResult lightingResult;
- CCSurfacesLightingInitializeColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);
+ CCSurfacesLightingInitializeColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, lightingResult.specularColorWithEnvLighting, surfaceData, lightingData);
lightingResultAccumulated.diffuseColorWithLighting = lightingResult.diffuseColorWithLighting;
lightingResultAccumulated.specularColorWithLighting = lightingResult.specularColorWithLighting;
+ lightingResultAccumulated.specularColorWithEnvLighting = lightingResult.specularColorWithEnvLighting;
- #if CC_SURFACES_LIGHTING_TRT
+ #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
vec3 diff;
- SurfacesMaterialData surfaceDataTRT;
- CCSurfacesGetSurfacesMaterialDataTRT(surfaceDataTRT, surfaceData);
- CCSurfacesLightingInitializeColorWithLighting(diff, lightingResultAccumulated.specularColorWithLightingTRT, surfaceDataTRT, lightingData);
+ SurfacesMaterialData surfaceData2ndSpecular;
+ CCSurfacesGetSurfacesMaterialData2ndSpecular(surfaceData2ndSpecular, surfaceData);
+ CCSurfacesLightingInitializeColorWithLighting(diff, lightingResultAccumulated.specularColorWithLighting2ndSpecular, lightingResultAccumulated.specularColorWithEnvLighting2ndSpecular, surfaceData2ndSpecular, lightingData);
#endif
int numLights = CC_PIPELINE_TYPE == CC_PIPELINE_TYPE_FORWARD ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);
for (int i = 0; i < LIGHTS_PER_PASS; i++) {
if (i >= numLights) break;
- vec3 lightDirWithLength = IS_RANGED_DIRECTIONAL_LIGHT(cc_lightPos[i].w) ? -normalize(cc_lightDir[i].xyz) : cc_lightPos[i].xyz - worldPos;
- CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData, surfaceData, lightDirWithLength);
- CCSurfacesLightingCalculateColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);
+ CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData, surfaceData, cc_lightPos[i].xyz - worldPos);
+ CCSurfacesLightingCalculateColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, lightingResult.specularColorWithEnvLighting, surfaceData, lightingData);
vec3 diffuseLighting, specularLighting;
CCSurfacesLightingCalculateDirect(diffuseLighting, specularLighting, lightingData, cc_lightColor[i]);
@@ -38,10 +38,9 @@
fresnel = lightingResult.fresnel = CCSurfaceLightingCalculateFresnel(lightingData);
#endif
- // shadows
float shadow = 1.0;
#if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP
- if (IS_SPOT_LIGHT(cc_lightPos[i].w) && cc_lightSizeRangeAngle[i].w > 0.0) {
+ if (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {
vec4 shadowPos = vec4(0.0), shadowPosWithDepthBias = vec4(0.0);
if (CCSurfacesLightingEnableShadow(lightingData.NoL)) {
shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);
@@ -65,23 +64,16 @@
#endif
lightingResult.shadow = shadow;
-
- // attenuations
- float distAtt = 1.0;
- if(IS_RANGED_DIRECTIONAL_LIGHT(cc_lightPos[i].w)) {
- distAtt = GetOutOfRange(worldPos, cc_lightPos[i].xyz, cc_lightDir[i].xyz, cc_lightSizeRangeAngle[i].xyz, cc_lightBoundingSizeVS[i].xyz);
- } else {
- distAtt = CCSurfacesLightingCalculateDistanceAttenuation(lightingData, cc_lightSizeRangeAngle[i], cc_lightPos[i].w);
- }
+
+ float distAtt = CCSurfacesLightingCalculateDistanceAttenuation(lightingData, cc_lightSizeRangeAngle[i]);
float angleAtt = 1.0;
- if (IS_SPOT_LIGHT(cc_lightPos[i].w)) {
+ if (cc_lightPos[i].w > 0.0) {
angleAtt = CCSurfacesLightingCalculateAngleAttenuation(lightingData, cc_lightSizeRangeAngle[i], -cc_lightDir[i].xyz);
}
float multiplier = distAtt * angleAtt;
- // output
lightingData.angleAttenuation = angleAtt;
lightingData.distAttenuation = distAtt;
lightingResult.directDiffuse = diffuseLighting * multiplier;
@@ -98,16 +90,16 @@
#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE
LightingIntermediateData lightingDataTD;
CCSurfacesGetLightingIntermediateDataTransmitDiffuse(lightingDataTD, lightingData, surfaceData);
- CCSurfacesLightingCalculateIntermediateData_PerLight(lightingDataTD, surfaceData, lightDirWithLength);
+ CCSurfacesLightingCalculateIntermediateData_PerLight(lightingDataTD, surfaceData, cc_lightPos[i].xyz - worldPos);
CCSurfacesLightingCalculateDirectTransmitDiffuse(lightingResult.directTransmitDiffuse, lightingDataTD, attenuatedLightColorAndIntensity, lightingResult.shadow);
#endif
- #if CC_SURFACES_LIGHTING_TRT
- LightingIntermediateData lightingDataTRT;
- CCSurfacesGetLightingIntermediateDataTRT(lightingDataTRT, lightingData, surfaceData);
- CCSurfacesLightingCalculateIntermediateData_PerLight(lightingDataTRT, surfaceData, lightDirWithLength);
- CCSurfacesLightingCalculateDirectTRT(lightingResult.directTRT, lightingDataTRT, attenuatedLightColorAndIntensity, lightingResult.directSpecular);
- lightingResult.directTRT *= multiplier * fresnel;
+ #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ LightingIntermediateData lightingData2ndSpecular;
+ CCSurfacesInitializeLightingIntermediateData(lightingData2ndSpecular, surfaceData2ndSpecular);
+ CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData2ndSpecular, surfaceData, cc_lightPos[i].xyz - worldPos);
+ CCSurfacesLightingCalculateDirect2ndSpecular(lightingResult.direct2ndSpecular, lightingData2ndSpecular, attenuatedLightColorAndIntensity, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.directSpecular);
+ lightingResult.direct2ndSpecular *= multiplier * fresnel;
#endif
#if CC_SURFACES_LIGHTING_TT
@@ -124,7 +116,7 @@
miscData.lightColorAndIntensity = cc_lightColor[i];
miscData.lightSizeRangeAngle = cc_lightSizeRangeAngle[i];
SurfacesLightingModifyFinalResult(lightingResult, lightingData, surfaceData, miscData);
- #endif
+ #endif
// accumulate per-light results
CCSurfacesAccumulateLightingResult(lightingResultAccumulated, lightingResult);
@@ -140,7 +132,7 @@
CCSurfacesInitializeLightingIntermediateData(lightingData, surfaceData);
CCSurfacesInitializeLightingResult(lightingResult, surfaceData);
- CCSurfacesLightingInitializeColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);
+ CCSurfacesLightingInitializeColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, lightingResult.specularColorWithEnvLighting, surfaceData, lightingData);
CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData, surfaceData, -cc_mainLitDir.xyz);
@@ -186,14 +178,15 @@
#if CC_SURFACES_USE_LIGHT_MAP == LIGHT_MAP_TYPE_INDIRECT_OCCLUSION
lightingResult.shadow *= lightmapShadow;
- lightingResult.ao *= lightmapAO;
#endif
+ // env lighting hasn't baked with static / stationary type, so ao need to be output all the time
+ lightingResult.ao *= lightmapAO;
#endif
// dynamic & stationary dir light
lightingResult.directDiffuse = lightingResult.directSpecular = vec3(0.0);
#if !CC_DISABLE_DIRECTIONAL_LIGHT && !CC_FORWARD_ADD
- CCSurfacesLightingCalculateColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);
+ CCSurfacesLightingCalculateColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, lightingResult.specularColorWithEnvLighting, surfaceData, lightingData);
CCSurfacesLightingCalculateDirect(lightingResult.directDiffuse, lightingResult.directSpecular, lightingData, cc_mainLitColor);
#endif
@@ -221,17 +214,18 @@
CCSurfacesLightingCalculateEnvironmentTransmitDiffuse(lightingResult.environmentTransmitDiffuse, lightingDataTD, cc_ambientSky.w, lightingResult.ao, -cc_mainLitDir.xyz);
#endif
- #if CC_SURFACES_LIGHTING_TRT
- LightingIntermediateData lightingDataTRT;
- CCSurfacesGetLightingIntermediateDataTRT(lightingDataTRT, lightingData, surfaceData);
- CCSurfacesLightingCalculateIntermediateData_PerLight(lightingDataTRT, surfaceData, -cc_mainLitDir.xyz);
- CCSurfacesLightingCalculateDirectTRT(lightingResult.directTRT, lightingDataTRT, cc_mainLitColor, lightingResult.directSpecular);
- CCSurfacesLightingCalculateEnvironmentTRT(lightingResult.environmentTRT, lightingDataTRT, cc_ambientSky.w, lightingResult.environmentSpecular);
+ #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ SurfacesMaterialData surfaceData2ndSpecular;
+ CCSurfacesGetSurfacesMaterialData2ndSpecular(surfaceData2ndSpecular, surfaceData);
+
+ LightingIntermediateData lightingData2ndSpecular;
+ CCSurfacesInitializeLightingIntermediateData(lightingData2ndSpecular, surfaceData2ndSpecular);
+ CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData2ndSpecular, surfaceData2ndSpecular, -cc_mainLitDir.xyz);
+ CCSurfacesLightingCalculateDirect2ndSpecular(lightingResult.direct2ndSpecular, lightingData2ndSpecular, cc_mainLitColor, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.directSpecular);
+ CCSurfacesLightingCalculateEnvironment2ndSpecular(lightingResult.environment2ndSpecular, lightingData2ndSpecular, cc_ambientSky.w, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.environmentSpecular);
vec3 diff;
- SurfacesMaterialData surfaceDataTRT;
- CCSurfacesGetSurfacesMaterialDataTRT(surfaceDataTRT, surfaceData);
- CCSurfacesLightingInitializeColorWithLighting(diff, lightingResult.specularColorWithLightingTRT, surfaceDataTRT, lightingDataTRT);
+ CCSurfacesLightingInitializeColorWithLighting(diff, lightingResult.specularColorWithLighting2ndSpecular, lightingResult.specularColorWithEnvLighting2ndSpecular, surfaceData2ndSpecular, lightingData2ndSpecular);
#endif
#if CC_SURFACES_LIGHTING_TT
@@ -247,7 +241,7 @@
miscData.lightColorAndIntensity = cc_mainLitColor;
miscData.lightSizeRangeAngle = vec4(0.0, 0.0, 0.0, 0.0);
SurfacesLightingModifyFinalResult(lightingResult, lightingData, surfaceData, miscData);
- #endif
+ #endif
}
#if CC_ENABLE_CLUSTERED_LIGHT_CULLING
// #todo: cluster related lighting flow, invoke after CCSurfacesLighting
diff --git a/editor/assets/chunks/lighting-models/model-functions/standard.chunk b/editor/assets/chunks/lighting-models/model-functions/standard.chunk
index 88cfc17f81..922bc513a2 100644
--- a/editor/assets/chunks/lighting-models/model-functions/standard.chunk
+++ b/editor/assets/chunks/lighting-models/model-functions/standard.chunk
@@ -113,6 +113,7 @@ void CCSurfacesLightingCalculateEnvironment(out vec3 lightingDiffuse, out vec3 l
void CCSurfacesLightingCalculateDirectTransmitDiffuse(out vec3 transmitDiffuse, in LightingIntermediateData lightingData, in vec4 lightSourceColorAndIntensity, float shadow)
{
+ #if !CC_SURFACES_LIGHTING_DISABLE_DIFFUSE
float distance = lightingData.transmitScatteringParams.w;
if (!DONOT_USE_SHADOWMAP_DISTANCE)
{
@@ -123,10 +124,14 @@ void CCSurfacesLightingCalculateEnvironment(out vec3 lightingDiffuse, out vec3 l
vec3 backIrradiance = CalculateDirectDiffuse(lightingData, lightSourceColorAndIntensity);
backIrradiance *= shadow * transmitMask;
transmitDiffuse = CalculateScattering(backIrradiance, distance, lightingData.transmitScatteringParams.x, lightingData.transmitScatteringParams.x, lightingData.transmitScatteringParams.y, lightingData.inScatteringColor.rgb, lightingData.outScatteringColor.rgb);
+ #else
+ transmitDiffuse = vec3(0.0);
+ #endif
}
// depend on dir-light shadow direction, if there are some occluders in front of the light source, env transmit will dark
void CCSurfacesLightingCalculateEnvironmentTransmitDiffuse(out vec3 transmitDiffuse, in LightingIntermediateData lightingData, float lightIntensity, float ao, vec3 shadowLightDirection)
{
+ #if !CC_SURFACES_LIGHTING_DISABLE_DIFFUSE
float distance = lightingData.transmitScatteringParams.w;
if (!DONOT_USE_SHADOWMAP_DISTANCE)
{
@@ -141,6 +146,9 @@ void CCSurfacesLightingCalculateEnvironment(out vec3 lightingDiffuse, out vec3 l
backIrradiance *= ao * transmitMask;
transmitDiffuse = CalculateScattering(backIrradiance, distance, lightingData.transmitScatteringParams.x, lightingData.transmitScatteringParams.x, lightingData.transmitScatteringParams.y, lightingData.inScatteringColor.rgb, lightingData.outScatteringColor.rgb);
transmitDiffuse *= envTransmitScale;
+ #else
+ transmitDiffuse = vec3(0.0);
+ #endif
}
#undef objectThickness
@@ -151,38 +159,48 @@ void CCSurfacesLightingCalculateEnvironment(out vec3 lightingDiffuse, out vec3 l
#undef SHADOWMAP_DISTANCE
#endif
-#if CC_SURFACES_LIGHTING_TRT
+#if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
// this surface function used for adjust TRT color with brdf lighting, input are lighting result and surface data
// the default function can only be defined here
- #ifndef CC_SURFACES_FRAGMENT_MODIFY_TRT_SPECULAR_COLOR
- vec3 SurfacesLightingGetTRTSpecularColor(float specBRDF, bool isSaturated)
+ #ifndef CC_SURFACES_FRAGMENT_MODIFY_2ND_SPECULAR_COLOR
+ vec3 SurfacesLightingGet2ndSpecularColor(float specBRDF, bool isSaturated)
{
- return vec3(specBRDF);
+ return vec3(saturate(specBRDF));
}
#endif
- void CCSurfacesLightingCalculateDirectTRT(out vec3 TRTLighting, in LightingIntermediateData lightingData, in vec4 lightSourceColorAndIntensity, in vec3 originalSpecular)
+ void CCSurfacesLightingCalculateDirect2ndSpecular(out vec3 specularLighting, in LightingIntermediateData lightingData, in vec4 lightSourceColorAndIntensity, float intensitySpecular, in vec3 originalSpecular)
{
+ #if !CC_SURFACES_LIGHTING_DISABLE_SPECULAR
vec3 unused;
// light color has less influence
- CCSurfacesLightingCalculateDirect(unused, TRTLighting, lightingData, vec4(1.0));
- float brdf = TRTLighting.x;
- vec3 Color = SurfacesLightingGetTRTSpecularColor(brdf, true);
+ CCSurfacesLightingCalculateDirect(unused, specularLighting, lightingData, lightSourceColorAndIntensity);
+ // float brdf = specularLighting.x;
+ // vec3 Color = SurfacesLightingGet2ndSpecularColor(brdf, true);
// todo: modify Color to add some light color influence
- TRTLighting *= Color * lightSourceColorAndIntensity.w;
- // TRTLighting -= originalSpecular;
+ // specularLighting *= Color * lightSourceColorAndIntensity.w;
+ specularLighting *= intensitySpecular;
+ // specularLighting -= originalSpecular;
+ #else
+ specularLighting = vec3(0.0);
+ #endif
}
- void CCSurfacesLightingCalculateEnvironmentTRT(out vec3 TRTLighting, in LightingIntermediateData lightingData, float lightIntensity, in vec3 originalSpecular)
+ void CCSurfacesLightingCalculateEnvironment2ndSpecular(out vec3 specularLighting, in LightingIntermediateData lightingData, float lightIntensity, float intensitySpecular, in vec3 originalSpecular)
{
+ #if !CC_SURFACES_LIGHTING_DISABLE_SPECULAR
vec3 unused;
// light color has less influence
- TRTLighting = CalculateEnvironmentSpecular(lightingData, 1.0);
- float brdf = length(TRTLighting);
- vec3 Color = SurfacesLightingGetTRTSpecularColor(brdf, false);
+ specularLighting = CalculateEnvironmentSpecular(lightingData, lightIntensity);
+ // float brdf = length(specularLighting);
+ // vec3 Color = SurfacesLightingGet2ndSpecularColor(brdf, false);
// todo: modify Color to add some light color influence
- TRTLighting *= Color * lightIntensity;
- // TRTLighting -= originalSpecular;
+ // specularLighting *= Color * lightIntensity;
+ specularLighting *= intensitySpecular;
+ // specularLighting -= originalSpecular;
+ #else
+ specularLighting = vec3(0.0);
+ #endif
}
#endif
diff --git a/editor/assets/chunks/shading-entries/data-structures/fs-input.chunk b/editor/assets/chunks/shading-entries/data-structures/fs-input.chunk
index 2b434328e3..bf3553519f 100644
--- a/editor/assets/chunks/shading-entries/data-structures/fs-input.chunk
+++ b/editor/assets/chunks/shading-entries/data-structures/fs-input.chunk
@@ -17,7 +17,7 @@ void CCSurfacesGetFragmentInput(out SurfacesStandardFragmentInput fsInput)
// Use macros instead of structure to avoid structure precision issues
#define FSInput_worldPos v_worldPos
-#define FSInput_worldNormal v_normal.xyz
+#define FSInput_worldNormal v_normal.xyz // unnormalized
#define FSInput_faceSideSign v_normal.w // physical face side, has no relation to USE_TWO_SIDED
#define FSInput_texcoord v_uv
@@ -28,7 +28,7 @@ void CCSurfacesGetFragmentInput(out SurfacesStandardFragmentInput fsInput)
#endif
#if CC_SURFACES_USE_TANGENT_SPACE
- #define FSInput_worldTangent v_tangent.xyz
+ #define FSInput_worldTangent v_tangent.xyz // unnormalized
#define FSInput_mirrorNormal v_tangent.w
#else
#define FSInput_worldTangent vec3(0.0, 0.0, 0.0)
diff --git a/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-fs.chunk b/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-fs.chunk
index 1917b6c597..75f283169a 100644
--- a/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-fs.chunk
+++ b/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-fs.chunk
@@ -7,16 +7,11 @@ void main () {
//#uniformStyle need sync here
// Color output
-#if CC_USE_HDR
- #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
- if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING)
+ #if CC_USE_RGBE_OUTPUT
+ color = packRGBE(color.rgb);
+ #elif !CC_USE_FLOAT_OUTPUT
+ color.rgb = LinearToSRGB(color.rgb);
#endif
- color.rgb = ACESToneMap(color.rgb);
-#endif
-#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
- if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION)
-#endif
- color.rgb = LinearToSRGB(color.rgb);
fragColorX = color;
}
diff --git a/editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk b/editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk
index baeb8b0539..74e5b4de8e 100644
--- a/editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk
+++ b/editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk
@@ -15,20 +15,12 @@ void main() {
vec4 color = SurfacesFragmentModifyBaseColorAndTransparency();
color.a = 1.0;
- #if CC_USE_HDR
- #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
- if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING)
- #endif
- color.rgb = ACESToneMap(color.rgb);
- #endif
- #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
- if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION)
- #endif
+ #if CC_USE_RGBE_OUTPUT
+ color = packRGBE(color.rgb);
+ #elif !CC_USE_FLOAT_OUTPUT
+ color.rgb = HDRToLDR(color.rgb);
color.rgb = LinearToSRGB(color.rgb);
-
- #if CC_USE_RGBE_OUTPUT
- color = packRGBE(color.rgb);
- #endif
+ #endif
fragColorX = color;
}
diff --git a/editor/assets/chunks/shading-entries/main-functions/render-to-scene/pipeline/forward-fs.chunk b/editor/assets/chunks/shading-entries/main-functions/render-to-scene/pipeline/forward-fs.chunk
index b29e2a3058..34744a4bde 100644
--- a/editor/assets/chunks/shading-entries/main-functions/render-to-scene/pipeline/forward-fs.chunk
+++ b/editor/assets/chunks/shading-entries/main-functions/render-to-scene/pipeline/forward-fs.chunk
@@ -41,8 +41,8 @@ void main() {
// Fog factor
+ float fogFactor = 1.0;
#if !CC_FORWARD_ADD
- float fogFactor = 1.0;
#if CC_USE_FOG != CC_FOG_NONE
#if !CC_USE_ACCURATE_FOG
fogFactor = FSInput_fogFactor;
@@ -71,7 +71,10 @@ void main() {
#if !CC_FORWARD_ADD
CCSurfacesDebugViewMeshData(debugColor);
- CCSurfacesDebugViewSurfaceData(debugColor, surfaceData);
+ if (CCSurfacesDebugViewSurfaceData(debugColor, surfaceData))
+ {
+ debugColor.a = materialTransparency;
+ }
if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_FOG))
{
debugColor.rgb = vec3(1.0 - fogFactor);
@@ -81,7 +84,7 @@ void main() {
// only base pass or direct lighting is enabled in add pass
#if CC_FORWARD_ADD
if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE) || IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR) || IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_DIRECT_ALL) ||
- IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE) || IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR) || IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_TRT_DIRECT))
+ IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE) || IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR) || IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR))
#endif
{
if (CCSurfacesDebugViewLightingResult(debugColor, lightingResult))
@@ -90,12 +93,10 @@ void main() {
debugColor.a = materialTransparency;
// lighting needs color space conversion
- #if CC_USE_HDR
- if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING)
- debugColor.rgb = ACESToneMap(debugColor.rgb);
+ #if !CC_USE_FLOAT_OUTPUT
+ debugColor.rgb = HDRToLDR(debugColor.rgb);
+ debugColor.rgb = LinearToSRGB(debugColor.rgb);
#endif
- if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION)
- debugColor.rgb = LinearToSRGB(debugColor.rgb);
}
}
if (IS_DEBUG_VIEW_ENABLE_WITH_CAMERA) {
@@ -123,26 +124,32 @@ void main() {
#endif
#endif
- // Color output
- #if CC_USE_RGBE_OUTPUT
- fragColorX = packRGBE(color.rgb); // for reflection-map
- return;
- #endif
-
- #if CC_USE_HDR
- #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW
- if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING)
+ // Fog, linear output
+ #if CC_USE_FOG != CC_FOG_NONE
+ #if CC_USE_RGBE_OUTPUT || CC_USE_FLOAT_OUTPUT
+ CC_APPLY_FOG_BASE(color, fogFactor);
#endif
- color.rgb = ACESToneMap(color.rgb);
- #endif
- #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
- if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION)
- #endif
- color.rgb = LinearToSRGB(color.rgb);
-
- #if !CC_FORWARD_ADD && CC_USE_FOG != CC_FOG_NONE
- CC_APPLY_FOG_BASE(color, fogFactor);
#endif
- fragColorX = CCSurfacesDebugDisplayInvalidNumber(color);
+ // Color output
+ #if CC_USE_RGBE_OUTPUT
+ color = packRGBE(color.rgb); // for reflection-map
+ #else
+ color = CCSurfacesDebugDisplayInvalidNumber(color);
+ #if !CC_USE_FLOAT_OUTPUT
+ color.rgb = HDRToLDR(color.rgb);
+ color.rgb = LinearToSRGB(color.rgb);
+ #endif
+ #endif
+
+ // todo:
+ // can not perform forward-add with fog with 8888 output, and should blend with LDR gamma color, need move before color output
+ #if !CC_USE_RGBE_OUTPUT && !CC_USE_FLOAT_OUTPUT && !CC_FORWARD_ADD
+ #if CC_USE_FOG != CC_FOG_NONE
+ CC_APPLY_FOG_BASE(color, fogFactor);
+ #endif
+ #endif
+
+
+ fragColorX = color;
}
diff --git a/editor/assets/chunks/shading-entries/main-functions/render-to-scene/vs.chunk b/editor/assets/chunks/shading-entries/main-functions/render-to-scene/vs.chunk
index 392f91b91a..1f784d5958 100644
--- a/editor/assets/chunks/shading-entries/main-functions/render-to-scene/vs.chunk
+++ b/editor/assets/chunks/shading-entries/main-functions/render-to-scene/vs.chunk
@@ -31,8 +31,12 @@ void main()
// Other Data
CCSurfacesVertexTransformUV(In);
CCSurfacesVertexTransferFog(In);
- CCSurfacesVertexTransferShadow(In);
CCSurfacesVertexTransferLightMapUV(In);
+ CCSurfacesVertexTransferShadow(In);
+ #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE
+ In.shadowBiasAndProbeId.xy = SurfacesVertexModifyShadowBias(In, In.shadowBiasAndProbeId.xy);
+ #endif
+
CCSurfacesVertexOutput(In);
}
diff --git a/editor/assets/chunks/shading-entries/main-functions/render-to-shadowmap/fs.chunk b/editor/assets/chunks/shading-entries/main-functions/render-to-shadowmap/fs.chunk
index e4fcac8b96..20e72c8354 100644
--- a/editor/assets/chunks/shading-entries/main-functions/render-to-shadowmap/fs.chunk
+++ b/editor/assets/chunks/shading-entries/main-functions/render-to-shadowmap/fs.chunk
@@ -4,8 +4,9 @@ layout(location = 0) out vec4 fragColorX;
void main () {
// better performance than SurfacesFragmentModifyBaseColorAndTransparency
+#ifdef CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY
SurfacesFragmentAlphaClipOnly();
-
+#endif
highp float clipDepth = v_clip_depth.x / v_clip_depth.y * 0.5 + 0.5;
// spot use linear
diff --git a/editor/assets/chunks/surfaces/data-structures/standard.chunk b/editor/assets/chunks/surfaces/data-structures/standard.chunk
index ec98a8411a..52cbfb976b 100644
--- a/editor/assets/chunks/surfaces/data-structures/standard.chunk
+++ b/editor/assets/chunks/surfaces/data-structures/standard.chunk
@@ -26,10 +26,10 @@ struct SurfacesMaterialData
#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE
vec4 transmitDiffuseParams;
#endif
-#if CC_SURFACES_LIGHTING_TRT
- vec3 baseColorTRT;
- float trtIntensity, roughnessTRT;
- vec3 worldNormalTRT, worldTangentTRT, worldBinormalTRT;
+#if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ vec3 baseColor2ndSpecular, color2ndSpecular;
+ float intensity2ndSpecular, roughness2ndSpecular;
+ vec3 worldNormal2ndSpecular, worldTangent2ndSpecular, worldBinormal2ndSpecular;
#endif
#if CC_SURFACES_LIGHTING_TT
vec3 baseColorTT;
diff --git a/editor/assets/chunks/surfaces/default-functions/common-vs.chunk b/editor/assets/chunks/surfaces/default-functions/common-vs.chunk
index 794b3dfeac..3b2409de34 100644
--- a/editor/assets/chunks/surfaces/default-functions/common-vs.chunk
+++ b/editor/assets/chunks/surfaces/default-functions/common-vs.chunk
@@ -1,4 +1,5 @@
#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS
+// depends on CC_SURFACES_VERTEX_MODIFY_LOCAL_POS
vec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)
{
return In.position.xyz;
@@ -6,6 +7,7 @@ vec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)
#endif
#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL
+// depends on CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL
vec3 SurfacesVertexModifyLocalNormal(in SurfacesStandardVertexIntermediate In)
{
return In.normal.xyz;
@@ -14,6 +16,7 @@ vec3 SurfacesVertexModifyLocalNormal(in SurfacesStandardVertexIntermediate In)
#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT
#if CC_SURFACES_USE_TANGENT_SPACE
+// depends on CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT
vec4 SurfacesVertexModifyLocalTangent(in SurfacesStandardVertexIntermediate In)
{
return In.tangent;
@@ -21,9 +24,10 @@ vec3 SurfacesVertexModifyLocalNormal(in SurfacesStandardVertexIntermediate In)
#endif
#endif
+#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA
+// depends on CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA
// some vertex datas use shared raw data, avoid sample / calculate same raw data multiply times, use this function for better performance
// this function invokes before world transform
-#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA
void SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)
{
}
@@ -31,6 +35,7 @@ void SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediat
#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS
+// depends on CC_SURFACES_VERTEX_MODIFY_WORLD_POS
vec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)
{
return In.worldPos;
@@ -38,6 +43,7 @@ vec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)
#endif
#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS
+// depends on CC_SURFACES_VERTEX_MODIFY_CLIP_POS
vec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)
{
return In.clipPos;
@@ -45,6 +51,7 @@ vec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)
#endif
#ifndef CC_SURFACES_VERTEX_MODIFY_UV
+// depends on CC_SURFACES_VERTEX_MODIFY_UV
void SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)
{
// In.texCoord = In.texCoord;
@@ -55,6 +62,7 @@ void SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)
#endif
#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL
+// depends on CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL
vec3 SurfacesVertexModifyWorldNormal(in SurfacesStandardVertexIntermediate In)
{
vec3 worldNormal = In.worldNormal.xyz;
@@ -65,9 +73,19 @@ vec3 SurfacesVertexModifyWorldNormal(in SurfacesStandardVertexIntermediate In)
}
#endif
+#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS
+// depends on CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS
+// shadow bias for submesh-level
+vec2 SurfacesVertexModifyShadowBias(in SurfacesStandardVertexIntermediate In, vec2 originShadowBias)
+{
+ return originShadowBias;
+}
+#endif
+
+#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA
+// depends on CC_SURFACES_VERTEX_MODIFY_SHARED_DATA
// some vertex datas use shared raw data, avoid sample / calculate same raw data multiply times, use this function for better performance
// this function invokes at last
-#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA
void SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)
{
}
diff --git a/editor/assets/chunks/surfaces/default-functions/standard-fs.chunk b/editor/assets/chunks/surfaces/default-functions/standard-fs.chunk
index 73a7ba2f2f..545e6f8f3c 100644
--- a/editor/assets/chunks/surfaces/default-functions/standard-fs.chunk
+++ b/editor/assets/chunks/surfaces/default-functions/standard-fs.chunk
@@ -1,4 +1,5 @@
#ifndef CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY
+// depends on CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY
vec4 SurfacesFragmentModifyBaseColorAndTransparency()
{
return FSInput_vertexColor;
@@ -6,6 +7,7 @@ vec4 SurfacesFragmentModifyBaseColorAndTransparency()
#endif
#ifndef CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY
+// depends on CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY
// for base shape without color usage, such as render-to-shadow
void SurfacesFragmentAlphaClipOnly()
{
@@ -14,6 +16,7 @@ void SurfacesFragmentAlphaClipOnly()
#ifndef CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL
+// depends on CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL
vec3 SurfacesFragmentModifyWorldNormal()
{
return normalize(FSInput_worldNormal);
@@ -21,9 +24,10 @@ vec3 SurfacesFragmentModifyWorldNormal()
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_WORLD_TANGENT_AND_BINORMAL
+// depends on CC_SURFACES_FRAGMENT_MODIFY_WORLD_TANGENT_AND_BINORMAL
void SurfacesFragmentModifyWorldTangentAndBinormal(inout vec3 worldTangent, inout vec3 worldBinormal, vec3 worldNormal)
{
- vec3 tangent = FSInput_worldTangent;
+ vec3 tangent = normalize(FSInput_worldTangent);
#if CC_SURFACES_USE_TANGENT_SPACE
vec3 binormal = normalize(CalculateBinormal(worldNormal.xyz, tangent, FSInput_mirrorNormal));
@@ -38,6 +42,7 @@ void SurfacesFragmentModifyWorldTangentAndBinormal(inout vec3 worldTangent, inou
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_IOR
+// depends on CC_SURFACES_FRAGMENT_MODIFY_IOR
float SurfacesFragmentModifyIOR()
{
return 1.0;
@@ -45,6 +50,7 @@ float SurfacesFragmentModifyIOR()
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_ANISOTROPY_PARAMS
+// depends on CC_SURFACES_FRAGMENT_MODIFY_ANISOTROPY_PARAMS
// isRotation=1.0: shape(0~1), rotation(0~2PI), 0.0, 0.0
// or
// isRotation=0.0: shape(0~1), anisoDir.xyz(-1~1)
@@ -56,6 +62,7 @@ vec4 SurfacesFragmentModifyAnisotropyParams(out float isRotation)
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE
+// depends on CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE
vec3 SurfacesFragmentModifyEmissive()
{
return vec3(0.0, 0.0, 0.0);
@@ -63,6 +70,7 @@ vec3 SurfacesFragmentModifyEmissive()
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_PBRPARAMS
+// depends on CC_SURFACES_FRAGMENT_MODIFY_PBRPARAMS
vec4 SurfacesFragmentModifyPBRParams()
{
// ao, roughness, metallic, specularIntensity
@@ -71,6 +79,7 @@ vec4 SurfacesFragmentModifyPBRParams()
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_SCATTERING_PARAMS
+// depends on CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_SCATTERING_PARAMS
// scattering related parameters and colors
vec4 SurfacesFragmentModifyTransmitScatteringParams()
{
@@ -85,6 +94,7 @@ vec4 SurfacesFragmentModifyTransmitScatteringParams()
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_IN_SCATTERING_COLOR
+// depends on CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_IN_SCATTERING_COLOR
vec3 SurfacesFragmentModifyTransmitInScatteringColor()
{
// added light multiplier
@@ -92,6 +102,7 @@ vec3 SurfacesFragmentModifyTransmitInScatteringColor()
}
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_OUT_SCATTERING_COLOR
+// depends on CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_OUT_SCATTERING_COLOR
vec3 SurfacesFragmentModifyTransmitOutScatteringColor()
{
// transmit background multiplier
@@ -100,6 +111,7 @@ vec3 SurfacesFragmentModifyTransmitOutScatteringColor()
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_DIFFUSE_PARAMS
+// depends on CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_DIFFUSE_PARAMS
vec4 SurfacesFragmentModifyTransmitDiffuseParams()
{
// this param valid only when CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT is 1
@@ -115,6 +127,7 @@ vec4 SurfacesFragmentModifyTransmitDiffuseParams()
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRT_PARAMS
+// depends on CC_SURFACES_FRAGMENT_MODIFY_TRT_PARAMS
vec4 SurfacesFragmentModifyTRTParams()
{
//x: roughness offset
@@ -123,7 +136,9 @@ vec4 SurfacesFragmentModifyTRTParams()
return vec4(0.2, 0.0, 0.0, 1.0);
}
#endif
+
#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRT_COLOR
+// depends on CC_SURFACES_FRAGMENT_MODIFY_TRT_COLOR
vec3 SurfacesFragmentModifyTRTColor()
{
return vec3(1.0, 1.0, 1.0);
@@ -131,6 +146,7 @@ vec3 SurfacesFragmentModifyTRTColor()
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_TT_PARAMS
+// depends on CC_SURFACES_FRAGMENT_MODIFY_TT_PARAMS
vec4 SurfacesFragmentModifyTTParams()
{
//x: scatter coef
@@ -138,29 +154,43 @@ vec4 SurfacesFragmentModifyTTParams()
return vec4(0.0, 0.0, 0.0, 1.0);
}
#endif
+
#ifndef CC_SURFACES_FRAGMENT_MODIFY_TT_COLOR
-vec3 SurfacesFragmentModifyTTColor(in vec3 baseColor, in vec3 trtColor)
+// depends on CC_SURFACES_FRAGMENT_MODIFY_TT_COLOR
+vec3 SurfacesFragmentModifyTTColor(in vec3 baseColor)
{
- // baseColor and trtColor for reference
+ // baseColor for reference
return vec3(1.0, 1.0, 1.0);
}
#endif
+#ifndef CC_SURFACES_FRAGMENT_MODIFY_DUAL_LOBE_SPECULAR_PARAMS
+// depends on CC_SURFACES_FRAGMENT_MODIFY_DUAL_LOBE_SPECULAR_PARAMS
+vec4 SurfacesFragmentModifyDualLobeSpecularParams(float roughness)
+{
+ //x: secondary lobe roughness, according to argument (first lobe roughness)
+ //w: intensity
+ return vec4(0.2, 0.0, 0.0, 1.0);
+}
+#endif
+
#ifndef CC_SURFACES_FRAGMENT_MODIFY_SSS_PARAMS
+// depends on CC_SURFACES_FRAGMENT_MODIFY_SSS_PARAMS
vec4 SurfacesFragmentModifySSSParams()
{
// x: sssIntensity, moisture
// y: sssCurvature, for preintegrated sss
// z: sssColoration, for sss transmitted light color with dark area
- // w: cavity for specular
- return vec4(1.0, 0.1, 1.0, 1.0);
+ // w: unused
+ return vec4(1.0, 0.1, 1.0, 0.0);
}
#endif
+#ifndef CC_SURFACES_FRAGMENT_MODIFY_SHARED_DATA
+// depends on CC_SURFACES_FRAGMENT_MODIFY_SHARED_DATA
// some material datas use shared raw data, avoid sample / calculate same raw data multiply times, use this function for better performance
// this function invokes at last
// should use corresponding shading-model header: #include before function define
-#ifndef CC_SURFACES_FRAGMENT_MODIFY_SHARED_DATA
void SurfacesFragmentModifySharedData(inout SurfacesMaterialData surfaceData)
{
}
diff --git a/editor/assets/chunks/surfaces/default-functions/toon-fs.chunk b/editor/assets/chunks/surfaces/default-functions/toon-fs.chunk
index d37ff7a50d..b6253e6f3e 100644
--- a/editor/assets/chunks/surfaces/default-functions/toon-fs.chunk
+++ b/editor/assets/chunks/surfaces/default-functions/toon-fs.chunk
@@ -1,6 +1,7 @@
#include
#ifndef CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE
+// depends on CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE
void SurfacesFragmentModifyBaseColorAndToonShade(out vec4 baseColorAndTransparency, out vec3 shade1, out vec3 shade2, in vec3 baseColor)
{
baseColorAndTransparency = FSInput_vertexColor;
@@ -9,6 +10,7 @@ void SurfacesFragmentModifyBaseColorAndToonShade(out vec4 baseColorAndTransparen
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER
+// depends on CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER
vec4 SurfacesFragmentModifyToonStepAndFeather()
{
return vec3(0.8, 0.001, 0.5, 0.001);
@@ -16,6 +18,7 @@ vec4 SurfacesFragmentModifyToonStepAndFeather()
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER
+// depends on CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER
float SurfacesFragmentModifyToonShadowCover()
{
return 0.5;
@@ -23,6 +26,7 @@ float SurfacesFragmentModifyToonShadowCover()
#endif
#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR
+// depends on CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR
vec4 SurfacesFragmentModifyToonSpecular()
{
return vec4(1.0, 1.0, 1.0, 0.3);
diff --git a/editor/assets/chunks/surfaces/effect-macros/common-macros.chunk b/editor/assets/chunks/surfaces/effect-macros/common-macros.chunk
index 6f3e83157e..ec59329781 100644
--- a/editor/assets/chunks/surfaces/effect-macros/common-macros.chunk
+++ b/editor/assets/chunks/surfaces/effect-macros/common-macros.chunk
@@ -68,6 +68,12 @@
#ifndef CC_SURFACES_LIGHTING_TRT
#define CC_SURFACES_LIGHTING_TRT 0
#endif
+#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR
+ #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0
+#endif
+#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT
+ #define CC_SURFACES_LIGHTING_CLEAR_COAT 0
+#endif
#ifndef CC_SURFACES_LIGHTING_TT
#define CC_SURFACES_LIGHTING_TT 0
#endif
@@ -75,17 +81,22 @@
#define CC_SURFACES_LIGHTING_SSS 0
#endif
+// common 2nd-specular for TRT / Dual-Lobe / Wet / ClearCoat...
+#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_CLEAR_COAT
+ #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1
+ #endif
+#endif
+
+#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0
+#endif
+
+
// render-to-color-map can disable functionality to avoid error data map
#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW
#define CC_SURFACES_ENABLE_DEBUG_VIEW 1
#endif
-// for skin
-/*
-#ifndef CC_SURFACES_LIGHTING_DISABLE_DIFFUSE
- #define CC_SURFACES_LIGHTING_DISABLE_DIFFUSE 0
-#endif
-#ifndef CC_SURFACES_LIGHTING_DISABLE_SPECULAR
- #define CC_SURFACES_LIGHTING_DISABLE_SPECULAR 0
-#endif
-*/
+// for ssss skin, only can be defined in pass embedded macros
+// CC_SURFACES_LIGHTING_DISABLE_DIFFUSE / CC_SURFACES_LIGHTING_DISABLE_SPECULAR
diff --git a/editor/assets/chunks/surfaces/includes/common-fs.chunk b/editor/assets/chunks/surfaces/includes/common-fs.chunk
index e99bf8f895..26677dfded 100644
--- a/editor/assets/chunks/surfaces/includes/common-fs.chunk
+++ b/editor/assets/chunks/surfaces/includes/common-fs.chunk
@@ -48,7 +48,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/editor/assets/chunks/surfaces/module-functions/debug-view.chunk b/editor/assets/chunks/surfaces/module-functions/debug-view.chunk
index 7f08400730..2ea1d14f81 100644
--- a/editor/assets/chunks/surfaces/module-functions/debug-view.chunk
+++ b/editor/assets/chunks/surfaces/module-functions/debug-view.chunk
@@ -110,7 +110,7 @@ vec4 CCSurfacesDebugDisplayInvalidInputData(vec4 color, vec3 data)
if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR))
{
- color.rgb = lightingResult.directSpecular * lightingResult.specularColorWithLighting;
+ color.rgb = lightingResult.directSpecular * lightingResult.specularColorWithEnvLighting;
isSRGBColor = true;
}
@@ -128,7 +128,7 @@ vec4 CCSurfacesDebugDisplayInvalidInputData(vec4 color, vec3 data)
if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR))
{
- color.rgb = lightingResult.environmentSpecular * lightingResult.specularColorWithLighting;
+ color.rgb = lightingResult.environmentSpecular * lightingResult.specularColorWithEnvLighting;
isSRGBColor = true;
}
@@ -165,8 +165,8 @@ vec4 CCSurfacesDebugDisplayInvalidInputData(vec4 color, vec3 data)
float fresnel = 0.0;
vec3 directTransmitSpecular = vec3(0.0), environmentTransmitSpecular = vec3(0.0);
vec3 directTransmitDiffuse = vec3(0.0), environmentTransmitDiffuse = vec3(0.0);
- vec3 diffuseColorWithLightingTT = vec3(0.0), specularColorWithLightingTRT = vec3(0.0);
- vec3 directTRT = vec3(0.0), environmentTRT = vec3(0.0);
+ vec3 diffuseColorWithLightingTT = vec3(0.0), specularColorWithLighting2ndSpecular = vec3(0.0);
+ vec3 direct2ndSpecular = vec3(0.0), environment2ndSpecular = vec3(0.0);
#if CC_SURFACES_LIGHTING_USE_FRESNEL
fresnel = lightingResult.fresnel;
#endif
@@ -178,10 +178,10 @@ vec4 CCSurfacesDebugDisplayInvalidInputData(vec4 color, vec3 data)
directTransmitDiffuse = lightingResult.directTransmitDiffuse;
environmentTransmitDiffuse = lightingResult.environmentTransmitDiffuse;
#endif
- #if CC_SURFACES_LIGHTING_TRT
- directTRT = lightingResult.directTRT;
- environmentTRT = lightingResult.environmentTRT;
- specularColorWithLightingTRT = lightingResult.specularColorWithLightingTRT;
+ #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ direct2ndSpecular = lightingResult.direct2ndSpecular;
+ environment2ndSpecular = lightingResult.environment2ndSpecular;
+ specularColorWithLighting2ndSpecular = lightingResult.specularColorWithEnvLighting2ndSpecular;
#endif
if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_FRESNEL))
@@ -218,19 +218,19 @@ vec4 CCSurfacesDebugDisplayInvalidInputData(vec4 color, vec3 data)
isSRGBColor = true;
}
- if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_TRT_DIRECT))
+ if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR))
{
- color.rgb = directTRT * specularColorWithLightingTRT;
+ color.rgb = direct2ndSpecular * specularColorWithLighting2ndSpecular;
isSRGBColor = true;
}
- if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_TRT_ENVIRONMENT))
+ if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR))
{
- color.rgb = environmentTRT * specularColorWithLightingTRT;
+ color.rgb = environment2ndSpecular * specularColorWithLighting2ndSpecular;
isSRGBColor = true;
}
- if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_TRT_ALL))
+ if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL))
{
- color.rgb = (directTRT + environmentTRT) * specularColorWithLightingTRT;
+ color.rgb = (direct2ndSpecular + environment2ndSpecular) * specularColorWithLighting2ndSpecular;
isSRGBColor = true;
}
@@ -265,9 +265,9 @@ vec4 CCSurfacesDebugDisplayInvalidInputData(vec4 color, vec3 data)
lightingResult.directTransmitSpecular = lightingResult.environmentTransmitSpecular = vec3(0.0);
#endif
- #if CC_SURFACES_LIGHTING_TRT
- if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRT)
- lightingResult.directTRT = lightingResult.environmentTRT = vec3(0.0);
+ #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR)
+ lightingResult.direct2ndSpecular = lightingResult.environment2ndSpecular = vec3(0.0);
#endif
#if CC_SURFACES_LIGHTING_TT
diff --git a/editor/assets/chunks/surfaces/module-functions/standard-fs.chunk b/editor/assets/chunks/surfaces/module-functions/standard-fs.chunk
index e37c9a9b6a..df4a67ce35 100644
--- a/editor/assets/chunks/surfaces/module-functions/standard-fs.chunk
+++ b/editor/assets/chunks/surfaces/module-functions/standard-fs.chunk
@@ -43,23 +43,36 @@ void CCSurfacesFragmentGetMaterialData(inout SurfacesMaterialData surfaceData)
surfaceData.transmitDiffuseParams = SurfacesFragmentModifyTransmitDiffuseParams();
#endif
- vec3 baseColorTRT = vec3(0.0);
#if CC_SURFACES_LIGHTING_TRT
+ // skip in shader graph, need extra code
vec4 trtParams = SurfacesFragmentModifyTRTParams();
- surfaceData.roughnessTRT = saturate(surfaceData.roughness + trtParams.x);
- surfaceData.trtIntensity = trtParams.w;
- surfaceData.baseColorTRT = baseColorTRT = SurfacesFragmentModifyTRTColor();
- surfaceData.worldNormalTRT = surfaceData.worldNormal;
- surfaceData.worldTangentTRT = surfaceData.worldTangent;
- surfaceData.worldBinormalTRT = surfaceData.worldBinormal;
- RotateNormalAndBinormal(surfaceData.worldBinormalTRT, surfaceData.worldNormalTRT, surfaceData.worldTangentTRT, trtParams.y);
+ surfaceData.roughness2ndSpecular = saturate(surfaceData.roughness + trtParams.x);
+ surfaceData.intensity2ndSpecular = trtParams.w;
+ surfaceData.baseColor2ndSpecular = vec3(1.0); // specular color use specified trt color only
+ surfaceData.color2ndSpecular = SurfacesFragmentModifyTRTColor();
+ surfaceData.worldNormal2ndSpecular = surfaceData.worldNormal;
+ surfaceData.worldTangent2ndSpecular = surfaceData.worldTangent;
+ surfaceData.worldBinormal2ndSpecular = surfaceData.worldBinormal;
+ RotateNormalAndBinormal(surfaceData.worldBinormal2ndSpecular, surfaceData.worldNormal2ndSpecular, surfaceData.worldTangent2ndSpecular, trtParams.y, FSInput_mirrorNormal);
#endif
#if CC_SURFACES_LIGHTING_TT
vec4 ttParams = SurfacesFragmentModifyTTParams();
surfaceData.ttScatterCoef = ttParams.x;
surfaceData.ttIntensity = ttParams.w;
- surfaceData.baseColorTT = SurfacesFragmentModifyTTColor(surfaceData.baseColor.rgb, baseColorTRT);
+ surfaceData.baseColorTT = SurfacesFragmentModifyTTColor(surfaceData.baseColor.rgb);
+#endif
+
+#if CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR
+ // skip in shader graph, need extra code
+ vec4 dualLobeParams = SurfacesFragmentModifyDualLobeSpecularParams(surfaceData.roughness);
+ surfaceData.roughness2ndSpecular = saturate(dualLobeParams.x);
+ surfaceData.intensity2ndSpecular = dualLobeParams.w;
+ surfaceData.baseColor2ndSpecular = surfaceData.baseColor.rgb;
+ surfaceData.color2ndSpecular = vec3(1.0); // no extra coloration
+ surfaceData.worldNormal2ndSpecular = surfaceData.worldNormal;
+ surfaceData.worldTangent2ndSpecular = surfaceData.worldTangent;
+ surfaceData.worldBinormal2ndSpecular = surfaceData.worldBinormal;
#endif
#if CC_SURFACES_LIGHTING_SSS
@@ -70,8 +83,8 @@ void CCSurfacesFragmentGetMaterialData(inout SurfacesMaterialData surfaceData)
#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP) {
- surfaceData.worldNormal = FSInput_worldNormal;
- surfaceData.worldTangent = FSInput_worldTangent;
+ surfaceData.worldNormal = normalize(FSInput_worldNormal);
+ surfaceData.worldTangent = normalize(FSInput_worldTangent);
}
#endif
@@ -79,8 +92,8 @@ void CCSurfacesFragmentGetMaterialData(inout SurfacesMaterialData surfaceData)
if (!IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO)
{
surfaceData.baseColor.rgb = vec3(1.0);
- #if CC_SURFACES_LIGHTING_TRT
- surfaceData.baseColorTRT.rgb = vec3(1.0);
+ #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ surfaceData.baseColor2ndSpecular.rgb = vec3(1.0);
#endif
#if CC_SURFACES_LIGHTING_TT
surfaceData.baseColorTT.rgb = vec3(1.0);
@@ -101,15 +114,16 @@ vec3 CCSurfacesGetSpecularColor(in SurfacesMaterialData surfaceData)
}
// Diffuse/Specular Color with BRDF lighting preparation
-void CCSurfacesLightingInitializeColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)
+void CCSurfacesLightingInitializeColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, inout vec3 specularColorWithEnvLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)
{
diffuseColorWithLighting = CCSurfacesGetDiffuseColor(surfaceData);
+ specularColorWithLighting = CCSurfacesGetSpecularColor(surfaceData).xyz;
// (Intergrated) GF/4Pi use approximate value for both direct lighting and environment lighting
// accuracy value can be calculated in LightingCalculateDirect/Environment instead of IntegratedGFApprox
- specularColorWithLighting = IntegratedGFApprox(CCSurfacesGetSpecularColor(surfaceData).xyz, surfaceData.roughness, lightingData.NoVAbsSat);
+ specularColorWithEnvLighting = IntegratedGFApprox(specularColorWithLighting, surfaceData.roughness, lightingData.NoVAbsSat);
}
// Update two colors with BRDF which depend on lights (optional)
-void CCSurfacesLightingCalculateColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)
+void CCSurfacesLightingCalculateColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, inout vec3 specularColorWithEnvLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)
{
}
@@ -153,26 +167,22 @@ void CCSurfacesGetLightingIntermediateDataTransmitDiffuse(inout LightingIntermed
lightingDataTD = lightingData;
// view-depenedent mode make sure normal always back from view direction
// (-N) + (-V) for smoother result
- lightingDataTD.N = lightingData.transmitScatteringParams.z > 0.0 ? -lightingData.N : -normalize(lightingData.N+lightingData.V);
+ // ignore normalMap for 3S simulation
+ lightingDataTD.N = lightingData.transmitScatteringParams.z > 0.0 ? -FSInput_worldNormal : -(normalize(FSInput_worldNormal)+lightingData.V);
+ lightingDataTD.N = normalize(lightingDataTD.N);
}
#endif
-#if CC_SURFACES_LIGHTING_TRT
-// pass original lightingData, get TRT lightingData
-void CCSurfacesGetLightingIntermediateDataTRT(inout LightingIntermediateData lightingDataTRT, in LightingIntermediateData lightingData, in SurfacesMaterialData surfaceData)
+#if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+// pass original surfaceData, get surfaceData for 2nd specular
+void CCSurfacesGetSurfacesMaterialData2ndSpecular(inout SurfacesMaterialData surfaceData2ndSpecular, in SurfacesMaterialData surfaceData)
{
- lightingDataTRT = lightingData;
- lightingDataTRT.specularParam = surfaceData.roughnessTRT;
- // new TBN with anisotropic offset
- lightingDataTRT.N = surfaceData.worldNormalTRT;
- lightingDataTRT.T = surfaceData.worldTangentTRT;
- lightingDataTRT.B = surfaceData.worldBinormalTRT;
-}
-// pass original surfaceData, get TRT surfaceData
-void CCSurfacesGetSurfacesMaterialDataTRT(inout SurfacesMaterialData surfaceDataTRT, in SurfacesMaterialData surfaceData)
-{
- surfaceDataTRT = surfaceData;
- surfaceDataTRT.baseColor = vec4(surfaceData.baseColorTRT, 1.0);
+ surfaceData2ndSpecular = surfaceData;
+ surfaceData2ndSpecular.baseColor = vec4(surfaceData.baseColor2ndSpecular, 1.0);
+ surfaceData2ndSpecular.roughness = surfaceData.roughness2ndSpecular;
+ surfaceData2ndSpecular.worldNormal = surfaceData.worldNormal2ndSpecular;
+ surfaceData2ndSpecular.worldTangent = surfaceData.worldTangent2ndSpecular;
+ surfaceData2ndSpecular.worldBinormal = surfaceData.worldBinormal2ndSpecular;
}
#endif
@@ -194,8 +204,8 @@ void CCSurfacesInitializeLightingResult(inout LightingResult lightingResult)
#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE
lightingResult.directTransmitDiffuse = vec3(0.0);
#endif
-#if CC_SURFACES_LIGHTING_TRT
- lightingResult.directTRT = vec3(0.0);
+#if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ lightingResult.direct2ndSpecular = vec3(0.0);
#endif
#if CC_SURFACES_LIGHTING_TT
lightingResult.directTT = vec3(0.0);
@@ -214,8 +224,8 @@ void CCSurfacesAccumulateLightingResult(inout LightingResult lightingResultAccum
#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE
lightingResultAccumulated.directTransmitDiffuse += lightingResult.directTransmitDiffuse;
#endif
- #if CC_SURFACES_LIGHTING_TRT
- lightingResultAccumulated.directTRT += lightingResult.directTRT * lightingResult.shadow;
+ #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ lightingResultAccumulated.direct2ndSpecular += lightingResult.direct2ndSpecular * lightingResult.shadow;
#endif
#if CC_SURFACES_LIGHTING_TT
lightingResultAccumulated.directTT += lightingResult.directTT * lightingResult.shadow;
@@ -246,15 +256,16 @@ vec4 CCSurfacesShading(in SurfacesMaterialData surfaceData, in LightingResult li
{
vec4 color = vec4(0.0, 0.0, 0.0, surfaceData.baseColor.a);
+ // todo: local lighting also use EnvLightingSpecularColor for estimated GF terms, calculate accurate GF instead in the future, CCSurfacesDebugViewLightingResult also needs modified
#if CC_FORWARD_ADD
// shadow and fresnel has already been applied with common flow
color.xyz += lightingResult.directDiffuse * lightingResult.diffuseColorWithLighting
- + lightingResult.directSpecular * lightingResult.specularColorWithLighting
+ + lightingResult.directSpecular * lightingResult.specularColorWithEnvLighting
#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR
- + lightingResult.directTransmitSpecular * lightingResult.specularColorWithLighting
+ + lightingResult.directTransmitSpecular * lightingResult.specularColorWithEnvLighting
#endif
- #if CC_SURFACES_LIGHTING_TRT
- + lightingResult.directTRT * lightingResult.specularColorWithLightingTRT * surfaceData.trtIntensity * surfaceData.baseColorTRT
+ #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ + lightingResult.direct2ndSpecular * lightingResult.specularColorWithEnvLighting2ndSpecular * surfaceData.color2ndSpecular
#endif
#if CC_SURFACES_LIGHTING_TT
+ lightingResult.directTT * lightingResult.diffuseColorWithLightingTT
@@ -273,12 +284,12 @@ vec4 CCSurfacesShading(in SurfacesMaterialData surfaceData, in LightingResult li
color.xyz +=
( lightingResult.directDiffuse * lightingResult.diffuseColorWithLighting
- + lightingResult.directSpecular * lightingResult.specularColorWithLighting * fresnel
+ + lightingResult.directSpecular * lightingResult.specularColorWithEnvLighting * fresnel
#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR
- + lightingResult.directTransmitSpecular * lightingResult.specularColorWithLighting * invFresnel
+ + lightingResult.directTransmitSpecular * lightingResult.specularColorWithEnvLighting * invFresnel
#endif
- #if CC_SURFACES_LIGHTING_TRT
- + lightingResult.directTRT * lightingResult.specularColorWithLightingTRT * surfaceData.trtIntensity * surfaceData.baseColorTRT
+ #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ + lightingResult.direct2ndSpecular * lightingResult.specularColorWithEnvLighting2ndSpecular * surfaceData.color2ndSpecular
#endif
#if CC_SURFACES_LIGHTING_TT
+ lightingResult.directTT * lightingResult.diffuseColorWithLightingTT
@@ -298,12 +309,12 @@ vec4 CCSurfacesShading(in SurfacesMaterialData surfaceData, in LightingResult li
color.xyz +=
( lightingResult.environmentDiffuse * lightingResult.diffuseColorWithLighting
- + lightingResult.environmentSpecular * lightingResult.specularColorWithLighting * fresnel
+ + lightingResult.environmentSpecular * lightingResult.specularColorWithEnvLighting * fresnel
#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR
- + lightingResult.environmentTransmitSpecular * lightingResult.specularColorWithLighting * invFresnel
+ + lightingResult.environmentTransmitSpecular * lightingResult.specularColorWithEnvLighting * invFresnel
#endif
- #if CC_SURFACES_LIGHTING_TRT
- + lightingResult.environmentTRT * lightingResult.specularColorWithLightingTRT * surfaceData.trtIntensity * surfaceData.baseColorTRT
+ #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR
+ + lightingResult.environment2ndSpecular * lightingResult.specularColorWithEnvLighting2ndSpecular * surfaceData.color2ndSpecular
#endif
)
* lightingResult.ao
@@ -314,15 +325,16 @@ vec4 CCSurfacesShading(in SurfacesMaterialData surfaceData, in LightingResult li
color.xyz += lightingResult.emissive;
#endif
-
+
return color;
}
// Debug view
#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE
-void CCSurfacesDebugViewSurfaceData(inout vec4 color, in SurfacesMaterialData surfaceData)
+bool CCSurfacesDebugViewSurfaceData(inout vec4 color, in SurfacesMaterialData surfaceData)
{
+ bool enableMaterialAlpha = true;
vec4 black = vec4(0.0, 0.0, 0.0, 1.0);
float scalar;
if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL))
@@ -349,6 +361,7 @@ void CCSurfacesDebugViewSurfaceData(inout vec4 color, in SurfacesMaterialData su
if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_TRANSPARENCY)) {
scalar = surfaceData.baseColor.a;
color = vec4(scalar, scalar, scalar, 1.0);
+ enableMaterialAlpha = false;
}
if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_BASE_COLOR))
color = vec4(LinearToSRGB(surfaceData.baseColor.rgb), 1.0);
@@ -375,6 +388,8 @@ void CCSurfacesDebugViewSurfaceData(inout vec4 color, in SurfacesMaterialData su
scalar = surfaceData.ior - 1.0;
color = vec4(scalar, scalar, scalar, 1.0);
}
+
+ return enableMaterialAlpha;
}
#endif
diff --git a/editor/assets/chunks/surfaces/module-functions/toon-fs.chunk b/editor/assets/chunks/surfaces/module-functions/toon-fs.chunk
index 43becca4b6..d530b9022c 100644
--- a/editor/assets/chunks/surfaces/module-functions/toon-fs.chunk
+++ b/editor/assets/chunks/surfaces/module-functions/toon-fs.chunk
@@ -25,7 +25,7 @@ void CCSurfacesFragmentGetMaterialData(inout SurfacesMaterialData surfaceData)
#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC
if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP)
- surfaceData.worldNormal = FSInput_worldNormal;
+ surfaceData.worldNormal = normalize(FSInput_worldNormal);
#endif
#if CC_USE_DEBUG_VIEW
@@ -50,11 +50,12 @@ vec3 CCSurfacesGetSpecularColor(in SurfacesMaterialData surfaceData)
{
return surfaceData.specular.xyz;
}
-void CCSurfacesLightingInitializeColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)
+void CCSurfacesLightingInitializeColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, inout vec3 specularColorWithEnvLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)
{
- specularColorWithLighting = surfaceData.specular.xyz * surfaceData.baseStep;
+ diffuseColorWithLighting = vec3(0.0);
+ specularColorWithEnvLighting = specularColorWithLighting = surfaceData.specular.xyz * surfaceData.baseStep;
}
-void CCSurfacesLightingCalculateColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)
+void CCSurfacesLightingCalculateColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, inout vec3 specularColorWithEnvLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)
{
float NL = 0.5 * lightingData.NoL + 0.5;
@@ -139,7 +140,8 @@ vec4 CCSurfacesShading(in SurfacesMaterialData surfaceData, in LightingResult li
LightingIntermediateData lightingData;
lightingData.NoL = -1.0;
vec3 backLightingDiffuse, backLightingSpecular;
- CCSurfacesLightingCalculateColorWithLighting(backLightingDiffuse, backLightingSpecular, surfaceData, lightingData);
+ CCSurfacesLightingInitializeColorWithLighting(backLightingDiffuse, backLightingSpecular, backLightingSpecular, surfaceData, lightingData);
+ CCSurfacesLightingCalculateColorWithLighting(backLightingDiffuse, backLightingSpecular, backLightingSpecular, surfaceData, lightingData);
color.xyz +=
mix(lightingResult.directDiffuse, lightingResult.lightmapColor, lightmapCoef) * mix(backLightingDiffuse, lightingResult.diffuseColorWithLighting, lightingResult.shadow)
@@ -156,8 +158,9 @@ vec4 CCSurfacesShading(in SurfacesMaterialData surfaceData, in LightingResult li
// Debug view
#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE
-void CCSurfacesDebugViewSurfaceData(inout vec4 color, in SurfacesMaterialData surfaceData)
+bool CCSurfacesDebugViewSurfaceData(inout vec4 color, in SurfacesMaterialData surfaceData)
{
+ bool enableMaterialAlpha = true;
float scalar;
if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL))
color = vec4(surfaceData.worldNormal * 0.5 + vec3(0.5), 1.0);
@@ -172,6 +175,7 @@ void CCSurfacesDebugViewSurfaceData(inout vec4 color, in SurfacesMaterialData su
{
scalar = surfaceData.baseColor.a;
color = vec4(scalar, scalar, scalar, 1.0);
+ enableMaterialAlpha = false;
}
if (IS_DEBUG_VIEW_SINGLE_MODE(CC_SURFACES_DEBUG_VIEW_BASE_COLOR))
@@ -188,6 +192,8 @@ void CCSurfacesDebugViewSurfaceData(inout vec4 color, in SurfacesMaterialData su
scalar = surfaceData.specular.a;
color = vec4(scalar, scalar, scalar, 1.0);
}
+
+ return enableMaterialAlpha;
}
#endif
diff --git a/editor/assets/effects/advanced/common-functions.chunk b/editor/assets/effects/advanced/common-functions.chunk
index 079785bcdf..3209f0ebc0 100644
--- a/editor/assets/effects/advanced/common-functions.chunk
+++ b/editor/assets/effects/advanced/common-functions.chunk
@@ -52,7 +52,7 @@
vec3 normal = FSInput_worldNormal;
#if USE_NORMAL_MAP
vec3 nmmp = texture(normalMap, NORMAL_UV).xyz - vec3(0.5);
- normal = CalculateNormalFromTangentSpace(nmmp, emissiveScaleParam.w, normal.xyz, FSInput_worldTangent, FSInput_mirrorNormal);
+ normal = CalculateNormalFromTangentSpace(nmmp, emissiveScaleParam.w, normalize(normal.xyz), normalize(FSInput_worldTangent), FSInput_mirrorNormal);
#endif
return normalize(normal);
diff --git a/editor/assets/effects/advanced/eye.chunk b/editor/assets/effects/advanced/eye.chunk
new file mode 100644
index 0000000000..41f5056a34
--- /dev/null
+++ b/editor/assets/effects/advanced/eye.chunk
@@ -0,0 +1,169 @@
+#include
+
+vec3 lerp_3Color(vec3 A, vec3 B, vec3 C, float alpha)
+{
+ float alpha1 = saturate(alpha * 2.0);
+ float alpha2 = saturate(alpha * 2.0 - 1.0);
+ vec3 AB = lerp(A, B, alpha1);
+ return lerp(AB, C, alpha2);
+}
+
+vec3 GetIrisUVMask(float IrisUVRadius)
+{
+ const float IrisBorderWidth = 0.04, IrisBleedWidth = 0.035, IrisMaskWidth = 0.045;
+
+ vec3 arg3_LimbusUVWidth = vec3(IrisBorderWidth, IrisBleedWidth, IrisMaskWidth);
+ float arg8_IrisUVRadius = IrisUVRadius * 0.03 + 0.15;
+ // vec3 out_IrisUVMask = Custom1(IrisUVRadius,UV,LimbusUVWidth)
+ {
+ float IrisUVRadiusTemp = arg8_IrisUVRadius;
+ vec2 UV = FSInput_texcoord;
+ vec3 LimbusUVWidth = arg3_LimbusUVWidth;
+ UV = UV - vec2(0.5, 0.5);
+
+ vec3 r = (vec3(length(UV)) - (vec3(IrisUVRadiusTemp) - LimbusUVWidth)) / LimbusUVWidth;
+ return smoothstep(0.0, 1.0, saturate(vec3(1.0) - r));
+ }
+}
+
+vec2 GetIrisUV(vec2 refractedUV, float IrisUVRadius, float PupilScale)
+{
+ // code between Refract->Parallax, for control pupil size
+ const float PupilShiftX = 0.0, PupilShiftY = 0.0, ScaleIrisWithinMask = 1.0;
+
+ float uvRadius = (IrisUVRadius*0.03+0.15) * 2.0;
+ vec2 UV1 = refractedUV - vec2(0.5);
+ vec2 UV =(UV1 / uvRadius) + vec2(0.5);
+
+ vec2 UVscaled;// = ScalePupils(UV,PupilScale1,PupilShiftX1,PupilShiftY1)
+ {
+ float ShiftMask = pow(saturate(-4.0 * (distance(vec2(0.5), UV) - 0.45)),0.7);
+ vec2 UVshifted = UV + vec2(PupilShiftX * (ShiftMask * -0.1), PupilShiftY * (ShiftMask * 0.1));
+ vec2 UVcentered = UVshifted - vec2(0.5, 0.5);
+ float UVlength = length(UVcentered);
+ // UV on circle at distance 0.5 from the center, in direction of original UV
+ vec2 UVmax = normalize(UVcentered) * 0.5;
+ UVscaled = lerp(UVmax, vec2(0.0, 0.0), saturate((1.0 - UVlength * 2.0) * PupilScale)) + vec2(0.5, 0.5);
+ }
+ float TextureScale = ScaleIrisWithinMask;
+ vec2 UVs_out;// = ScaleUVsByCenter(UVscaled,TextureScale)
+ {
+ UVs_out = (UVscaled - vec2(0.5)) * TextureScale + vec2(0.5);
+ }
+
+ return UVs_out;
+}
+
+vec3 GetGeneratedColorForIris(vec2 irisUV, sampler2D irisColorMap, float IrisColor1U, float IrisColor2U, float IrisColor1Bright, float IrisColor2Bright)
+{
+ //MF_irisGenerator
+ // custom pupil spherical scaling, should after refraction
+/* vec2 centeredUV = (irisUV - vec2(0.5)) * 2.0;
+ float lengthUV = length(centeredUV);
+ vec2 dirUV = normalize(centeredUV);
+ irisUV = pow(lengthUV, pupilScale) * dirUV * 0.5 + vec2(0.5);
+*/
+ const float IrisColor1V = 0.3, IrisColor2V = 0.3, IrisColorValueVariation = 0.25, IrisColorHueVariation = 0.1;
+ const float IrisColorBalance = 0.5, IrisColorBalanceSmoothness = 0.5, IrisSaturationVariation = 0.25;
+ const float RadialStructuralBlendSwitch = 0.0, LimbusDarkAmount = 0.5, AOinIris = 0.7;
+
+ vec4 M_Tex = texture(irisColorMap/*T_Iris_A_M*/, irisUV);
+
+ vec2 uv1 = vec2(IrisColor2U - IrisColorHueVariation, IrisColor2V + IrisColorValueVariation);
+ vec2 uv2 = vec2(IrisColor2U + IrisColorHueVariation, IrisColor2V - IrisColorHueVariation);
+ vec2 uv3 = vec2(IrisColor1U - IrisColorHueVariation, IrisColor1V + IrisColorValueVariation);
+ vec2 uv4 = vec2(IrisColor1U + IrisColorHueVariation, IrisColor1V - IrisColorValueVariation);
+ vec3 col2 = SRGBToLinear(texture(irisGradientMap, vec2(IrisColor2U, IrisColor2V)).rgb) * IrisColor2Bright;
+ vec3 col2_hue1 = SRGBToLinear(texture(irisGradientMap, uv1).rgb) * IrisColor2Bright;
+ vec3 col2_hue2 = SRGBToLinear(texture(irisGradientMap, uv2).rgb) * IrisColor2Bright;
+ vec3 col1 = SRGBToLinear(texture(irisGradientMap, vec2(IrisColor1U, IrisColor1V)).rgb) * IrisColor1Bright;
+ vec3 col1_hue1 = SRGBToLinear(texture(irisGradientMap, uv3).rgb) * IrisColor1Bright;
+ vec3 col1_hue2 = SRGBToLinear(texture(irisGradientMap, uv4).rgb) * IrisColor1Bright;
+
+ float minValue = IrisColorBalance - IrisColorBalanceSmoothness;
+ float maxValue = IrisColorBalance + IrisColorBalanceSmoothness;
+ vec2 invMaskRB = vec2(1.0) - M_Tex.rb;
+ vec2 alphaRB = smoothstep(minValue, maxValue, invMaskRB);
+ float Fraction = lerp(-1.0, 1.0, M_Tex.r) * IrisSaturationVariation;
+ vec3 desat_col1 = Desaturation(lerp_3Color(col1_hue2, col1, col1_hue1, M_Tex.r), Fraction);
+ vec3 desat_col2 = Desaturation(lerp_3Color(col2_hue2, col2, col2_hue1, M_Tex.r), Fraction);
+ vec3 b = lerp(desat_col2, desat_col1, alphaRB.x);
+ vec3 a = lerp(desat_col2, desat_col1, alphaRB.y);
+ vec3 lerpedColor = lerp(a, b, RadialStructuralBlendSwitch) * M_Tex.a;
+ vec3 base = lerpedColor * lerp(1.0, M_Tex.g, AOinIris);
+
+ float radius = distance(irisUV - vec2(0.5), vec2(0.0));
+ float alpha = smoothstep(0.275, 0.5, radius);
+ return lerp(base, pow(base, vec3(LimbusDarkAmount + 1.0)), alpha);
+}
+
+vec3 GetBlendColorForIrisAndSclera(vec3 irisUVMask, vec3 irisGeneratedColor, sampler2D irisHeightMapAlpha, sampler2D scleraDiffuse, sampler2D T_Veins_D, vec3 scleraTintColor, float VeinsPower, float scleraBright)
+{
+ const float ScleraCornerDarkRadius = 0.6, ScleraCornerDarkHardness = 0.4, ScleraBrightness = 0.5, ScleraPower = 1.0, ScleraTintU = 0.2, ScleraTintV = 0.2, ScleraRotate = 0.0;
+ const float VeinsRotate = 0.0, IrisBrightness = 1.0, IrisSaturation = 0.5, CloudyIrisRadius = 0.13, CloudyIrisHardness = 0.0;
+ const vec4 ScleraCornerDarkColor = vec4(0.745,0.213,0.237,1), IrisBleedTint = vec4(1.0,1.0,1.0,1.0), CloudyIrisColor = vec4(0.009684,0.011247,0.015625,1.0);
+
+ float heightAlpha = texture(irisHeightMapAlpha, FSInput_texcoord).r;
+ vec2 scleraUV = Rotator(FSInput_texcoord, vec2(0.5,0.5), heightAlpha * ScleraRotate, 6.283);
+ vec2 veinsUV = Rotator(FSInput_texcoord, vec2(0.5,0.5), heightAlpha * VeinsRotate, 6.283);
+ vec3 scleraTexColor = SRGBToLinear(texture(/*T_Sclera_D*/scleraDiffuse, scleraUV).rgb) * scleraBright;
+ vec3 veinsTexColor = SRGBToLinear(texture(T_Veins_D, veinsUV).rgb) * scleraBright;
+ // use fixed color for optimizing, scleraTintColor = texture(T_sclera_tint_picker, vec2(ScleraTintU,ScleraTintV)).rgb;
+ vec3 scleraColor = pow(scleraTexColor, vec3(ScleraPower))*ScleraBrightness*1.1 + vec3(0.8);
+ scleraColor *= scleraTintColor;
+ vec3 bleededScleraColor = lerp(scleraColor, IrisBleedTint.rgb * scleraColor, irisUVMask.g);
+ vec3 veinsColor = pow(veinsTexColor, vec3(VeinsPower));
+ vec3 ScleraColor = bleededScleraColor * veinsColor;
+
+ vec3 irisColor = Desaturation(irisGeneratedColor * IrisBrightness, (IrisSaturation - 0.5) * -2.0);
+ vec3 lerpedScleraAndIris = lerp(ScleraColor, irisColor, irisUVMask.r);
+ vec3 cloudyPupilAddColor = SphereMask(FSInput_texcoord, vec2(0.5), CloudyIrisRadius, CloudyIrisHardness) * CloudyIrisColor.rgb;
+
+ float scleraCornerDarkMask = SphereMask(FSInput_texcoord, vec2(0.5), ScleraCornerDarkRadius, ScleraCornerDarkHardness);
+ vec3 ScleraCorner = lerp(ScleraCornerDarkColor.rgb, vec3(1.0), scleraCornerDarkMask);
+ vec3 BaseColor = ScleraCorner * (cloudyPupilAddColor + lerpedScleraAndIris);
+ return BaseColor;
+}
+
+
+
+// unused
+// out_RefractedUV = GetRefractedUV(out_IrisUVMask, irisHeightMap, irisNormalMap, viewDir, IrisUVRadius, CONREAL_IOR);
+vec2 GetRefractedUV(vec3 irisUVMask, sampler2D irisHeightMap, sampler2D T_Eye_N, vec3 viewDir, float IrisUVRadius, float internalIoR)
+{
+ const float RefractionDepthScale = 1.2;
+ vec3 normalW = normalize(FSInput_worldNormal), cameraW = viewDir;
+ vec3 RefractionDirection;
+ // RefractionDirection = custom2(internalloR,normalW,cameraW)
+ {
+ float n = internalIoR;
+ float facing = dot(normalW, cameraW);
+ float w = n * facing;
+ float k = sqrt(1.0+(w-n)*(w+n));
+ vec3 t;
+ t = (w - k)*normalW - n*cameraW;
+ t = normalize(t);
+ RefractionDirection = -t;
+ }
+ float arg8_IrisUVRadius = IrisUVRadius * 0.03 + 0.15;
+ vec2 arg2_UV = FSInput_texcoord;
+ float arg4_DepthScale = RefractionDepthScale;
+ float arg5_DepthPlaneOffset = SampleTextureExr(irisHeightMap, vec2(arg8_IrisUVRadius + 0.5, 0.5)).r;
+ vec3 arg6_MidPlaneDisplacement = SampleTextureExr(irisHeightMap, FSInput_texcoord).rgb;
+ vec3 arg7_EyeDirectionWorld = TransformNormalMap(texture(T_Eye_N, FSInput_texcoord).rgb);
+ vec3 a5 = max(arg6_MidPlaneDisplacement - arg5_DepthPlaneOffset, vec3(0.0)) * arg4_DepthScale;
+ float b5 = lerp(0.325, 1.0, dot(cameraW,arg7_EyeDirectionWorld) * dot(cameraW,arg7_EyeDirectionWorld));
+ vec3 heightW = a5 / b5;
+ vec3 b3 = RefractionDirection*heightW;
+ vec3 tangent = normalize(FSInput_worldTangent);
+ vec3 a3 = normalize(tangent - dot(tangent, arg7_EyeDirectionWorld) * arg7_EyeDirectionWorld);
+ vec3 a4 = cross(a3,arg7_EyeDirectionWorld);
+ vec3 b4 = b3;
+ vec2 b2 = vec2(dot(a3,b3),dot(a4,b4));
+ // float VectorLength = distance(vec2(0.0), vec2(arg8_IrisUVRadius*vec2(-1.0,1.0)*b2));
+ // float out_Transparency = VectorLength - arg8_IrisUVRadius;
+ vec2 a1 = arg2_UV;
+ vec2 b1 = vec2(arg8_IrisUVRadius) * vec2(-1.0,1.0)*b2 + arg2_UV;
+ float alpha1 = irisUVMask.r;
+ return lerp(a1,b1,alpha1);
+}
\ No newline at end of file
diff --git a/editor/assets/effects/advanced/eye.chunk.meta b/editor/assets/effects/advanced/eye.chunk.meta
new file mode 100644
index 0000000000..12b37e4dce
--- /dev/null
+++ b/editor/assets/effects/advanced/eye.chunk.meta
@@ -0,0 +1,9 @@
+{
+ "ver": "1.0.7",
+ "importer": "effect-header",
+ "imported": true,
+ "uuid": "bce797be-05d4-400e-8eb8-f2816147b869",
+ "files": [],
+ "subMetas": {},
+ "userData": {}
+}
diff --git a/editor/assets/effects/advanced/eye.effect b/editor/assets/effects/advanced/eye.effect
new file mode 100644
index 0000000000..b8a11ee4e2
--- /dev/null
+++ b/editor/assets/effects/advanced/eye.effect
@@ -0,0 +1,408 @@
+// Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd.
+
+CCEffect %{
+ techniques:
+ - name: opaque
+ passes:
+ - vert: standard-vs
+ frag: standard-fs
+ properties: &props
+ occlusion: { value: 1.0, target: pbrParams.x, editor: { slide: true, range: [0, 1.0], step: 0.001 } }
+ roughness: { value: 0.07, target: pbrParams.y, editor: { slide: true, range: [0, 1.0], step: 0.001 } }
+ metallic: { value: 0.0, target: pbrParams.z, editor: { slide: true, range: [0, 1.0], step: 0.001 } }
+ specularIntensity: { value: 1.0, target: pbrParams.w, editor: { slide: true, range: [0.0, 1.0], step: 0.001 } }
+ normalStrength: { value: 1.0, target: emissiveScaleParam.w, editor: { parent: USE_NORMAL_MAP, slide: true, range: [0, 5.0], step: 0.001 } }
+ mainTexture: { value: grey, target: albedoMap, editor: { displayName: ScleraColorMap, tooltip: 'T_Sclera_D' } }
+ normalMap: { value: normal, editor: { displayName: ScleraNormalMap, tooltip: 'T_Sclera_N' } }
+ occlusionMap: { value: white }
+ irisGradientMap: { value: white, editor: { tooltip: 'T_Eye_Gradient' } }
+ irisColorMaskMap: { value: black, editor: { tooltip: 'T_Iris_A_M' } }
+ veinsColorMap: { value: black, editor: { tooltip: 'T_Veins_D' } }
+ irisNormalMap: { value: normal, editor: { parent: USE_IRIS_REFRACTION, tooltip: 'normalMap with conreal shape like T_Eye_N' } }
+ irisHeightMap: { value: black, editor: { tooltip: 'T_EyeMidPlaneDisplacement' } }
+ irisHeightMapAlpha: { value: black, editor: { tooltip: 'T_EyeMidPlaneDisplacement Alpha Channel' } }
+ irisHeightScale: { value: 1.0, target: irisParams.x, editor: { parent: USE_IRIS_REFRACTION, slide: true, range: [0, 5.0], step: 0.001 } }
+ irisScale: { value: 0.5, target: irisParams.z, editor: { slide: true, range: [0, 1.0], step: 0.001 } }
+ pupilScale: { value: 1.0, target: irisParams.w, editor: { slide: true, range: [1.0, 3.0], step: 0.001 } }
+ veinsBleeding: { value: 1.5, target: irisParams.y, editor: { slide: true, range: [0.0, 3.0], step: 0.001 } }
+ irisMainColor: { value: 0.8, target: irisColorParams.x, editor: { slide: true, range: [0.0, 1.0], step: 0.001 } }
+ irisMainBright: { value: 1.0, target: irisColorParams.y, editor: { slide: true, range: [0.0, 5.0], step: 0.001 } }
+ irisEdgeColor: { value: 0.5, target: irisColorParams.z, editor: { slide: true, range: [0.0, 1.0], step: 0.001 } }
+ irisEdgeBright: { value: 1.0, target: irisColorParams.w, editor: { slide: true, range: [0.0, 5.0], step: 0.001 } }
+ reflectionEnhancement: { value: 1.5, target: emissiveScaleParam.x, editor: { slide: true, range: [1.0, 3.0], step: 0.001 } }
+ scleraBright: { value: 1.0, target: emissiveScaleParam.y, editor: { slide: true, range: [0.0, 1.0], step: 0.001 } }
+ causticsPosition: { value: 0.3, target: causticsParams.x, editor: { parent: USE_IRIS_CAUSTICS, slide: true, range: [0.0, 1.0], step: 0.001 } }
+ causticsWidth: { value: 0.3, target: causticsParams.y, editor: { parent: USE_IRIS_CAUSTICS, slide: true, range: [0.0, 1.0], step: 0.001 } }
+ causticsIntensity: { value: 1.0, target: causticsParams.w, editor: { parent: USE_IRIS_CAUSTICS, slide: true, range: [0.0, 3.0], step: 0.001 } }
+ - &forward-add
+ vert: standard-vs
+ frag: standard-fs
+ phase: forward-add
+ propertyIndex: 0
+ embeddedMacros: { CC_FORWARD_ADD: true }
+ depthStencilState:
+ depthFunc: equal
+ depthTest: true
+ depthWrite: false
+ blendState:
+ targets:
+ - blend: true
+ blendSrc: one
+ blendDst: one
+ blendSrcAlpha: zero
+ blendDstAlpha: one
+ - &shadow-caster
+ vert: shadow-caster-vs
+ frag: shadow-caster-fs
+ phase: shadow-caster
+ propertyIndex: 0
+ rasterizerState:
+ cullMode: front
+ properties:
+ mainTexture: { value: grey, target: albedoMap, editor: { displayName: AlbedoMap } }
+ - &reflect-map
+ vert: standard-vs
+ frag: reflect-map-fs
+ phase: reflect-map
+ propertyIndex: 0
+ - name: transparent
+ passes:
+ - vert: standard-vs
+ frag: standard-fs
+ embeddedMacros: { CC_FORCE_FORWARD_SHADING: true }
+ depthStencilState:
+ depthTest: true
+ depthWrite: false
+ blendState:
+ targets:
+ - blend: true
+ blendSrc: src_alpha
+ blendDst: one_minus_src_alpha
+ blendDstAlpha: one_minus_src_alpha
+ properties: *props
+ - *forward-add
+ - *shadow-caster
+}%
+
+CCProgram shared-ubos %{
+ uniform Constants {
+ vec4 pbrParams;
+ vec4 emissiveScaleParam;
+ vec4 irisParams;
+ vec4 irisColorParams;
+ vec4 causticsParams;
+ };
+}%
+
+CCProgram macro-remapping %{
+ // depend on UI macros
+#if USE_NORMAL_MAP
+ #define CC_SURFACES_USE_TANGENT_SPACE 1
+#endif
+}%
+
+CCProgram surface-vertex %{
+ out vec4 v_planeN;
+ out vec4 v_planeT;
+
+ #define CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA
+ void SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)
+ {
+ mat4 matWorld, matWorldIT;
+ CCGetWorldMatrixFull(matWorld, matWorldIT);
+
+ v_planeN.xyz = normalize((matWorldIT * vec4(0.0, 0.0, 1.0, 0.0)).xyz); // meta human exported mesh is facing to Z-Axis
+ v_planeT.xyz = normalize((matWorldIT * vec4(1.0, 0.0, 0.0, 0.0)).xyz);
+ v_planeN.w = v_planeT.w = 1.0;
+ }
+}%
+
+CCProgram surface-fragment %{
+ uniform sampler2D albedoMap;
+ #if USE_NORMAL_MAP
+ uniform sampler2D normalMap;
+ #endif
+ #if USE_OCCLUSION_MAP
+ uniform sampler2D occlusionMap;
+ #endif
+
+ ////////////////////////////////////////////////////////////////User Define
+ in vec4 v_planeN;
+ in vec4 v_planeT;
+ #if USE_IRIS_REFRACTION
+ uniform sampler2D irisNormalMap;
+ #endif
+ uniform sampler2D irisHeightMap;
+ uniform sampler2D irisHeightMapAlpha;
+ uniform sampler2D irisColorMaskMap;
+ uniform sampler2D irisGradientMap;
+ uniform sampler2D veinsColorMap;
+
+
+ #define CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL
+ vec3 SurfacesFragmentModifyWorldNormal()
+ {
+ vec3 normal = FSInput_worldNormal;
+ #if USE_NORMAL_MAP
+ vec3 nmmp = texture(normalMap, FSInput_texcoord).xyz - vec3(0.5);
+ normal = CalculateNormalFromTangentSpace(nmmp, emissiveScaleParam.w, normalize(normal.xyz), normalize(FSInput_worldTangent), FSInput_mirrorNormal);
+ #endif
+
+ return normalize(normal);
+ }
+
+ #define CC_SURFACES_FRAGMENT_MODIFY_PBRPARAMS
+ vec4 SurfacesFragmentModifyPBRParams()
+ {
+ vec4 pbr = pbrParams;
+ pbr.x = 1.0;
+ #if USE_OCCLUSION_MAP
+ pbr.x = mix(1.0, texture(occlusionMap, FSInput_texcoord).r, pbrParams.x);
+ #endif
+
+ return pbr;
+ }
+
+
+ #include
+ #include
+ #include
+
+ #define CONREAL_IOR 1.336
+ vec2 GetEllipseRefractionOffset(vec3 planeN, vec3 planeT, vec3 planeB, vec3 conrealNormal, vec3 refractDir, float height)
+ {
+ float NoR = dot(conrealNormal, -refractDir);
+ float lenR = height / max(NoR, EPSILON_LOWP);
+ vec3 refract = refractDir * lenR;
+ // project R onto plane UV space, -B for Y -> V dir correction
+ return vec2(dot(refract, planeT), dot(refract, -planeB));
+ }
+
+
+ // definition of SurfacesMaterialData structure with corresponding shading-model
+ #include
+
+ //see for more overrided functions, XXXX is shading-model name
+ #define CC_SURFACES_FRAGMENT_MODIFY_SHARED_DATA
+ void SurfacesFragmentModifySharedData(inout SurfacesMaterialData surfaceData)
+ {
+ vec3 worldPos;
+ HIGHP_VALUE_FROM_STRUCT_DEFINED(worldPos, surfaceData.worldPos);
+
+ float irisHeightScale = irisParams.x;
+ float IrisUVRadius = irisParams.z * 2.0; // default is 0.5
+ float PupilScale = irisParams.w;
+ float VeinsPower = irisParams.y;
+ float IrisColor1U = irisColorParams.x; // default is 0.8 for asian
+ float IrisColor2U = irisColorParams.z; // default is 0.5 for asian
+ float IrisColor1Bright = irisColorParams.y;
+ float IrisColor2Bright = irisColorParams.w;
+ float scleraBright = emissiveScaleParam.y;
+ vec3 scleraTintColor = vec3(1.0);
+
+ vec3 viewDir = normalize(cc_cameraPos.xyz - worldPos);
+
+ // vec2 irisUV = (FSInput_texcoord - vec2(0.5)) / IrisScale + vec2(0.5);
+ // if (irisUV.x > 0.0 && irisUV.y > 0.0 && irisUV.x < 1.0 && irisUV.y < 1.0)
+
+ // Iris Mask with Limbus Ring falloff
+ vec3 out_IrisUVMask = GetIrisUVMask(IrisUVRadius);
+
+ // Refraction
+ vec2 out_RefractedUV = FSInput_texcoord;
+ #if USE_IRIS_REFRACTION
+ float texHeight = SampleTextureExr(irisHeightMap, FSInput_texcoord).x;
+ float height = texHeight * irisHeightScale;
+
+ vec3 irisN = normalize(FSInput_worldNormal);
+ vec3 R = CalculateRefractDirection(irisN, viewDir, dot(irisN, viewDir), CONREAL_IOR);
+
+ vec3 receivePlaneN = v_planeN.xyz;
+ vec3 receivePlaneT = v_planeT.xyz;
+ vec3 receivePlaneB = CalculateBinormal(receivePlaneN, receivePlaneT, 1.0);
+
+ vec2 uv_offset = GetEllipseRefractionOffset(receivePlaneN, receivePlaneT, receivePlaneB, irisN, normalize(R), height);
+ out_RefractedUV = saturate(FSInput_texcoord + uv_offset /** texHeight*/ * 0.1); //需要边缘位移稍微小一点的话就加texHeight
+ #endif
+
+ // scaling pupil
+ vec2 out_IrisUV = GetIrisUV(out_RefractedUV, IrisUVRadius, PupilScale);
+
+ // generating iris color
+ vec3 out_IrisGeneratedColor = GetGeneratedColorForIris(out_IrisUV, irisColorMaskMap, IrisColor1U, IrisColor2U, IrisColor1Bright, IrisColor2Bright);
+
+ // blend iris and sclera use IrisMask
+ surfaceData.baseColor.rgb = GetBlendColorForIrisAndSclera(out_IrisUVMask, out_IrisGeneratedColor, irisHeightMapAlpha, albedoMap, veinsColorMap, scleraTintColor, VeinsPower, scleraBright);
+
+ // flatterned normal for iris area
+ surfaceData.worldNormal = normalize(lerp(surfaceData.worldNormal, FSInput_worldNormal, out_IrisUVMask.r));
+
+ // iris area flag (UVMask) and attenuation for caustics
+ // irisUVMask area is a little bit larger than irisGeneratedColor
+ float irisAttenuation = saturate(out_IrisUVMask.r * length(out_IrisGeneratedColor) * 10.0);
+ surfaceData.ior = irisAttenuation;
+ surfaceData.emissive = out_IrisUVMask;
+ }
+
+ // see for more overrided functions, XXXX is lighting-model name
+ #include
+ #define CC_SURFACES_LIGHTING_MODIFY_FINAL_RESULT
+ void SurfacesLightingModifyFinalResult(inout LightingResult result, in LightingIntermediateData lightingData, in SurfacesMaterialData surfaceData, in LightingMiscData miscData)
+ {
+ #if USE_IRIS_REFRACTION
+ vec3 worldPos;
+ HIGHP_VALUE_FROM_STRUCT_DEFINED(worldPos, surfaceData.worldPos);
+
+ vec3 L = lightingData.L;
+ vec3 viewDir = normalize(cc_cameraPos.xyz - worldPos);
+
+ LightingIntermediateData lightingDataRefract = lightingData;
+ vec3 newL = -CalculateRefractDirection(surfaceData.worldNormal, L, dot(surfaceData.worldNormal, L), CONREAL_IOR);
+ CCSurfacesLightingGetIntermediateData_PerLight(lightingDataRefract, newL);
+ if (surfaceData.emissive.x > 0.0) {
+ result.directSpecular = CalculateDirectSpecular(lightingDataRefract, miscData.lightColorAndIntensity);
+
+ #if !CC_FORWARD_ADD
+ lightingDataRefract.V = -CalculateRefractDirection(surfaceData.worldNormal, viewDir, dot(surfaceData.worldNormal, viewDir), CONREAL_IOR);
+ result.environmentSpecular = CalculateEnvironmentSpecular(lightingDataRefract, cc_ambientSky.w);
+ #endif
+ }
+ #endif
+
+ // enhanced more contrast for brighter part
+ result.environmentSpecular = pow(result.environmentSpecular, vec3(emissiveScaleParam.x));
+
+
+ #if USE_SCLERA_SSS
+ LightingIntermediateData lightingData3S = lightingData;
+ lightingData3S.N = normalize(FSInput_worldNormal);
+ CCSurfacesLightingGetIntermediateData_PerLight(lightingData3S, lightingData.L);
+ result.directDiffuse = CalculateDirectDiffuse(lightingData3S, miscData.lightColorAndIntensity);
+ #endif
+
+
+ #if USE_IRIS_CAUSTICS
+ vec3 receivePlaneN = v_planeN.xyz;
+ vec3 receivePlaneT = v_planeT.xyz;
+ vec3 receivePlaneB = CalculateBinormal(receivePlaneN, receivePlaneT, 1.0);
+
+ // conreal back face normal has inverse projector dir with plane T B
+ float projectorN = dot(surfaceData.worldNormal, receivePlaneN);
+ float projectorT = dot(surfaceData.worldNormal, receivePlaneT);
+ float projectorB = dot(surfaceData.worldNormal, receivePlaneB);
+ vec3 backN = normalize(projectorN * receivePlaneN - projectorT * receivePlaneT - projectorB * receivePlaneB);
+
+ LightingIntermediateData lightingDataCaustics = lightingData;
+ lightingDataCaustics.N = backN;
+ CCSurfacesLightingGetIntermediateData_PerLight(lightingDataCaustics, lightingData.L);
+
+ float causticsIntensity = causticsParams.w;
+
+ float irisMaskAttenuation = surfaceData.ior;
+ #if USE_IRIS_CAUSTICS_RANGE
+ // rangeFilter results according to UV distribution, 5.0 can be modified to match different UVs
+ float uvLength = saturate(length(FSInput_texcoord - vec2(0.5)) * 5.0);
+ float start = causticsParams.x, end = saturate(start + causticsParams.y), widthAtten = 0.2;
+ float rangeFilter = saturate(smoothstep(start, end, uvLength)) * (1.0 - saturate(smoothstep(end, saturate(end + widthAtten), uvLength)));
+ // rangeFilter can be ignored
+ irisMaskAttenuation *= rangeFilter;
+ #endif
+
+ vec3 directCaustics = vec3(pow(lightingDataCaustics.NoLSat, 10.0)) * 2.0;
+ result.directDiffuse += directCaustics * causticsIntensity * irisMaskAttenuation * miscData.lightColorAndIntensity.rgb * miscData.lightColorAndIntensity.w;
+ #if !CC_FORWARD_ADD
+ vec3 envCaustics = CalculateEnvironmentDiffuse(lightingDataCaustics, 1.0);
+ envCaustics = pow(envCaustics, vec3(4.0)) * 0.5;
+ result.environmentDiffuse += envCaustics * causticsIntensity * irisMaskAttenuation * cc_ambientSky.w;
+ #endif
+ #endif
+
+ // restore emissive
+ result.emissive = vec3(0.0);
+ }
+}%
+
+CCProgram standard-vs %{
+ precision highp float;
+
+ // 1. surface internal macros, for technique usage or remapping some user (material) macros to surface internal macros
+ #include
+ #include
+
+ // 2. common include with corresponding shader stage, include before surface functions
+ #include
+
+ // 3. user surface functions that can use user (effect) parameters (ubo Constants)
+ // see surfaces/default-functions/xxx.chunk
+ #include
+ #include
+
+ // 4. surface include with corresponding shader stage and shading-model (optional)
+ #include
+
+ // 5. shader entry with corresponding shader stage and technique usage/type
+ #include
+}%
+
+
+CCProgram shadow-caster-vs %{
+ precision highp float;
+ #include
+ #include
+ #include
+ #include
+ #include
+}%
+
+
+
+CCProgram standard-fs %{
+ // shading-model : standard
+ // lighting-model : standard (isotropy / anisotropy pbr)
+ // shader stage : fs
+ // technique usage/type : render-to-scene
+
+ precision highp float;
+ // 1. surface internal macros, for technique usage or remapping some user (material) macros to surface internal macros
+ #include
+ #include
+
+ // 2. common include with corresponding shader stage, include before surface functions
+ #include
+
+ // 3. user surface functions that can use user (effect) parameters (ubo Constants)
+ // see surfaces/default-functions/xxx.chunk
+ #include
+ #include
+
+ // 4. lighting-model (optional)
+ #include
+
+ // 5. surface include with corresponding shader stage and shading-model (optional)
+ #include
+
+ // 6. shader entry with corresponding shader stage and technique usage/type
+ #include
+}%
+
+CCProgram shadow-caster-fs %{
+ precision highp float;
+ #include
+ #include
+ #include
+ #include
+ #include
+}%
+
+
+CCProgram reflect-map-fs %{
+ precision highp float;
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+}%
diff --git a/editor/assets/effects/advanced/eye.effect.meta b/editor/assets/effects/advanced/eye.effect.meta
new file mode 100644
index 0000000000..0cd76ea35f
--- /dev/null
+++ b/editor/assets/effects/advanced/eye.effect.meta
@@ -0,0 +1,11 @@
+{
+ "ver": "1.7.0",
+ "importer": "effect",
+ "imported": true,
+ "uuid": "f0475923-826e-45dc-85cc-b5d9c2b220e9",
+ "files": [
+ ".json"
+ ],
+ "subMetas": {},
+ "userData": {}
+}
diff --git a/editor/assets/effects/advanced/hair.effect b/editor/assets/effects/advanced/hair.effect
index 93fb51c238..da6686afb3 100644
--- a/editor/assets/effects/advanced/hair.effect
+++ b/editor/assets/effects/advanced/hair.effect
@@ -21,7 +21,7 @@ CCEffect %{
anisotropyIntensity: { value: 1.0, target: anisotropyParam.x, editor: { slide : true, range : [0.0, 1.0] , step : 0.0001 } }
anisotropyRotation: { value: 0.0, target: anisotropyParam.y, editor: { slide : true, range : [0, 1.0] , step : 0.0001 } }
mainTexture: { value: grey, target: albedoMap, editor: { displayName: AlbedoMap } }
- transparencyMap: { value: white, editor: { parent: USE_TRANSPRENCY_MAP, displayName: AlbedoMap } }
+ transparencyMap: { value: white, editor: { parent: USE_TRANSPRENCY_MAP, displayName: TransparencyMap } }
normalMap: { value: normal }
pbrMap: { value: grey }
occlusionMap: { value: white }
@@ -34,9 +34,10 @@ CCEffect %{
ScatterCoefTT: { value: 0.0, target: ttParams.x, editor: { displayName: TT Scatter Coef, slide: true, range: [0, 1.0], step: 0.01, tooltip: 'The saturation of internal transmit lighting color' } }
IntensityTT: { value: 1.0, target: ttParams.w, editor: { displayName: TT Intensity, slide: true, range: [0, 1.0], step: 0.01 } }
baseColorTT: { value: [0.5, 0.33, 0.18, 1.0], target: ttColor, linear: true, editor: { displayName: TT Albedo, type: color, tooltip: 'The color of internal transmit lighting, allow the light color to vary between backlit and light-facing areas' } }
- thickness: { value: 1.0, target: ttParams.y, editor: { displayName: Scatter Thickness, slide: true, range: [0, 1.0], step: 0.001, tooltip: 'The extend range of internal reflection lighting around the direct specular' } }
- extinction: { value: 0.0, target: ttParams.z, editor: { displayName: Scatter Extinction, slide: true, range: [0, 10.0], step: 0.001, tooltip: 'The position offset of internal reflection lighting compared to direct specular' } }
- depthMap: { value: white }
+ thickness: { value: 1.0, target: ttParams.y, editor: { parent: USE_BACK_LIT, displayName: Scatter Thickness, slide: true, range: [0, 1.0], step: 0.001, tooltip: 'The extend range of internal reflection lighting around the direct specular' } }
+ extinction: { value: 0.0, target: ttParams.z, editor: { parent: USE_BACK_LIT, displayName: Scatter Extinction, slide: true, range: [0, 10.0], step: 0.001, tooltip: 'The position offset of internal reflection lighting compared to direct specular' } }
+ transmitColor: { value: [0.7, 0.5, 0.3, 1.0], linear: true, editor: { parent: USE_BACK_LIT, displayName: Transmit Scatter Color, type: color, tooltip: 'The color of scattered lighting' } }
+ thicknessMap: { value: white, editor: { parent: USE_BACK_LIT } }
selfShadowMap: { value: white, editor: { parent: USE_SELF_SHADOW_MAP } }
rasterizerState:
cullMode: None
@@ -149,7 +150,7 @@ CCEffect %{
albedoScale: { value: [1.0, 1.0, 1.0], target: albedoScaleAndCutoff.xyz }
alphaThreshold: { value: 0.5, target: albedoScaleAndCutoff.w, editor: { parent: USE_ALPHA_TEST } }
mainTexture: { value: grey, target: albedoMap, editor: { displayName: AlbedoMap } }
- transparencyMap: { value: white, editor: { parent: USE_TRANSPRENCY_MAP, displayName: AlbedoMap } }
+ transparencyMap: { value: white, editor: { parent: USE_TRANSPRENCY_MAP, displayName: TransparencyMap } }
- &reflect-map
vert: standard-vs
frag: reflect-map-fs
@@ -187,6 +188,7 @@ CCProgram shared-ubos %{
vec4 trtParams;
vec4 ttColor;
vec4 ttParams;
+ vec4 transmitColor;
};
}%
@@ -197,15 +199,17 @@ CCProgram macro-remapping %{
#pragma define IS_ANISOTROPY 1
#pragma define-meta USE_VERTEX_COLOR
#pragma define-meta USE_DITHERED_ALPHA_TEST
+ #pragma define-meta USE_BACK_LIT
+ #pragma define-meta USE_HIGH_QUALITY_REFLECTION
#define CC_SURFACES_USE_SECOND_UV HAS_SECOND_UV
#define CC_SURFACES_USE_TWO_SIDED USE_TWOSIDE
#define CC_SURFACES_LIGHTING_ANISOTROPIC IS_ANISOTROPY
#define CC_SURFACES_USE_VERTEX_COLOR USE_VERTEX_COLOR
+ #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE USE_BACK_LIT
#define CC_SURFACES_LIGHTING_TRT 1
#define CC_SURFACES_LIGHTING_TT 1
- #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 1
#define CC_SURFACES_TRANSFER_CLIP_POS 1
// depend on UI macros
@@ -214,7 +218,9 @@ CCProgram macro-remapping %{
#endif
// functionality for each effect
- #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 31
+#if USE_HIGH_QUALITY_REFLECTION
+ #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 9
+#endif
}%
CCProgram surface-vertex %{
@@ -259,8 +265,8 @@ CCProgram surface-fragment %{
uniform sampler2D anisotropyMap;
#endif
- #if USE_DEPTH_MAP
- uniform sampler2D depthMap;
+ #if USE_BACK_LIT && USE_THICKNESS_MAP
+ uniform sampler2D thicknessMap;
#endif
#if USE_SELF_SHADOW_MAP
uniform sampler2D selfShadowMap;
@@ -284,7 +290,7 @@ CCProgram surface-fragment %{
return ttParams;
}
#define CC_SURFACES_FRAGMENT_MODIFY_TT_COLOR
- vec3 SurfacesFragmentModifyTTColor(in vec3 baseColor, in vec3 trtColor)
+ vec3 SurfacesFragmentModifyTTColor(in vec3 baseColor)
{
return mix(baseColor.rgb, ttColor.rgb, ttColor.a); //ttColor can be (0.992, 0.808, 0.516)
}
@@ -294,8 +300,8 @@ CCProgram surface-fragment %{
{
float depth = SURFACES_MAX_TRANSMIT_DEPTH_VALUE;
depth = ttParams.y;
- #if USE_DEPTH_MAP
- // depth = texture(depthMap, FSInput_texcoord).x;
+ #if USE_BACK_LIT && USE_THICKNESS_MAP
+ // depth = texture(thicknessMap, FSInput_texcoord).x;
// depth = pow(depth, 1.0);
// depth = 1.0 - depth;
// depth *= ttParams.y;
@@ -307,8 +313,8 @@ CCProgram surface-fragment %{
vec4 SurfacesFragmentModifyTransmitDiffuseParams()
{
float mask = 1.0;
- #if USE_DEPTH_MAP
- mask = texture(depthMap, FSInput_texcoord).x;
+ #if USE_BACK_LIT && USE_THICKNESS_MAP
+ mask = texture(thicknessMap, FSInput_texcoord).x;
mask = pow(mask, 1.0);
mask = 1.0 - mask;
mask *= 10.0;
@@ -326,7 +332,7 @@ CCProgram surface-fragment %{
#define CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_OUT_SCATTERING_COLOR
vec3 SurfacesFragmentModifyTransmitOutScatteringColor()
{
- return vec3(0.7, 0.5, 0.3);
+ return transmitColor.rgb;
}
#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY
diff --git a/editor/assets/effects/advanced/simple-skin.effect b/editor/assets/effects/advanced/simple-skin.effect
index 9802048d03..a14929a57e 100644
--- a/editor/assets/effects/advanced/simple-skin.effect
+++ b/editor/assets/effects/advanced/simple-skin.effect
@@ -20,19 +20,21 @@ CCEffect %{
normalStrength: { value: 1.0, target: emissiveScaleParam.w, editor: { parent: USE_NORMAL_MAP, slide: true, range: [0, 5.0], step: 0.001 } }
mainTexture: { value: grey, target: albedoMap, editor: { displayName: AlbedoMap } }
normalMap: { value: normal }
- pbrMap: { value: grey }
+ pbrMap: { value: grey, editor: { displayName: PbrOrRoughnessMap } }
occlusionMap: { value: white }
emissiveMap: { value: grey }
sssIntensity: { value: 1.0, target: scatterParams.z, editor: { parent: USE_NORMAL_MAP, slide: true, range: [0, 1.0], step: 0.001 } }
preIntegratedSkinMap: { value: grey, editor: { parent: USE_PREINTEGRATED_SKIN } }
sssCurvatureMap: { value: white, editor: { parent: USE_PREINTEGRATED_SKIN } }
sssCurvature: { value: 0.1, target: scatterParams.w, editor: { parent: USE_PREINTEGRATED_SKIN, slide: true, range: [0, 1.0], step: 0.001 } }
- sssColoration: { value: 1.0, target: scatterColor.w, editor: { parent: USE_PREINTEGRATED_SKIN, slide: true, range: [0, 10.0], step: 0.001 } }
- cavityMap: { value: white }
- maskMap: { value: white, editor: { parent: USE_BACK_LIT } }
+ sssColoration: { value: 1.0, target: dualLobeParams.z, editor: { parent: USE_PREINTEGRATED_SKIN, slide: true, range: [0, 10.0], step: 0.001 } }
+ cavityMap: { value: white, editor: { tooltip: 'cavity map or specular map' } }
+ maskMap: { value: black, editor: { parent: USE_BACK_LIT } }
thickness: { value: 0.0, target: scatterParams.x, editor: { parent: USE_BACK_LIT, displayName: Object Thickness, range: [0, 1000.0], tooltip: 'Object thickness (world space unit), setting a too small value will cause the scattered light to disappear' } }
extinction: { value: 0.0, target: scatterParams.y, editor: { parent: USE_BACK_LIT, displayName: Transmit Scatter Extinction, slide: true, range: [0, 10.0], step: 0.001 } }
- scatterColor: { value: [1.0, 0.2, 0.1, 1.0], linear: true, editor: { parent: USE_BACK_LIT, displayName: Transmit Scatter Color, type: color, tooltip: 'The color of scattered lighting' } }
+ transmitColor: { value: [1.0, 0.2, 0.1, 1.0], linear: true, editor: { parent: USE_BACK_LIT, displayName: Transmit Scatter Color, type: color, tooltip: 'The color of scattered lighting' } }
+ dualLobeRoughness: { value: 0.5, target: dualLobeParams.x, editor: { parent: USE_DUAL_LOBE_SPECULAR, range: [0, 1.0] } }
+ dualLobeIntensity: { value: 0.02, target: dualLobeParams.w, editor: { parent: USE_DUAL_LOBE_SPECULAR, slide: true, range: [0, 0.1], step: 0.001 } }
rasterizerState:
cullMode: None
depthStencilState:
@@ -98,8 +100,9 @@ CCProgram shared-ubos %{
vec4 pbrParams;
vec4 emissive;
vec4 emissiveScaleParam;
- vec4 scatterColor;
+ vec4 transmitColor;
vec4 scatterParams;
+ vec4 dualLobeParams;
};
}%
@@ -110,11 +113,13 @@ CCProgram macro-remapping %{
#pragma define-meta USE_VERTEX_COLOR
#pragma define-meta USE_BACK_LIT
#pragma define-meta USE_PREINTEGRATED_SKIN
+ #pragma define-meta USE_DUAL_LOBE_SPECULAR
#define CC_SURFACES_USE_SECOND_UV HAS_SECOND_UV
#define CC_SURFACES_USE_TWO_SIDED USE_TWOSIDE
#define CC_SURFACES_USE_VERTEX_COLOR USE_VERTEX_COLOR
+ #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR USE_DUAL_LOBE_SPECULAR
#define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE USE_BACK_LIT
#define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT USE_BACK_LIT
#define CC_SURFACES_LIGHTING_SSS 1
@@ -178,7 +183,7 @@ CCProgram surface-fragment %{
{
float mask = 1.0;
#if USE_BACK_LIT
- mask = texture(maskMap, FSInput_texcoord).x > 0.0 ? 1.0 : 0.0;
+ mask = texture(maskMap, FSInput_texcoord).x;
#endif
return vec4(scatterParams.x, mask, 1.0, 1.0);
}
@@ -192,21 +197,40 @@ CCProgram surface-fragment %{
#define CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_OUT_SCATTERING_COLOR
vec3 SurfacesFragmentModifyTransmitOutScatteringColor()
{
- return scatterColor.rgb;
+ return transmitColor.rgb;
}
-
+ #define CC_SURFACES_FRAGMENT_MODIFY_DUAL_LOBE_SPECULAR_PARAMS
+ vec4 SurfacesFragmentModifyDualLobeSpecularParams(float roughness)
+ {
+ return vec4(dualLobeParams.x * roughness, 0.0, 0.0, dualLobeParams.w);
+ }
+
#define CC_SURFACES_FRAGMENT_MODIFY_SSS_PARAMS
vec4 SurfacesFragmentModifySSSParams()
{
float sssCurvature = scatterParams.w;
- float cavity = texture(cavityMap, FSInput_texcoord).x;
#if USE_PREINTEGRATED_SKIN
sssCurvature *= texture(sssCurvatureMap, FSInput_texcoord).x;
#endif
- return vec4(scatterParams.z, sssCurvature, scatterColor.w, cavity);
+ return vec4(scatterParams.z, sssCurvature, dualLobeParams.z, 0.0);
}
#include
+
+ #include
+ #define CC_SURFACES_FRAGMENT_MODIFY_SHARED_DATA
+ void SurfacesFragmentModifySharedData(inout SurfacesMaterialData surfaceData)
+ {
+ float cavity = texture(cavityMap, FSInput_texcoord).x;
+ surfaceData.specularIntensity *= cavity;
+
+ // ao and metallic ignored from pbrMap
+ #if !USE_OCCLUSION_MAP
+ surfaceData.ao = 1.0;
+ #endif
+ surfaceData.metallic = 0.0;
+ }
+
#include
}%
diff --git a/editor/assets/effects/advanced/water.effect b/editor/assets/effects/advanced/water.effect
index 8cb60ae178..762fec71e6 100644
--- a/editor/assets/effects/advanced/water.effect
+++ b/editor/assets/effects/advanced/water.effect
@@ -141,7 +141,7 @@ CCProgram surface-fragment %{
{
}
-
+ #include
vec3 GetDetailedNormal(vec2 texCoord, float tiling, sampler2D normalMap, sampler2D normalMapDetailed, vec3 N, vec3 T)
{
float waterSpeed = waterParam.x;
@@ -155,7 +155,7 @@ CCProgram surface-fragment %{
vec2 uvDetailed = texCoord * detailedTiling + vec2(0.0, cc_time.w) * detailedSpeed;
vec3 nmmpDetailed = texture(normalMapDetailed, uvDetailed).xyz - vec3(0.5);
// normal blending
- nmmp = normalize(vec3(nmmp.xy + nmmpDetailed.xy * detailedIntensity, nmmp.z));
+ nmmp = BlendDetailedNormalMap(nmmp, nmmpDetailed, detailedIntensity);
return normalize(CalculateNormalFromTangentSpace(nmmp, normalIntensity, N, T, FSInput_mirrorNormal));
}
@@ -165,7 +165,7 @@ CCProgram surface-fragment %{
{
vec3 normal = FSInput_worldNormal;
#if USE_NORMAL_MAP
- normal = GetDetailedNormal(NORMAL_UV, pbrParams.x, normalMap, normalMapDetailed, normal, FSInput_worldTangent);
+ normal = GetDetailedNormal(NORMAL_UV, pbrParams.x, normalMap, normalMapDetailed, normalize(normal), normalize(FSInput_worldTangent));
#endif
return normalize(normal);
diff --git a/editor/assets/effects/builtin-standard.effect b/editor/assets/effects/builtin-standard.effect
index ec903c379a..2647767170 100644
--- a/editor/assets/effects/builtin-standard.effect
+++ b/editor/assets/effects/builtin-standard.effect
@@ -21,6 +21,7 @@ CCEffect %{
anisotropyIntensity: { value: 1.0, target: anisotropyParam.x, editor: { parent: IS_ANISOTROPY, slide : true, range : [0.0, 1.0] , step : 0.0001 } }
anisotropyRotation: { value: 0.0, target: anisotropyParam.y, editor: { parent: IS_ANISOTROPY, slide : true, range : [0, 1.0] , step : 0.0001 } }
anisotropyMapResolutionHeight: { value: 0.0, target: anisotropyParam.w, editor: { parent: FIX_ANISOTROPIC_ROTATION_MAP } }
+ addOnShadowBias: { value: 0.0, target: anisotropyParam.z }
mainTexture: { value: grey, target: albedoMap, editor: { displayName: AlbedoMap } }
normalMap: { value: normal }
pbrMap: { value: grey }
@@ -117,6 +118,12 @@ CCProgram macro-remapping %{
}%
CCProgram surface-vertex %{
+ #define CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS
+ vec2 SurfacesVertexModifyShadowBias(in SurfacesStandardVertexIntermediate In, vec2 originShadowBias)
+ {
+ return originShadowBias + vec2(anisotropyParam.z, 0.0);
+ }
+
/*#define CC_SURFACES_VERTEX_MODIFY_WORLD_POS
vec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)
{
@@ -236,7 +243,7 @@ CCProgram surface-fragment %{
vec3 normal = FSInput_worldNormal;
#if USE_NORMAL_MAP
vec3 nmmp = texture(normalMap, NORMAL_UV).xyz - vec3(0.5);
- normal = CalculateNormalFromTangentSpace(nmmp, emissiveScaleParam.w, normal.xyz, FSInput_worldTangent, FSInput_mirrorNormal);
+ normal = CalculateNormalFromTangentSpace(nmmp, emissiveScaleParam.w, normalize(normal.xyz), normalize(FSInput_worldTangent), FSInput_mirrorNormal);
#endif
return normalize(normal);
diff --git a/editor/assets/effects/builtin-terrain.effect b/editor/assets/effects/builtin-terrain.effect
index 7536128420..ac5d592ee6 100644
--- a/editor/assets/effects/builtin-terrain.effect
+++ b/editor/assets/effects/builtin-terrain.effect
@@ -133,8 +133,14 @@ CCProgram surface-fragment %{
#endif
surfaceData.baseColor = vec4(SRGBToLinear(baseColor.rgb), 1.0);
- vec4 baseNormal = vec4(0, 0, 0, 0);
+ vec3 normal = FSInput_worldNormal;
+ vec3 tangent = vec3(1.0, 0.0, 0.0);
+ vec3 binormal = vec3(0.0, 0.0, 1.0);
+ binormal = cross(tangent, normal);
+ tangent = cross(normal, binormal);
+
#if USE_NORMALMAP
+ vec4 baseNormal = vec4(0, 0, 0, 0);
#if LAYERS == 1
baseNormal = texture(normalMap0, uv0);
#elif LAYERS == 2
@@ -153,20 +159,12 @@ CCProgram surface-fragment %{
baseNormal = texture(normalMap0, uv0);
#endif
- vec3 tangent = vec3(1.0, 0.0, 0.0);
- vec3 binormal = vec3(0.0, 0.0, 1.0);
-
- binormal = cross(tangent, FSInput_worldNormal);
- tangent = cross(FSInput_worldNormal, binormal);
-
vec3 nmmp = baseNormal.xyz - vec3(0.5);
- surfaceData.worldNormal =
- nmmp.x * normalize(tangent) +
- nmmp.y * normalize(binormal) +
- nmmp.z * normalize(FSInput_worldNormal);
- #else
- surfaceData.worldNormal = FSInput_worldNormal;
+ normal = CalculateNormalFromTangentSpace(nmmp, 1.0, normalize(normal.xyz), normalize(tangent), 1.0);
#endif
+ surfaceData.worldNormal = normalize(normal);
+ surfaceData.worldTangent = normalize(tangent);
+ surfaceData.worldBinormal = normalize(binormal);
float roughnessValue = 1.0;
float metallicValue = 0.0;
diff --git a/editor/assets/effects/builtin-toon.effect b/editor/assets/effects/builtin-toon.effect
index d88e7e1c8e..c57cb4ba44 100644
--- a/editor/assets/effects/builtin-toon.effect
+++ b/editor/assets/effects/builtin-toon.effect
@@ -194,7 +194,7 @@ CCProgram surface-fragment %{
vec3 normal = FSInput_worldNormal;
#if USE_NORMAL_MAP
vec3 nmmp = texture(normalMap, FSInput_texcoord).xyz - vec3(0.5);
- normal = CalculateNormalFromTangentSpace(nmmp, emissiveScaleAndStrenth.w, normal.xyz, FSInput_worldTangent, FSInput_mirrorNormal);
+ normal = CalculateNormalFromTangentSpace(nmmp, emissiveScaleAndStrenth.w, normalize(normal.xyz), normalize(FSInput_worldTangent), FSInput_mirrorNormal);
#endif
return normalize(normal);
diff --git a/editor/assets/effects/builtin-unlit.effect b/editor/assets/effects/builtin-unlit.effect
index d291ad980f..89eff207d6 100644
--- a/editor/assets/effects/builtin-unlit.effect
+++ b/editor/assets/effects/builtin-unlit.effect
@@ -109,7 +109,6 @@ CCProgram unlit-vs %{
CCProgram unlit-fs %{
precision highp float;
#include
- #include
#include
#if USE_ALPHA_TEST
@@ -150,9 +149,6 @@ CCProgram unlit-fs %{
#endif
CC_APPLY_FOG(o);
- #if CC_USE_RGBE_OUTPUT
- o = packRGBE(o.rgb);
- #endif
return CCFragOutput(o);
}
}%
diff --git a/editor/assets/effects/pipeline/skybox.effect b/editor/assets/effects/pipeline/skybox.effect
index 8f6acbd3e6..f9513c2d99 100644
--- a/editor/assets/effects/pipeline/skybox.effect
+++ b/editor/assets/effects/pipeline/skybox.effect
@@ -69,9 +69,6 @@ CCProgram sky-fs %{
vec3 c = SRGBToLinear(fragTextureLod(environmentMap, rotationDir.xyz, 0.0).rgb);
#endif
vec4 color = CCFragOutput(vec4(c * cc_ambientSky.w, 1.0));
- #if CC_USE_RGBE_OUTPUT
- color = packRGBE(color.rgb);
- #endif
return color;
}
}%
diff --git a/editor/assets/effects/util/dcc/imported-metallic-roughness.effect b/editor/assets/effects/util/dcc/imported-metallic-roughness.effect
index 6e0018b9bd..ea78a95179 100644
--- a/editor/assets/effects/util/dcc/imported-metallic-roughness.effect
+++ b/editor/assets/effects/util/dcc/imported-metallic-roughness.effect
@@ -260,7 +260,7 @@ CCProgram surface-fragment %{
vec3 normal = FSInput_worldNormal;
#if USE_NORMAL_MAP
vec3 nmmp = texture(normalMap, NORMAL_UV).xyz - vec3(0.5);
- normal = CalculateNormalFromTangentSpace(nmmp, normalStrength, normal.xyz, FSInput_worldTangent, FSInput_mirrorNormal);
+ normal = CalculateNormalFromTangentSpace(nmmp, normalStrength, normalize(normal.xyz), normalize(FSInput_worldTangent), FSInput_mirrorNormal);
#endif
return normalize(normal);
diff --git a/editor/assets/effects/util/dcc/imported-specular-glossiness.effect b/editor/assets/effects/util/dcc/imported-specular-glossiness.effect
index 493b70f5ac..342817e02d 100644
--- a/editor/assets/effects/util/dcc/imported-specular-glossiness.effect
+++ b/editor/assets/effects/util/dcc/imported-specular-glossiness.effect
@@ -263,7 +263,7 @@ CCProgram surface-fragment %{
vec3 normal = FSInput_worldNormal;
#if USE_NORMAL_MAP
vec3 nmmp = texture(normalMap, NORMAL_UV).xyz - vec3(0.5);
- normal = CalculateNormalFromTangentSpace(nmmp, normalScale, normal.xyz, FSInput_worldTangent, FSInput_mirrorNormal);
+ normal = CalculateNormalFromTangentSpace(nmmp, normalScale, normalize(normal.xyz), normalize(FSInput_worldTangent), FSInput_mirrorNormal);
#endif
return normalize(normal);
diff --git a/editor/assets/tools/debug-view-runtime-control.ts b/editor/assets/tools/debug-view-runtime-control.ts
index 47a8cf2c65..5c255ac386 100644
--- a/editor/assets/tools/debug-view-runtime-control.ts
+++ b/editor/assets/tools/debug-view-runtime-control.ts
@@ -54,9 +54,9 @@ export class DebugViewRuntimeControl extends Component {
'Env Transmit Diffuse',
'Env Transmit Specular',
'Transmit All',
- 'Direct TRT',
- 'Env TRT',
- 'TRT All',
+ 'Direct Internal Specular',
+ 'Env Internal Specular',
+ 'Internal All',
'Fog',
];
@@ -79,7 +79,7 @@ export class DebugViewRuntimeControl extends Component {
'Fresnel',
'Transmit Diffuse',
'Transmit Specular',
- 'TRT',
+ 'Internal Specular',
'TT',
];
private strMisc: string[] = [
diff --git a/editor/assets/tools/parsed-effect-info.json b/editor/assets/tools/parsed-effect-info.json
index f3b49a1c80..044654bd27 100644
--- a/editor/assets/tools/parsed-effect-info.json
+++ b/editor/assets/tools/parsed-effect-info.json
@@ -1 +1 @@
-{"list":[{"args":["vec3 color"],"column":4,"file":"editor\\assets\\chunks\\common\\color\\aces.chunk","line":1,"name":"ACESToneMap","type":"vec3","usage":"function"},{"args":["vec4 shadowPos","vec3 worldNormal","float normalBias","vec3 matViewDir0","vec3 matViewDir1","vec3 matViewDir2","vec2 projScaleXY"],"column":6,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":51,"name":"ApplyShadowDepthBias_FaceNormal","type":"vec4","usage":"function"},{"args":["vec4 shadowPos","vec3 worldNormal","float normalBias","mat4 matLightView","vec2 projScaleXY"],"column":6,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":63,"name":"ApplyShadowDepthBias_FaceNormal","type":"vec4","usage":"function"},{"args":["vec4 shadowPos","float viewspaceDepthBias","float projScaleZ","float projBiasZ"],"column":6,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":109,"name":"ApplyShadowDepthBias_Orthographic","type":"vec4","usage":"function"},{"args":["vec4 shadowPos","float viewspaceDepthBias"],"column":6,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":84,"name":"ApplyShadowDepthBias_Perspective","type":"vec4","usage":"function"},{"args":["vec4 shadowPos","float viewspaceDepthBias","vec3 worldPos"],"column":6,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":126,"name":"ApplyShadowDepthBias_PerspectiveLinearDepth","type":"vec4","usage":"function"},{"args":["out vec4 csmPos","out vec4 csmNDCPosWithBias","vec3 worldPos","vec3 N","vec2 shadowBias"],"column":9,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":346,"name":"CCCSMFactorBase","type":"float","usage":"function"},{"args":["out vec4 csmPos","out vec4 csmNDCPosWithBias","vec3 worldPos","vec3 N","vec2 shadowBias"],"column":9,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":415,"name":"CCCSMFactorBase","type":"float","usage":"function"},{"args":["vec3 worldPos","vec3 N","vec2 shadowBias"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":427,"name":"CCCSMFactorBase","type":"float","usage":"function"},{"args":["out vec4 csmPos","out vec4 shadowProjDepthInfo","out vec4 shadowProjInfo","out vec3 shadowViewDir0","out vec3 shadowViewDir1","out vec3 shadowViewDir2","vec3 worldPos","int level"],"column":8,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":293,"name":"CCGetCSMLevel","type":"void","usage":"function"},{"args":["out bool isTransitionArea","out highp float transitionRatio","out vec4 csmPos","out vec4 shadowProjDepthInfo","out vec4 shadowProjInfo","out vec3 shadowViewDir0","out vec3 shadowViewDir1","out vec3 shadowViewDir2","vec3 worldPos"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":312,"name":"CCGetCSMLevel","type":"int","usage":"function"},{"args":["out vec4 csmPos","out vec4 shadowProjDepthInfo","out vec4 shadowProjInfo","out vec3 shadowViewDir0","out vec3 shadowViewDir1","out vec3 shadowViewDir2","vec3 worldPos"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":338,"name":"CCGetCSMLevel","type":"int","usage":"function"},{"args":["out vec4 csmPos","out vec4 shadowProjDepthInfo","out vec4 shadowProjInfo","out vec3 shadowViewDir0","out vec3 shadowViewDir1","out vec3 shadowViewDir2","vec3 worldPos"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":411,"name":"CCGetCSMLevel","type":"int","usage":"function"},{"args":["out highp float ratio","vec3 clipPos"],"column":8,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":252,"name":"CCGetCSMLevelWithTransition","type":"bool","usage":"function"},{"args":["vec4 shadowPosWithDepthBias"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":135,"name":"CCGetDirLightShadowFactorHard","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":143,"name":"CCGetDirLightShadowFactorSoft","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":151,"name":"CCGetDirLightShadowFactorSoft3X","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":159,"name":"CCGetDirLightShadowFactorSoft5X","type":"float","usage":"function"},{"args":["vec3 worldPos","float viewSpaceBias"],"column":5,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":20,"name":"CCGetLinearDepth","type":"float","usage":"function"},{"args":["vec3 worldPos"],"column":5,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":26,"name":"CCGetLinearDepth","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias","vec3 worldPos"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":169,"name":"CCGetSpotLightShadowFactorHard","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias","vec3 worldPos"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":177,"name":"CCGetSpotLightShadowFactorSoft","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias","vec3 worldPos"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":185,"name":"CCGetSpotLightShadowFactorSoft3X","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias","vec3 worldPos"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":193,"name":"CCGetSpotLightShadowFactorSoft5X","type":"float","usage":"function"},{"args":["out mat4 matWorld"],"column":4,"file":"editor\\assets\\chunks\\builtin\\functionalities\\world-transform.chunk","line":2,"name":"CCGetWorldMatrix","type":"void","usage":"function"},{"args":["out mat4 matWorld","out mat4 matWorldIT"],"column":4,"file":"editor\\assets\\chunks\\builtin\\functionalities\\world-transform.chunk","line":16,"name":"CCGetWorldMatrixFull","type":"void","usage":"function"},{"args":["int level","vec3 worldPos"],"column":8,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":276,"name":"CCHasCSMLevel","type":"bool","usage":"function"},{"args":["out vec4 shadowNDCPosWithBias","vec4 shadowPos","vec3 N","vec2 shadowBias"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":228,"name":"CCShadowFactorBase","type":"float","usage":"function"},{"args":["vec4 shadowPos","vec3 N","vec2 shadowBias"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":422,"name":"CCShadowFactorBase","type":"float","usage":"function"},{"args":["out vec4 shadowNDCPosWithBias","vec4 shadowPos","vec3 worldPos","vec2 shadowBias"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":203,"name":"CCSpotShadowFactorBase","type":"float","usage":"function"},{"args":["vec4 shadowPos","vec3 worldPos","vec2 shadowBias"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":432,"name":"CCSpotShadowFactorBase","type":"float","usage":"function"},{"args":["inout vec4 color","float factor"],"column":4,"file":"editor\\assets\\chunks\\builtin\\functionalities\\fog.chunk","line":28,"name":"CC_APPLY_FOG_BASE","type":"void","usage":"function"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":76,"name":"CC_SURFACES_ENABLE_DEBUG_VIEW","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":38,"name":"CC_SURFACES_FLIP_UV","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":47,"name":"CC_SURFACES_LIGHTING_ANISOTROPIC","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":50,"name":"CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":81,"name":"CC_SURFACES_LIGHTING_DISABLE_DIFFUSE","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":84,"name":"CC_SURFACES_LIGHTING_DISABLE_SPECULAR","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":62,"name":"CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":59,"name":"CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":68,"name":"CC_SURFACES_LIGHTING_TRT","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":71,"name":"CC_SURFACES_LIGHTING_TT","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":56,"name":"CC_SURFACES_LIGHTING_USE_FRESNEL","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":65,"name":"CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":24,"name":"CC_SURFACES_TRANSFER_CLIP_POS","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":21,"name":"CC_SURFACES_TRANSFER_LOCAL_POS","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":53,"name":"CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":30,"name":"CC_SURFACES_USE_LIGHT_MAP","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":44,"name":"CC_SURFACES_USE_REFLECTION_DENOISE","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":12,"name":"CC_SURFACES_USE_SECOND_UV","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":15,"name":"CC_SURFACES_USE_TANGENT_SPACE","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":41,"name":"CC_SURFACES_USE_TWO_SIDED","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":18,"name":"CC_SURFACES_USE_VERTEX_COLOR","type":"","usage":"macro"},{"args":["vec4 pos","out float factor"],"column":4,"file":"editor\\assets\\chunks\\builtin\\functionalities\\fog.chunk","line":13,"name":"CC_TRANSFER_FOG_BASE","type":"void","usage":"function"},{"args":["vec3 spotLightDir","vec3 L","float cosAngleOuter"],"column":5,"file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":41,"name":"CalculateAngleAttenuation","type":"float","usage":"function"},{"args":["vec3 normal","vec3 tangent","float mirrorNormal"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":58,"name":"CalculateBinormal","type":"vec3","usage":"function"},{"args":["vec3 R","vec3 worldPos","vec3 cubeCenterPos","vec3 cubeBoxHalfSize"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\functions.chunk","line":50,"name":"CalculateBoxProjectedDirection","type":"vec4","usage":"function"},{"args":["float distToLightSqr","float lightRadius","float lightRange"],"column":5,"file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":30,"name":"CalculateDistanceAttenuation","type":"float","usage":"function"},{"args":["float ior","float NoVSat"],"column":5,"file":"editor\\assets\\chunks\\common\\lighting\\bxdf.chunk","line":2,"name":"CalculateFresnelCoefficient","type":"float","usage":"function"},{"args":["vec3 normalFromTangentSpace","float normalStrength","vec3 normal","vec3 tangent","float mirrorNormal"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":66,"name":"CalculateNormalFromTangentSpace","type":"vec3","usage":"function"},{"args":["vec3 N","vec3 V","vec3 worldPos","vec4 plane","vec3 cameraPos","float probeReflectedDepth"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\functions.chunk","line":26,"name":"CalculatePlanarReflectPositionOnPlane","type":"vec3","usage":"function"},{"args":["vec3 N","vec3 V","float NoV"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\functions.chunk","line":17,"name":"CalculateReflectDirection","type":"vec3","usage":"function"},{"args":["vec3 N","vec3 V","float NoV","float ior"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\functions.chunk","line":4,"name":"CalculateRefractDirection","type":"vec3","usage":"function"},{"args":["vec3 unscatteredColor","float distance","float outScatterExtinctCoef","float inScatterExtinctCoef","float inScatterCoef","vec3 inScatterColor","vec3 outScatterColor"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\bxdf.chunk","line":15,"name":"CalculateScattering","type":"vec3","usage":"function"},{"args":["out vec2 deltaV","float frameCount","float animSpeed","float elapseTime"],"column":5,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":28,"name":"CalculateVATAnimationUV","type":"float","usage":"function"},{"args":["float A","float B"],"column":5,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":167,"name":"CalculateVATDecodeUV","type":"float","usage":"function"},{"args":["inout vec3 L[5]","out int n"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\rect-area-light.chunk","line":11,"name":"ClipQuadToHorizon","type":"void","usage":"function"},{"args":["float roughness","float NoH"],"column":5,"file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":2,"name":"D_GGX","type":"float","usage":"function"},{"args":["float RoughnessX","float RoughnessY","float NoH","vec3 H","vec3 X","vec3 Y"],"column":5,"file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":31,"name":"D_GGXAniso","type":"float","usage":"function"},{"args":["float roughness","float NoH"],"column":5,"file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":10,"name":"D_GGXMobile","type":"float","usage":"function"},{"args":["vec4 clipPos","vec2 screen_resolution","float transparency"],"column":4,"file":"editor\\assets\\chunks\\common\\effect\\special-effects.chunk","line":3,"name":"DitheredAlphaClip","type":"void","usage":"function"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":17,"name":"EPSILON","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":18,"name":"EPSILON_LOWP","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":20,"name":"EXP_VALUE","type":"","usage":"macro"},{"args":["samplerCube tex","vec3 R","float roughness","float mipCount"],"column":6,"file":"editor\\assets\\chunks\\common\\texture\\cubemap.chunk","line":32,"name":"EnvReflection","type":"vec3","usage":"function"},{"args":["vec3 R","float roughness","float mipCount","float denoiseIntensity"],"column":6,"file":"editor\\assets\\chunks\\common\\texture\\cubemap.chunk","line":2,"name":"EnvReflectionWithMipFiltering","type":"vec3","usage":"function"},{"args":["vec4 pos","vec3 cameraPos","float fogStart","float fogDensity","float fogAtten"],"column":5,"file":"editor\\assets\\chunks\\common\\effect\\fog.chunk","line":10,"name":"ExpFog","type":"float","usage":"function"},{"args":["vec4 pos","vec3 cameraPos","float fogStart","float fogDensity","float fogAtten"],"column":5,"file":"editor\\assets\\chunks\\common\\effect\\fog.chunk","line":17,"name":"ExpSquaredFog","type":"float","usage":"function"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":21,"name":"FP_MAX","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":22,"name":"FP_SCALE","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":23,"name":"FP_SCALE_INV","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":57,"name":"FSInput_clipPos","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":14,"name":"FSInput_faceSideSign","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":49,"name":"FSInput_fogFactor","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":38,"name":"FSInput_lightMapUV","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":53,"name":"FSInput_localPos","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":25,"name":"FSInput_mirrorNormal","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":45,"name":"FSInput_reflectionProbeId","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":42,"name":"FSInput_shadowBias","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":15,"name":"FSInput_texcoord","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":32,"name":"FSInput_texcoord1","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":18,"name":"FSInput_vertexColor","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":13,"name":"FSInput_worldNormal","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":12,"name":"FSInput_worldPos","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":24,"name":"FSInput_worldTangent","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":24,"name":"GRAY_VECTOR","type":"","usage":"macro"},{"args":["vec3 L","vec3 litDir","float litAngleScale","float litAngleOffset"],"column":5,"file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":21,"name":"GetAngleAtt","type":"float","usage":"function"},{"args":["float roughness","float anisotropyShape","vec3 V","vec3 N","vec3 X","vec3 Y"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":41,"name":"GetAnisotropicReflect","type":"vec3","usage":"function"},{"args":["float roughness","float anisotropyShape","out float roughnessX","out float roughnessY"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":18,"name":"GetAnisotropicRoughness","type":"void","usage":"function"},{"args":["float depthHS","mat4 matProj"],"column":5,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":30,"name":"GetCameraDepthRH","type":"float","usage":"function"},{"args":["float depthHS","float matProj32","float matProj22"],"column":5,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":34,"name":"GetCameraDepthRH","type":"float","usage":"function"},{"args":["out vec3 centerPos","out vec3 boxHalfSize","out float mipCount","float probeId"],"column":4,"file":"editor\\assets\\chunks\\builtin\\functionalities\\probe.chunk","line":28,"name":"GetCubeReflectionProbeData","type":"void","usage":"function"},{"args":["float distSqr","float invSqrAttRadius"],"column":5,"file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":15,"name":"GetDistAtt","type":"float","usage":"function"},{"args":["out vec3 lightmapColor","out float dirShadow","out float ao","sampler2D lightingMap","vec2 luv","float lum","vec3 worldNormal"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\light-map.chunk","line":22,"name":"GetLightMapColor","type":"void","usage":"function"},{"args":["vec3 viewPos","float near","float far"],"column":5,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":52,"name":"GetLinearDepthFromViewSpace","type":"float","usage":"function"},{"args":["out float metallic","out vec3 albedo","vec3 diffuse","vec3 specular","float channelFaultTolerant","float f0"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\material.chunk","line":0,"name":"GetMetallicAlbedoFromDiffuseSpecularMathematic","type":"bool","usage":"function"},{"args":["out float metallic","out vec3 albedo","vec3 diffuse","vec3 specular","float f0"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\material.chunk","line":28,"name":"GetMetallicAlbedoFromDiffuseSpecularWithoutColor","type":"bool","usage":"function"},{"args":["vec3 worldPos","mat4 matVirtualCameraViewProj","float flipNDCSign","vec3 viewDir","vec3 reflectDir"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":20,"name":"GetPlanarReflectScreenUV","type":"vec2","usage":"function"},{"args":["out vec4 plane","out float planarReflectionDepthScale","out float mipCount","float probeId"],"column":4,"file":"editor\\assets\\chunks\\builtin\\functionalities\\probe.chunk","line":10,"name":"GetPlanarReflectionProbeData","type":"void","usage":"function"},{"args":["vec4 clipPos","float flipNDCSign"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":6,"name":"GetScreenUV","type":"vec2","usage":"function"},{"args":["vec3 worldPos","mat4 matViewProj","float flipNDCSign"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":14,"name":"GetScreenUV","type":"vec2","usage":"function"},{"args":["out vec3 shadowNDCPos","vec4 shadowPosWithDepthBias"],"column":6,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":39,"name":"GetShadowNDCPos","type":"bool","usage":"function"},{"args":["sampler2D dataMap","float dataMapWidth","float x","float uv_y"],"column":4,"file":"editor\\assets\\chunks\\builtin\\functionalities\\probe.chunk","line":1,"name":"GetTexData","type":"vec4","usage":"function"},{"args":["vec3 posHS","mat4 matProj","mat4 matProjInv"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":40,"name":"GetViewPosFromNDCPosRH","type":"vec4","usage":"function"},{"args":["float NDCDepth","float projScaleZ","float projBiasZ"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":75,"name":"GetViewSpaceDepthFromNDCDepth_Orthgraphic","type":"float","usage":"function"},{"args":["float NDCDepth","float homogenousDividW","float invProjScaleZ","float invProjBiasZ"],"column":7,"file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":79,"name":"GetViewSpaceDepthFromNDCDepth_Perspective","type":"float","usage":"function"},{"args":["vec3 posHS","mat4 matProj","mat4 matViewProjInv"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":46,"name":"GetWorldPosFromNDCPosRH","type":"vec4","usage":"function"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":6,"name":"HALF_PI","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":12,"name":"INV_HALF_PI","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":13,"name":"INV_PI","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":14,"name":"INV_PI2","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":15,"name":"INV_PI4","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":11,"name":"INV_QUATER_PI","type":"","usage":"macro"},{"args":["light_type"],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":63,"name":"IS_DIRECTIONAL_LIGHT","type":"","usage":"macro"},{"args":["light_type"],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":66,"name":"IS_POINT_LIGHT","type":"","usage":"macro"},{"args":["light_type"],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":67,"name":"IS_RANGED_DIRECTIONAL_LIGHT","type":"","usage":"macro"},{"args":["light_type"],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":64,"name":"IS_SPHERE_LIGHT","type":"","usage":"macro"},{"args":["light_type"],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":65,"name":"IS_SPOT_LIGHT","type":"","usage":"macro"},{"args":["vec3 v1","vec3 v2"],"column":5,"file":"editor\\assets\\chunks\\common\\lighting\\rect-area-light.chunk","line":106,"name":"IntegrateEdge","type":"float","usage":"function"},{"args":["vec3 specular","float roughness","float NoV"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":59,"name":"IntegratedGFApprox","type":"vec3","usage":"function"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":49,"name":"LIGHT_MAP_TYPE_ALL_IN_ONE","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":48,"name":"LIGHT_MAP_TYPE_DISABLED","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":50,"name":"LIGHT_MAP_TYPE_INDIRECT_OCCLUSION","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":58,"name":"LIGHT_TYPE_DIRECTIONAL","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":59,"name":"LIGHT_TYPE_POINT","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":62,"name":"LIGHT_TYPE_RANGED_DIRECTIONAL","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":61,"name":"LIGHT_TYPE_SPHERE","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":60,"name":"LIGHT_TYPE_SPOT","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":19,"name":"LOG2","type":"","usage":"macro"},{"args":["vec3 N","vec3 V","vec3 P","mat3 Minv","vec3 points[4]"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\rect-area-light.chunk","line":113,"name":"LTC_Evaluate","type":"vec3","usage":"function"},{"args":["vec4 pos","vec3 cameraPos","float fogTop","float fogRange","float fogAtten"],"column":5,"file":"editor\\assets\\chunks\\common\\effect\\fog.chunk","line":25,"name":"LayeredFog","type":"float","usage":"function"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\lighting-models\\data-structures\\lighting-intermediate-data.chunk","line":2,"name":"LightingIntermediateData","type":"","usage":"varaible"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\lighting-models\\data-structures\\lighting-misc-data.chunk","line":2,"name":"LightingMiscData","type":"","usage":"varaible"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\lighting-models\\data-structures\\lighting-result.chunk","line":2,"name":"LightingResult","type":"","usage":"varaible"},{"args":["vec4 pos","vec3 cameraPos","float fogStart","float fogEnd"],"column":5,"file":"editor\\assets\\chunks\\common\\effect\\fog.chunk","line":3,"name":"LinearFog","type":"float","usage":"function"},{"args":["vec3 linear"],"column":4,"file":"editor\\assets\\chunks\\common\\color\\gamma.chunk","line":18,"name":"LinearToSRGB","type":"vec3","usage":"function"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":7,"name":"PI","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":8,"name":"PI2","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":9,"name":"PI4","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":5,"name":"QUATER_PI","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":54,"name":"REFLECTION_PROBE_TYPE_CUBE","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":53,"name":"REFLECTION_PROBE_TYPE_NONE","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\common\\common-define.chunk","line":55,"name":"REFLECTION_PROBE_TYPE_PLANAR","type":"","usage":"macro"},{"args":["inout vec3 tangent","inout vec3 binormal","vec3 normal","float rotationAngle"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":84,"name":"RotateTangentAndBinormal","type":"void","usage":"function"},{"args":["vec3 v","float cosTheta","float sinTheta"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":74,"name":"RotationVecFromAxisY","type":"vec3","usage":"function"},{"args":["vec3 normal"],"column":4,"file":"editor\\assets\\chunks\\builtin\\functionalities\\sh.chunk","line":3,"name":"SHEvaluate","type":"vec3","usage":"function"},{"args":["vec3 gamma"],"column":4,"file":"editor\\assets\\chunks\\common\\color\\gamma.chunk","line":5,"name":"SRGBToLinear","type":"vec3","usage":"function"},{"args":["out vec3 lightmapColor","out float dirShadow","out float ao","sampler2D lightingMap","vec2 luv","float lum","vec3 worldNormal"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\light-map.chunk","line":1,"name":"SampleAndDecodeLightMapColor","type":"void","usage":"function"},{"args":["sampler2D exrRGBE","vec2 uv"],"column":4,"file":"editor\\assets\\chunks\\common\\texture\\texture-misc.chunk","line":2,"name":"SampleTextureExr","type":"vec3","usage":"function"},{"args":["sampler2D exrRGBE","sampler2D exrSign","vec2 uv"],"column":4,"file":"editor\\assets\\chunks\\common\\texture\\texture-misc.chunk","line":8,"name":"SampleTextureExr","type":"vec3","usage":"function"},{"args":["sampler2D exrRGBE","sampler2D exrSign","sampler2D exrAlpha","vec2 uv"],"column":4,"file":"editor\\assets\\chunks\\common\\texture\\texture-misc.chunk","line":15,"name":"SampleTextureExrWithAlpha","type":"vec4","usage":"function"},{"args":["float distSqr","float invSqrAttRadius"],"column":5,"file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":9,"name":"SmoothDistAtt","type":"float","usage":"function"},{"args":["float distSqr","float invSqrAttRadius"],"column":5,"file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":1,"name":"SmoothDistAtt2","type":"float","usage":"function"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\legacy\\shading-standard-base.chunk","line":2,"name":"StandardSurface","type":"","usage":"varaible"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":9,"name":"SurfacesFragmentAlphaClipOnly","type":"void","usage":"function"},{"args":["out float isRotation"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":50,"name":"SurfacesFragmentModifyAnisotropyParams","type":"vec4","usage":"function"},{"args":["out vec4 baseColorAndTransparency","out vec3 shade1","out vec3 shade2","in vec3 baseColor"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\toon-fs.chunk","line":3,"name":"SurfacesFragmentModifyBaseColorAndToonShade","type":"void","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":1,"name":"SurfacesFragmentModifyBaseColorAndTransparency","type":"vec4","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":58,"name":"SurfacesFragmentModifyEmissive","type":"vec3","usage":"function"},{"args":[],"column":5,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":40,"name":"SurfacesFragmentModifyIOR","type":"float","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":65,"name":"SurfacesFragmentModifyPBRParams","type":"vec4","usage":"function"},{"args":["inout SurfacesMaterialData surfaceData"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":143,"name":"SurfacesFragmentModifySharedData","type":"void","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":117,"name":"SurfacesFragmentModifyTRTColor","type":"vec3","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":108,"name":"SurfacesFragmentModifyTRTParams","type":"vec4","usage":"function"},{"args":["in vec3 baseColor","in vec3 trtColor"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":132,"name":"SurfacesFragmentModifyTTColor","type":"vec3","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":124,"name":"SurfacesFragmentModifyTTParams","type":"vec4","usage":"function"},{"args":[],"column":5,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\toon-fs.chunk","line":18,"name":"SurfacesFragmentModifyToonShadowCover","type":"float","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\toon-fs.chunk","line":25,"name":"SurfacesFragmentModifyToonSpecular","type":"vec4","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\toon-fs.chunk","line":11,"name":"SurfacesFragmentModifyToonStepAndFeather","type":"vec4","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":98,"name":"SurfacesFragmentModifyTransmitDiffuseParams","type":"vec4","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":83,"name":"SurfacesFragmentModifyTransmitInScatteringColor","type":"vec3","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":90,"name":"SurfacesFragmentModifyTransmitOutScatteringColor","type":"vec3","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":73,"name":"SurfacesFragmentModifyTransmitScatteringParams","type":"vec4","usage":"function"},{"args":[],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":16,"name":"SurfacesFragmentModifyWorldNormal","type":"vec3","usage":"function"},{"args":["inout vec3 worldTangent","inout vec3 worldBinormal","vec3 worldNormal"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":23,"name":"SurfacesFragmentModifyWorldTangentAndBinormal","type":"void","usage":"function"},{"args":["in LightingIntermediateData lightingData","in float ssssCurvature"],"column":6,"file":"editor\\assets\\chunks\\lighting-models\\default-functions\\simple-skin.chunk","line":2,"name":"SurfacesLightingModifySkinDiffuseLighting","type":"vec3","usage":"function"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\surfaces\\data-structures\\standard.chunk","line":2,"name":"SurfacesMaterialData","type":"","usage":"varaible"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-intermediate.chunk","line":2,"name":"SurfacesStandardVertexIntermediate","type":"","usage":"varaible"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":40,"name":"SurfacesVertexModifyClipPos","type":"vec4","usage":"function"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":8,"name":"SurfacesVertexModifyLocalNormal","type":"vec3","usage":"function"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":1,"name":"SurfacesVertexModifyLocalPos","type":"vec3","usage":"function"},{"args":["inout SurfacesStandardVertexIntermediate In"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":26,"name":"SurfacesVertexModifyLocalSharedData","type":"void","usage":"function"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":6,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":16,"name":"SurfacesVertexModifyLocalTangent","type":"vec4","usage":"function"},{"args":["inout SurfacesStandardVertexIntermediate In"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":70,"name":"SurfacesVertexModifySharedData","type":"void","usage":"function"},{"args":["inout SurfacesStandardVertexIntermediate In"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":47,"name":"SurfacesVertexModifyUV","type":"void","usage":"function"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":57,"name":"SurfacesVertexModifyWorldNormal","type":"vec3","usage":"function"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":4,"file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":33,"name":"SurfacesVertexModifyWorldPos","type":"vec3","usage":"function"},{"args":["value","bit"],"column":0,"file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":14,"name":"UnpackBitFromFloat","type":"","usage":"macro"},{"args":["vec3 vatBoundingBoxMin","vec3 vatBoundingBoxMax","vec3 localPos"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":104,"name":"VATCalculateFluidVoxelUV","type":"vec3","usage":"function"},{"args":["vec2 lutTexResolution","float meshVertexCount"],"column":5,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":43,"name":"VATCalculateFrameCount","type":"float","usage":"function"},{"args":["out vec2 thisFrameUV","out vec2 nextFrameUV","vec2 meshUV","float frameCount","float animSpeed","float elapseTime"],"column":5,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":51,"name":"VATGetAnimUV","type":"float","usage":"function"},{"args":["out vec2 thisFrameUV","out vec2 nextFrameUV","vec2 meshUV","float frameCount","float animSpeed","float elapseTime","sampler2D lutTexture"],"column":5,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":60,"name":"VATGetAnimUV","type":"float","usage":"function"},{"args":["vec3 meshNormal","vec2 thisFrameUV","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":79,"name":"VATGetLocalNormal","type":"vec3","usage":"function"},{"args":["vec3 meshNormal","vec2 thisFrameUV","vec2 nextFrameUV","float frameLerp","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":93,"name":"VATGetLocalNormal","type":"vec3","usage":"function"},{"args":["vec2 thisFrameUV","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":73,"name":"VATGetLocalPosition","type":"vec3","usage":"function"},{"args":["vec2 thisFrameUV","vec2 nextFrameUV","float frameLerp","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":87,"name":"VATGetLocalPosition","type":"vec3","usage":"function"},{"args":["inout vec3 meshLocalPos","inout vec3 meshLocalNormal","inout vec3 meshLocalTangent","in vec4 meshVertexColor","vec2 thisFrameUV","float pivMax","float pivMin","float posMax","float posMin","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture","sampler2D vatPositionAlphaTexture","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":120,"name":"VATGetLocalPositionRigidBody20","type":"void","usage":"function"},{"args":["inout vec3 meshLocalPos","inout vec3 meshLocalNormal","inout vec3 meshLocalTangent","in vec4 meshVertexColor","vec2 thisFrameUV","float pivMax","float pivMin","float posMax","float posMin","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture","sampler2D vatPositionAlphaTexture","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":150,"name":"VATGetLocalPositionRigidBody20_UE","type":"void","usage":"function"},{"args":["inout vec3 meshLocalPos","inout vec3 meshLocalNormal","inout vec3 meshLocalTangent","in vec2 meshUV2","in vec2 meshUV3","vec2 thisFrameUV","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture","sampler2D vatPositionAlphaTexture","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture","bool isZUp"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":185,"name":"VATGetLocalPositionRigidBody30","type":"void","usage":"function"},{"args":["inout vec3 meshLocalPos","inout vec3 meshLocalNormal","inout vec3 meshLocalTangent","in vec2 meshUV2","in vec2 meshUV3","vec2 thisFrameUV","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture","sampler2D vatPositionAlphaTexture","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":258,"name":"VATGetLocalPositionRigidBody30_Cocos","type":"void","usage":"function"},{"args":["inout vec3 meshLocalPos","inout vec3 meshLocalNormal","inout vec3 meshLocalTangent","in vec2 meshUV2","in vec2 meshUV3","vec2 thisFrameUV","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture","sampler2D vatPositionAlphaTexture","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":4,"file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":244,"name":"VATGetLocalPositionRigidBody30_UE","type":"void","usage":"function"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":48,"name":"VSOutput_clipPos","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":12,"name":"VSOutput_faceSideSign","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":40,"name":"VSOutput_fogFactor","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":29,"name":"VSOutput_lightMapUV","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":44,"name":"VSOutput_localPos","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":21,"name":"VSOutput_mirrorNormal","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":36,"name":"VSOutput_reflectionProbeId","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":33,"name":"VSOutput_shadowBias","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":13,"name":"VSOutput_texcoord","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":25,"name":"VSOutput_texcoord1","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":16,"name":"VSOutput_vertexColor","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":11,"name":"VSOutput_worldNormal","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":10,"name":"VSOutput_worldPos","type":"","usage":"macro"},{"args":[],"column":0,"file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":20,"name":"VSOutput_worldTangent","type":"","usage":"macro"},{"args":[],"column":0,"file":"","line":0,"name":"abs","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"acos","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"all","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"any","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"asin","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"atan","type":"","usage":"function"},{"args":["float y","float x"],"column":5,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":242,"name":"atan2","type":"float","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"attribute","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"bool","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"break","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"bvec2","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"bvec3","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"bvec4","type":"","usage":"keyword"},{"args":[],"column":25,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":14,"name":"cc_ambientGround","type":"vec4","usage":"varaible"},{"args":[],"column":22,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":13,"name":"cc_ambientSky","type":"vec4","usage":"varaible"},{"args":[],"column":23,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":7,"name":"cc_cameraPos","type":"vec4","usage":"varaible"},{"args":[],"column":27,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":6,"name":"cc_debug_view_mode","type":"vec4","usage":"varaible"},{"args":[],"column":20,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":10,"name":"cc_exposure","type":"vec4","usage":"varaible"},{"args":[],"column":18,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":17,"name":"cc_fogAdd","type":"vec4","usage":"varaible"},{"args":[],"column":19,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":16,"name":"cc_fogBase","type":"vec4","usage":"varaible"},{"args":[],"column":20,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":15,"name":"cc_fogColor","type":"vec4","usage":"varaible"},{"args":["LIGHTS_PER_PASS"],"column":38,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-forward-light.chunk","line":2,"name":"cc_lightColor","type":"vec4","usage":"varaible"},{"args":["LIGHTS_PER_PASS"],"column":36,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-forward-light.chunk","line":4,"name":"cc_lightDir","type":"vec4","usage":"varaible"},{"args":["LIGHTS_PER_PASS"],"column":37,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-forward-light.chunk","line":1,"name":"cc_lightPos","type":"vec4","usage":"varaible"},{"args":["LIGHTS_PER_PASS"],"column":47,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-forward-light.chunk","line":3,"name":"cc_lightSizeRangeAngle","type":"vec4","usage":"varaible"},{"args":[],"column":30,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":3,"name":"cc_lightingMapUVParam","type":"vec4","usage":"varaible"},{"args":[],"column":27,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":4,"name":"cc_localShadowBias","type":"vec4","usage":"varaible"},{"args":[],"column":24,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":12,"name":"cc_mainLitColor","type":"vec4","usage":"varaible"},{"args":[],"column":22,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":11,"name":"cc_mainLitDir","type":"vec4","usage":"varaible"},{"args":[],"column":24,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":1,"name":"cc_matLightView","type":"mat4","usage":"varaible"},{"args":[],"column":28,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":2,"name":"cc_matLightViewProj","type":"mat4","usage":"varaible"},{"args":[],"column":21,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":3,"name":"cc_matProj","type":"mat4","usage":"varaible"},{"args":[],"column":24,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":4,"name":"cc_matProjInv","type":"mat4","usage":"varaible"},{"args":[],"column":21,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":1,"name":"cc_matView","type":"mat4","usage":"varaible"},{"args":[],"column":24,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":2,"name":"cc_matViewInv","type":"mat4","usage":"varaible"},{"args":[],"column":25,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":5,"name":"cc_matViewProj","type":"mat4","usage":"varaible"},{"args":[],"column":28,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":6,"name":"cc_matViewProjInv","type":"mat4","usage":"varaible"},{"args":[],"column":20,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":1,"name":"cc_matWorld","type":"mat4","usage":"varaible"},{"args":[],"column":22,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":2,"name":"cc_matWorldIT","type":"mat4","usage":"varaible"},{"args":[],"column":22,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":3,"name":"cc_nativeSize","type":"vec4","usage":"varaible"},{"args":[],"column":19,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":18,"name":"cc_nearFar","type":"vec4","usage":"varaible"},{"args":[],"column":24,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":10,"name":"cc_planarNDInfo","type":"vec4","usage":"varaible"},{"args":[],"column":21,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":4,"name":"cc_probeInfo","type":"vec4","usage":"varaible"},{"args":[],"column":32,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":5,"name":"cc_reflectionProbeData1","type":"vec4","usage":"varaible"},{"args":[],"column":32,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":6,"name":"cc_reflectionProbeData2","type":"vec4","usage":"varaible"},{"args":[],"column":23,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":9,"name":"cc_screenScale","type":"vec4","usage":"varaible"},{"args":[],"column":22,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":2,"name":"cc_screenSize","type":"vec4","usage":"varaible"},{"args":[],"column":23,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":9,"name":"cc_shadowColor","type":"vec4","usage":"varaible"},{"args":[],"column":34,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":3,"name":"cc_shadowInvProjDepthInfo","type":"vec4","usage":"varaible"},{"args":[],"column":26,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":8,"name":"cc_shadowLPNNInfo","type":"vec4","usage":"varaible"},{"args":[],"column":26,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":6,"name":"cc_shadowNFLSInfo","type":"vec4","usage":"varaible"},{"args":[],"column":31,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":4,"name":"cc_shadowProjDepthInfo","type":"vec4","usage":"varaible"},{"args":[],"column":26,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":5,"name":"cc_shadowProjInfo","type":"vec4","usage":"varaible"},{"args":[],"column":26,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":7,"name":"cc_shadowWHPBInfo","type":"vec4","usage":"varaible"},{"args":[],"column":28,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":8,"name":"cc_surfaceTransform","type":"vec4","usage":"varaible"},{"args":[],"column":18,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":1,"name":"cc_time","type":"vec4","usage":"varaible"},{"args":[],"column":20,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":19,"name":"cc_viewPort","type":"vec4","usage":"varaible"},{"args":[],"column":28,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-world-bound.chunk","line":1,"name":"cc_worldBoundCenter","type":"vec4","usage":"varaible"},{"args":[],"column":33,"file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-world-bound.chunk","line":2,"name":"cc_worldBoundHalfExtents","type":"vec4","usage":"varaible"},{"args":[],"column":0,"file":"","line":0,"name":"ceil","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"clamp","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"const","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"continue","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"cos","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"cross","type":"","usage":"function"},{"args":["anytype ShaderInputData"],"column":0,"file":"","line":0,"name":"dFdx","type":"anytype","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"dFdx","type":"","usage":"function"},{"args":["anytype ShaderInputData"],"column":0,"file":"","line":0,"name":"dFdxCoarse","type":"anytype","usage":"function"},{"args":["anytype ShaderInputData"],"column":0,"file":"","line":0,"name":"dFdxFine","type":"anytype","usage":"function"},{"args":["anytype ShaderInputData"],"column":0,"file":"","line":0,"name":"dFdy","type":"anytype","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"dFdy","type":"","usage":"function"},{"args":["anytype ShaderInputData"],"column":0,"file":"","line":0,"name":"dFdyCoarse","type":"anytype","usage":"function"},{"args":["anytype ShaderInputData"],"column":0,"file":"","line":0,"name":"dFdyFine","type":"anytype","usage":"function"},{"args":["highp vec4 rgba"],"column":11,"file":"editor\\assets\\chunks\\common\\data\\unpack.chunk","line":5,"name":"decode32","type":"float","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"degrees","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"discard","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"distance","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"do","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"dot","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"else","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"equal","type":"","usage":"function"},{"args":["vec3 euler"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":223,"name":"eulerToQuat","type":"vec4","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"exp2","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"faceforward","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"false","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"float","type":"","usage":"keyword"},{"args":["in vec3 v"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\octahedron-transform.chunk","line":6,"name":"float32x3_to_oct","type":"vec2","usage":"function"},{"args":["floatVECType value"],"column":0,"file":"","line":0,"name":"floatBitsToInt","type":"UINTVECType","usage":"function"},{"args":["floatVECType value"],"column":0,"file":"","line":0,"name":"floatBitsToUint","type":"UINTVECType","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"floor","type":"","usage":"function"},{"args":["floatVECType Data"," floatVECType multiplier"," floatVECType bias"],"column":0,"file":"","line":0,"name":"fma","type":"floatVECType","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"for","type":"","usage":"keyword"},{"args":["anytype Data"],"column":0,"file":"","line":0,"name":"fract","type":"anytype","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"fract","type":"","usage":"function"},{"args":["sampler2D tex","vec2 P","vec2 dPdx","vec2 dPdy"],"column":4,"file":"editor\\assets\\chunks\\common\\texture\\texture-lod.chunk","line":28,"name":"fragTextureGrad","type":"vec4","usage":"function"},{"args":["samplerCube tex","vec3 P","vec3 dPdx","vec3 dPdy"],"column":4,"file":"editor\\assets\\chunks\\common\\texture\\texture-lod.chunk","line":40,"name":"fragTextureGrad","type":"vec4","usage":"function"},{"args":["sampler2D tex","vec2 coord","float lod"],"column":4,"file":"editor\\assets\\chunks\\common\\texture\\texture-lod.chunk","line":4,"name":"fragTextureLod","type":"vec4","usage":"function"},{"args":["samplerCube tex","vec3 coord","float lod"],"column":4,"file":"editor\\assets\\chunks\\common\\texture\\texture-lod.chunk","line":16,"name":"fragTextureLod","type":"vec4","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"ftransform","type":"","usage":"function"},{"args":["anytype ShaderInputData"],"column":0,"file":"","line":0,"name":"fwidth","type":"anytype","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"fwidth","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"gl_FragColor","type":"","usage":"varaible"},{"args":[],"column":0,"file":"","line":0,"name":"greaterThan","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"greaterThanEqual","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"highp","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"if","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"in","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"inout","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"int","type":"","usage":"keyword"},{"args":["INTVECType value"],"column":0,"file":"","line":0,"name":"intBitsToFloat","type":"floatVECType","usage":"function"},{"args":["floatVECType interpolant"],"column":0,"file":"","line":0,"name":"interpolateAtCentroid","type":"floatVECType","usage":"function"},{"args":["floatVECType interpolant","vec2 offset"],"column":0,"file":"","line":0,"name":"interpolateAtOffset","type":"floatVECType","usage":"function"},{"args":["floatVECType interpolant","int sampleIndex"],"column":0,"file":"","line":0,"name":"interpolateAtSample","type":"floatVECType","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"inversesqrt","type":"","usage":"function"},{"args":["float x"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":4,"name":"isinf","type":"bool","usage":"function"},{"args":["vec2 val"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":19,"name":"isinfs","type":"bool","usage":"function"},{"args":["vec3 val"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":22,"name":"isinfs","type":"bool","usage":"function"},{"args":["vec4 val"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":25,"name":"isinfs","type":"bool","usage":"function"},{"args":["float val"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":1,"name":"isnan","type":"bool","usage":"function"},{"args":["vec2 val"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":9,"name":"isnans","type":"bool","usage":"function"},{"args":["vec3 val"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":12,"name":"isnans","type":"bool","usage":"function"},{"args":["vec4 val"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":15,"name":"isnans","type":"bool","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"ivec2","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"ivec3","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"ivec4","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"length","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"lessThan","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"lessThanEqual","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"log2","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"lowp","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"mat2","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"mat3","type":"","usage":"keyword"},{"args":["mat3 mat"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":188,"name":"mat3ToQuat","type":"vec4","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"mat4","type":"","usage":"keyword"},{"args":["vec4 q","vec3 t","vec3 s"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":97,"name":"matFromRTS","type":"mat4","usage":"function"},{"args":["vec4 q","vec3 p"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":75,"name":"matrixFromRT","type":"mat4","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"max","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"maxtrixCompMult","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"mediump","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"min","type":"","usage":"function"},{"args":["anytype Data1_Left","anytype Data2_Right","anytype Coef_DirectMulToData2"],"column":0,"file":"","line":0,"name":"mix","type":"anytype","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"mix","type":"","usage":"function"},{"args":["floatVECType Data"," floatVECType Divisor"],"column":0,"file":"","line":0,"name":"mod","type":"floatVECType","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"mod","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"normalize","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"not","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"notEqual","type":"","usage":"function"},{"args":["vec2 e"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\octahedron-transform.chunk","line":13,"name":"oct_to_float32x3","type":"vec3","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"out","type":"","usage":"keyword"},{"args":["float depth"],"column":4,"file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":3,"name":"packDepthToRGBA","type":"vec4","usage":"function"},{"args":["out type mainPart","out type modPart","highp type data"],"column":4,"file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":23,"name":"packHighpData","type":"void","usage":"function"},{"args":["out type mainPart","out type modPart","highp type data","const float modValue"],"column":4,"file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":31,"name":"packHighpData","type":"void","usage":"function"},{"args":["vec3 rgb"],"column":4,"file":"editor\\assets\\chunks\\common\\data\\unpack.chunk","line":14,"name":"packRGBE","type":"vec4","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"pow","type":"","usage":"function"},{"args":["vec4 a","vec4 b"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":128,"name":"quatMultiply","type":"vec4","usage":"function"},{"args":["vec4 q"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":246,"name":"quatToEuler","type":"vec3","usage":"function"},{"args":["vec4 q"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":167,"name":"quatToMat3","type":"mat3","usage":"function"},{"args":["vec4 q"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":183,"name":"quatToMat4","type":"mat4","usage":"function"},{"args":["vec3 xAxis","vec3 yAxis","vec3 zAxis"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":10,"name":"quaternionFromAxis","type":"vec4","usage":"function"},{"args":["float angle","vec3 axis"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":1,"name":"quaternionFromAxisAngle","type":"vec4","usage":"function"},{"args":["vec3 angle"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":53,"name":"quaternionFromEuler","type":"vec4","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"radians","type":"","usage":"function"},{"args":["vec2 seeds_zero_to_one"],"column":5,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":59,"name":"rand","type":"float","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"reflect","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"return","type":"","usage":"keyword"},{"args":["inout vec2 corner","float angle"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":160,"name":"rotateCorner","type":"void","usage":"function"},{"args":["vec3 pos","vec3 xAxis","vec3 yAxis","vec3 zAxis","vec4 q"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":153,"name":"rotateInLocalSpace","type":"vec3","usage":"function"},{"args":["vec3 v","vec3 axis","float theta"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":149,"name":"rotateVecFromAxis","type":"vec3","usage":"function"},{"args":["inout vec3 v","vec4 q"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":137,"name":"rotateVecFromQuat","type":"void","usage":"function"},{"args":["float value"],"column":7,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":32,"name":"round","type":"float","usage":"function"},{"args":["vec2 value"],"column":6,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":36,"name":"round","type":"vec2","usage":"function"},{"args":["vec3 value"],"column":6,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":37,"name":"round","type":"vec3","usage":"function"},{"args":["vec4 value"],"column":6,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":38,"name":"round","type":"vec4","usage":"function"},{"args":["float value"],"column":5,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":41,"name":"rsqrt","type":"float","usage":"function"},{"args":["vec2 value"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":44,"name":"rsqrt","type":"vec2","usage":"function"},{"args":["vec3 value"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":45,"name":"rsqrt","type":"vec3","usage":"function"},{"args":["vec4 value"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":46,"name":"rsqrt","type":"vec4","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"sampler1D","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"sampler1DShadow","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"sampler2D","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"sampler2DShadow","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"sampler3D","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"samplerCube","type":"","usage":"keyword"},{"args":["float value"],"column":5,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":48,"name":"saturate","type":"float","usage":"function"},{"args":["vec2 value"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":51,"name":"saturate","type":"vec2","usage":"function"},{"args":["vec3 value"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":52,"name":"saturate","type":"vec3","usage":"function"},{"args":["vec4 value"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":53,"name":"saturate","type":"vec4","usage":"function"},{"args":["inout mat4 m","float s"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":122,"name":"scaleMatrix","type":"void","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"shadow1D","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"shadow1DLod","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"shadow1DProj","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"shadow1DProjLod","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"shadow2D","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"shadow2DLod","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"shadow2DProj","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"shadow2DProjLod","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"sign","type":"","usage":"function"},{"args":["vec2 v"],"column":4,"file":"editor\\assets\\chunks\\common\\math\\octahedron-transform.chunk","line":1,"name":"signNotZero","type":"vec2","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"sin","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"smoothstep","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"sqrt","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"step","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"struct","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"tan","type":"","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTexelCoord","int lod"],"column":0,"file":"","line":0,"name":"texelFetch","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTexelCoord","int lod","INTVECType vOffset"],"column":0,"file":"","line":0,"name":"texelFetchOffset","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","__opt float bias"],"column":0,"file":"","line":0,"name":"texture","type":"anytype","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture1D","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture1DLod","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture1DProj","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture1DProjLod","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture2D","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture2DLod","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture2DProj","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture2DProjLod","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture3D","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture3DLod","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture3DProj","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"texture3DProjLod","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"textureCube","type":"","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"textureCubeLod","type":"","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","float lod"],"column":0,"file":"","line":0,"name":"textureGrad","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","float lod","INTVECType vOffset"],"column":0,"file":"","line":0,"name":"textureGradOffset","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","float lod"],"column":0,"file":"","line":0,"name":"textureLod","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","float lod","INTVECType vOffset"],"column":0,"file":"","line":0,"name":"textureLodOffset","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","INTVECType vOffset","__opt float bias"],"column":0,"file":"","line":0,"name":"textureOffset","type":"anytype","usage":"function"},{"args":["sampler any_type_tex"],"column":0,"file":"","line":0,"name":"textureQueryLevels","type":"int","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord"],"column":0,"file":"","line":0,"name":"textureQueryLod","type":"vec2","usage":"function"},{"args":["sampler MSAAtex"],"column":0,"file":"","line":0,"name":"textureSamples","type":"int","usage":"function"},{"args":["sampler any_type_tex","int lod"],"column":0,"file":"","line":0,"name":"textureSize","type":"INTVECType","usage":"function"},{"args":["mat3 v"],"column":4,"file":"editor\\assets\\chunks\\common\\lighting\\rect-area-light.chunk","line":2,"name":"transposeMat3","type":"mat3","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"true","type":"","usage":"keyword"},{"args":["UINTVECType value"],"column":0,"file":"","line":0,"name":"uintBitsToFloat","type":"floatVECType","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"uniform","type":"","usage":"keyword"},{"args":["type mainPart","type modPart"],"column":10,"file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":19,"name":"unpackHighpData","type":"type","usage":"function"},{"args":["type mainPart","type modPart","const float modValue"],"column":10,"file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":27,"name":"unpackHighpData","type":"type","usage":"function"},{"args":["vec4 rgbe"],"column":4,"file":"editor\\assets\\chunks\\common\\data\\unpack.chunk","line":28,"name":"unpackRGBE","type":"vec3","usage":"function"},{"args":[],"column":0,"file":"","line":0,"name":"varying","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"vec2","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"vec3","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"vec4","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"void","type":"","usage":"keyword"},{"args":[],"column":0,"file":"","line":0,"name":"while","type":"","usage":"keyword"}]}
\ No newline at end of file
+{"list":[{"args":["vec3 color"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\color\\aces.chunk","line":2,"name":"ACESToneMap","type":"vec3","usage":"function"},{"args":["vec4 shadowPos","vec3 worldNormal","float normalBias","vec3 matViewDir0","vec3 matViewDir1","vec3 matViewDir2","vec2 projScaleXY"],"column":7,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":52,"name":"ApplyShadowDepthBias_FaceNormal","type":"vec4","usage":"function"},{"args":["vec4 shadowPos","vec3 worldNormal","float normalBias","mat4 matLightView","vec2 projScaleXY"],"column":7,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":64,"name":"ApplyShadowDepthBias_FaceNormal","type":"vec4","usage":"function"},{"args":["vec4 shadowPos","float viewspaceDepthBias","float projScaleZ","float projBiasZ"],"column":7,"comment":" (projScaleZ, projBiasZ) = cc_shadowProjDepthInfo.xy","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":110,"name":"ApplyShadowDepthBias_Orthographic","type":"vec4","usage":"function"},{"args":["vec4 shadowPos","float viewspaceDepthBias"],"column":7,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":85,"name":"ApplyShadowDepthBias_Perspective","type":"vec4","usage":"function"},{"args":["vec4 shadowPos","float viewspaceDepthBias","vec3 worldPos"],"column":7,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":127,"name":"ApplyShadowDepthBias_PerspectiveLinearDepth","type":"vec4","usage":"function"},{"args":["float baseColor","float detailedColor"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\effect\\special-effects.chunk","line":21,"name":"BlendDetailedColorMap","type":"float","usage":"function"},{"args":["vec3 baseColor","vec3 detailedColor"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\effect\\special-effects.chunk","line":36,"name":"BlendDetailedColorMap","type":"vec3","usage":"function"},{"args":["vec3 baseNormalFromMap","vec3 detailedNormalFromMap","float detailedIntensity"],"column":5,"comment":" NormalFromMap is: texture(normalmap) - 0.5","file":"editor\\assets\\chunks\\common\\effect\\special-effects.chunk","line":15,"name":"BlendDetailedNormalMap","type":"vec3","usage":"function"},{"args":["out vec4 csmPos","out vec4 csmPosWithBias","vec3 worldPos","vec3 N","vec2 shadowBias"],"column":10,"comment":" output csmPos is non-biased position that can be used for sampling shadow map after homogeneous divid","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":347,"name":"CCCSMFactorBase","type":"float","usage":"function"},{"args":["out vec4 csmPos","out vec4 csmPosWithBias","vec3 worldPos","vec3 N","vec2 shadowBias"],"column":10,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":416,"name":"CCCSMFactorBase","type":"float","usage":"function"},{"args":["vec3 worldPos","vec3 N","vec2 shadowBias"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":428,"name":"CCCSMFactorBase","type":"float","usage":"function"},{"args":["out vec4 csmPos","out vec4 shadowProjDepthInfo","out vec4 shadowProjInfo","out vec3 shadowViewDir0","out vec3 shadowViewDir1","out vec3 shadowViewDir2","vec3 worldPos","int level"],"column":9,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":294,"name":"CCGetCSMLevel","type":"void","usage":"function"},{"args":["out bool isTransitionArea","out highp float transitionRatio","out vec4 csmPos","out vec4 shadowProjDepthInfo","out vec4 shadowProjInfo","out vec3 shadowViewDir0","out vec3 shadowViewDir1","out vec3 shadowViewDir2","vec3 worldPos"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":313,"name":"CCGetCSMLevel","type":"int","usage":"function"},{"args":["out vec4 csmPos","out vec4 shadowProjDepthInfo","out vec4 shadowProjInfo","out vec3 shadowViewDir0","out vec3 shadowViewDir1","out vec3 shadowViewDir2","vec3 worldPos"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":339,"name":"CCGetCSMLevel","type":"int","usage":"function"},{"args":["out vec4 csmPos","out vec4 shadowProjDepthInfo","out vec4 shadowProjInfo","out vec3 shadowViewDir0","out vec3 shadowViewDir1","out vec3 shadowViewDir2","vec3 worldPos"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":412,"name":"CCGetCSMLevel","type":"int","usage":"function"},{"args":["out highp float ratio","vec3 clipPos"],"column":9,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":253,"name":"CCGetCSMLevelWithTransition","type":"bool","usage":"function"},{"args":["vec4 shadowPosWithDepthBias"],"column":8,"comment":"////////////////////////////////////////////////////////Directional Light Shadow","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":136,"name":"CCGetDirLightShadowFactorHard","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":144,"name":"CCGetDirLightShadowFactorSoft","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":152,"name":"CCGetDirLightShadowFactorSoft3X","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":160,"name":"CCGetDirLightShadowFactorSoft5X","type":"float","usage":"function"},{"args":["vec3 worldPos","float viewSpaceBias"],"column":6,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":21,"name":"CCGetLinearDepth","type":"float","usage":"function"},{"args":["vec3 worldPos"],"column":6,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":27,"name":"CCGetLinearDepth","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias","vec3 worldPos"],"column":8,"comment":"////////////////////////////////////////////////////////Spot Light Shadow","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":170,"name":"CCGetSpotLightShadowFactorHard","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias","vec3 worldPos"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":178,"name":"CCGetSpotLightShadowFactorSoft","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias","vec3 worldPos"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":186,"name":"CCGetSpotLightShadowFactorSoft3X","type":"float","usage":"function"},{"args":["vec4 shadowPosWithDepthBias","vec3 worldPos"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":194,"name":"CCGetSpotLightShadowFactorSoft5X","type":"float","usage":"function"},{"args":["out mat4 matWorld"],"column":5,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\world-transform.chunk","line":3,"name":"CCGetWorldMatrix","type":"void","usage":"function"},{"args":["out mat4 matWorld","out mat4 matWorldIT"],"column":5,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\world-transform.chunk","line":17,"name":"CCGetWorldMatrixFull","type":"void","usage":"function"},{"args":["int level","vec3 worldPos"],"column":9,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":277,"name":"CCHasCSMLevel","type":"bool","usage":"function"},{"args":["out vec4 shadowPosWithDepthBias","vec4 shadowPos","vec3 N","vec2 shadowBias"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":229,"name":"CCShadowFactorBase","type":"float","usage":"function"},{"args":["vec4 shadowPos","vec3 N","vec2 shadowBias"],"column":8,"comment":" compatible version","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":423,"name":"CCShadowFactorBase","type":"float","usage":"function"},{"args":["out vec4 shadowPosWithDepthBias","vec4 shadowPos","vec3 worldPos","vec2 shadowBias"],"column":8,"comment":"////////////////////////////////////////////////////////Main Functions","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":204,"name":"CCSpotShadowFactorBase","type":"float","usage":"function"},{"args":["vec4 shadowPos","vec3 worldPos","vec2 shadowBias"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":433,"name":"CCSpotShadowFactorBase","type":"float","usage":"function"},{"args":["inout vec4 color","float factor"],"column":5,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\fog.chunk","line":29,"name":"CC_APPLY_FOG_BASE","type":"void","usage":"function"},{"args":["uv"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":47,"name":"CC_HANDLE_GET_CLIP_FLIP","type":"","usage":"macro"},{"args":["uv"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":46,"name":"CC_HANDLE_RT_SAMPLE_FLIP","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":98,"name":"CC_SURFACES_ENABLE_DEBUG_VIEW","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":39,"name":"CC_SURFACES_FLIP_UV","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":87,"name":"CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":48,"name":"CC_SURFACES_LIGHTING_ANISOTROPIC","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":51,"name":"CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":75,"name":"CC_SURFACES_LIGHTING_CLEAR_COAT","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":72,"name":"CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":81,"name":"CC_SURFACES_LIGHTING_SSS","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":63,"name":"CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":60,"name":"CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":69,"name":"CC_SURFACES_LIGHTING_TRT","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":78,"name":"CC_SURFACES_LIGHTING_TT","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":57,"name":"CC_SURFACES_LIGHTING_USE_FRESNEL","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":66,"name":"CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":25,"name":"CC_SURFACES_TRANSFER_CLIP_POS","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":22,"name":"CC_SURFACES_TRANSFER_LOCAL_POS","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":54,"name":"CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":31,"name":"CC_SURFACES_USE_LIGHT_MAP","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":45,"name":"CC_SURFACES_USE_REFLECTION_DENOISE","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":13,"name":"CC_SURFACES_USE_SECOND_UV","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":16,"name":"CC_SURFACES_USE_TANGENT_SPACE","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":42,"name":"CC_SURFACES_USE_TWO_SIDED","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\effect-macros\\common-macros.chunk","line":19,"name":"CC_SURFACES_USE_VERTEX_COLOR","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":2,"name":"CC_SURFACES_VARING_MODIFIER","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":2,"name":"CC_SURFACES_VARING_MODIFIER","type":"","usage":"macro"},{"args":["vec4 pos","out float factor"],"column":5,"comment":" Fog helper functions","file":"editor\\assets\\chunks\\builtin\\functionalities\\fog.chunk","line":14,"name":"CC_TRANSFER_FOG_BASE","type":"void","usage":"function"},{"args":["vec3 spotLightDir","vec3 L","float cosAngleOuter"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":42,"name":"CalculateAngleAttenuation","type":"float","usage":"function"},{"args":["vec3 normal","vec3 tangent","float mirrorNormal"],"column":5,"comment":" for right-hand coordinates, params must be normalized","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":60,"name":"CalculateBinormal","type":"vec3","usage":"function"},{"args":["vec3 R","vec3 worldPos","vec3 cubeCenterPos","vec3 cubeBoxHalfSize"],"column":5,"comment":" fix cubemap direction with box projection\r\n return unnormalized vector and weight for exceeding","file":"editor\\assets\\chunks\\common\\lighting\\functions.chunk","line":72,"name":"CalculateBoxProjectedDirection","type":"vec4","usage":"function"},{"args":["float distToLightSqr","float lightRadius","float lightRange"],"column":6,"comment":" advanced","file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":31,"name":"CalculateDistanceAttenuation","type":"float","usage":"function"},{"args":["float ior","float NoVSat"],"column":6,"comment":" saturated N dot V","file":"editor\\assets\\chunks\\common\\lighting\\bxdf.chunk","line":3,"name":"CalculateFresnelCoefficient","type":"float","usage":"function"},{"args":["vec3 tangent","vec3 binormal"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":68,"name":"CalculateNormal","type":"vec3","usage":"function"},{"args":["vec3 normalFromTangentSpace","float normalStrength","vec3 normal","vec3 tangent","float mirrorNormal"],"column":5,"comment":" param1 is normal from normalmap\r\n return value is un-normalized","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":76,"name":"CalculateNormalFromTangentSpace","type":"vec3","usage":"function"},{"args":["vec3 N","vec3 V","vec3 worldPos","vec4 plane","vec3 cameraPos","float probeReflectedDepth"],"column":5,"comment":" for bumped planar reflection","file":"editor\\assets\\chunks\\common\\lighting\\functions.chunk","line":44,"name":"CalculatePlanarReflectPositionOnPlane","type":"vec3","usage":"function"},{"args":["vec3 N","vec3 V","float NoV"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\functions.chunk","line":35,"name":"CalculateReflectDirection","type":"vec3","usage":"function"},{"args":["vec3 N","vec3 V","float NoV","float ior"],"column":5,"comment":" return unnormalized vector, support oppo-side\r\n V from pixel to camera","file":"editor\\assets\\chunks\\common\\lighting\\functions.chunk","line":5,"name":"CalculateRefractDirection","type":"vec3","usage":"function"},{"args":["vec3 N","vec3 V","float NoV","float ior"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\functions.chunk","line":23,"name":"CalculateRefractDirectionFast","type":"vec3","usage":"function"},{"args":["vec3 unscatteredColor","float distance","float outScatterExtinctCoef","float inScatterExtinctCoef","float inScatterCoef","vec3 inScatterColor","vec3 outScatterColor"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\bxdf.chunk","line":16,"name":"CalculateScattering","type":"vec3","usage":"function"},{"args":["vec3 normal","vec3 binormal"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":64,"name":"CalculateTangent","type":"vec3","usage":"function"},{"args":["out vec2 deltaV","float frameCount","float animSpeed","float elapseTime"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":29,"name":"CalculateVATAnimationUV","type":"float","usage":"function"},{"args":["float A","float B"],"column":6,"comment":" Experimental","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":168,"name":"CalculateVATDecodeUV","type":"float","usage":"function"},{"args":["inout vec3 L[5",", out int n"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\rect-area-light.chunk","line":12,"name":"ClipQuadToHorizon","type":"void","usage":"function"},{"args":["type"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":19,"name":"DEFINE_PACK_HIGHP_FUNC","type":"","usage":"macro"},{"args":["float roughness","float NoH"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":3,"name":"D_GGX","type":"float","usage":"function"},{"args":["float RoughnessX","float RoughnessY","float NoH","vec3 H","vec3 X","vec3 Y"],"column":6,"comment":" How to get an anisotropic offset along T/B:\r\n 1. accurate: rotation TBN basis, let N intend to T/B, such as flow map as normalmap, output vec3(0, delta, 1) instead of vec3(0, 0, 1)\r\n 2. not accurate: H intend to V, and passed to this function","file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":35,"name":"D_GGXAniso","type":"float","usage":"function"},{"args":["float roughness","float NoH"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":11,"name":"D_GGXMobile","type":"float","usage":"function"},{"args":["vec3 color","float fraction"],"column":5,"comment":" fraction is saturation percentage, 0 means gray","file":"editor\\assets\\chunks\\common\\graph-expression\\base.chunk","line":5,"name":"Desaturation","type":"vec3","usage":"function"},{"args":["vec4 clipPos","vec2 screen_resolution","float transparency"],"column":5,"comment":" dithered transparency (dithered alpha test), better looking with TAA\r\n arguments: FSInput_clipPos, cc_viewPort.zw, baseColor.a","file":"editor\\assets\\chunks\\common\\effect\\special-effects.chunk","line":4,"name":"DitheredAlphaClip","type":"void","usage":"function"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":18,"name":"EPSILON","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":19,"name":"EPSILON_LOWP","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":21,"name":"EXP_VALUE","type":"","usage":"macro"},{"args":["samplerCube tex","vec3 R","float roughness","float mipCount"],"column":7,"comment":"","file":"editor\\assets\\chunks\\common\\texture\\cubemap.chunk","line":33,"name":"EnvReflection","type":"vec3","usage":"function"},{"args":["vec3 R","float roughness","float mipCount","float denoiseIntensity"],"column":7,"comment":"","file":"editor\\assets\\chunks\\common\\texture\\cubemap.chunk","line":3,"name":"EnvReflectionWithMipFiltering","type":"vec3","usage":"function"},{"args":["vec4 pos","vec3 cameraPos","float fogStart","float fogDensity","float fogAtten"],"column":6,"comment":"pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z","file":"editor\\assets\\chunks\\common\\effect\\fog.chunk","line":11,"name":"ExpFog","type":"float","usage":"function"},{"args":["vec4 pos","vec3 cameraPos","float fogStart","float fogDensity","float fogAtten"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\effect\\fog.chunk","line":18,"name":"ExpSquaredFog","type":"float","usage":"function"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":22,"name":"FP_MAX","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":23,"name":"FP_SCALE","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":24,"name":"FP_SCALE_INV","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":58,"name":"FSInput_clipPos","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":15,"name":"FSInput_faceSideSign","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":50,"name":"FSInput_fogFactor","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":39,"name":"FSInput_lightMapUV","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":54,"name":"FSInput_localPos","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":26,"name":"FSInput_mirrorNormal","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":46,"name":"FSInput_reflectionProbeId","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":43,"name":"FSInput_shadowBias","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":16,"name":"FSInput_texcoord","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":33,"name":"FSInput_texcoord1","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":19,"name":"FSInput_vertexColor","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":14,"name":"FSInput_worldNormal","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":13,"name":"FSInput_worldPos","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\fs-input.chunk","line":25,"name":"FSInput_worldTangent","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":25,"name":"GRAY_VECTOR","type":"","usage":"macro"},{"args":["vec3 L","vec3 litDir","float litAngleScale","float litAngleOffset"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":22,"name":"GetAngleAtt","type":"float","usage":"function"},{"args":["float roughness","float anisotropyShape","vec3 V","vec3 N","vec3 X","vec3 Y"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":45,"name":"GetAnisotropicReflect","type":"vec3","usage":"function"},{"args":["float roughness","float anisotropyShape","out float roughnessX","out float roughnessY"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":19,"name":"GetAnisotropicRoughness","type":"void","usage":"function"},{"args":["float depthHS","mat4 matProj"],"column":6,"comment":" depthHS (Z) = ndc depth(-1 ~ +1)\r\n return camera depth (W), negative in RH","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":32,"name":"GetCameraDepthRH","type":"float","usage":"function"},{"args":["float depthHS","float matProj32","float matProj22"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":36,"name":"GetCameraDepthRH","type":"float","usage":"function"},{"args":["out vec3 centerPos","out vec3 boxHalfSize","out float mipCount","float probeId"],"column":5,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\probe.chunk","line":29,"name":"GetCubeReflectionProbeData","type":"void","usage":"function"},{"args":["float distSqr","float invSqrAttRadius"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":16,"name":"GetDistAtt","type":"float","usage":"function"},{"args":["out vec3 lightmapColor","out float dirShadow","out float ao","sampler2D lightingMap","vec2 luv","float lum","vec3 worldNormal"],"column":5,"comment":" for surface shader","file":"editor\\assets\\chunks\\common\\lighting\\light-map.chunk","line":23,"name":"GetLightMapColor","type":"void","usage":"function"},{"args":["vec3 viewPos","float near","float far"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":54,"name":"GetLinearDepthFromViewSpace","type":"float","usage":"function"},{"args":["out float metallic","out vec3 albedo","vec3 diffuse","vec3 specular","float channelFaultTolerant","float f0"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\mesh\\material.chunk","line":1,"name":"GetMetallicAlbedoFromDiffuseSpecularMathematic","type":"bool","usage":"function"},{"args":["out float metallic","out vec3 albedo","vec3 diffuse","vec3 specular","float f0"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\mesh\\material.chunk","line":29,"name":"GetMetallicAlbedoFromDiffuseSpecularWithoutColor","type":"bool","usage":"function"},{"args":["vec3 worldPos","mat4 matVirtualCameraViewProj","float flipNDCSign","vec3 viewDir","vec3 reflectDir"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":21,"name":"GetPlanarReflectScreenUV","type":"vec2","usage":"function"},{"args":["out vec4 plane","out float planarReflectionDepthScale","out float mipCount","float probeId"],"column":5,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\probe.chunk","line":11,"name":"GetPlanarReflectionProbeData","type":"void","usage":"function"},{"args":["vec4 clipPos","float flipNDCSign"],"column":5,"comment":" return 0-1","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":7,"name":"GetScreenUV","type":"vec2","usage":"function"},{"args":["vec3 worldPos","mat4 matViewProj","float flipNDCSign"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":15,"name":"GetScreenUV","type":"vec2","usage":"function"},{"args":["out vec3 shadowNDCPos","vec4 shadowPosWithDepthBias"],"column":7,"comment":"////////////////////////////////////////////////////////Helper Functions","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":40,"name":"GetShadowNDCPos","type":"bool","usage":"function"},{"args":["sampler2D dataMap","float dataMapWidth","float x","float uv_y"],"column":5,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\probe.chunk","line":2,"name":"GetTexData","type":"vec4","usage":"function"},{"args":["vec3 posHS","mat4 matProj","mat4 matProjInv"],"column":5,"comment":" posHS = ndc pos (xyz: -1 ~ +1)","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":42,"name":"GetViewPosFromNDCPosRH","type":"vec4","usage":"function"},{"args":["float NDCDepth","float projScaleZ","float projBiasZ"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":76,"name":"GetViewSpaceDepthFromNDCDepth_Orthgraphic","type":"float","usage":"function"},{"args":["float NDCDepth","float homogenousDividW","float invProjScaleZ","float invProjBiasZ"],"column":8,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\shadow-map.chunk","line":80,"name":"GetViewSpaceDepthFromNDCDepth_Perspective","type":"float","usage":"function"},{"args":["vec3 posHS","mat4 matProj","mat4 matViewProjInv"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":48,"name":"GetWorldPosFromNDCPosRH","type":"vec4","usage":"function"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":7,"name":"HALF_PI","type":"","usage":"macro"},{"args":["vec3 color"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\color\\tone-mapping.chunk","line":5,"name":"HDRToLDR","type":"vec3","usage":"function"},{"args":["value","defined"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":53,"name":"HIGHP_VALUE_FROM_STRUCT_DEFINED","type":"","usage":"macro"},{"args":["value","defined"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":70,"name":"HIGHP_VALUE_FROM_STRUCT_DEFINED_SMALL_RANGE","type":"","usage":"macro"},{"args":["type","name"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":44,"name":"HIGHP_VALUE_STRUCT_DEFINE","type":"","usage":"macro"},{"args":["value","defined"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":61,"name":"HIGHP_VALUE_TO_STRUCT_DEFINED","type":"","usage":"macro"},{"args":["value","defined"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":78,"name":"HIGHP_VALUE_TO_STRUCT_DEFINED_SMALL_RANGE","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":13,"name":"INV_HALF_PI","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":14,"name":"INV_PI","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":15,"name":"INV_PI2","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":16,"name":"INV_PI4","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":12,"name":"INV_QUATER_PI","type":"","usage":"macro"},{"args":["light_type"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":65,"name":"IS_DIRECTIONAL_LIGHT","type":"","usage":"macro"},{"args":["light_type"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":68,"name":"IS_POINT_LIGHT","type":"","usage":"macro"},{"args":["light_type"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":69,"name":"IS_RANGED_DIRECTIONAL_LIGHT","type":"","usage":"macro"},{"args":["light_type"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":66,"name":"IS_SPHERE_LIGHT","type":"","usage":"macro"},{"args":["light_type"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":67,"name":"IS_SPOT_LIGHT","type":"","usage":"macro"},{"args":["vec3 v1","vec3 v2"],"column":6,"comment":" https://eheitzresearch.wordpress.com/415-2/","file":"editor\\assets\\chunks\\common\\lighting\\rect-area-light.chunk","line":107,"name":"IntegrateEdge","type":"float","usage":"function"},{"args":["vec3 specular","float roughness","float NoV"],"column":5,"comment":" EnvBRDFApprox","file":"editor\\assets\\chunks\\common\\lighting\\brdf.chunk","line":63,"name":"IntegratedGFApprox","type":"vec3","usage":"function"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":51,"name":"LIGHT_MAP_TYPE_ALL_IN_ONE","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":50,"name":"LIGHT_MAP_TYPE_DISABLED","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":52,"name":"LIGHT_MAP_TYPE_INDIRECT_OCCLUSION","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":60,"name":"LIGHT_TYPE_DIRECTIONAL","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":61,"name":"LIGHT_TYPE_POINT","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":64,"name":"LIGHT_TYPE_RANGED_DIRECTIONAL","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":63,"name":"LIGHT_TYPE_SPHERE","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":62,"name":"LIGHT_TYPE_SPOT","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":20,"name":"LOG2","type":"","usage":"macro"},{"args":["vec3 N","vec3 V","vec3 P","mat3 Minv","vec3 points[4]"],"column":5,"comment":" https://blog.magnum.graphics/guest-posts/area-lights-with-ltcs/","file":"editor\\assets\\chunks\\common\\lighting\\rect-area-light.chunk","line":114,"name":"LTC_Evaluate","type":"vec3","usage":"function"},{"args":["vec4 pos","vec3 cameraPos","float fogTop","float fogRange","float fogAtten"],"column":6,"comment":"pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z","file":"editor\\assets\\chunks\\common\\effect\\fog.chunk","line":26,"name":"LayeredFog","type":"float","usage":"function"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\lighting-models\\data-structures\\lighting-intermediate-data.chunk","line":3,"name":"LightingIntermediateData","type":"","usage":"variable"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\lighting-models\\data-structures\\lighting-misc-data.chunk","line":3,"name":"LightingMiscData","type":"","usage":"variable"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\lighting-models\\data-structures\\lighting-result.chunk","line":3,"name":"LightingResult","type":"","usage":"variable"},{"args":["vec4 pos","vec3 cameraPos","float fogStart","float fogEnd"],"column":6,"comment":"pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y","file":"editor\\assets\\chunks\\common\\effect\\fog.chunk","line":4,"name":"LinearFog","type":"float","usage":"function"},{"args":["vec3 linear"],"column":5,"comment":" #pragma define LinearToSRGB(linear) pow(linear, vec3(0.454545))","file":"editor\\assets\\chunks\\common\\color\\gamma.chunk","line":19,"name":"LinearToSRGB","type":"vec3","usage":"function"},{"args":["v"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\data\\unpack.chunk","line":4,"name":"MOD_FINT_128","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":8,"name":"PI","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":9,"name":"PI2","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":10,"name":"PI4","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":6,"name":"QUATER_PI","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":56,"name":"REFLECTION_PROBE_TYPE_CUBE","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":55,"name":"REFLECTION_PROBE_TYPE_NONE","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":57,"name":"REFLECTION_PROBE_TYPE_PLANAR","type":"","usage":"macro"},{"args":["inout vec3 binormal","inout vec3 normal","in vec3 tangent","float rotationAngle","float mirrorNormal"],"column":5,"comment":" fast rotation for anisotropic offset\r\n rotationAngle: -1 - +1","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":115,"name":"RotateNormalAndBinormal","type":"void","usage":"function"},{"args":["inout vec3 tangent","inout vec3 binormal","vec3 normal","float rotationAngle"],"column":5,"comment":" rotationAngle: radians, 0-2Pi","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":99,"name":"RotateTangentAndBinormal","type":"void","usage":"function"},{"args":["vec3 v","float cosTheta","float sinTheta"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":84,"name":"RotationVecFromAxisY","type":"vec3","usage":"function"},{"args":["vec3 v","float rotateAngleArc"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\coordinates.chunk","line":93,"name":"RotationVecFromAxisY","type":"vec3","usage":"function"},{"args":["vec2 uv","vec2 centerUV","float time","float speed"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\graph-expression\\base.chunk","line":11,"name":"Rotator","type":"vec2","usage":"function"},{"args":["vec3 normal"],"column":5,"comment":"","file":"editor\\assets\\chunks\\builtin\\functionalities\\sh.chunk","line":4,"name":"SHEvaluate","type":"vec3","usage":"function"},{"args":["vec3 gamma"],"column":5,"comment":" #pragma define SRGBToLinear(gamma) pow(gamma, vec3(2.2))","file":"editor\\assets\\chunks\\common\\color\\gamma.chunk","line":6,"name":"SRGBToLinear","type":"vec3","usage":"function"},{"args":["v"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\data\\unpack.chunk","line":3,"name":"STEP_FINT_128","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":76,"name":"SURFACES_MAX_TRANSMIT_DEPTH_VALUE","type":"","usage":"macro"},{"args":["out vec3 lightmapColor","out float dirShadow","out float ao","sampler2D lightingMap","vec2 luv","float lum","vec3 worldNormal"],"column":5,"comment":" for legacy effects","file":"editor\\assets\\chunks\\common\\lighting\\light-map.chunk","line":2,"name":"SampleAndDecodeLightMapColor","type":"void","usage":"function"},{"args":["sampler2D exrRGBE","vec2 uv"],"column":5,"comment":" for exr data texture and sub resources","file":"editor\\assets\\chunks\\common\\texture\\texture-misc.chunk","line":3,"name":"SampleTextureExr","type":"vec3","usage":"function"},{"args":["sampler2D exrRGBE","sampler2D exrSign","vec2 uv"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\texture\\texture-misc.chunk","line":9,"name":"SampleTextureExr","type":"vec3","usage":"function"},{"args":["sampler2D exrRGBE","sampler2D exrSign","sampler2D exrAlpha","vec2 uv"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\texture\\texture-misc.chunk","line":16,"name":"SampleTextureExrWithAlpha","type":"vec4","usage":"function"},{"args":["float distSqr","float invSqrAttRadius"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":10,"name":"SmoothDistAtt","type":"float","usage":"function"},{"args":["float distSqr","float invSqrAttRadius"],"column":6,"comment":" base","file":"editor\\assets\\chunks\\common\\lighting\\attenuation.chunk","line":2,"name":"SmoothDistAtt2","type":"float","usage":"function"},{"args":["vec2 center","vec2 point","float radius","float hardness"],"column":6,"comment":" return 0.0 when out of range\r\n hardness: 0 - 1","file":"editor\\assets\\chunks\\common\\graph-expression\\base.chunk","line":36,"name":"SphereMask","type":"float","usage":"function"},{"args":["vec3 center","vec3 point","float radius","float hardness"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\graph-expression\\base.chunk","line":42,"name":"SphereMask","type":"float","usage":"function"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\legacy\\shading-standard-base.chunk","line":3,"name":"StandardSurface","type":"","usage":"variable"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\r\n for base shape without color usage, such as render-to-shadow","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":12,"name":"SurfacesFragmentAlphaClipOnly","type":"void","usage":"function"},{"args":["out float isRotation"],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_ANISOTROPY_PARAMS\r\n isRotation=1.0: shape(0~1), rotation(0~2PI), 0.0, 0.0\r\n or\r\n isRotation=0.0: shape(0~1), anisoDir.xyz(-1~1)","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":57,"name":"SurfacesFragmentModifyAnisotropyParams","type":"vec4","usage":"function"},{"args":["out vec4 baseColorAndTransparency","out vec3 shade1","out vec3 shade2","in vec3 baseColor"],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE","file":"editor\\assets\\chunks\\surfaces\\default-functions\\toon-fs.chunk","line":5,"name":"SurfacesFragmentModifyBaseColorAndToonShade","type":"void","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":3,"name":"SurfacesFragmentModifyBaseColorAndTransparency","type":"vec4","usage":"function"},{"args":["float roughness"],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_DUAL_LOBE_SPECULAR_PARAMS","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":169,"name":"SurfacesFragmentModifyDualLobeSpecularParams","type":"vec4","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":66,"name":"SurfacesFragmentModifyEmissive","type":"vec3","usage":"function"},{"args":[],"column":6,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_IOR","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":46,"name":"SurfacesFragmentModifyIOR","type":"float","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_PBRPARAMS","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":74,"name":"SurfacesFragmentModifyPBRParams","type":"vec4","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_SSS_PARAMS","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":179,"name":"SurfacesFragmentModifySSSParams","type":"vec4","usage":"function"},{"args":["inout SurfacesMaterialData surfaceData"],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_SHARED_DATA\r\n some material datas use shared raw data, avoid sample / calculate same raw data multiply times, use this function for better performance\r\n this function invokes at last\r\n should use corresponding shading-model header: #include before function define","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":194,"name":"SurfacesFragmentModifySharedData","type":"void","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_TRT_COLOR","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":142,"name":"SurfacesFragmentModifyTRTColor","type":"vec3","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_TRT_PARAMS","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":131,"name":"SurfacesFragmentModifyTRTParams","type":"vec4","usage":"function"},{"args":["in vec3 baseColor"],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_TT_COLOR","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":160,"name":"SurfacesFragmentModifyTTColor","type":"vec3","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_TT_PARAMS","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":150,"name":"SurfacesFragmentModifyTTParams","type":"vec4","usage":"function"},{"args":[],"column":6,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER","file":"editor\\assets\\chunks\\surfaces\\default-functions\\toon-fs.chunk","line":22,"name":"SurfacesFragmentModifyToonShadowCover","type":"float","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR","file":"editor\\assets\\chunks\\surfaces\\default-functions\\toon-fs.chunk","line":30,"name":"SurfacesFragmentModifyToonSpecular","type":"vec4","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER","file":"editor\\assets\\chunks\\surfaces\\default-functions\\toon-fs.chunk","line":14,"name":"SurfacesFragmentModifyToonStepAndFeather","type":"vec4","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_DIFFUSE_PARAMS","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":115,"name":"SurfacesFragmentModifyTransmitDiffuseParams","type":"vec4","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_IN_SCATTERING_COLOR","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":98,"name":"SurfacesFragmentModifyTransmitInScatteringColor","type":"vec3","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_OUT_SCATTERING_COLOR","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":106,"name":"SurfacesFragmentModifyTransmitOutScatteringColor","type":"vec3","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_SCATTERING_PARAMS\r\n scattering related parameters and colors","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":84,"name":"SurfacesFragmentModifyTransmitScatteringParams","type":"vec4","usage":"function"},{"args":[],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":20,"name":"SurfacesFragmentModifyWorldNormal","type":"vec3","usage":"function"},{"args":["inout vec3 worldTangent","inout vec3 worldBinormal","vec3 worldNormal"],"column":5,"comment":" depends on CC_SURFACES_FRAGMENT_MODIFY_WORLD_TANGENT_AND_BINORMAL","file":"editor\\assets\\chunks\\surfaces\\default-functions\\standard-fs.chunk","line":28,"name":"SurfacesFragmentModifyWorldTangentAndBinormal","type":"void","usage":"function"},{"args":["inout LightingResult result","in LightingIntermediateData lightingData","in SurfacesMaterialData surfaceData","in LightingMiscData miscData"],"column":7,"comment":"","file":"editor\\assets\\chunks\\lighting-models\\default-functions\\simple-skin.chunk","line":9,"name":"SurfacesLightingModifyFinalResult","type":"void","usage":"function"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\surfaces\\data-structures\\standard.chunk","line":3,"name":"SurfacesMaterialData","type":"","usage":"variable"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-intermediate.chunk","line":3,"name":"SurfacesStandardVertexIntermediate","type":"","usage":"variable"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":5,"comment":" depends on CC_SURFACES_VERTEX_MODIFY_CLIP_POS","file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":47,"name":"SurfacesVertexModifyClipPos","type":"vec4","usage":"function"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":5,"comment":" depends on CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL","file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":11,"name":"SurfacesVertexModifyLocalNormal","type":"vec3","usage":"function"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":5,"comment":" depends on CC_SURFACES_VERTEX_MODIFY_LOCAL_POS","file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":3,"name":"SurfacesVertexModifyLocalPos","type":"vec3","usage":"function"},{"args":["inout SurfacesStandardVertexIntermediate In"],"column":5,"comment":" depends on CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\r\n some vertex datas use shared raw data, avoid sample / calculate same raw data multiply times, use this function for better performance\r\n this function invokes before world transform","file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":31,"name":"SurfacesVertexModifyLocalSharedData","type":"void","usage":"function"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":7,"comment":" depends on CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT","file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":20,"name":"SurfacesVertexModifyLocalTangent","type":"vec4","usage":"function"},{"args":["in SurfacesStandardVertexIntermediate In","vec2 originShadowBias"],"column":5,"comment":" depends on CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\r\n shadow bias for submesh-level","file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":79,"name":"SurfacesVertexModifyShadowBias","type":"vec2","usage":"function"},{"args":["inout SurfacesStandardVertexIntermediate In"],"column":5,"comment":" depends on CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\r\n some vertex datas use shared raw data, avoid sample / calculate same raw data multiply times, use this function for better performance\r\n this function invokes at last","file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":89,"name":"SurfacesVertexModifySharedData","type":"void","usage":"function"},{"args":["inout SurfacesStandardVertexIntermediate In"],"column":5,"comment":" depends on CC_SURFACES_VERTEX_MODIFY_UV","file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":55,"name":"SurfacesVertexModifyUV","type":"void","usage":"function"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":5,"comment":" depends on CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL","file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":66,"name":"SurfacesVertexModifyWorldNormal","type":"vec3","usage":"function"},{"args":["in SurfacesStandardVertexIntermediate In"],"column":5,"comment":" depends on CC_SURFACES_VERTEX_MODIFY_WORLD_POS","file":"editor\\assets\\chunks\\surfaces\\default-functions\\common-vs.chunk","line":39,"name":"SurfacesVertexModifyWorldPos","type":"vec3","usage":"function"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":72,"name":"TONE_MAPPING_ACES","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":73,"name":"TONE_MAPPING_LINEAR","type":"","usage":"macro"},{"args":["vec3 vectorFromNormalMap"],"column":5,"comment":" tangent space -> world space\r\n same as TransformVector","file":"editor\\assets\\chunks\\common\\graph-expression\\base.chunk","line":23,"name":"TransformNormalMap","type":"vec3","usage":"function"},{"args":["value","bit"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":15,"name":"UnpackBitFromFloat","type":"","usage":"macro"},{"args":["vec3 vatBoundingBoxMin","vec3 vatBoundingBoxMax","vec3 localPos"],"column":5,"comment":" calculate simulation voxel coordinates","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":105,"name":"VATCalculateFluidVoxelUV","type":"vec3","usage":"function"},{"args":["vec2 lutTexResolution","float meshVertexCount"],"column":6,"comment":"/////////////////////////////////////////// public functions\r\n auto calculation frame count for fluid","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":44,"name":"VATCalculateFrameCount","type":"float","usage":"function"},{"args":["out vec2 thisFrameUV","out vec2 nextFrameUV","vec2 meshUV","float frameCount","float animSpeed","float elapseTime"],"column":6,"comment":" meshUV use texCoord0 for fluid\r\n meshUV use texCoord1 for rigid-body and soft-body","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":52,"name":"VATGetAnimUV","type":"float","usage":"function"},{"args":["out vec2 thisFrameUV","out vec2 nextFrameUV","vec2 meshUV","float frameCount","float animSpeed","float elapseTime","sampler2D lutTexture"],"column":6,"comment":" VAT with LUT, fluid only","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":61,"name":"VATGetAnimUV","type":"float","usage":"function"},{"args":["vec3 meshNormal","vec2 thisFrameUV","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":5,"comment":" meshNormal is up-axis for fluid","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":80,"name":"VATGetLocalNormal","type":"vec3","usage":"function"},{"args":["vec3 meshNormal","vec2 thisFrameUV","vec2 nextFrameUV","float frameLerp","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":94,"name":"VATGetLocalNormal","type":"vec3","usage":"function"},{"args":["vec2 thisFrameUV","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture"],"column":5,"comment":" return absolute position for fluid\r\n return position offset for soft-body","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":74,"name":"VATGetLocalPosition","type":"vec3","usage":"function"},{"args":["vec2 thisFrameUV","vec2 nextFrameUV","float frameLerp","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture"],"column":5,"comment":" for smooth animation","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":88,"name":"VATGetLocalPosition","type":"vec3","usage":"function"},{"args":["inout vec3 meshLocalPos","inout vec3 meshLocalNormal","inout vec3 meshLocalTangent","in vec4 meshVertexColor","vec2 thisFrameUV","float pivMax","float pivMin","float posMax","float posMin","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture","sampler2D vatPositionAlphaTexture","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":5,"comment":"//////////////////////////////////////////////////////////////Rigid-body","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":121,"name":"VATGetLocalPositionRigidBody20","type":"void","usage":"function"},{"args":["inout vec3 meshLocalPos","inout vec3 meshLocalNormal","inout vec3 meshLocalTangent","in vec4 meshVertexColor","vec2 thisFrameUV","float pivMax","float pivMin","float posMax","float posMin","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture","sampler2D vatPositionAlphaTexture","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":151,"name":"VATGetLocalPositionRigidBody20_UE","type":"void","usage":"function"},{"args":["inout vec3 meshLocalPos","inout vec3 meshLocalNormal","inout vec3 meshLocalTangent","in vec2 meshUV2","in vec2 meshUV3","vec2 thisFrameUV","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture","sampler2D vatPositionAlphaTexture","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture","bool isZUp"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":186,"name":"VATGetLocalPositionRigidBody30","type":"void","usage":"function"},{"args":["inout vec3 meshLocalPos","inout vec3 meshLocalNormal","inout vec3 meshLocalTangent","in vec2 meshUV2","in vec2 meshUV3","vec2 thisFrameUV","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture","sampler2D vatPositionAlphaTexture","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":259,"name":"VATGetLocalPositionRigidBody30_Cocos","type":"void","usage":"function"},{"args":["inout vec3 meshLocalPos","inout vec3 meshLocalNormal","inout vec3 meshLocalTangent","in vec2 meshUV2","in vec2 meshUV3","vec2 thisFrameUV","sampler2D vatPositionTexture","sampler2D vatPositionSignTexture","sampler2D vatPositionAlphaTexture","sampler2D vatRotationTexture","sampler2D vatRotationSignTexture","sampler2D vatRotationAlphaTexture"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\mesh\\vat-animation.chunk","line":245,"name":"VATGetLocalPositionRigidBody30_UE","type":"void","usage":"function"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":49,"name":"VSOutput_clipPos","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":13,"name":"VSOutput_faceSideSign","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":41,"name":"VSOutput_fogFactor","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":30,"name":"VSOutput_lightMapUV","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":45,"name":"VSOutput_localPos","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":22,"name":"VSOutput_mirrorNormal","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":37,"name":"VSOutput_reflectionProbeId","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":34,"name":"VSOutput_shadowBias","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":14,"name":"VSOutput_texcoord","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":26,"name":"VSOutput_texcoord1","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":17,"name":"VSOutput_vertexColor","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":12,"name":"VSOutput_worldNormal","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":11,"name":"VSOutput_worldPos","type":"","usage":"macro"},{"args":[],"column":1,"comment":"","file":"editor\\assets\\chunks\\shading-entries\\data-structures\\vs-output.chunk","line":21,"name":"VSOutput_worldTangent","type":"","usage":"macro"},{"args":["anytype Value_Radian"],"column":1,"comment":"","file":"","line":1,"name":"acos","type":"anytype","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" TRUE if all elements are non-zero","file":"","line":1,"name":"all","type":"bool","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" Returns TRUE if any one element is non-zero","file":"","line":1,"name":"any","type":"bool","usage":"function"},{"args":["anytype Value_Radian"],"column":1,"comment":"","file":"","line":1,"name":"asin","type":"anytype","usage":"function"},{"args":["anytype y_Div_x"],"column":1,"comment":" Calculates the arctangent of a given value, no quadrant can be determined","file":"","line":1,"name":"atan","type":"anytype","usage":"function"},{"args":["float y","float x"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":243,"name":"atan2","type":"float","usage":"function"},{"args":["anytype y","anytype x"],"column":1,"comment":" Computes the arctangent of y/x and can determine the quadrant","file":"","line":1,"name":"atan2","type":"anytype","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"attribute","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"bool","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"break","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"bvec2","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"bvec3","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"bvec4","type":"","usage":"keyword"},{"args":[],"column":26,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":15,"name":"cc_ambientGround","type":"vec4","usage":"variable"},{"args":[],"column":23,"comment":" view matrix","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":14,"name":"cc_ambientSky","type":"vec4","usage":"variable"},{"args":[],"column":24,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":8,"name":"cc_cameraPos","type":"vec4","usage":"variable"},{"args":[],"column":28,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":7,"name":"cc_debug_view_mode","type":"vec4","usage":"variable"},{"args":[],"column":21,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":11,"name":"cc_exposure","type":"vec4","usage":"variable"},{"args":[],"column":19,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":18,"name":"cc_fogAdd","type":"vec4","usage":"variable"},{"args":[],"column":20,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":17,"name":"cc_fogBase","type":"vec4","usage":"variable"},{"args":[],"column":21,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":16,"name":"cc_fogColor","type":"vec4","usage":"variable"},{"args":["LIGHTS_PER_PASS"],"column":39,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-forward-light.chunk","line":3,"name":"cc_lightColor","type":"vec4","usage":"variable"},{"args":["LIGHTS_PER_PASS"],"column":37,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-forward-light.chunk","line":5,"name":"cc_lightDir","type":"vec4","usage":"variable"},{"args":["LIGHTS_PER_PASS"],"column":38,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-forward-light.chunk","line":2,"name":"cc_lightPos","type":"vec4","usage":"variable"},{"args":["LIGHTS_PER_PASS"],"column":48,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-forward-light.chunk","line":4,"name":"cc_lightSizeRangeAngle","type":"vec4","usage":"variable"},{"args":[],"column":31,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":4,"name":"cc_lightingMapUVParam","type":"vec4","usage":"variable"},{"args":[],"column":28,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":5,"name":"cc_localShadowBias","type":"vec4","usage":"variable"},{"args":[],"column":25,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":13,"name":"cc_mainLitColor","type":"vec4","usage":"variable"},{"args":[],"column":23,"comment":" x: single mode, yzw: composite and misc flags combination value","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":12,"name":"cc_mainLitDir","type":"vec4","usage":"variable"},{"args":[],"column":25,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":2,"name":"cc_matLightView","type":"mat4","usage":"variable"},{"args":[],"column":29,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":3,"name":"cc_matLightViewProj","type":"mat4","usage":"variable"},{"args":[],"column":22,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":4,"name":"cc_matProj","type":"mat4","usage":"variable"},{"args":[],"column":25,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":5,"name":"cc_matProjInv","type":"mat4","usage":"variable"},{"args":[],"column":22,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":2,"name":"cc_matView","type":"mat4","usage":"variable"},{"args":[],"column":25,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":3,"name":"cc_matViewInv","type":"mat4","usage":"variable"},{"args":[],"column":26,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":6,"name":"cc_matViewProj","type":"mat4","usage":"variable"},{"args":[],"column":29,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":7,"name":"cc_matViewProjInv","type":"mat4","usage":"variable"},{"args":[],"column":21,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":2,"name":"cc_matWorld","type":"mat4","usage":"variable"},{"args":[],"column":23,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":3,"name":"cc_matWorldIT","type":"mat4","usage":"variable"},{"args":[],"column":23,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":4,"name":"cc_nativeSize","type":"vec4","usage":"variable"},{"args":[],"column":20,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":19,"name":"cc_nearFar","type":"vec4","usage":"variable"},{"args":[],"column":25,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":11,"name":"cc_planarNDInfo","type":"vec4","usage":"variable"},{"args":[],"column":22,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":5,"name":"cc_probeInfo","type":"vec4","usage":"variable"},{"args":[],"column":33,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":6,"name":"cc_reflectionProbeData1","type":"vec4","usage":"variable"},{"args":[],"column":33,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-local.chunk","line":7,"name":"cc_reflectionProbeData2","type":"vec4","usage":"variable"},{"args":[],"column":24,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":10,"name":"cc_screenScale","type":"vec4","usage":"variable"},{"args":[],"column":23,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":3,"name":"cc_screenSize","type":"vec4","usage":"variable"},{"args":[],"column":24,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":10,"name":"cc_shadowColor","type":"vec4","usage":"variable"},{"args":[],"column":35,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":4,"name":"cc_shadowInvProjDepthInfo","type":"vec4","usage":"variable"},{"args":[],"column":27,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":9,"name":"cc_shadowLPNNInfo","type":"vec4","usage":"variable"},{"args":[],"column":27,"comment":" x -> cc_matLightProj[0]; y -> cc_matLightProj[5]; z -> 1.0 / cc_matLightProj[0]; w -> 1.0 / cc_matLightProj[5];","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":7,"name":"cc_shadowNFLSInfo","type":"vec4","usage":"variable"},{"args":[],"column":32,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":5,"name":"cc_shadowProjDepthInfo","type":"vec4","usage":"variable"},{"args":[],"column":27,"comment":" x -> cc_matLightProj[10]([2][2]); y -> cc_matLightProj[14]([2][3]); z -> cc_matLightProj[11]([3][2]); w -> cc_matLightProj[15]([3][3]);","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":6,"name":"cc_shadowProjInfo","type":"vec4","usage":"variable"},{"args":[],"column":27,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-shadow.chunk","line":8,"name":"cc_shadowWHPBInfo","type":"vec4","usage":"variable"},{"args":[],"column":29,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":9,"name":"cc_surfaceTransform","type":"vec4","usage":"variable"},{"args":[],"column":19,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":2,"name":"cc_time","type":"vec4","usage":"variable"},{"args":[],"column":21,"comment":" xyz: camera position w: flip NDC sign","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-global.chunk","line":20,"name":"cc_viewPort","type":"vec4","usage":"variable"},{"args":[],"column":29,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-world-bound.chunk","line":2,"name":"cc_worldBoundCenter","type":"vec4","usage":"variable"},{"args":[],"column":34,"comment":"","file":"editor\\assets\\chunks\\builtin\\uniforms\\cc-world-bound.chunk","line":3,"name":"cc_worldBoundHalfExtents","type":"vec4","usage":"variable"},{"args":["anytype Data"],"column":1,"comment":" Take the integer that is greater than or equal to it and closest to it","file":"","line":1,"name":"ceil","type":"UINTVECType","usage":"function"},{"args":["anytype Data","anytype MinValue","anytype MaxValue"],"column":1,"comment":" Be especially careful with UINT variables, which must be converted to int before being passed in","file":"","line":1,"name":"clamp","type":"anytype","usage":"function"},{"args":["value"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":31,"name":"clip","type":"","usage":"macro"},{"args":["anytype AnyElementIsLessThanZeroThenClip"],"column":1,"comment":"","file":"","line":1,"name":"clip","type":"void","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"const","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"continue","type":"","usage":"keyword"},{"args":["anytype Value_Radian"],"column":1,"comment":"","file":"","line":1,"name":"cos","type":"anytype","usage":"function"},{"args":["anytype Value_Radian"],"column":1,"comment":" Hyperbolic sine","file":"","line":1,"name":"cosh","type":"anytype","usage":"function"},{"args":["VECType Data1","VECType Data2"],"column":1,"comment":" Left-hand rule","file":"","line":1,"name":"cross","type":"VECType","usage":"function"},{"args":["anytype ShaderInputData"],"column":1,"comment":"","file":"","line":1,"name":"dFdx","type":"anytype","usage":"function"},{"args":["anytype ShaderInputData"],"column":1,"comment":" Low precision, not supported by GLES","file":"","line":1,"name":"dFdxCoarse","type":"anytype","usage":"function"},{"args":["anytype ShaderInputData"],"column":1,"comment":" High precision, not supported by GLES","file":"","line":1,"name":"dFdxFine","type":"anytype","usage":"function"},{"args":["anytype ShaderInputData"],"column":1,"comment":"","file":"","line":1,"name":"dFdy","type":"anytype","usage":"function"},{"args":["anytype ShaderInputData"],"column":1,"comment":" Low precision, not supported by GLES","file":"","line":1,"name":"dFdyCoarse","type":"anytype","usage":"function"},{"args":["anytype ShaderInputData"],"column":1,"comment":" High precision, not supported by GLES","file":"","line":1,"name":"dFdyFine","type":"anytype","usage":"function"},{"args":["highp vec4 rgba"],"column":12,"comment":"","file":"editor\\assets\\chunks\\common\\data\\unpack.chunk","line":6,"name":"decode32","type":"float","usage":"function"},{"args":["floatVECType Value_Radian"],"column":1,"comment":" Turn radians into degrees","file":"","line":1,"name":"degrees","type":"floatVECType","usage":"function"},{"args":["MAT4 Data"],"column":1,"comment":" Matrix ranking","file":"","line":1,"name":"determinant","type":"float","usage":"function"},{"args":["anytype AnyElementIsLessThanZeroThenClip"],"column":1,"comment":"","file":"","line":1,"name":"discard","type":"void","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"discard","type":"","usage":"keyword"},{"args":["VECType Point1","VECType Point2"],"column":1,"comment":"","file":"","line":1,"name":"distance","type":"float","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"do","type":"","usage":"keyword"},{"args":["VECType Data1","VECType Data2"],"column":1,"comment":"","file":"","line":1,"name":"dot","type":"float","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"else","type":"","usage":"keyword"},{"args":["anytype Data1","anytype Data2"],"column":1,"comment":" Make a judgment for each element of Data1 and Data2","file":"","line":1,"name":"equal","type":"boolVECType","usage":"function"},{"args":["data1","data2"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":28,"name":"equalf","type":"","usage":"macro"},{"args":["data1","data2","epsilonValue"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":30,"name":"equalf_epsilon","type":"","usage":"macro"},{"args":["data1","data2"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":29,"name":"equalf_lowp","type":"","usage":"macro"},{"args":["vec3 euler"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":224,"name":"eulerToQuat","type":"vec4","usage":"function"},{"args":["anytype Power"],"column":1,"comment":" Exponent with natural logarithm base","file":"","line":1,"name":"exp","type":"anytype","usage":"function"},{"args":["anytype Power"],"column":1,"comment":" Exponent with a base of 2","file":"","line":1,"name":"exp2","type":"anytype","usage":"function"},{"args":["floatVECType Normal","floatVECType Incident","floatVECType Normal_referenced"],"column":1,"comment":"","file":"","line":1,"name":"faceforward","type":"floatVECType","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"false","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"float","type":"","usage":"keyword"},{"args":["in vec3 v"],"column":5,"comment":" Assume normalized input. Output is on [-1, 1] for each component.","file":"editor\\assets\\chunks\\common\\math\\octahedron-transform.chunk","line":7,"name":"float32x3_to_oct","type":"vec2","usage":"function"},{"args":["floatVECType value"],"column":1,"comment":" equivalent to asint, reads the floating point value as INT bit by bit, without changing the bit value","file":"","line":1,"name":"floatBitsToInt","type":"UINTVECType","usage":"function"},{"args":["floatVECType value"],"column":1,"comment":" equivalent to asuint, reads the floating point value as a UINT number bit by bit, without changing the bit value","file":"","line":1,"name":"floatBitsToUint","type":"UINTVECType","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" Take the integer that is less than or equal to it and closest to it","file":"","line":1,"name":"floor","type":"UINTVECType","usage":"function"},{"args":["double a","double b","double c"],"column":1,"comment":" Double type and safe calculation of a*b+c","file":"","line":1,"name":"fma","type":"double","usage":"function"},{"args":["floatVECType Data","floatVECType multiplier","floatVECType bias"],"column":1,"comment":" Equivalent to mad","file":"","line":1,"name":"fma","type":"floatVECType","usage":"function"},{"args":["floatVECType Data","floatVECType Divisor"],"column":1,"comment":" Floating-point special remainder function, equivalent to Data % Divisor","file":"","line":1,"name":"fmod","type":"floatVECType","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"for","type":"","usage":"keyword"},{"args":["anytype Data"],"column":1,"comment":" Take its fractional part","file":"","line":1,"name":"fract","type":"anytype","usage":"function"},{"args":["sampler2D tex","vec2 P","vec2 dPdx","vec2 dPdy"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\texture\\texture-lod.chunk","line":29,"name":"fragTextureGrad","type":"vec4","usage":"function"},{"args":["samplerCube tex","vec3 P","vec3 dPdx","vec3 dPdy"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\texture\\texture-lod.chunk","line":41,"name":"fragTextureGrad","type":"vec4","usage":"function"},{"args":["sampler2D tex","vec2 coord","float lod"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\texture\\texture-lod.chunk","line":5,"name":"fragTextureLod","type":"vec4","usage":"function"},{"args":["samplerCube tex","vec3 coord","float lod"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\texture\\texture-lod.chunk","line":17,"name":"fragTextureLod","type":"vec4","usage":"function"},{"args":["anytype Data","out anytype OutData"],"column":1,"comment":" decompose a number and return its tail, parameter 2 is the exponent of the output, with a base of 10","file":"","line":1,"name":"frexp","type":"anytype","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" Returns the sum of the absolute values of the partial derivatives of the input data, i.e., the sum of the absolute values of each of the two partial derivatives, which is equivalent to taking the absolute values internally before adding the gradients return abs(ddx)+abs(ddy)","file":"","line":1,"name":"fwidth","type":"anytype","usage":"function"},{"args":["anytype ShaderInputData"],"column":1,"comment":" return abs(dFdx) + abs(dFdy)","file":"","line":1,"name":"fwidth","type":"anytype","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"gl_FragColor","type":"","usage":"variable"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"gl_FragDepth","type":"","usage":"variable"},{"args":["anytype Data1","anytype Data2"],"column":1,"comment":" Judgment for each element of Data1 and Data2","file":"","line":1,"name":"greaterThan","type":"boolVECType","usage":"function"},{"args":["anytype Data1","anytype Data2"],"column":1,"comment":" Judgment for each element of Data1 and Data2","file":"","line":1,"name":"greaterThanEqual","type":"boolVECType","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"highp","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"if","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"in","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"inout","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"int","type":"","usage":"keyword"},{"args":["INTVECType value"],"column":1,"comment":" Equivalent to asfloat, reads int numbers as floating point values bit by bit, without changing the bit value","file":"","line":1,"name":"intBitsToFloat","type":"floatVECType","usage":"function"},{"args":["floatVECType interpolant"],"column":1,"comment":"","file":"","line":1,"name":"interpolateAtCentroid","type":"floatVECType","usage":"function"},{"args":["floatVECType interpolant","vec2 offset"],"column":1,"comment":"","file":"","line":1,"name":"interpolateAtOffset","type":"floatVECType","usage":"function"},{"args":["floatVECType interpolant","int sampleIndex"],"column":1,"comment":"","file":"","line":1,"name":"interpolateAtSample","type":"floatVECType","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" 1 / sqrt(Data)","file":"","line":1,"name":"inversesqrt","type":"anytype","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" whether it is finite, remove the possibility of irrational numbers and infinite size values, mainly used to judge the validity","file":"","line":1,"name":"isfinite","type":"bool","usage":"function"},{"args":["float x"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":5,"name":"isinf","type":"bool","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" whether it is infinitely large or infinitely small","file":"","line":1,"name":"isinf","type":"bool","usage":"function"},{"args":["vec2 val"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":20,"name":"isinfs","type":"bool","usage":"function"},{"args":["vec3 val"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":23,"name":"isinfs","type":"bool","usage":"function"},{"args":["vec4 val"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":26,"name":"isinfs","type":"bool","usage":"function"},{"args":["float val"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":2,"name":"isnan","type":"bool","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" whether it is an irrational number","file":"","line":1,"name":"isnan","type":"bool","usage":"function"},{"args":["vec2 val"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":10,"name":"isnans","type":"bool","usage":"function"},{"args":["vec3 val"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":13,"name":"isnans","type":"bool","usage":"function"},{"args":["vec4 val"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":16,"name":"isnans","type":"bool","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"ivec2","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"ivec3","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"ivec4","type":"","usage":"keyword"},{"args":["anytype Multiplier","anytype Power"],"column":1,"comment":" return Multiplier * 2^Power","file":"","line":1,"name":"ldexp","type":"anytype","usage":"function"},{"args":["VECType Data"],"column":1,"comment":"","file":"","line":1,"name":"length","type":"float","usage":"function"},{"args":["value1","value2","value2Multiplier"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\common-define.chunk","line":32,"name":"lerp","type":"","usage":"macro"},{"args":["anytype Data1_Left","anytype Data2_Right","anytype Coef_DirectMulToData2"],"column":1,"comment":"","file":"","line":1,"name":"lerp","type":"anytype","usage":"function"},{"args":["anytype Data1","anytype Data2"],"column":1,"comment":" Judge each element of Data1 and Data2","file":"","line":1,"name":"lessThan","type":"boolVECType","usage":"function"},{"args":["anytype Data1","anytype Data2"],"column":1,"comment":" Make a judgment for each element of Data1 and Data2","file":"","line":1,"name":"lessThanEqual","type":"boolVECType","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" Base on the natural logarithm e","file":"","line":1,"name":"log","type":"anytype","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" Base on 10","file":"","line":1,"name":"log10","type":"anytype","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" Base on 2","file":"","line":1,"name":"log2","type":"anytype","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"lowp","type":"","usage":"keyword"},{"args":["anytype A","anytype B","anytype C"],"column":1,"comment":" Returns A*B+C","file":"","line":1,"name":"mad","type":"anytype","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"mat2","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"mat3","type":"","usage":"keyword"},{"args":["mat3 mat"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":189,"name":"mat3ToQuat","type":"vec4","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"mat4","type":"","usage":"keyword"},{"args":["vec4 q","vec3 t","vec3 s"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":98,"name":"matFromRTS","type":"mat4","usage":"function"},{"args":["MATType m1","MATType m2"],"column":1,"comment":" Calculate the product of two matrices one by one for each element","file":"","line":1,"name":"matrixCompMult","type":"MATType","usage":"function"},{"args":["vec4 q","vec3 p"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":76,"name":"matrixFromRT","type":"mat4","usage":"function"},{"args":["anytype A","anytype B"],"column":1,"comment":"","file":"","line":1,"name":"max","type":"anytype","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"mediump","type":"","usage":"keyword"},{"args":["anytype A","anytype B"],"column":1,"comment":"","file":"","line":1,"name":"min","type":"anytype","usage":"function"},{"args":["anytype Data1_Left","anytype Data2_Right","anytype Coef_DirectMulToData2"],"column":1,"comment":"","file":"","line":1,"name":"mix","type":"anytype","usage":"function"},{"args":["floatVECType Data","floatVECType Divisor"],"column":1,"comment":" Floating-point-specific remainder function, equivalent to Data % divide","file":"","line":1,"name":"mod","type":"floatVECType","usage":"function"},{"args":["anytype Data","out INTVECType OutData_IntegerPortion"],"column":1,"comment":" return the fractional part, parameter 2 is the output of the integer part, the sign of these two parts will be the same as the input value","file":"","line":1,"name":"modf","type":"floatVECType","usage":"function"},{"args":["anytype Data1","anytype Data2"],"column":1,"comment":"","file":"","line":1,"name":"mul","type":"anytype","usage":"function"},{"args":["VECType param"],"column":1,"comment":" Can only be used in ShaderModel1","file":"","line":1,"name":"noise","type":"float","usage":"function"},{"args":["VECType Data"],"column":1,"comment":"","file":"","line":1,"name":"normalize","type":"VECType","usage":"function"},{"args":["anytype Data1","anytype Data2"],"column":1,"comment":" Judgment for each element of Data1 and Data2","file":"","line":1,"name":"notEqual","type":"boolVECType","usage":"function"},{"args":["vec2 e"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\octahedron-transform.chunk","line":14,"name":"oct_to_float32x3","type":"vec3","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"out","type":"","usage":"keyword"},{"args":["float depth"],"column":5,"comment":" float <--> RGBA8","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":4,"name":"packDepthToRGBA","type":"vec4","usage":"function"},{"args":["out type mainPart","out type modPart","highp type data"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":24,"name":"packHighpData","type":"void","usage":"function"},{"args":["out type mainPart","out type modPart","highp type data","const float modValue"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":32,"name":"packHighpData","type":"void","usage":"function"},{"args":["vec3 rgb"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\data\\unpack.chunk","line":15,"name":"packRGBE","type":"vec4","usage":"function"},{"args":["anytype Base","anytype Power"],"column":1,"comment":"","file":"","line":1,"name":"pow","type":"anytype","usage":"function"},{"args":["vec4 a","vec4 b"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":129,"name":"quatMultiply","type":"vec4","usage":"function"},{"args":["vec4 q"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":247,"name":"quatToEuler","type":"vec3","usage":"function"},{"args":["vec4 q"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":168,"name":"quatToMat3","type":"mat3","usage":"function"},{"args":["vec4 q"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":184,"name":"quatToMat4","type":"mat4","usage":"function"},{"args":["vec3 xAxis","vec3 yAxis","vec3 zAxis"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":11,"name":"quaternionFromAxis","type":"vec4","usage":"function"},{"args":["float angle","vec3 axis"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":2,"name":"quaternionFromAxisAngle","type":"vec4","usage":"function"},{"args":["vec3 angle"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":54,"name":"quaternionFromEuler","type":"vec4","usage":"function"},{"args":["floatVECType Value_Degree"],"column":1,"comment":" Turn degrees into radians","file":"","line":1,"name":"radians","type":"floatVECType","usage":"function"},{"args":["vec2 seeds_zero_to_one"],"column":6,"comment":" random number\r\n seeds value must be between zero to one, otherwise get 0\r\n such as fract(cc_time.z * FSInput_texcoord)","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":60,"name":"rand","type":"float","usage":"function"},{"args":["anytype Data"],"column":1,"comment":"","file":"","line":1,"name":"rcp","type":"anytype","usage":"function"},{"args":["VECType IncidentDirection","VECType Normal"],"column":1,"comment":" IncidentDirection is from elsewhere to pixel","file":"","line":1,"name":"reflect","type":"VECType","usage":"function"},{"args":["VECType IncidentDirection","VECType Normal","float ior"],"column":1,"comment":" IncidentDirection is from elsewhere to pixel","file":"","line":1,"name":"refract","type":"VECType","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"return","type":"","usage":"keyword"},{"args":["inout vec2 corner","float angle"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":161,"name":"rotateCorner","type":"void","usage":"function"},{"args":["vec3 pos","vec3 xAxis","vec3 yAxis","vec3 zAxis","vec4 q"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":154,"name":"rotateInLocalSpace","type":"vec3","usage":"function"},{"args":["vec3 v","vec3 axis","float theta"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":150,"name":"rotateVecFromAxis","type":"vec3","usage":"function"},{"args":["inout vec3 v","vec4 q"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":138,"name":"rotateVecFromQuat","type":"void","usage":"function"},{"args":["float value"],"column":8,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":33,"name":"round","type":"float","usage":"function"},{"args":["vec2 value"],"column":7,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":37,"name":"round","type":"vec2","usage":"function"},{"args":["vec3 value"],"column":7,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":38,"name":"round","type":"vec3","usage":"function"},{"args":["vec4 value"],"column":7,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":39,"name":"round","type":"vec4","usage":"function"},{"args":["anytype Data"],"column":1,"comment":" Rounding","file":"","line":1,"name":"round","type":"anytype","usage":"function"},{"args":["float value"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":42,"name":"rsqrt","type":"float","usage":"function"},{"args":["vec2 value"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":45,"name":"rsqrt","type":"vec2","usage":"function"},{"args":["vec3 value"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":46,"name":"rsqrt","type":"vec3","usage":"function"},{"args":["vec4 value"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":47,"name":"rsqrt","type":"vec4","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"sampler1D","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"sampler1DShadow","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"sampler2D","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"sampler2DShadow","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"sampler3D","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"samplerCube","type":"","usage":"keyword"},{"args":["float value"],"column":6,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":49,"name":"saturate","type":"float","usage":"function"},{"args":["vec2 value"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":52,"name":"saturate","type":"vec2","usage":"function"},{"args":["vec3 value"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":53,"name":"saturate","type":"vec3","usage":"function"},{"args":["vec4 value"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\number.chunk","line":54,"name":"saturate","type":"vec4","usage":"function"},{"args":["anytype Data_ClampTo_0_and_1"],"column":1,"comment":"","file":"","line":1,"name":"saturate","type":"anytype","usage":"function"},{"args":["inout mat4 m","float s"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\math\\transform.chunk","line":123,"name":"scaleMatrix","type":"void","usage":"function"},{"args":["anytype GetSign_LessThanZero_Or_MoreThanZero_Or_Zero"],"column":1,"comment":"","file":"","line":1,"name":"sign","type":"INTVECType","usage":"function"},{"args":["vec2 v"],"column":5,"comment":" Returns +/-1","file":"editor\\assets\\chunks\\common\\math\\octahedron-transform.chunk","line":2,"name":"signNotZero","type":"vec2","usage":"function"},{"args":["anytype Value_Radian"],"column":1,"comment":"","file":"","line":1,"name":"sin","type":"anytype","usage":"function"},{"args":["anytype Value_Radian","out anytype SinValue","out anytype CosValue"],"column":1,"comment":" Returns both sine and cosine","file":"","line":1,"name":"sincos","type":"void","usage":"function"},{"args":["anytype min","anytype max","anytype interpolate"],"column":1,"comment":" Do Hermite smoothing for the specified parameter 3, so that it changes from linear to curved, if the parameter 3 falls outside the min and max range, then Clamp, note that it is not a real Hermite curve, does not involve the tangent vector, there is not much controllability, can only be seen as a typical Hermite curve smoothing only","file":"","line":1,"name":"smoothstep","type":"anytype","usage":"function"},{"args":["anytype Data"],"column":1,"comment":"","file":"","line":1,"name":"sqrt","type":"anytype","usage":"function"},{"args":["anytype A","anytype B"],"column":1,"comment":" return A <= B or B >= A floating point number, remove the bool value conversion","file":"","line":1,"name":"step","type":"float","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"struct","type":"","usage":"keyword"},{"args":["anytype Value_Radian"],"column":1,"comment":"","file":"","line":1,"name":"tan","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTexelCoord","int lod"],"column":1,"comment":"","file":"","line":1,"name":"texelFetch","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTexelCoord","int lod","INTVECType vOffset"],"column":1,"comment":"","file":"","line":1,"name":"texelFetchOffset","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","__opt float bias"],"column":1,"comment":"","file":"","line":1,"name":"texture","type":"anytype","usage":"function"},{"args":["sampler2D ss","float2 v2TextureCoord"],"column":1,"comment":"","file":"","line":1,"name":"texture2D","type":"anytype","usage":"function"},{"args":["sampler2D ss","float2 v2TextureCoord","float lod"],"column":1,"comment":"","file":"","line":1,"name":"texture2DLodEXT","type":"anytype","usage":"function"},{"args":["samplerCUBE ss","float3 v3TextureCoord"],"column":1,"comment":"","file":"","line":1,"name":"textureCUBE","type":"anytype","usage":"function"},{"args":["samplerCUBE ss","float3 v3TextureCoord","float lod"],"column":1,"comment":"","file":"","line":1,"name":"textureCUBELodEXT","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","float lod"],"column":1,"comment":"","file":"","line":1,"name":"textureGrad","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","float lod","INTVECType vOffset"],"column":1,"comment":"","file":"","line":1,"name":"textureGradOffset","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","float lod"],"column":1,"comment":"","file":"","line":1,"name":"textureLod","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","float lod","INTVECType vOffset"],"column":1,"comment":"","file":"","line":1,"name":"textureLodOffset","type":"anytype","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord","INTVECType vOffset","__opt float bias"],"column":1,"comment":"","file":"","line":1,"name":"textureOffset","type":"anytype","usage":"function"},{"args":["sampler any_type_tex"],"column":1,"comment":" Query the number of mip, __VERSION__>=430","file":"","line":1,"name":"textureQueryLevels","type":"int","usage":"function"},{"args":["sampler any_type_tex","floatVECType vTextureCoord"],"column":1,"comment":"","file":"","line":1,"name":"textureQueryLod","type":"vec2","usage":"function"},{"args":["sampler MSAAtex"],"column":1,"comment":" Query the number of MSAA sampling points, __VERSION__>=450","file":"","line":1,"name":"textureSamples","type":"int","usage":"function"},{"args":["sampler any_type_tex","int lod"],"column":1,"comment":"","file":"","line":1,"name":"textureSize","type":"INTVECType","usage":"function"},{"args":["MAT4 Data"],"column":1,"comment":"","file":"","line":1,"name":"transpose","type":"MAT4","usage":"function"},{"args":["mat3 v"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\lighting\\rect-area-light.chunk","line":3,"name":"transposeMat3","type":"mat3","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"true","type":"","usage":"keyword"},{"args":["anytype Data"],"column":1,"comment":" Fetching integer parts","file":"","line":1,"name":"trunc","type":"anytype","usage":"function"},{"args":["UINTVECType value"],"column":1,"comment":" equivalent to asfloat, which reads UINT numbers as floating point values bit by bit, without changing the bit value","file":"","line":1,"name":"uintBitsToFloat","type":"floatVECType","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"uniform","type":"","usage":"keyword"},{"args":["type mainPart","type modPart"],"column":11,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":20,"name":"unpackHighpData","type":"type","usage":"function"},{"args":["type mainPart","type modPart","const float modValue"],"column":11,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":28,"name":"unpackHighpData","type":"type","usage":"function"},{"args":["color"],"column":1,"comment":"","file":"editor\\assets\\chunks\\common\\data\\packing.chunk","line":11,"name":"unpackRGBAToDepth","type":"","usage":"macro"},{"args":["vec4 rgbe"],"column":5,"comment":"","file":"editor\\assets\\chunks\\common\\data\\unpack.chunk","line":29,"name":"unpackRGBE","type":"vec3","usage":"function"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"varying","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"vec2","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"vec3","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"vec4","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"void","type":"","usage":"keyword"},{"args":[],"column":1,"comment":"","file":"","line":1,"name":"while","type":"","usage":"keyword"}]}
\ No newline at end of file
diff --git a/editor/exports/offline-mappings.ts b/editor/exports/offline-mappings.ts
index 7c4ac6900c..9bfa066fb4 100644
--- a/editor/exports/offline-mappings.ts
+++ b/editor/exports/offline-mappings.ts
@@ -95,6 +95,7 @@ typeMap.usampler3D = Type.SAMPLER3D;
typeMap.isamplerCube = Type.SAMPLER_CUBE;
typeMap.usamplerCube = Type.SAMPLER_CUBE;
typeMap.samplerCubeShadow = Type.SAMPLER_CUBE;
+typeMap.uimage2D = Type.IMAGE2D;
const isSampler = (type) => type >= Type.SAMPLER1D;
const isPaddedMatrix = (type) => type >= Type.MAT2 && type < Type.MAT4;
diff --git a/editor/i18n/zh/assets.js b/editor/i18n/zh/assets.js
index 70cdc4c33c..f37fd3491a 100644
--- a/editor/i18n/zh/assets.js
+++ b/editor/i18n/zh/assets.js
@@ -381,7 +381,7 @@ module.exports = {
},
agressiveness: {
name: '误差距离',
- title: '模型减面算法的激进程度。
当设置数值越高时,算法的减免策略会越激进,但是过于激进的策略更有可能导致结果错误。',
+ title: '模型减面算法的激进程度。
当设置数值越高时,算法的减面策略会越激进,但是过于激进的策略更有可能导致结果错误。',
},
maxIterationCount: {
name: '计算迭代次数',
diff --git a/editor/inspector/assets/animation-graph-variant.js b/editor/inspector/assets/animation-graph-variant.js
index a79f5c7635..d88471fb87 100644
--- a/editor/inspector/assets/animation-graph-variant.js
+++ b/editor/inspector/assets/animation-graph-variant.js
@@ -85,6 +85,10 @@ exports.methods = {
await Editor.Message.request('scene', 'apply-animation-graph-variant', this.asset.uuid, this.animationGraphVariant);
},
+ abort() {
+ this.reset();
+ },
+
reset() {
/**
* reset 环节只需把 uuid 清空
diff --git a/editor/inspector/assets/animation-mask.js b/editor/inspector/assets/animation-mask.js
index 640dfd7895..17bad1664d 100644
--- a/editor/inspector/assets/animation-mask.js
+++ b/editor/inspector/assets/animation-mask.js
@@ -101,6 +101,10 @@ exports.methods = {
await Editor.Message.request('scene', 'apply-animation-mask', this.asset.uuid);
},
+ abort() {
+ this.reset();
+ },
+
reset() {
this.dirtyData.uuid = '';
},
diff --git a/editor/inspector/assets/material.js b/editor/inspector/assets/material.js
index 7a5b4d5670..4adbcfbd6d 100644
--- a/editor/inspector/assets/material.js
+++ b/editor/inspector/assets/material.js
@@ -84,6 +84,7 @@ exports.methods = {
},
async abort() {
+ this.reset();
await Editor.Message.request('scene', 'preview-material', this.asset.uuid);
},
@@ -216,6 +217,7 @@ exports.methods = {
$container.$children[i] = document.createElement('ui-prop');
$container.$children[i].setAttribute('type', 'dump');
+ $container.$children[i].setAttribute('pass-index', i);
$container.appendChild($container.$children[i]);
$container.$children[i].render(pass);
@@ -344,10 +346,10 @@ exports.methods = {
return;
}
- cacheProperty(pass.value);
+ cacheProperty(pass.value, i);
});
- function cacheProperty(prop) {
+ function cacheProperty(prop, passIndex) {
for (const name in prop) {
// 这些字段是基础类型或配置性的数据,不需要变动
if (excludeNames.includes(name)) {
@@ -355,22 +357,27 @@ exports.methods = {
}
if (prop[name] && typeof prop[name] === 'object') {
- if (!(name in cacheData)) {
- const { type, value } = prop[name];
- if (type) {
- if (value !== undefined) {
- cacheData[name] = { type };
- if (value && typeof value === 'object') {
- cacheData[name].value = JSON.parse(JSON.stringify(value));
- } else {
- cacheData[name].value = value;
- }
+ if (!cacheData.name) {
+ cacheData[name] = {};
+ }
+
+ const { type, value } = prop[name];
+ if (type && value !== undefined) {
+ if (!cacheData[name][passIndex]) {
+ if (name === 'USE_INSTANCING' && passIndex !== 0) {
+ continue;
+ }
+ cacheData[name][passIndex] = { type };
+ if (value && typeof value === 'object') {
+ cacheData[name][passIndex].value = JSON.parse(JSON.stringify(value));
+ } else {
+ cacheData[name][passIndex].value = value;
}
}
}
if (prop[name].childMap && typeof prop[name].childMap === 'object') {
- cacheProperty(prop[name].childMap);
+ cacheProperty(prop[name].childMap, passIndex);
}
}
}
@@ -380,13 +387,13 @@ exports.methods = {
this.updateInstancing();
},
- storeCache(dump) {
+ storeCache(dump, passIndex) {
const { name, type, value, default: defaultValue } = dump;
if (JSON.stringify(value) === JSON.stringify(defaultValue)) {
- delete this.cacheData[name];
+ delete this.cacheData[name][passIndex];
} else {
- this.cacheData[name] = JSON.parse(JSON.stringify({ type, value }));
+ this.cacheData[name][passIndex] = JSON.parse(JSON.stringify({ type, value }));
}
},
@@ -397,25 +404,28 @@ exports.methods = {
return;
}
- updateProperty(pass.value);
+ updateProperty(pass.value, i);
});
- function updateProperty(prop) {
+ function updateProperty(prop, passIndex) {
for (const name in prop) {
if (prop[name] && typeof prop[name] === 'object') {
if (name in cacheData) {
- const { type, value } = cacheData[name];
- if (prop[name].type === type && JSON.stringify(prop[name].value) !== JSON.stringify(value)) {
- if (value && typeof value === 'object') {
- prop[name].value = JSON.parse(JSON.stringify(value));
- } else {
- prop[name].value = value;
+ const passItem = cacheData[name][passIndex];
+ if (passItem) {
+ const { type, value } = passItem;
+ if (prop[name].type === type && JSON.stringify(prop[name].value) !== JSON.stringify(value)) {
+ if (value && typeof value === 'object') {
+ prop[name].value = JSON.parse(JSON.stringify(value));
+ } else {
+ prop[name].value = value;
+ }
}
}
}
if (prop[name].childMap && typeof prop[name].childMap === 'object') {
- updateProperty(prop[name].childMap);
+ updateProperty(prop[name].childMap, passIndex);
}
}
}
@@ -532,7 +542,7 @@ exports.ready = function() {
// The event is triggered when the useInstancing is modified
this.$.useInstancing.addEventListener('change-dump', (event) => {
this.changeInstancing(event.target.dump.value);
- this.storeCache(event.target.dump);
+ this.storeCache(event.target.dump, 0);
this.change();
this.snapshot();
});
@@ -541,7 +551,15 @@ exports.ready = function() {
this.$.materialDump.addEventListener('change-dump', (event) => {
const dump = event.target.dump;
- this.storeCache(dump);
+ let passIndex = 0;
+ for (let element of event.path) {
+ if (element instanceof HTMLElement && element.hasAttribute('pass-index')) {
+ passIndex = Number(element.getAttribute('pass-index'));
+ break;
+ }
+ }
+
+ this.storeCache(dump, passIndex);
this.change();
});
diff --git a/editor/inspector/assets/physics-material.js b/editor/inspector/assets/physics-material.js
index 3c879225b8..d93335fd19 100644
--- a/editor/inspector/assets/physics-material.js
+++ b/editor/inspector/assets/physics-material.js
@@ -51,6 +51,10 @@ exports.methods = {
await Editor.Message.request('scene', 'apply-physics-material', this.asset.uuid, this.queryData);
},
+ abort() {
+ this.reset();
+ },
+
reset() {
/**
* reset 环节只需把 uuid 清空
diff --git a/editor/inspector/assets/render-pipeline.js b/editor/inspector/assets/render-pipeline.js
index 8cb4d55396..a3325103f2 100644
--- a/editor/inspector/assets/render-pipeline.js
+++ b/editor/inspector/assets/render-pipeline.js
@@ -54,6 +54,10 @@ exports.methods = {
await Editor.Message.request('scene', 'apply-render-pipeline', this.asset.uuid, this.pipeline);
},
+ abort() {
+ this.reset();
+ },
+
reset() {
/**
* reset 环节只需把 uuid 清空
diff --git a/editor/inspector/components/class.js b/editor/inspector/components/class.js
index c7a53033e9..17ac85ca55 100644
--- a/editor/inspector/components/class.js
+++ b/editor/inspector/components/class.js
@@ -32,8 +32,11 @@ exports.methods = {
$group.$header.setAttribute('class', 'tab-header');
$group.appendChild($group.$header);
$group.$header.addEventListener('change', (e) => {
+ active(e.target.value);
+ });
+ function active(index) {
const tabNames = Object.keys($group.tabs);
- const tabName = tabNames[e.target.value || 0];
+ const tabName = tabNames[index];
$group.childNodes.forEach((child) => {
if (!child.classList.contains('tab-content')) {
return;
@@ -44,12 +47,9 @@ exports.methods = {
child.style.display = 'none';
}
});
- });
+ }
setTimeout(() => {
- const $firstTab = $group.$header.shadowRoot.querySelector('ui-button');
- if ($firstTab) {
- $firstTab.dispatch('confirm');
- }
+ active(0);
});
return $group;
},
diff --git a/editor/inspector/components/particle-system.js b/editor/inspector/components/particle-system.js
index dd26951863..a0446b14db 100644
--- a/editor/inspector/components/particle-system.js
+++ b/editor/inspector/components/particle-system.js
@@ -18,8 +18,8 @@ exports.template = /* html*/`
-
-
+
+
@@ -27,8 +27,8 @@ exports.template = /* html*/`
-
-
+
+
diff --git a/editor/inspector/contributions/asset.css b/editor/inspector/contributions/asset.css
index 3b9c56b752..180f0ffc65 100644
--- a/editor/inspector/contributions/asset.css
+++ b/editor/inspector/contributions/asset.css
@@ -51,9 +51,15 @@
opacity: 0.55;
}
+:host > .container > .header > .copy {
+ margin-left: 5px;
+ line-height: 26px;
+}
+
:host > .container > .header > .help {
display: none;
- margin-right: 10px;
+ margin-left: 8px;
+ margin-right: 3px;
}
:host > .container > .header > .lock {
diff --git a/editor/inspector/contributions/asset.js b/editor/inspector/contributions/asset.js
index ccdba50e41..78a2e5038e 100644
--- a/editor/inspector/contributions/asset.js
+++ b/editor/inspector/contributions/asset.js
@@ -1,6 +1,8 @@
'use strict';
const fs = require('fs');
const path = require('path');
+module.paths.push(path.join(Editor.App.path, 'node_modules'));
+const { throttle } = require('lodash');
const History = require('./asset-history/index');
const showImage = ['image', 'texture', 'sprite-frame', 'gltf-mesh'];
@@ -14,9 +16,6 @@ exports.template = `
-
-
-
@@ -26,6 +25,9 @@ exports.template = `
+
+
+
@@ -56,20 +58,37 @@ const Elements = {
panel: {
ready() {
const panel = this;
- panel.__assetChangedHandle__ = undefined;
+
+ panel.throttleUpdate = throttle(() => {
+ if (!panel.readyToUpdate) {
+ return;
+ }
+ panel.reset();
+ }, 100, { leading: false, trailing: true });
panel.__assetChanged__ = (uuid) => {
if (Array.isArray(panel.uuidList) && panel.uuidList.includes(uuid)) {
- window.cancelAnimationFrame(panel.__assetChangedHandle__);
- panel.__assetChangedHandle__ = window.requestAnimationFrame(async () => {
- await panel.reset();
- });
+ panel.throttleUpdate();
}
};
Editor.Message.addBroadcastListener('asset-db:asset-change', panel.__assetChanged__);
panel.history = new History();
+
+ panel._readyToUpdate = true;
+ Object.defineProperty(panel, 'readyToUpdate', {
+ enumerable: true,
+ get() {
+ return panel._readyToUpdate;
+ },
+ set(val) {
+ panel._readyToUpdate = val;
+ if (val) {
+ panel.throttleUpdate();
+ }
+ },
+ });
},
async update() {
const panel = this;
@@ -150,10 +169,8 @@ const Elements = {
close() {
const panel = this;
- if (panel.__assetChangedHandle__) {
- window.cancelAnimationFrame(panel.__assetChangedHandle__);
- panel.__assetChangedHandle__ = undefined;
- }
+ panel.throttleUpdate.cancel();
+ panel.throttleUpdate = undefined;
Editor.Message.removeBroadcastListener('asset-db:asset-change', panel.__assetChanged__);
@@ -498,6 +515,8 @@ exports.methods = {
return;
}
+ panel.readyToUpdate = false;
+
// 有些资源在内部的 apply 保存数据后,会自动重导资源,自动更新 meta 数据,所以 meta 不需要再额外更新
let continueSaveMeta = true;
@@ -514,6 +533,7 @@ exports.methods = {
* return; 是保存成功,且向上冒泡继续保存 meta
*/
if (saveState === false) {
+ panel.readyToUpdate = true;
return;
} else if (saveState === true) {
continueSaveMeta = false;
@@ -523,6 +543,7 @@ exports.methods = {
panel.$.header.removeAttribute('dirty');
if (continueSaveMeta === false) {
+ panel.readyToUpdate = true;
return;
}
@@ -535,6 +556,8 @@ exports.methods = {
panel.metaListOrigin[index] = content;
Editor.Message.request('asset-db', 'save-asset-meta', uuid, content);
});
+
+ panel.readyToUpdate = true;
},
async abort() {
const panel = this;
@@ -560,10 +583,6 @@ exports.methods = {
}
}
- if (panel.ready !== true) {
- return;
- }
-
panel.$this.update(panel.uuidList, panel.renderMap);
},
getHelpUrl(url) {
@@ -605,7 +624,6 @@ exports.update = async function update(uuidList, renderMap, dropConfig) {
exports.ready = function ready() {
const panel = this;
- panel.ready = true;
for (const prop in Elements) {
const element = Elements[prop];
@@ -674,7 +692,6 @@ exports.beforeClose = async function beforeClose() {
exports.close = async function close() {
const panel = this;
- panel.ready = false;
for (const prop in Elements) {
const element = Elements[prop];
diff --git a/editor/inspector/contributions/node.css b/editor/inspector/contributions/node.css
index f310cdda37..6d49419bc8 100644
--- a/editor/inspector/contributions/node.css
+++ b/editor/inspector/contributions/node.css
@@ -135,6 +135,7 @@
.node .layer-content > .layer-select {
flex: 1;
+ margin-top: 0;
}
.node .layer-content > .layer-edit {
diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js
index f653b41692..4fbf6cc7fb 100644
--- a/editor/inspector/contributions/node.js
+++ b/editor/inspector/contributions/node.js
@@ -1,6 +1,8 @@
'use strict';
const fs = require('fs');
const path = require('path');
+module.paths.push(path.join(Editor.App.path, 'node_modules'));
+const { throttle } = require('lodash');
const utils = require('./utils');
const { trackEventWithTimer } = require('../utils/metrics');
@@ -25,8 +27,6 @@ exports.listeners = {
let setChildrenLayer = false;
if (dump.path === 'layer') {
- const newValue = Number(panel.$.nodeLayerSelect.value);
-
if (panel.dumps && panel.dumps.some((perdump) => perdump.children && perdump.children.length > 0)) {
// 只修改自身节点
let choose = 1;
@@ -47,24 +47,21 @@ exports.listeners = {
// 取消,需要还原数值
if (choose === 2) {
+ dump.value = panel.$.nodeLayerSelect.prevValues[0];
+ if (dump.values) {
+ dump.values = panel.$.nodeLayerSelect.prevValues;
+ }
Elements.layer.update.call(panel);
return;
} else {
setChildrenLayer = choose === 0 ? true : false;
-
- dump.value = newValue;
- if (setChildrenLayer && 'values' in dump) {
- dump.values.forEach((val, index) => {
- dump.values[index] = newValue;
- });
- }
}
- } else {
- dump.value = newValue;
}
}
try {
+ panel.readyToUpdate = false;
+
for (let i = 0; i < panel.uuidList.length; i++) {
const uuid = panel.uuidList[i];
const { path, type, isArray } = dump;
@@ -97,15 +94,17 @@ exports.listeners = {
}
} catch (error) {
console.error(error);
+ } finally {
+ if (!panel.snapshotLock) {
+ Editor.Message.send('scene', 'snapshot');
+ }
+ panel.readyToUpdate = true;
}
},
'confirm-dump'() {
const panel = this;
panel.snapshotLock = false;
-
- // In combination with change-dump, snapshot only generated once after ui-elements continuously changed.
- Editor.Message.send('scene', 'snapshot');
},
async 'create-dump'(event) {
const panel = this;
@@ -329,10 +328,10 @@ exports.template = /* html*/`
-
+
-
+
Edit
@@ -395,7 +394,6 @@ exports.$ = {
nodeRotation: '.node > .rotation',
nodeScale: '.node > .scale',
nodeMobility: '.node > .mobility',
- nodeLayer: '.node > .layer',
nodeLayerSelect: '.node > .layer .layer-select',
nodeLayerButton: '.node > .layer .layer-edit',
@@ -411,22 +409,22 @@ const Elements = {
panel: {
ready() {
const panel = this;
- panel.__nodeChangedHandle__ = undefined;
+
+ panel.throttleUpdate = throttle(async () => {
+ if (!panel.readyToUpdate) {
+ return;
+ }
+ for (const prop in Elements) {
+ const element = Elements[prop];
+ if (element.update) {
+ await element.update.call(panel);
+ }
+ }
+ }, 100, { leading: false, trailing: true });
panel.__nodeChanged__ = (uuid) => {
if (Array.isArray(panel.uuidList) && panel.uuidList.includes(uuid)) {
- window.cancelAnimationFrame(panel.__nodeChangedHandle__);
- panel.__nodeChangedHandle__ = window.requestAnimationFrame(async () => {
- for (const prop in Elements) {
- if (!panel.ready) {
- return;
- }
- const element = Elements[prop];
- if (element.update) {
- await element.update.call(panel);
- }
- }
- });
+ panel.throttleUpdate();
}
};
@@ -494,6 +492,20 @@ const Elements = {
Editor.Message.send('scene', 'snapshot');
});
+
+ panel._readyToUpdate = true;
+ Object.defineProperty(panel, 'readyToUpdate', {
+ enumerable: true,
+ get() {
+ return panel._readyToUpdate;
+ },
+ set(val) {
+ panel._readyToUpdate = val;
+ if (val) {
+ panel.throttleUpdate();
+ }
+ },
+ });
},
async update() {
const panel = this;
@@ -540,10 +552,8 @@ const Elements = {
close() {
const panel = this;
- if (panel.__nodeChangedHandle__) {
- window.cancelAnimationFrame(panel.__nodeChangedHandle__);
- panel.__nodeChangedHandle__ = undefined;
- }
+ panel.throttleUpdate.cancel();
+ panel.throttleUpdate = undefined;
Editor.Message.removeBroadcastListener('scene:change-node', panel.__nodeChanged__);
Editor.Message.removeBroadcastListener('scene:animation-time-change', panel.__animationTimeChange__);
@@ -561,7 +571,6 @@ const Elements = {
return;
}
- Editor.Message.send('scene', 'snapshot');
const role = button.getAttribute('role');
@@ -569,8 +578,18 @@ const Elements = {
const prefab = dump.__prefab__;
switch (role) {
+ case 'edit': {
+ const assetId = prefab.prefabStateInfo?.assetUuid;
+ if (!assetId) {
+ return;
+ }
+ Editor.Message.request('asset-db', 'open-asset', assetId);
+ break;
+ }
case 'unlink': {
+ Editor.Message.send('scene', 'snapshot');
await Editor.Message.request('scene', 'unlink-prefab', prefab.rootUuid, false);
+ Editor.Message.send('scene', 'snapshot');
break;
}
case 'local': {
@@ -578,25 +597,19 @@ const Elements = {
break;
}
case 'reset': {
+ Editor.Message.send('scene', 'snapshot');
await Editor.Message.request('scene', 'restore-prefab', prefab.rootUuid, prefab.uuid);
+ Editor.Message.send('scene', 'snapshot');
break;
}
case 'save': {
+ Editor.Message.send('scene', 'snapshot');
await Editor.Message.request('scene', 'apply-prefab', prefab.rootUuid);
+ Editor.Message.send('scene', 'snapshot');
break;
}
}
}
-
- Editor.Message.send('scene', 'snapshot');
- });
-
- panel.$.prefabEdit.addEventListener('click', () => {
- const assetId = panel.dump?.__prefab__?.prefabStateInfo?.assetUuid;
- if (!assetId) {
- return;
- }
- Editor.Message.request('asset-db', 'open-asset', assetId);
});
},
async update() {
@@ -892,7 +905,12 @@ const Elements = {
});
}
},
- async setReflectionConvolutionMap(uuid) {
+ async setEnvMapAndConvolutionMap(uuid) {
+ await Editor.Message.request('scene', 'execute-scene-script', {
+ name: 'inspector',
+ method: 'setSkyboxEnvMap',
+ args: [uuid],
+ });
if (uuid) {
await Editor.Message.request('scene', 'execute-scene-script', {
name: 'inspector',
@@ -982,7 +1000,7 @@ const Elements = {
const $prop = useHDR ? panel.$.sceneSkyboxEnvmapHDR : panel.$.sceneSkyboxEnvmapLDR;
const uuid = $prop.dump.value.uuid;
- Elements.scene.setReflectionConvolutionMap.call(panel, uuid);
+ Elements.scene.setEnvMapAndConvolutionMap.call(panel, uuid);
},
skyboxEnvmapChange(useHDR, event) {
const panel = this;
@@ -993,7 +1011,7 @@ const Elements = {
const $prop = event.currentTarget;
const uuid = $prop.dump.value.uuid;
- Elements.scene.setReflectionConvolutionMap.call(panel, uuid);
+ Elements.scene.setEnvMapAndConvolutionMap.call(panel, uuid);
},
},
node: {
@@ -1029,7 +1047,6 @@ const Elements = {
panel.$.nodeRotation.render(panel.dump.rotation);
panel.$.nodeScale.render(panel.dump.scale);
panel.$.nodeMobility.render(panel.dump.mobility);
- panel.$.nodeLayer.render(panel.dump.layer);
// 查找需要渲染的 component 列表
const componentList = [];
@@ -1360,31 +1377,20 @@ const Elements = {
Editor.Message.send('project', 'open-settings', 'project', 'layer');
});
},
- async update() {
+ update() {
const panel = this;
if (!panel.dump || panel.dump.isScene) {
return;
}
- const layerDump = panel.dump.layer;
- const enumList = layerDump.enumList || [];
+ panel.$.nodeLayerSelect.render(panel.dump.layer);
- let optionHtml = '';
- if (enumList) {
- for (const item of enumList) {
- optionHtml += ``;
- }
+ let prevValues = [panel.dump.layer.value];
+ if (panel.dump.layer.values) {
+ prevValues = panel.dump.layer.values.slice();
}
- panel.$.nodeLayerSelect.innerHTML = optionHtml;
- panel.$.nodeLayerSelect.value = layerDump.value;
-
- if (layerDump.values && layerDump.values.some((value) => value !== layerDump.value)) {
- panel.$.nodeLayerSelect.invalid = true;
- } else {
- panel.$.nodeLayerSelect.invalid = false;
- }
- panel.$.nodeLayer.setReadonly(layerDump, panel.$.nodeLayerSelect);
+ panel.$.nodeLayerSelect.prevValues = prevValues;
},
},
footer: {
@@ -2022,7 +2028,6 @@ exports.ready = async function ready() {
// 为了避免把 ui-num-input, ui-color 的连续 change 进行 snapshot
panel.snapshotLock = false;
- panel.ready = true;
for (const prop in Elements) {
const element = Elements[prop];
@@ -2039,7 +2044,6 @@ exports.ready = async function ready() {
exports.close = async function close() {
const panel = this;
- panel.ready = false;
for (const prop in Elements) {
const element = Elements[prop];
diff --git a/editor/inspector/utils/prop.js b/editor/inspector/utils/prop.js
index 459bd2c378..5c3419dc52 100644
--- a/editor/inspector/utils/prop.js
+++ b/editor/inspector/utils/prop.js
@@ -346,8 +346,12 @@ exports.createTabGroup = function(dump, panel) {
$group.appendChild($group.$header);
$group.$header.addEventListener('change', (e) => {
+ active(e.target.value);
+ });
+
+ function active(index) {
const tabNames = Object.keys($group.tabs);
- const tabName = tabNames[e.target.value || 0];
+ const tabName = tabNames[index];
$group.childNodes.forEach((child) => {
if (!child.classList.contains('tab-content')) {
return;
@@ -358,7 +362,7 @@ exports.createTabGroup = function(dump, panel) {
child.style.display = 'none';
}
});
- });
+ }
// check style
if (!panel.$this.shadowRoot.querySelector('style#group-style')) {
@@ -383,10 +387,7 @@ exports.createTabGroup = function(dump, panel) {
}
setTimeout(() => {
- const $firstTab = $group.$header.shadowRoot.querySelector('ui-button');
- if ($firstTab) {
- $firstTab.dispatch('confirm');
- }
+ active(0);
});
return $group;
diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt
index 6cfd23150d..b9f945ad9d 100644
--- a/native/CMakeLists.txt
+++ b/native/CMakeLists.txt
@@ -459,6 +459,8 @@ cocos_source_files(
cocos/base/ThreadPool.cpp
cocos/base/ThreadPool.h
cocos/base/TypeDef.h
+ cocos/base/BinaryArchive.cpp
+ cocos/base/BinaryArchive.h
cocos/base/std/any.h
cocos/base/std/optional.h
cocos/base/std/variant.h
@@ -1208,6 +1210,8 @@ cocos_source_files(
cocos/renderer/gfx-base/GFXTexture.cpp
cocos/renderer/gfx-base/GFXTexture.h
cocos/renderer/gfx-base/GFXDeviceObject.h
+ cocos/renderer/gfx-base/GFXUtil.cpp
+ cocos/renderer/gfx-base/GFXUtil.h
cocos/renderer/gfx-base/states/GFXGeneralBarrier.cpp
cocos/renderer/gfx-base/states/GFXGeneralBarrier.h
cocos/renderer/gfx-base/states/GFXSampler.cpp
@@ -1398,6 +1402,9 @@ cocos_source_files(
cocos/renderer/pipeline/custom/ArchiveFwd.h
cocos/renderer/pipeline/custom/ArchiveTypes.cpp
cocos/renderer/pipeline/custom/ArchiveTypes.h
+ cocos/renderer/pipeline/custom/CustomFwd.h
+ cocos/renderer/pipeline/custom/CustomTypes.cpp
+ cocos/renderer/pipeline/custom/CustomTypes.h
cocos/renderer/pipeline/custom/FGDispatcherGraphs.h
cocos/renderer/pipeline/custom/FGDispatcherTypes.cpp
cocos/renderer/pipeline/custom/FGDispatcherTypes.h
@@ -1685,6 +1692,8 @@ if(CC_USE_GLES3)
cocos/renderer/gfx-gles3/GLES3Texture.h
cocos/renderer/gfx-gles3/GLES3Wrangler.cpp
cocos/renderer/gfx-gles3/GLES3Wrangler.h
+ cocos/renderer/gfx-gles3/GLES3PipelineCache.cpp
+ cocos/renderer/gfx-gles3/GLES3PipelineCache.h
cocos/renderer/gfx-gles3/states/GLES3GeneralBarrier.cpp
cocos/renderer/gfx-gles3/states/GLES3GeneralBarrier.h
cocos/renderer/gfx-gles3/states/GLES3Sampler.cpp
@@ -1782,6 +1791,8 @@ if(CC_USE_VULKAN)
cocos/renderer/gfx-vulkan/volk.c
cocos/renderer/gfx-vulkan/volk.h
cocos/renderer/gfx-vulkan/VKGPURecycleBin.cpp
+ cocos/renderer/gfx-vulkan/VKPipelineCache.cpp
+ cocos/renderer/gfx-vulkan/VKPipelineCache.h
cocos/renderer/gfx-vulkan/states/VKGeneralBarrier.cpp
cocos/renderer/gfx-vulkan/states/VKGeneralBarrier.h
cocos/renderer/gfx-vulkan/states/VKSampler.cpp
diff --git a/native/cocos/3d/models/BakedSkinningModel.cpp b/native/cocos/3d/models/BakedSkinningModel.cpp
index 4783185c16..d4e993b5b1 100644
--- a/native/cocos/3d/models/BakedSkinningModel.cpp
+++ b/native/cocos/3d/models/BakedSkinningModel.cpp
@@ -66,6 +66,7 @@ void BakedSkinningModel::destroy() {
CC_SAFE_DELETE(_jointMedium.texture.value());
}
applyJointTexture(ccstd::nullopt);
+ emit();
Super::destroy();
}
diff --git a/native/cocos/3d/models/BakedSkinningModel.h b/native/cocos/3d/models/BakedSkinningModel.h
index 8a01914a43..5b500cb814 100644
--- a/native/cocos/3d/models/BakedSkinningModel.h
+++ b/native/cocos/3d/models/BakedSkinningModel.h
@@ -29,6 +29,7 @@
#include "3d/assets/Skeleton.h"
#include "3d/models/MorphModel.h"
#include "3d/skeletal-animation/SkeletalAnimationUtils.h"
+#include "core/event/EventTarget.h"
#include "gfx-base/GFXDef-common.h"
namespace cc {
@@ -48,13 +49,15 @@ struct BakedJointInfo {
};
class BakedSkinningModel final : public MorphModel {
+ IMPL_EVENT_TARGET(BakedSkinningModel)
+ DECLARE_TARGET_EVENT_BEGIN(BakedSkinningModel)
+ TARGET_EVENT_ARG0(Destroy)
+ DECLARE_TARGET_EVENT_END()
public:
using Super = MorphModel;
BakedSkinningModel();
~BakedSkinningModel() override = default;
-
void destroy() override;
-
ccstd::vector getMacroPatches(index_t subModelIndex) override;
void updateLocalDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet) override;
void updateTransform(uint32_t stamp) override;
diff --git a/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp b/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp
index a6b3fc1be8..474b9858a0 100644
--- a/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp
+++ b/native/cocos/3d/skeletal-animation/SkeletalAnimationUtils.cpp
@@ -158,7 +158,11 @@ void JointTexturePool::clear() {
void JointTexturePool::registerCustomTextureLayouts(const ccstd::vector &layouts) {
for (const auto &layout : layouts) {
- uint32_t chunkIdx = _customPool->createChunk(layout.textureLength);
+ auto textureLength = layout.textureLength;
+ if (!(static_cast(_device->getFormatFeatures(cc::gfx::Format::RGBA32F) & cc::gfx::FormatFeature::SAMPLED_TEXTURE))) {
+ textureLength *= 2;
+ }
+ uint32_t chunkIdx = _customPool->createChunk(textureLength);
for (const auto &content : layout.contents) {
auto skeleton = content.skeleton;
_chunkIdxMap[skeleton] = chunkIdx; // include default pose too
diff --git a/native/cocos/base/BinaryArchive.cpp b/native/cocos/base/BinaryArchive.cpp
new file mode 100644
index 0000000000..ac47e663c5
--- /dev/null
+++ b/native/cocos/base/BinaryArchive.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+ Copyright (c) 2023 Xiamen Yaji Software Co., Ltd.
+
+ http://www.cocos.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+****************************************************************************/
+
+#include "BinaryArchive.h"
+#include "base/Assertf.h"
+
+namespace cc {
+
+bool BinaryInputArchive::load(char *data, uint32_t size) {
+ CC_ASSERT(!!_stream);
+ return _stream.rdbuf()->sgetn(data, size) == size;
+}
+
+void BinaryInputArchive::move(uint32_t length) {
+ CC_ASSERT(!!_stream);
+ _stream.ignore(length);
+}
+
+void BinaryOutputArchive::save(const char *data, uint32_t size) {
+ CC_ASSERT(!!_stream);
+ auto len = _stream.rdbuf()->sputn(data, size);
+ CC_ASSERT(len == size);
+}
+
+} // namespace cc
diff --git a/native/cocos/base/BinaryArchive.h b/native/cocos/base/BinaryArchive.h
new file mode 100644
index 0000000000..9f79cabfc4
--- /dev/null
+++ b/native/cocos/base/BinaryArchive.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+ Copyright (c) 2023 Xiamen Yaji Software Co., Ltd.
+
+ http://www.cocos.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+****************************************************************************/
+
+#pragma once
+
+#include
+
+namespace cc {
+
+/**
+ * Binary input stream archive.
+ */
+class BinaryInputArchive {
+public:
+ explicit BinaryInputArchive(std::istream &stream) : _stream(stream) {}
+ ~BinaryInputArchive() = default;
+
+ /**
+ * Read data from stream.
+ * @param data Pointer to data address to read.
+ * @param size Length of the data.
+ */
+ bool load(char *data, uint32_t size);
+
+ /**
+ * Read arithmetic data from stream.
+ * @param val Data to read.
+ */
+ template >>
+ bool load(T &val) {
+ return load(reinterpret_cast(std::addressof(val)), sizeof(T));
+ }
+
+ /**
+ * Skip data length
+ * @param length Skip length
+ */
+ void move(uint32_t length);
+
+private:
+ std::istream &_stream;
+};
+
+/**
+ * Binary output stream archive.
+ */
+class BinaryOutputArchive {
+public:
+ explicit BinaryOutputArchive(std::ostream &stream) : _stream(stream) {}
+ ~BinaryOutputArchive() = default;
+
+ /**
+ * Write data to stream.
+ * @param data Pointer to data address to write.
+ * @param size Length of the data.
+ */
+ void save(const char *data, uint32_t size);
+
+ /**
+ * Write arithmetic data to stream.
+ * @param val Data to write.
+ */
+ template >>
+ void save(const T &v) {
+ save(reinterpret_cast(std::addressof(v)), sizeof(T));
+ }
+
+private:
+ std::ostream &_stream;
+};
+
+} // namespace cc
diff --git a/native/cocos/bindings/manual/jsb_global.cpp b/native/cocos/bindings/manual/jsb_global.cpp
index e1d18e5c13..81a7402756 100644
--- a/native/cocos/bindings/manual/jsb_global.cpp
+++ b/native/cocos/bindings/manual/jsb_global.cpp
@@ -789,9 +789,9 @@ static bool JSB_copyTextToClipboard(se::State &s) { // NOLINT
ccstd::string text;
ok = sevalue_to_native(args[0], &text);
SE_PRECONDITION2(ok, false, "text is invalid!");
- ISystemWindow *systemWindowIntf = CC_GET_PLATFORM_INTERFACE(ISystemWindow);
- CC_ASSERT_NOT_NULL(systemWindowIntf);
- systemWindowIntf->copyTextToClipboard(text);
+ ISystem *systemIntf = CC_GET_PLATFORM_INTERFACE(ISystem);
+ CC_ASSERT_NOT_NULL(systemIntf);
+ systemIntf->copyTextToClipboard(text);
return true;
}
diff --git a/native/cocos/bindings/manual/jsb_scene_manual.cpp b/native/cocos/bindings/manual/jsb_scene_manual.cpp
index bd5370b0c1..09fb8f22cd 100644
--- a/native/cocos/bindings/manual/jsb_scene_manual.cpp
+++ b/native/cocos/bindings/manual/jsb_scene_manual.cpp
@@ -809,6 +809,20 @@ static bool js_Model_registerListeners(se::State &s) // NOLINT(readability-ident
}
SE_BIND_FUNC(js_Model_registerListeners) // NOLINT(readability-identifier-naming)
+static bool js_BakedSkinningModel_registerOnDestroy(se::State &s) // NOLINT(readability-identifier-naming)
+{
+ auto *cobj = SE_THIS_OBJECT(s);
+ SE_PRECONDITION2(cobj, false, "Invalid Native Object");
+
+ auto *jsObject = s.thisObject();
+ cobj->on([=](cc::BakedSkinningModel * /*emitter*/) {
+ se::AutoHandleScope hs;
+ se::ScriptEngine::getInstance()->callFunction(jsObject, "_onDestroy", 0, nullptr);
+ });
+ return true;
+}
+SE_BIND_FUNC(js_BakedSkinningModel_registerOnDestroy) // NOLINT(readability-identifier-naming)
+
static bool js_assets_MaterialInstance_registerListeners(se::State &s) // NOLINT(readability-identifier-naming)
{
auto *cobj = SE_THIS_OBJECT(s);
@@ -896,6 +910,7 @@ bool register_all_scene_manual(se::Object *obj) // NOLINT(readability-identifier
__jsb_cc_scene_Model_proto->defineFunction("_setInstancedAttribute", _SE(js_Model_setInstancedAttribute));
__jsb_cc_scene_Model_proto->defineFunction("_registerListeners", _SE(js_Model_registerListeners));
+ __jsb_cc_BakedSkinningModel_proto->defineFunction("_registerOnDestroy", _SE(js_BakedSkinningModel_registerOnDestroy));
__jsb_cc_MaterialInstance_proto->defineFunction("_registerListeners", _SE(js_assets_MaterialInstance_registerListeners));
return true;
diff --git a/native/cocos/core/Root.cpp b/native/cocos/core/Root.cpp
index ffc636894d..6e5d15514a 100644
--- a/native/cocos/core/Root.cpp
+++ b/native/cocos/core/Root.cpp
@@ -89,7 +89,7 @@ void Root::initialize(gfx::Swapchain * /*swapchain*/) {
addWindowEventListener();
// TODO(minggo):
// return Promise.resolve(builtinResMgr.initBuiltinRes(this._device));
- const uint32_t usedUBOVectorCount = (pipeline::UBOGlobal::COUNT + pipeline::UBOCamera::COUNT + pipeline::UBOShadow::COUNT + pipeline::UBOLocal::COUNT) / 4;
+ const uint32_t usedUBOVectorCount = (pipeline::UBOGlobal::COUNT + pipeline::UBOCamera::COUNT + pipeline::UBOShadow::COUNT + pipeline::UBOLocal::COUNT + pipeline::UBOWorldBound::COUNT) / 4;
uint32_t maxJoints = (_device->getCapabilities().maxVertexUniformVectors - usedUBOVectorCount) / 3;
maxJoints = maxJoints < 256 ? maxJoints : 256;
pipeline::localDescriptorSetLayoutResizeMaxJoints(maxJoints);
@@ -561,6 +561,7 @@ void Root::doXRFrameMove(int32_t totalFrames) {
if (_xr->isRenderAllowable()) {
bool isSceneUpdated = false;
int viewCount = _xr->getXRConfig(xr::XRConfigKey::VIEW_COUNT).getInt();
+ bool forceUpdateSceneTwice = _xr->getXRConfig(xr::XRConfigKey::EYE_RENDER_JS_CALLBACK).getBool();
for (int xrEye = 0; xrEye < viewCount; xrEye++) {
_xr->beginRenderEyeFrame(xrEye);
@@ -594,6 +595,9 @@ void Root::doXRFrameMove(int32_t totalFrames) {
}
bool isNeedUpdateScene = xrEye == static_cast(xr::XREye::LEFT) || (xrEye == static_cast(xr::XREye::RIGHT) && !isSceneUpdated);
+ if (forceUpdateSceneTwice) {
+ isNeedUpdateScene = true;
+ }
frameMoveProcess(isNeedUpdateScene, totalFrames);
auto camIter = _cameraList.begin();
while (camIter != _cameraList.end()) {
diff --git a/native/cocos/core/assets/EffectAsset.h b/native/cocos/core/assets/EffectAsset.h
index 8d111e51b6..aec19b88c5 100644
--- a/native/cocos/core/assets/EffectAsset.h
+++ b/native/cocos/core/assets/EffectAsset.h
@@ -515,7 +515,7 @@ struct IDefineInfo {
ccstd::optional> range; // cjh number is float? ?: number[];
ccstd::optional> options;
ccstd::optional defaultVal;
- ccstd::optional> defines; // NOTE: it's only used in Editor
+ ccstd::optional> defines; // NOTE: it's only used in Editor
ccstd::optional>> editor; // NOTE: it's only used in Editor
};
@@ -558,7 +558,7 @@ struct IShaderSource {
struct IShaderInfo {
ccstd::string name;
- ccstd::hash_t hash{0xFFFFFFFFU};
+ ccstd::hash_t hash{gfx::INVALID_SHADER_HASH};
IShaderSource glsl4;
IShaderSource glsl3;
IShaderSource glsl1;
diff --git a/native/cocos/core/assets/RenderTexture.cpp b/native/cocos/core/assets/RenderTexture.cpp
index ef61ffa3b2..79224297f7 100644
--- a/native/cocos/core/assets/RenderTexture.cpp
+++ b/native/cocos/core/assets/RenderTexture.cpp
@@ -118,6 +118,18 @@ void RenderTexture::initWindow(const IRenderTextureCreateInfo &info) {
windowInfo.renderPassInfo = getDefaultRenderPassInfo(device);
}
+ if (info.externalResLow.has_value()) {
+ windowInfo.externalResLow = info.externalResLow.value();
+ }
+
+ if (info.externalResHigh.has_value()) {
+ windowInfo.externalResHigh = info.externalResHigh.value();
+ }
+
+ if (info.externalFlag.has_value()) {
+ windowInfo.externalFlag = info.externalFlag.value();
+ }
+
if (_window != nullptr) {
_window->destroy();
_window->initialize(device, windowInfo);
diff --git a/native/cocos/core/assets/RenderTexture.h b/native/cocos/core/assets/RenderTexture.h
index 743f064301..8aa19e7dfa 100644
--- a/native/cocos/core/assets/RenderTexture.h
+++ b/native/cocos/core/assets/RenderTexture.h
@@ -34,6 +34,9 @@ struct IRenderTextureCreateInfo {
uint32_t width;
uint32_t height;
ccstd::optional passInfo;
+ ccstd::optional externalResLow; // for vulkan vkImage/opengl es texture created from external
+ ccstd::optional externalResHigh; // for vulkan vkImage created from external
+ ccstd::optional externalFlag; // external texture type normal or oes
};
namespace scene {
class RenderWindow;
diff --git a/native/cocos/platform/android/AndroidPlatform.cpp b/native/cocos/platform/android/AndroidPlatform.cpp
index dd962ea89d..6a19716746 100644
--- a/native/cocos/platform/android/AndroidPlatform.cpp
+++ b/native/cocos/platform/android/AndroidPlatform.cpp
@@ -535,6 +535,7 @@ public:
ev.type = cc::WindowEvent::Type::SIZE_CHANGED;
ev.width = ANativeWindow_getWidth(_androidPlatform->_app->window);
ev.height = ANativeWindow_getHeight(_androidPlatform->_app->window);
+ ev.windowId = ISystemWindow::mainWindowId;
events::WindowEvent::broadcast(ev);
break;
}
diff --git a/native/cocos/platform/android/java/src/com/cocos/lib/CocosActivity.java b/native/cocos/platform/android/java/src/com/cocos/lib/CocosActivity.java
index a245052b25..a20829e1e0 100644
--- a/native/cocos/platform/android/java/src/com/cocos/lib/CocosActivity.java
+++ b/native/cocos/platform/android/java/src/com/cocos/lib/CocosActivity.java
@@ -82,6 +82,8 @@ public class CocosActivity extends GameActivity {
setImmersiveMode();
Utils.hideVirtualButton();
+
+ mSurfaceView.setOnTouchListener((v, event) -> processMotionEvent(event));
}
private void setImmersiveMode() {
diff --git a/native/cocos/platform/android/java/src/com/cocos/lib/CocosEditBoxActivity.java b/native/cocos/platform/android/java/src/com/cocos/lib/CocosEditBoxActivity.java
index 4712f52956..7e885b7967 100644
--- a/native/cocos/platform/android/java/src/com/cocos/lib/CocosEditBoxActivity.java
+++ b/native/cocos/platform/android/java/src/com/cocos/lib/CocosEditBoxActivity.java
@@ -466,7 +466,7 @@ public class CocosEditBoxActivity extends Activity {
Native functions invoked by UI.
**************************************************************************************/
private void onKeyboardInput(String text) {
- CocosHelper.runOnGameThreadAtForeground(new Runnable() {
+ CocosHelper.runOnGameThread(new Runnable() {
@Override
public void run() {
CocosEditBoxActivity.onKeyboardInputNative(text);
@@ -475,7 +475,7 @@ public class CocosEditBoxActivity extends Activity {
}
private void onKeyboardComplete(String text) {
- CocosHelper.runOnGameThreadAtForeground(new Runnable() {
+ CocosHelper.runOnGameThread(new Runnable() {
@Override
public void run() {
CocosEditBoxActivity.onKeyboardCompleteNative(text);
@@ -484,7 +484,7 @@ public class CocosEditBoxActivity extends Activity {
}
private void onKeyboardConfirm(String text) {
- CocosHelper.runOnGameThreadAtForeground(new Runnable() {
+ CocosHelper.runOnGameThread(new Runnable() {
@Override
public void run() {
CocosEditBoxActivity.onKeyboardConfirmNative(text);
diff --git a/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRApi.java b/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRApi.java
index cef6d5cc41..a8e97a94eb 100644
--- a/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRApi.java
+++ b/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRApi.java
@@ -33,6 +33,8 @@ import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
+import java.lang.ref.WeakReference;
+
public class CocosXRApi {
private static final String TAG = "CocosXRApi";
private final static String ACTION_ADB_CMD = "com.cocosxr.adb.cmd";
@@ -71,7 +73,12 @@ public class CocosXRApi {
} else if (cmdValue instanceof String) {
valueStr = intent.getStringExtra("CMD_VALUE");
}
- onAdbCmd(key, valueStr);
+
+ try {
+ onAdbCmd(key, valueStr);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
}
}
}
@@ -84,12 +91,14 @@ public class CocosXRApi {
}
private Application application;
+ private WeakReference activityWeakReference;
private Context applicationContext;
private Application.ActivityLifecycleCallbacks activityLifecycleCallbacks;
private CocosXRActionReceiver actionReceiver;
private CocosXRWebViewManager webViewManager;
public void onCreate(Activity activity) {
+ activityWeakReference = new WeakReference<>(activity);
application = activity.getApplication();
applicationContext = activity.getApplicationContext();
webViewManager = new CocosXRWebViewManager();
@@ -97,40 +106,68 @@ public class CocosXRApi {
activityLifecycleCallbacks = new Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
- onActivityLifecycleCallback(ActivityLifecycleType.Created.ordinal(), activity.getLocalClassName());
+ try {
+ onActivityLifecycleCallback(ActivityLifecycleType.Created.ordinal(), activity.getLocalClassName());
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
}
@Override
public void onActivityStarted(Activity activity) {
webViewManager.onCreate(activity);
- onActivityLifecycleCallback(ActivityLifecycleType.Started.ordinal(), activity.getLocalClassName());
+ try {
+ onActivityLifecycleCallback(ActivityLifecycleType.Started.ordinal(), activity.getLocalClassName());
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
}
@Override
public void onActivityResumed(Activity activity) {
- onActivityLifecycleCallback(ActivityLifecycleType.Resumed.ordinal(), activity.getLocalClassName());
+ try {
+ onActivityLifecycleCallback(ActivityLifecycleType.Resumed.ordinal(), activity.getLocalClassName());
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
webViewManager.onResume();
}
@Override
public void onActivityPaused(Activity activity) {
- onActivityLifecycleCallback(ActivityLifecycleType.Paused.ordinal(), activity.getLocalClassName());
+ try {
+ onActivityLifecycleCallback(ActivityLifecycleType.Paused.ordinal(), activity.getLocalClassName());
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
webViewManager.onPause();
}
@Override
public void onActivityStopped(Activity activity) {
- onActivityLifecycleCallback(ActivityLifecycleType.Stopped.ordinal(), activity.getLocalClassName());
+ try {
+ onActivityLifecycleCallback(ActivityLifecycleType.Stopped.ordinal(), activity.getLocalClassName());
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
- onActivityLifecycleCallback(ActivityLifecycleType.SaveInstanceState.ordinal(), activity.getLocalClassName());
+ try {
+ onActivityLifecycleCallback(ActivityLifecycleType.SaveInstanceState.ordinal(), activity.getLocalClassName());
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
}
@Override
public void onActivityDestroyed(Activity activity) {
- onActivityLifecycleCallback(ActivityLifecycleType.Destroyed.ordinal(), activity.getLocalClassName());
+ try {
+ onActivityLifecycleCallback(ActivityLifecycleType.Destroyed.ordinal(), activity.getLocalClassName());
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
webViewManager.onDestroy();
}
};
@@ -161,6 +198,14 @@ public class CocosXRApi {
}
}
+ public Context getContext() {
+ return applicationContext;
+ }
+
+ public Activity getActivity() {
+ return activityWeakReference.get();
+ }
+
// native
private native void onActivityLifecycleCallback(int id, String activityClassName);
private native void onAdbCmd(String key, String value);
diff --git a/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRVideoManager.java b/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRVideoManager.java
index 77aeb8e487..47dacde325 100644
--- a/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRVideoManager.java
+++ b/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRVideoManager.java
@@ -42,6 +42,7 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
@@ -156,9 +157,9 @@ public class CocosXRVideoManager {
final String XR_VIDEO_EVENT_TAG = "xr-event";
HashMap xrVideoPlayerHashMap = new HashMap<>();
+ HashMap> cachedScriptEventHashMap = new HashMap<>();
CocosXRVideoGLThread videoGLThread = null;
boolean isPaused = false;
-
public void onCreate(Activity activity) {
activityWeakReference = new WeakReference<>(activity);
for (int i = 0; i < MAX_COUNT; i++) {
@@ -180,6 +181,16 @@ public class CocosXRVideoManager {
if(videoGLThread != null) {
videoGLThread.onResume();
}
+ Set>> entrySets = cachedScriptEventHashMap.entrySet();
+ for (Map.Entry> entrySet : entrySets) {
+ if (entrySet.getKey() != null && entrySet.getValue() != null) {
+ for (String data : entrySet.getValue()) {
+ Log.d(TAG, "onResume.dispatchEventToScript:" + entrySet.getKey() + ":" + data);
+ JsbBridgeWrapper.getInstance().dispatchEventToScript(entrySet.getKey(), data);
+ }
+ }
+ }
+ cachedScriptEventHashMap.clear();
}
public void onPause() {
@@ -211,7 +222,11 @@ public class CocosXRVideoManager {
if(videoGLThread == null) return;
if(isPaused) {
- Log.e(TAG, "sendVideoEvent failed, because is paused !!!");
+ Log.e(TAG, "sendVideoEvent failed, because is paused !!! [" + data + "]");
+ if (!cachedScriptEventHashMap.containsKey(eventName)) {
+ cachedScriptEventHashMap.put(eventName, new ArrayList<>());
+ }
+ Objects.requireNonNull(cachedScriptEventHashMap.get(eventName)).add(data.toString());
return;
}
JsbBridgeWrapper.getInstance().dispatchEventToScript(eventName, data.toString());
@@ -234,41 +249,41 @@ public class CocosXRVideoManager {
videoGLThread.start();
}
} else if (videoEventData.eventId == VIDEO_EVENT_PLAY) {
- xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).play();
+ Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).play();
} else if (videoEventData.eventId == VIDEO_EVENT_PAUSE) {
- xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).pause();
+ Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).pause();
} else if (videoEventData.eventId == VIDEO_EVENT_STOP) {
- xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).stop();
+ Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).stop();
} else if (videoEventData.eventId == VIDEO_EVENT_RESET) {
- xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).reset();
+ Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).reset();
} else if (videoEventData.eventId == VIDEO_EVENT_DESTROY) {
- xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).release();
+ Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).release();
videoGLThread.queueEvent(() -> {
- xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).onGLDestroy();
+ Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).onGLDestroy();
xrVideoPlayerHashMap.remove(videoEventData.videoPlayerHandleKey);
});
} else if (videoEventData.eventId == VIDEO_EVENT_GET_POSITION) {
- int position = xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).getCurrentPosition();
+ int position = Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).getCurrentPosition();
sendVideoEvent(videoEventData, String.valueOf(position));
} else if (videoEventData.eventId == VIDEO_EVENT_GET_DURATION) {
- int duration = xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).getDuration();
+ int duration = Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).getDuration();
sendVideoEvent(videoEventData, String.valueOf(duration));
} else if (videoEventData.eventId == VIDEO_EVENT_GET_IS_PALYING) {
- boolean isPlaying = xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).isPlaying();
+ boolean isPlaying = Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).isPlaying();
sendVideoEvent(videoEventData, String.valueOf(isPlaying));
} else if (videoEventData.eventId == VIDEO_EVENT_GET_IS_LOOPING) {
- boolean isLooping = xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).isLooping();
+ boolean isLooping = Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).isLooping();
sendVideoEvent(videoEventData, String.valueOf(isLooping));
} else if (videoEventData.eventId == VIDEO_EVENT_SET_LOOP) {
- xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).setLooping(videoEventData.isLoop);
+ Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).setLooping(videoEventData.isLoop);
} else if (videoEventData.eventId == VIDEO_EVENT_SEEK_TO) {
- xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).seekTo(videoEventData.seekToMsec);
+ Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).seekTo(videoEventData.seekToMsec);
} else if(videoEventData.eventId == VIDEO_EVENT_SET_VOLUME) {
- xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).setVolume(videoEventData.volume);
+ Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).setVolume(videoEventData.volume);
} else if(videoEventData.eventId == VIDEO_EVENT_SET_TEXTURE_INFO) {
- xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).setTextureInfo(videoEventData.videoWidth, videoEventData.videoHeight, videoEventData.videoTextureId);
+ Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).setTextureInfo(videoEventData.videoWidth, videoEventData.videoHeight, videoEventData.videoTextureId);
} else if(videoEventData.eventId == VIDEO_EVENT_SET_SPEED) {
- xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey).setPlaybackSpeed(videoEventData.playbackSpeed);
+ Objects.requireNonNull(xrVideoPlayerHashMap.get(videoEventData.videoPlayerHandleKey)).setPlaybackSpeed(videoEventData.playbackSpeed);
}
}
@@ -288,6 +303,7 @@ public class CocosXRVideoManager {
entrySet.getValue().release();
}
xrVideoPlayerHashMap.clear();
+ cachedScriptEventHashMap.clear();
}
class CocosXRVideoGLThread extends Thread {
diff --git a/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRVideoPlayer.java b/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRVideoPlayer.java
index e2b3122eb3..175fec4597 100644
--- a/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRVideoPlayer.java
+++ b/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/CocosXRVideoPlayer.java
@@ -30,8 +30,10 @@ import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Build;
+import android.text.TextUtils;
import android.util.Log;
import android.view.Surface;
+
import java.io.IOException;
import java.lang.ref.WeakReference;
@@ -135,6 +137,11 @@ public class CocosXRVideoPlayer {
}
this.videoSourceType = data.videoSourceType;
this.videoSourceUrl = data.videoSourceUrl;
+ if(TextUtils.isEmpty(this.videoSourceUrl)) {
+ Log.w(TAG, "prepare failed, because video source is empty !!!");
+ return;
+ }
+
try {
if (data.videoSourceType == CocosXRVideoManager.VIDEO_SOURCE_TYPE_LOCAL) {
AssetFileDescriptor afd = atyWeakReference.get().getResources().getAssets().openFd(data.videoSourceUrl);
diff --git a/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/permission/CocosXRPermissionHelper.java b/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/permission/CocosXRPermissionHelper.java
index 1e5f6fabb5..edf9718787 100644
--- a/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/permission/CocosXRPermissionHelper.java
+++ b/native/cocos/platform/android/libcocosxr/src/com/cocos/lib/xr/permission/CocosXRPermissionHelper.java
@@ -25,12 +25,15 @@
package com.cocos.lib.xr.permission;
import android.app.Activity;
+import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import com.cocos.lib.CocosHelper;
import com.cocos.lib.JsbBridgeWrapper;
+import com.cocos.lib.xr.CocosXRApi;
+
import java.util.Arrays;
public class CocosXRPermissionHelper {
@@ -38,9 +41,6 @@ public class CocosXRPermissionHelper {
public static final String XR_PERMISSION_EVENT_NAME = "xr-permission";
public static final String XR_PERMISSION_TAG_CHECK = "check";
public static final String XR_PERMISSION_TAG_REQUEST = "request";
- public static Activity getForegroundActivity() {
- return CocosHelper.getActivity();
- }
public interface PermissionCallback {
void onRequestPermissionsResult(String[] permissions, int[] grantResults);
}
@@ -58,10 +58,10 @@ public class CocosXRPermissionHelper {
}
public static boolean checkPermission(String permission) {
- Activity activity = getForegroundActivity();
- if (activity == null)
+ Context context = CocosXRApi.getInstance().getContext();
+ if (context == null)
return false;
- if (activity.checkPermission(permission, android.os.Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED) {
+ if (context.checkPermission(permission, android.os.Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED) {
Log.d(LOG_TAG, "checkPermission: " + permission + " has granted");
return true;
} else {
@@ -71,9 +71,8 @@ public class CocosXRPermissionHelper {
}
public static void acquirePermissions(String[] permissions, PermissionCallback callback) {
- Activity activity = getForegroundActivity();
permissionCallback = callback;
- CocosXRPermissionHelper.acquirePermissions(permissions, activity);
+ CocosXRPermissionHelper.acquirePermissions(permissions, CocosXRApi.getInstance().getActivity());
}
public static void acquirePermissions(String[] permissions, Activity InActivity) {
diff --git a/native/cocos/platform/empty/modules/System.cpp b/native/cocos/platform/empty/modules/System.cpp
index baf862eeef..c9fe0afac1 100644
--- a/native/cocos/platform/empty/modules/System.cpp
+++ b/native/cocos/platform/empty/modules/System.cpp
@@ -58,4 +58,9 @@ System::LanguageType System::getLanguageTypeByISO2(const char *code) const {
LanguageType ret = LanguageType::ENGLISH;
return ret;
}
+
+void System::copyTextToClipboard(const ccstd::string &text) {
+ // TODO
+}
+
} // namespace cc
\ No newline at end of file
diff --git a/native/cocos/platform/empty/modules/System.h b/native/cocos/platform/empty/modules/System.h
index 1dd6fba91c..68c7799665 100644
--- a/native/cocos/platform/empty/modules/System.h
+++ b/native/cocos/platform/empty/modules/System.h
@@ -59,6 +59,7 @@ public:
@return True if the resource located by the URL was successfully opened; otherwise false.
*/
bool openURL(const ccstd::string &url) override;
+ void copyTextToClipboard(const ccstd::string &text) override;
private:
LanguageType getLanguageTypeByISO2(const char *code) const;
diff --git a/native/cocos/platform/empty/modules/SystemWindow.cpp b/native/cocos/platform/empty/modules/SystemWindow.cpp
index 4a4eae0b6e..e40c9bad75 100644
--- a/native/cocos/platform/empty/modules/SystemWindow.cpp
+++ b/native/cocos/platform/empty/modules/SystemWindow.cpp
@@ -54,10 +54,6 @@ uint32_t SystemWindow::getWindowId() const {
void SystemWindow::setCursorEnabled(bool value) {
}
-void SystemWindow::copyTextToClipboard(const ccstd::string& text) {
- // TODO
-}
-
int SystemWindow::init() {
return 0;
}
diff --git a/native/cocos/platform/empty/modules/SystemWindow.h b/native/cocos/platform/empty/modules/SystemWindow.h
index ffb390fd9c..dd1b14ad48 100644
--- a/native/cocos/platform/empty/modules/SystemWindow.h
+++ b/native/cocos/platform/empty/modules/SystemWindow.h
@@ -43,7 +43,6 @@ public:
@brief enable/disable(lock) the cursor, default is enabled
*/
void setCursorEnabled(bool value) override;
- void copyTextToClipboard(const std::string& text) override;
int init();
void pollEvent(bool* quit);
diff --git a/native/cocos/platform/interfaces/modules/ISystem.h b/native/cocos/platform/interfaces/modules/ISystem.h
index 6e0e432ca4..0f9d68d129 100644
--- a/native/cocos/platform/interfaces/modules/ISystem.h
+++ b/native/cocos/platform/interfaces/modules/ISystem.h
@@ -79,6 +79,7 @@ public:
virtual ccstd::string getCurrentLanguageToString();
+ virtual void copyTextToClipboard(const ccstd::string& text) = 0;
/**
@brief Open url in default browser.
@param String with url to open.
diff --git a/native/cocos/platform/interfaces/modules/ISystemWindow.h b/native/cocos/platform/interfaces/modules/ISystemWindow.h
index 0903b31e4c..021baa7df2 100644
--- a/native/cocos/platform/interfaces/modules/ISystemWindow.h
+++ b/native/cocos/platform/interfaces/modules/ISystemWindow.h
@@ -102,8 +102,6 @@ public:
@brief enable/disable(lock) the cursor, default is enabled
*/
virtual void setCursorEnabled(bool value) = 0;
-
- virtual void copyTextToClipboard(const ccstd::string& text) = 0;
};
} // namespace cc
diff --git a/native/cocos/platform/interfaces/modules/XRCommon.h b/native/cocos/platform/interfaces/modules/XRCommon.h
index f05efca767..35a128ae19 100644
--- a/native/cocos/platform/interfaces/modules/XRCommon.h
+++ b/native/cocos/platform/interfaces/modules/XRCommon.h
@@ -115,6 +115,7 @@ enum class XRConfigKey {
SPATIAL_MESHING = 51,
SPATIAL_MESHING_DATA = 52,
SPATIAL_MESHING_SUPPORT_STATUS = 53,
+ EYE_RENDER_JS_CALLBACK = 54,
ASYNC_LOAD_ASSETS_IMAGE = 55,
ASYNC_LOAD_ASSETS_IMAGE_RESULTS = 56,
MAX_COUNT
@@ -377,17 +378,16 @@ struct XRTrackingImageData {
#define GraphicsApiVulkan_1_1 "Vulkan2"
enum class XRActivityLifecycleType {
- UnKnown,
- Created,
- Started,
- Resumed,
- Paused,
- Stopped,
- SaveInstanceState,
- Destroyed
+ UnKnown,
+ Created,
+ Started,
+ Resumed,
+ Paused,
+ Stopped,
+ SaveInstanceState,
+ Destroyed
};
-
} // namespace xr
} // namespace cc
#endif // XR_COMMON_H_
diff --git a/native/cocos/platform/ios/modules/System.h b/native/cocos/platform/ios/modules/System.h
index bacf60f941..e78a49352c 100644
--- a/native/cocos/platform/ios/modules/System.h
+++ b/native/cocos/platform/ios/modules/System.h
@@ -58,7 +58,8 @@ public:
* @param String with url to open.
* @return True if the resource located by the URL was successfully opened; otherwise false.
*/
- bool openURL(const ccstd::string &url) override;
+ bool openURL(const ccstd::string& url) override;
+ void copyTextToClipboard(const std::string& text) override;
};
} // namespace cc
diff --git a/native/cocos/platform/ios/modules/System.mm b/native/cocos/platform/ios/modules/System.mm
index b90ff216a0..d2c253f45f 100644
--- a/native/cocos/platform/ios/modules/System.mm
+++ b/native/cocos/platform/ios/modules/System.mm
@@ -100,4 +100,10 @@ bool System::openURL(const ccstd::string &url) {
}];
return flag;
}
+
+void System::copyTextToClipboard(const std::string& text) {
+ UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
+ pasteboard.string = [NSString stringWithCString:text.c_str() encoding:NSUTF8StringEncoding];
+}
+
} // namespace cc
diff --git a/native/cocos/platform/ios/modules/SystemWindow.h b/native/cocos/platform/ios/modules/SystemWindow.h
index 5d9968bd36..0871b9f052 100644
--- a/native/cocos/platform/ios/modules/SystemWindow.h
+++ b/native/cocos/platform/ios/modules/SystemWindow.h
@@ -43,7 +43,6 @@ public:
@brief enable/disable(lock) the cursor, default is enabled
*/
void setCursorEnabled(bool value) override;
- void copyTextToClipboard(const std::string& text) override;
uint32_t getWindowId() const override { return _windowId; }
UIWindow* getUIWindow() const { return _window; }
diff --git a/native/cocos/platform/ios/modules/SystemWindow.mm b/native/cocos/platform/ios/modules/SystemWindow.mm
index 46a271b779..dd6d5549fe 100644
--- a/native/cocos/platform/ios/modules/SystemWindow.mm
+++ b/native/cocos/platform/ios/modules/SystemWindow.mm
@@ -41,10 +41,6 @@ SystemWindow::~SystemWindow() = default;
void SystemWindow::setCursorEnabled(bool value) {
}
-void SystemWindow::copyTextToClipboard(const std::string& text) {
- UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
- pasteboard.string = [NSString stringWithCString:text.c_str() encoding:NSUTF8StringEncoding];
-}
void SystemWindow::closeWindow() {
// Force quit as there's no API to exit UIApplication
IOSPlatform* platform = dynamic_cast(BasePlatform::getPlatform());
diff --git a/native/cocos/platform/java/modules/CommonSystem.cpp b/native/cocos/platform/java/modules/CommonSystem.cpp
index 5f2505acbc..b5d44dd2d3 100644
--- a/native/cocos/platform/java/modules/CommonSystem.cpp
+++ b/native/cocos/platform/java/modules/CommonSystem.cpp
@@ -95,4 +95,8 @@ bool CommonSystem::openURL(const ccstd::string &url) {
return openURLJNI(url);
}
+void CommonSystem::copyTextToClipboard(const ccstd::string &text) {
+ copyTextToClipboardJNI(text);
+}
+
} // namespace cc
\ No newline at end of file
diff --git a/native/cocos/platform/java/modules/CommonSystem.h b/native/cocos/platform/java/modules/CommonSystem.h
index d1074f90a5..1ec7e08067 100644
--- a/native/cocos/platform/java/modules/CommonSystem.h
+++ b/native/cocos/platform/java/modules/CommonSystem.h
@@ -56,7 +56,9 @@ public:
@param String with url to open.
@return True if the resource located by the URL was successfully opened; otherwise false.
*/
- bool openURL(const ccstd::string &url) override;
+ bool openURL(const ccstd::string& url) override;
+
+ void copyTextToClipboard(const std::string& text) override;
};
} // namespace cc
\ No newline at end of file
diff --git a/native/cocos/platform/java/modules/SystemWindow.cpp b/native/cocos/platform/java/modules/SystemWindow.cpp
index 8886e9d7ae..d73f951fa3 100644
--- a/native/cocos/platform/java/modules/SystemWindow.cpp
+++ b/native/cocos/platform/java/modules/SystemWindow.cpp
@@ -52,10 +52,6 @@ SystemWindow::SystemWindow(uint32_t windowId, void *externalHandle)
void SystemWindow::setCursorEnabled(bool value) {
}
-void SystemWindow::copyTextToClipboard(const ccstd::string &text) {
- copyTextToClipboardJNI(text);
-}
-
void SystemWindow::setWindowHandle(void *handle) {
#if (CC_PLATFORM == CC_PLATFORM_ANDROID)
//The getWindowHandle interface may have been called earlier, causing _handleMutex to be occupied all the time.
diff --git a/native/cocos/platform/java/modules/SystemWindow.h b/native/cocos/platform/java/modules/SystemWindow.h
index 53fc471f6f..6933acb620 100644
--- a/native/cocos/platform/java/modules/SystemWindow.h
+++ b/native/cocos/platform/java/modules/SystemWindow.h
@@ -43,8 +43,6 @@ public:
*/
void setCursorEnabled(bool value) override;
- void copyTextToClipboard(const std::string &text) override;
-
void setWindowHandle(void *handle);
uintptr_t getWindowHandle() const override;
uint32_t getWindowId() const override { return _windowId; }
diff --git a/native/cocos/platform/java/modules/XRInterface.cpp b/native/cocos/platform/java/modules/XRInterface.cpp
index 7697190bda..a9995cbfe5 100644
--- a/native/cocos/platform/java/modules/XRInterface.cpp
+++ b/native/cocos/platform/java/modules/XRInterface.cpp
@@ -27,20 +27,20 @@
#include
#include
#include
-#include "cocos-version.h"
#include "android/AndroidPlatform.h"
#include "base/Log.h"
#include "base/Macros.h"
#include "base/StringUtil.h"
#include "bindings/event/EventDispatcher.h"
+#include "cocos-version.h"
#include "cocos/bindings/jswrapper/SeApi.h"
+#include "core/scene-graph/Node.h"
#include "java/jni/JniHelper.h"
-#include "renderer/GFXDeviceManager.h"
#include "platform/interfaces/modules/ISystemWindow.h"
#include "platform/interfaces/modules/ISystemWindowManager.h"
+#include "renderer/GFXDeviceManager.h"
#include "scene/Camera.h"
#include "scene/RenderWindow.h"
-#include "core/scene-graph/Node.h"
#ifdef CC_USE_VULKAN
#include "gfx-vulkan/VKDevice.h"
#endif
@@ -472,7 +472,7 @@ void XRInterface::initialize(void *javaVM, void *activity) {
_gThreadPool = LegacyThreadPool::newSingleThreadPool();
}
_gThreadPool->pushTask([imagePath, this](int /*tid*/) {
- this->asyncLoadAssetsImage(imagePath);
+ this->asyncLoadAssetsImage(imagePath);
});
} else if (key == xr::XRConfigKey::ASYNC_LOAD_ASSETS_IMAGE && value.isInt()) {
_isFlipPixelY = value.getInt() == static_cast(gfx::API::GLES3);
@@ -801,6 +801,7 @@ bool XRInterface::platformLoopStart() {
bool XRInterface::beginRenderFrame() {
#if CC_USE_XR
if (IS_ENABLE_XR_LOG) CC_LOG_INFO("[XR] beginRenderFrame.%d", _committedFrame);
+ _isEnabledEyeRenderJsCallback = xr::XrEntry::getInstance()->getXRConfig(xr::XRConfigKey::EYE_RENDER_JS_CALLBACK).getBool();
if (gfx::DeviceAgent::getInstance()) {
static uint64_t frameId = 0;
frameId++;
@@ -846,6 +847,11 @@ bool XRInterface::isRenderAllowable() {
bool XRInterface::beginRenderEyeFrame(uint32_t eye) {
#if CC_USE_XR
if (IS_ENABLE_XR_LOG) CC_LOG_INFO("[XR] beginRenderEyeFrame %d", eye);
+ if (_isEnabledEyeRenderJsCallback) {
+ se::ValueArray args;
+ args.emplace_back(se::Value(eye));
+ EventDispatcher::doDispatchJsEvent("onXREyeRenderBegin", args);
+ }
if (gfx::DeviceAgent::getInstance()) {
ENQUEUE_MESSAGE_1(gfx::DeviceAgent::getInstance()->getMessageQueue(),
BeginRenderEyeFrame, eye, eye,
@@ -865,6 +871,11 @@ bool XRInterface::beginRenderEyeFrame(uint32_t eye) {
bool XRInterface::endRenderEyeFrame(uint32_t eye) {
#if CC_USE_XR
if (IS_ENABLE_XR_LOG) CC_LOG_INFO("[XR] endRenderEyeFrame %d", eye);
+ if (_isEnabledEyeRenderJsCallback) {
+ se::ValueArray args;
+ args.emplace_back(se::Value(eye));
+ EventDispatcher::doDispatchJsEvent("onXREyeRenderEnd", args);
+ }
if (gfx::DeviceAgent::getInstance()) {
ENQUEUE_MESSAGE_1(gfx::DeviceAgent::getInstance()->getMessageQueue(),
EndRenderEyeFrame, eye, eye,
@@ -1143,7 +1154,7 @@ void XRInterface::asyncLoadAssetsImage(const std::string &imagePath) {
}
} else {
buffer = new uint8_t[bufferSize];
- if(_isFlipPixelY) {
+ if (_isFlipPixelY) {
for (uint32_t y = 0; y < imageHeight; y++) {
for (uint32_t x = 0; x < imageWidth; x++) {
const unsigned int pixel = x + y * imageWidth;
@@ -1168,28 +1179,28 @@ void XRInterface::asyncLoadAssetsImage(const std::string &imagePath) {
auto engine = app->getEngine();
CC_ASSERT_NOT_NULL(engine);
engine->getScheduler()->performFunctionInCocosThread([=]() {
- auto *imageData = new xr::XRTrackingImageData();
- imageData->friendlyName = imagePath;
- imageData->bufferSize = bufferSize;
- imageData->buffer = buffer;
- imageData->pixelSizeWidth = imageWidth;
- imageData->pixelSizeHeight = imageHeight;
- if (!this->getXRConfig(xr::XRConfigKey::ASYNC_LOAD_ASSETS_IMAGE_RESULTS).getPointer()) {
- auto *imagesMapPtr = new std::unordered_map();
- (*imagesMapPtr).emplace(std::make_pair(imagePath, static_cast(imageData)));
- this->setXRConfig(xr::XRConfigKey::ASYNC_LOAD_ASSETS_IMAGE_RESULTS, static_cast(imagesMapPtr));
- } else {
- auto *imagesMapPtr = static_cast *>(getXRConfig(xr::XRConfigKey::ASYNC_LOAD_ASSETS_IMAGE_RESULTS).getPointer());
- (*imagesMapPtr).emplace(std::make_pair(imagePath, static_cast(imageData)));
- }
+ auto *imageData = new xr::XRTrackingImageData();
+ imageData->friendlyName = imagePath;
+ imageData->bufferSize = bufferSize;
+ imageData->buffer = buffer;
+ imageData->pixelSizeWidth = imageWidth;
+ imageData->pixelSizeHeight = imageHeight;
+ if (!this->getXRConfig(xr::XRConfigKey::ASYNC_LOAD_ASSETS_IMAGE_RESULTS).getPointer()) {
+ auto *imagesMapPtr = new std::unordered_map();
+ (*imagesMapPtr).emplace(std::make_pair(imagePath, static_cast(imageData)));
+ this->setXRConfig(xr::XRConfigKey::ASYNC_LOAD_ASSETS_IMAGE_RESULTS, static_cast(imagesMapPtr));
+ } else {
+ auto *imagesMapPtr = static_cast *>(getXRConfig(xr::XRConfigKey::ASYNC_LOAD_ASSETS_IMAGE_RESULTS).getPointer());
+ (*imagesMapPtr).emplace(std::make_pair(imagePath, static_cast(imageData)));
+ }
});
assetsImage->release();
}
#if CC_USE_XR
-extern "C" JNIEXPORT void JNICALL Java_com_cocos_lib_xr_CocosXRApi_onAdbCmd(JNIEnv * /*env*/, jobject /*thiz*/, jstring key, jstring value) {
+extern "C" JNIEXPORT void JNICALL Java_com_cocos_lib_xr_CocosXRApi_onAdbCmd(JNIEnv * /*env*/, jobject /*thiz*/, jstring key, jstring value) {
auto cmdKey = cc::JniHelper::jstring2string(key);
auto cmdValue = cc::JniHelper::jstring2string(value);
if (IS_ENABLE_XR_LOG) {
@@ -1198,7 +1209,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_cocos_lib_xr_CocosXRApi_onAdbCmd(JNIE
cc::xr::XrEntry::getInstance()->setXRConfig(cc::xr::XRConfigKey::ADB_COMMAND, cmdKey.append(":").append(cmdValue));
}
-extern "C" JNIEXPORT void JNICALL Java_com_cocos_lib_xr_CocosXRApi_onActivityLifecycleCallback(JNIEnv * /*env*/, jobject /*thiz*/, jint type, jstring activityClassName) {
+extern "C" JNIEXPORT void JNICALL Java_com_cocos_lib_xr_CocosXRApi_onActivityLifecycleCallback(JNIEnv * /*env*/, jobject /*thiz*/, jint type, jstring activityClassName) {
auto name = cc::JniHelper::jstring2string(activityClassName);
if (IS_ENABLE_XR_LOG) {
CC_LOG_INFO("CocosXRApi_onActivityLifecycleCallback_%d_%s", type, name.c_str());
diff --git a/native/cocos/platform/java/modules/XRInterface.h b/native/cocos/platform/java/modules/XRInterface.h
index af4e5cebd1..f82a7e4550 100644
--- a/native/cocos/platform/java/modules/XRInterface.h
+++ b/native/cocos/platform/java/modules/XRInterface.h
@@ -100,6 +100,7 @@ public:
void bindXREyeWithRenderWindow(void *window, xr::XREye eye) override;
void handleAppCommand(int appCmd) override;
void adaptOrthographicMatrix(cc::scene::Camera *camera, const ccstd::array &preTransform, Mat4 &proj, Mat4 &view) override;
+
private:
void loadImageTrackingData(const std::string &imageInfo);
void asyncLoadAssetsImage(const std::string &imagePath);
@@ -133,6 +134,7 @@ private:
#endif
LegacyThreadPool *_gThreadPool{nullptr};
bool _isFlipPixelY{false};
+ bool _isEnabledEyeRenderJsCallback{false};
};
} // namespace cc
diff --git a/native/cocos/platform/linux/modules/System.cpp b/native/cocos/platform/linux/modules/System.cpp
index cdaab9b760..59e696a3f5 100644
--- a/native/cocos/platform/linux/modules/System.cpp
+++ b/native/cocos/platform/linux/modules/System.cpp
@@ -25,6 +25,7 @@
#include "platform/linux/modules/System.h"
#include
#include
+#include "SDL2/SDL_clipboard.h"
namespace cc {
@@ -123,4 +124,9 @@ System::LanguageType System::getLanguageTypeByISO2(const char *code) const {
}
return ret;
}
+
+void System::copyTextToClipboard(const ccstd::string &text) {
+ SDL_SetClipboardText(text.c_str());
+}
+
} // namespace cc
\ No newline at end of file
diff --git a/native/cocos/platform/linux/modules/System.h b/native/cocos/platform/linux/modules/System.h
index 540292e2f2..dd20d1ca69 100644
--- a/native/cocos/platform/linux/modules/System.h
+++ b/native/cocos/platform/linux/modules/System.h
@@ -60,6 +60,8 @@ public:
*/
bool openURL(const ccstd::string &url) override;
+ void copyTextToClipboard(const std::string &text) override;
+
private:
LanguageType getLanguageTypeByISO2(const char *code) const;
};
diff --git a/native/cocos/platform/linux/modules/SystemWindow.cpp b/native/cocos/platform/linux/modules/SystemWindow.cpp
index acc9e1c29f..7c3d280aa3 100644
--- a/native/cocos/platform/linux/modules/SystemWindow.cpp
+++ b/native/cocos/platform/linux/modules/SystemWindow.cpp
@@ -96,10 +96,6 @@ void SystemWindow::setCursorEnabled(bool value) {
SDLHelper::setCursorEnabled(value);
}
-void SystemWindow::copyTextToClipboard(const ccstd::string &text) {
- //TODO
-}
-
SystemWindow::Size SystemWindow::getViewSize() const {
return Size{static_cast(_width), static_cast(_height)};
}
diff --git a/native/cocos/platform/linux/modules/SystemWindow.h b/native/cocos/platform/linux/modules/SystemWindow.h
index da19d53f60..8bf9267a64 100644
--- a/native/cocos/platform/linux/modules/SystemWindow.h
+++ b/native/cocos/platform/linux/modules/SystemWindow.h
@@ -3,23 +3,23 @@
http://www.cocos.com
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights to
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- of the Software, and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
****************************************************************************/
#pragma once
@@ -58,7 +58,6 @@ public:
@brief enable/disable(lock) the cursor, default is enabled
*/
void setCursorEnabled(bool value) override;
- void copyTextToClipboard(const std::string& text) override;
private:
SDL_Window* getSDLWindow() const { return _window; }
diff --git a/native/cocos/platform/mac/modules/System.h b/native/cocos/platform/mac/modules/System.h
index 31908ab6fa..d86d917145 100644
--- a/native/cocos/platform/mac/modules/System.h
+++ b/native/cocos/platform/mac/modules/System.h
@@ -58,7 +58,9 @@ public:
@param String with url to open.
@return True if the resource located by the URL was successfully opened; otherwise false.
*/
- bool openURL(const ccstd::string &url) override;
+ bool openURL(const ccstd::string& url) override;
+
+ void copyTextToClipboard(const std::string& text) override;
};
} // namespace cc
diff --git a/native/cocos/platform/mac/modules/System.mm b/native/cocos/platform/mac/modules/System.mm
index 343e0605fe..562f4944b5 100644
--- a/native/cocos/platform/mac/modules/System.mm
+++ b/native/cocos/platform/mac/modules/System.mm
@@ -96,4 +96,12 @@ bool System::openURL(const ccstd::string &url) {
NSURL *nsUrl = [NSURL URLWithString:msg];
return [[NSWorkspace sharedWorkspace] openURL:nsUrl];
}
+
+void System::copyTextToClipboard(const std::string &text) {
+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
+ [pasteboard clearContents];
+ NSString *tmp = [NSString stringWithCString:text.c_str() encoding:NSUTF8StringEncoding];
+ [pasteboard setString:tmp forType:NSPasteboardTypeString];
+}
+
} // namespace cc
diff --git a/native/cocos/platform/mac/modules/SystemWindow.h b/native/cocos/platform/mac/modules/SystemWindow.h
index 2aeb273df7..5a58f9c685 100644
--- a/native/cocos/platform/mac/modules/SystemWindow.h
+++ b/native/cocos/platform/mac/modules/SystemWindow.h
@@ -56,10 +56,10 @@ public:
@brief enable/disable(lock) the cursor, default is enabled
*/
void setCursorEnabled(bool value) override;
- void copyTextToClipboard(const std::string& text) override;
-
+
bool isPointerLock() const;
void setLastMousePos(float x, float y);
+
private:
bool _pointerLock{false};
float _lastMousePosX{0.0F};
diff --git a/native/cocos/platform/mac/modules/SystemWindow.mm b/native/cocos/platform/mac/modules/SystemWindow.mm
index f51a186a08..bb8d4760ac 100644
--- a/native/cocos/platform/mac/modules/SystemWindow.mm
+++ b/native/cocos/platform/mac/modules/SystemWindow.mm
@@ -117,13 +117,6 @@ void SystemWindow::setCursorEnabled(bool value) {
events::PointerLock::broadcast(!value);
}
-void SystemWindow::copyTextToClipboard(const std::string &text) {
- NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
- [pasteboard clearContents];
- NSString *tmp = [NSString stringWithCString:text.c_str() encoding:NSUTF8StringEncoding];
- [pasteboard setString:tmp forType:NSPasteboardTypeString];
-}
-
uintptr_t SystemWindow::getWindowHandle() const {
//NSView *view = [[[[NSApplication sharedApplication] delegate] getWindow] contentView];
return _windowHandle;
diff --git a/native/cocos/platform/win32/modules/System.cpp b/native/cocos/platform/win32/modules/System.cpp
index 1ce378982c..a14854c857 100644
--- a/native/cocos/platform/win32/modules/System.cpp
+++ b/native/cocos/platform/win32/modules/System.cpp
@@ -24,8 +24,8 @@
#include "platform/win32/modules/System.h"
#include
+#include "SDL2/SDL_clipboard.h"
#include "base/memory/Memory.h"
-
namespace cc {
using OSType = System::OSType;
@@ -147,4 +147,9 @@ bool System::openURL(const ccstd::string &url) {
delete[] temp;
return (size_t)r > 32;
}
+
+void System::copyTextToClipboard(const ccstd::string &text) {
+ SDL_SetClipboardText(text.c_str());
+}
+
} // namespace cc
diff --git a/native/cocos/platform/win32/modules/System.h b/native/cocos/platform/win32/modules/System.h
index 8775f73ee0..ff8d98e927 100644
--- a/native/cocos/platform/win32/modules/System.h
+++ b/native/cocos/platform/win32/modules/System.h
@@ -58,7 +58,8 @@ public:
@param String with url to open.
@return True if the resource located by the URL was successfully opened; otherwise false.
*/
- bool openURL(const ccstd::string &url) override;
+ bool openURL(const ccstd::string& url) override;
+ void copyTextToClipboard(const std::string& text) override;
};
} // namespace cc
diff --git a/native/cocos/platform/win32/modules/SystemWindow.cpp b/native/cocos/platform/win32/modules/SystemWindow.cpp
index 27128fa481..1d58d8c081 100644
--- a/native/cocos/platform/win32/modules/SystemWindow.cpp
+++ b/native/cocos/platform/win32/modules/SystemWindow.cpp
@@ -29,7 +29,6 @@
#include "engine/EngineEvents.h"
#include "platform/SDLHelper.h"
#include "platform/win32/WindowsPlatform.h"
-#include "sdl2/SDL_clipboard.h"
namespace cc {
SystemWindow::SystemWindow(uint32_t windowId, void *externalHandle)
@@ -91,10 +90,6 @@ void SystemWindow::setCursorEnabled(bool value) {
SDLHelper::setCursorEnabled(value);
}
-void SystemWindow::copyTextToClipboard(const ccstd::string &text) {
- SDL_SetClipboardText(text.c_str());
-}
-
SystemWindow::Size SystemWindow::getViewSize() const {
return Size{static_cast(_width), static_cast(_height)};
}
diff --git a/native/cocos/platform/win32/modules/SystemWindow.h b/native/cocos/platform/win32/modules/SystemWindow.h
index 9365a64613..3a8ee14cd1 100644
--- a/native/cocos/platform/win32/modules/SystemWindow.h
+++ b/native/cocos/platform/win32/modules/SystemWindow.h
@@ -58,7 +58,6 @@ public:
@brief enable/disable(lock) the cursor, default is enabled
*/
void setCursorEnabled(bool value) override;
- void copyTextToClipboard(const std::string& text) override;
private:
SDL_Window* getSDLWindow() const { return _window; }
diff --git a/native/cocos/renderer/core/ProgramLib.cpp b/native/cocos/renderer/core/ProgramLib.cpp
index 36097092d4..ab2faddc85 100644
--- a/native/cocos/renderer/core/ProgramLib.cpp
+++ b/native/cocos/renderer/core/ProgramLib.cpp
@@ -488,7 +488,7 @@ gfx::Shader *ProgramLib::getGFXShader(gfx::Device *device, const ccstd::string &
tmplInfo.shaderInfo.attributes = render::getActiveAttributes(tmpl, tmplInfo.gfxAttributes, defines);
tmplInfo.shaderInfo.name = render::getShaderInstanceName(name, macroArray);
-
+ tmplInfo.shaderInfo.hash = tmpl.hash;
auto *shader = device->createShader(tmplInfo.shaderInfo);
_cache[key] = shader;
// CC_LOG_DEBUG("ProgramLib::_cache[%s]=%p, defines: %d", key.c_str(), shader, defines.size());
diff --git a/native/cocos/renderer/gfx-agent/CommandBufferAgent.cpp b/native/cocos/renderer/gfx-agent/CommandBufferAgent.cpp
index 04276e9ec1..204df36faf 100644
--- a/native/cocos/renderer/gfx-agent/CommandBufferAgent.cpp
+++ b/native/cocos/renderer/gfx-agent/CommandBufferAgent.cpp
@@ -383,6 +383,27 @@ void CommandBufferAgent::updateBuffer(Buffer *buff, const void *data, uint32_t s
});
}
+void CommandBufferAgent::copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) {
+ Texture *actorSrcTexture = nullptr;
+ Texture *actorDstTexture = nullptr;
+ if (srcTexture) actorSrcTexture = static_cast(srcTexture)->getActor();
+ if (dstTexture) actorDstTexture = static_cast(dstTexture)->getActor();
+
+ auto *actorRegions = _messageQueue->allocate(count);
+ memcpy(actorRegions, regions, count * sizeof(TextureCopy));
+
+ ENQUEUE_MESSAGE_5(
+ _messageQueue, CommandBufferBlitTexture,
+ actor, getActor(),
+ srcTexture, actorSrcTexture,
+ dstTexture, actorDstTexture,
+ regions, actorRegions,
+ count, count,
+ {
+ actor->copyTexture(srcTexture, dstTexture, regions, count);
+ });
+}
+
void CommandBufferAgent::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) {
Texture *actorSrcTexture = nullptr;
Texture *actorDstTexture = nullptr;
@@ -450,7 +471,7 @@ void CommandBufferAgent::pipelineBarrier(const GeneralBarrier *barrier, const Bu
actor, getActor(),
barrier, barrier,
bufferBarriers, actorBufferBarriers,
- buffers, buffers,
+ buffers, actorBuffers,
bufferBarrierCount, bufferBarrierCount,
textureBarriers, actorTextureBarriers,
textures, actorTextures,
@@ -510,5 +531,15 @@ void CommandBufferAgent::completeQueryPool(QueryPool *queryPool) {
});
}
+void CommandBufferAgent::customCommand(CustomCommand &&cmd) {
+ ENQUEUE_MESSAGE_2(
+ _messageQueue, CommandBufferCompleteQueryPool,
+ actor, getActor(),
+ cmd, cmd,
+ {
+ actor->customCommand(std::move(cmd));
+ });
+}
+
} // namespace gfx
} // namespace cc
diff --git a/native/cocos/renderer/gfx-agent/CommandBufferAgent.h b/native/cocos/renderer/gfx-agent/CommandBufferAgent.h
index fef058d3b5..95ddf92a57 100644
--- a/native/cocos/renderer/gfx-agent/CommandBufferAgent.h
+++ b/native/cocos/renderer/gfx-agent/CommandBufferAgent.h
@@ -60,6 +60,7 @@ public:
void updateBuffer(Buffer *buff, const void *data, uint32_t size) override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) override;
void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) override;
+ void copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) override;
void execute(CommandBuffer *const *cmdBuffs, uint32_t count) override;
void dispatch(const DispatchInfo &info) override;
void pipelineBarrier(const GeneralBarrier *barrier, const BufferBarrier *const *bufferBarriers, const Buffer *const *buffers, uint32_t bufferBarrierCount, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint32_t textureBarrierCount) override;
@@ -67,6 +68,7 @@ public:
void endQuery(QueryPool *queryPool, uint32_t id) override;
void resetQueryPool(QueryPool *queryPool) override;
void completeQueryPool(QueryPool *queryPool) override;
+ void customCommand(CustomCommand &&cmd) override;
uint32_t getNumDrawCalls() const override { return _actor->getNumDrawCalls(); }
uint32_t getNumInstances() const override { return _actor->getNumInstances(); }
diff --git a/native/cocos/renderer/gfx-agent/DeviceAgent.cpp b/native/cocos/renderer/gfx-agent/DeviceAgent.cpp
index 0f89e3dbb7..16fe3f531e 100644
--- a/native/cocos/renderer/gfx-agent/DeviceAgent.cpp
+++ b/native/cocos/renderer/gfx-agent/DeviceAgent.cpp
@@ -287,6 +287,10 @@ TextureBarrier *DeviceAgent::getTextureBarrier(const TextureBarrierInfo &info) {
return _actor->getTextureBarrier(info);
}
+BufferBarrier *DeviceAgent::getBufferBarrier(const BufferBarrierInfo &info) {
+ return _actor->getBufferBarrier(info);
+}
+
template
void doBufferTextureCopy(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count, MessageQueue *mq, T *actor) {
uint32_t bufferCount = 0U;
diff --git a/native/cocos/renderer/gfx-agent/DeviceAgent.h b/native/cocos/renderer/gfx-agent/DeviceAgent.h
index e7507b36d5..cbbb969346 100644
--- a/native/cocos/renderer/gfx-agent/DeviceAgent.h
+++ b/native/cocos/renderer/gfx-agent/DeviceAgent.h
@@ -86,6 +86,7 @@ public:
Sampler *getSampler(const SamplerInfo &info) override;
GeneralBarrier *getGeneralBarrier(const GeneralBarrierInfo &info) override;
TextureBarrier *getTextureBarrier(const TextureBarrierInfo &info) override;
+ BufferBarrier *getBufferBarrier(const BufferBarrierInfo &info) override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint32_t count) override;
void copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint32_t count) override;
diff --git a/native/cocos/renderer/gfx-base/GFXBarrier.cpp b/native/cocos/renderer/gfx-base/GFXBarrier.cpp
index 4d44186197..165532b534 100644
--- a/native/cocos/renderer/gfx-base/GFXBarrier.cpp
+++ b/native/cocos/renderer/gfx-base/GFXBarrier.cpp
@@ -1,845 +1,903 @@
-/****************************************************************************
- Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
-
- https://www.cocos.com/
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights to
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- of the Software, and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-****************************************************************************/
-
-#include "GFXBarrier.h"
-#include
-#include
-
-namespace cc {
-
-namespace gfx {
-
-namespace {
-
-enum class ResourceType : uint32_t {
- UNKNOWN,
- BUFFER,
- TEXTURE,
-};
-
-enum class CommonUsage : uint32_t {
- NONE = 1 << 0,
- COPY_SRC = 1 << 1,
- COPY_DST = 1 << 2,
- ROM = 1 << 3, // sampled or UNIFORM
- STORAGE = 1 << 4,
- IB_OR_CA = 1 << 5,
- VB_OR_DS = 1 << 6,
- INDIRECT_OR_INPUT = 1 << 7,
-};
-CC_ENUM_BITWISE_OPERATORS(CommonUsage);
-
-constexpr CommonUsage textureUsageToCommonUsage(TextureUsage usage) {
- CommonUsage res{0};
- if (hasFlag(usage, TextureUsage::NONE)) {
- res |= CommonUsage::NONE;
- }
- if (hasFlag(usage, TextureUsage::TRANSFER_SRC)) {
- res |= CommonUsage::COPY_SRC;
- }
- if (hasFlag(usage, TextureUsage::TRANSFER_DST)) {
- res |= CommonUsage::COPY_DST;
- }
- if (hasFlag(usage, TextureUsage::SAMPLED)) {
- res |= CommonUsage::ROM;
- }
- if (hasFlag(usage, TextureUsage::STORAGE)) {
- res |= CommonUsage::STORAGE;
- }
- if (hasFlag(usage, TextureUsage::COLOR_ATTACHMENT)) {
- res |= CommonUsage::IB_OR_CA;
- }
- if (hasFlag(usage, TextureUsage::DEPTH_STENCIL_ATTACHMENT)) {
- res |= CommonUsage::VB_OR_DS;
- }
- if (hasFlag(usage, TextureUsage::INPUT_ATTACHMENT)) {
- res |= CommonUsage::INDIRECT_OR_INPUT;
- }
- return res;
-}
-
-constexpr CommonUsage bufferUsageToCommonUsage(BufferUsage usage) {
- CommonUsage res{0};
- if (hasFlag(usage, BufferUsage::NONE)) {
- res |= CommonUsage::NONE;
- }
- if (hasFlag(usage, BufferUsage::TRANSFER_SRC)) {
- res |= CommonUsage::COPY_SRC;
- }
- if (hasFlag(usage, BufferUsage::TRANSFER_DST)) {
- res |= CommonUsage::COPY_DST;
- }
- if (hasFlag(usage, BufferUsage::UNIFORM)) {
- res |= CommonUsage::ROM;
- }
- if (hasFlag(usage, BufferUsage::STORAGE)) {
- res |= CommonUsage::STORAGE;
- }
- if (hasFlag(usage, BufferUsage::INDEX)) {
- res |= CommonUsage::IB_OR_CA;
- }
- if (hasFlag(usage, BufferUsage::VERTEX)) {
- res |= CommonUsage::VB_OR_DS;
- }
- if (hasFlag(usage, BufferUsage::INDIRECT)) {
- res |= CommonUsage::INDIRECT_OR_INPUT;
- }
- return res;
-}
-
-struct AccessElem {
- uint32_t mask{0xFFFFFFFF};
- uint32_t key{0xFFFFFFFF};
- AccessFlags access{AccessFlags::NONE};
-};
-
-// 20 and above :reserved
-// 18 ~ 19: MemoryAccess
-// 16 ~ 17: MemoryUsage
-// 14 ~ 15: ResourceType
-// 8 ~ 13: ShaderStageFlags
-// 0 ~ 7: CommonUsage
-constexpr uint32_t IGNORE_MEMACCESS = 0b00111111111111111111;
-constexpr uint32_t IGNORE_MEMUSAGE = 0b11001111111111111111;
-constexpr uint32_t IGNORE_RESTYPE = 0b11110011111111111111;
-constexpr uint32_t IGNORE_SHADERSTAGE = 0b11111100000011111111;
-constexpr uint32_t IGNORE_CMNUSAGE = 0b11111111111100000000;
-constexpr uint32_t IGNORE_NONE = 0xFFFFFFFF;
-
-constexpr uint32_t CARE_MEMACCESS = ~IGNORE_MEMACCESS;
-constexpr uint32_t CARE_MEMUSAGE = ~IGNORE_MEMUSAGE;
-constexpr uint32_t CARE_RESTYPE = ~IGNORE_RESTYPE;
-constexpr uint32_t CARE_SHADERSTAGE = ~IGNORE_SHADERSTAGE;
-constexpr uint32_t CARE_CMNUSAGE = ~IGNORE_CMNUSAGE;
-constexpr uint32_t CARE_NONE = ~IGNORE_NONE;
-
-#define OPERABLE(val) static_cast::type>(val)
-
-constexpr auto ACCESS_WRITE = OPERABLE(MemoryAccess::WRITE_ONLY) << 18;
-constexpr auto ACCESS_READ = OPERABLE(MemoryAccess::READ_ONLY) << 18;
-constexpr auto MEM_HOST = OPERABLE(MemoryUsage::HOST) << 16;
-constexpr auto MEM_DEVICE = OPERABLE(MemoryUsage::DEVICE) << 16;
-constexpr auto RES_TEXTURE = OPERABLE(ResourceType::TEXTURE) << 14;
-constexpr auto RES_BUFFER = OPERABLE(ResourceType::BUFFER) << 14;
-constexpr auto SHADERSTAGE_COMP = 1 << 13;
-constexpr auto SHADERSTAGE_FRAG = 1 << 12;
-constexpr auto SHADERSTAGE_GEOM = 1 << 11;
-constexpr auto SHADERSTAGE_EVAL = 1 << 10;
-constexpr auto SHADERSTAGE_CTRL = 1 << 9;
-constexpr auto SHADERSTAGE_VERT = 1 << 8;
-constexpr auto CMN_NONE = OPERABLE(CommonUsage::NONE);
-constexpr auto CMN_COPY_SRC = OPERABLE(CommonUsage::COPY_SRC);
-constexpr auto CMN_COPY_DST = OPERABLE(CommonUsage::COPY_DST);
-constexpr auto CMN_ROM = OPERABLE(CommonUsage::ROM);
-constexpr auto CMN_STORAGE = OPERABLE(CommonUsage::STORAGE);
-constexpr auto CMN_IB_OR_CA = OPERABLE(CommonUsage::IB_OR_CA);
-constexpr auto CMN_VB_OR_DS = OPERABLE(CommonUsage::VB_OR_DS);
-constexpr auto CMN_INDIRECT_OR_INPUT = OPERABLE(CommonUsage::INDIRECT_OR_INPUT);
-
-constexpr std::array ACCESS_MAP = {{
- {CARE_MEMACCESS,
- 0x0,
- AccessFlags::NONE},
-
- {CARE_MEMUSAGE,
- 0x0,
- AccessFlags::NONE},
-
- {CARE_RESTYPE | CARE_CMNUSAGE,
- RES_BUFFER | CMN_INDIRECT_OR_INPUT,
- AccessFlags::INDIRECT_BUFFER},
-
- {CARE_RESTYPE | CARE_CMNUSAGE,
- RES_BUFFER | CMN_IB_OR_CA,
- AccessFlags::INDEX_BUFFER}, // buffer usage indicates what it is, so shader stage ignored.
-
- {CARE_RESTYPE | CARE_CMNUSAGE,
- ACCESS_READ | RES_BUFFER | CMN_VB_OR_DS,
- AccessFlags::VERTEX_BUFFER}, // ditto
-
- {IGNORE_MEMUSAGE,
- ACCESS_READ | RES_BUFFER | SHADERSTAGE_VERT | CMN_ROM,
- AccessFlags::VERTEX_SHADER_READ_UNIFORM_BUFFER},
-
- {IGNORE_MEMUSAGE,
- ACCESS_READ | RES_TEXTURE | SHADERSTAGE_VERT | CMN_ROM,
- AccessFlags::VERTEX_SHADER_READ_TEXTURE},
-
- {IGNORE_MEMUSAGE & IGNORE_RESTYPE,
- ACCESS_READ | SHADERSTAGE_VERT | CMN_STORAGE,
- AccessFlags::VERTEX_SHADER_READ_OTHER},
-
- {IGNORE_MEMUSAGE,
- ACCESS_READ | RES_BUFFER | SHADERSTAGE_FRAG | CMN_ROM,
- AccessFlags::FRAGMENT_SHADER_READ_UNIFORM_BUFFER},
-
- {IGNORE_MEMUSAGE,
- ACCESS_READ | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_ROM,
- AccessFlags::FRAGMENT_SHADER_READ_TEXTURE},
-
- {IGNORE_MEMUSAGE,
- ACCESS_READ | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_IB_OR_CA | CMN_INDIRECT_OR_INPUT,
- AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT},
-
- {IGNORE_MEMUSAGE,
- ACCESS_READ | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_VB_OR_DS | CMN_INDIRECT_OR_INPUT,
- AccessFlags::FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT},
-
- {IGNORE_MEMUSAGE & IGNORE_RESTYPE,
- ACCESS_READ | SHADERSTAGE_FRAG | CMN_STORAGE,
- AccessFlags::FRAGMENT_SHADER_READ_OTHER},
-
- //{IGNORE_MEMUSAGE,
- // ACCESS_READ | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_IB_OR_CA,
- // AccessFlags::COLOR_ATTACHMENT_READ},
-
- //{IGNORE_MEMUSAGE,
- // ACCESS_READ | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_VB_OR_DS,
- // AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ},
-
- {IGNORE_MEMUSAGE,
- ACCESS_READ | RES_BUFFER | SHADERSTAGE_COMP | CMN_ROM,
- AccessFlags::COMPUTE_SHADER_READ_UNIFORM_BUFFER},
-
- {IGNORE_MEMUSAGE,
- ACCESS_READ | RES_TEXTURE | SHADERSTAGE_COMP | CMN_ROM,
- AccessFlags::COMPUTE_SHADER_READ_TEXTURE},
-
- {CARE_MEMACCESS | CARE_SHADERSTAGE | CARE_CMNUSAGE,
- ACCESS_READ | SHADERSTAGE_COMP | CMN_STORAGE,
- AccessFlags::COMPUTE_SHADER_READ_OTHER},
-
- {CARE_MEMACCESS | CARE_CMNUSAGE,
- ACCESS_READ | CMN_COPY_SRC,
- AccessFlags::TRANSFER_READ},
-
- {CARE_MEMACCESS | CARE_MEMUSAGE,
- ACCESS_READ | MEM_HOST,
- AccessFlags::HOST_READ},
-
- {CARE_CMNUSAGE | CARE_RESTYPE,
- RES_TEXTURE | CMN_NONE,
- AccessFlags::PRESENT},
-
- {CARE_MEMACCESS | CARE_SHADERSTAGE | CARE_CMNUSAGE,
- ACCESS_WRITE | SHADERSTAGE_VERT | CMN_STORAGE,
- AccessFlags::VERTEX_SHADER_WRITE},
-
- {CARE_MEMACCESS | CARE_SHADERSTAGE | CARE_CMNUSAGE,
- ACCESS_WRITE | SHADERSTAGE_FRAG | CMN_STORAGE,
- AccessFlags::FRAGMENT_SHADER_WRITE},
-
- {IGNORE_MEMUSAGE,
- ACCESS_WRITE | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_IB_OR_CA,
- AccessFlags::COLOR_ATTACHMENT_WRITE},
-
- {IGNORE_NONE,
- ACCESS_WRITE | MEM_DEVICE | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_VB_OR_DS,
- AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE},
-
- {CARE_MEMACCESS | CARE_SHADERSTAGE | CARE_CMNUSAGE,
- ACCESS_WRITE | SHADERSTAGE_COMP | CMN_STORAGE,
- AccessFlags::COMPUTE_SHADER_WRITE},
-
- {CARE_MEMACCESS | CARE_CMNUSAGE,
- ACCESS_WRITE | CMN_COPY_DST,
- AccessFlags::TRANSFER_WRITE},
-
- {CARE_MEMACCESS | CARE_MEMUSAGE,
- ACCESS_WRITE | MEM_HOST,
- AccessFlags::HOST_WRITE},
-}};
-
-constexpr bool validateAccess(ResourceType type, CommonUsage usage, MemoryAccess access, ShaderStageFlags visibility) {
- bool res = true;
- if (type == ResourceType::BUFFER) {
- uint32_t conflicts[] = {
- hasFlag(usage, CommonUsage::ROM) && hasFlag(access, MemoryAccess::WRITE_ONLY), // uniform has write access.
- hasAnyFlags(usage, CommonUsage::IB_OR_CA | CommonUsage::VB_OR_DS) && !hasFlag(visibility, ShaderStageFlags::VERTEX), // color/ds/input not in fragment
- hasAllFlags(usage, CommonUsage::ROM | CommonUsage::STORAGE), // storage ^ sampled
- hasFlag(usage, CommonUsage::COPY_SRC) && hasAllFlags(MemoryAccess::READ_ONLY, access), // transfer src ==> read_only
- hasFlag(usage, CommonUsage::COPY_DST) && hasAllFlags(MemoryAccess::WRITE_ONLY, access), // transfer dst ==> write_only
- hasAllFlags(usage, CommonUsage::COPY_SRC | CommonUsage::COPY_DST), // both src and dst
- hasFlag(usage, CommonUsage::VB_OR_DS) && hasAnyFlags(usage, CommonUsage::IB_OR_CA | CommonUsage::INDIRECT_OR_INPUT),
- hasFlag(usage, CommonUsage::IB_OR_CA) && hasAnyFlags(usage, CommonUsage::VB_OR_DS | CommonUsage::INDIRECT_OR_INPUT),
- hasFlag(usage, CommonUsage::INDIRECT_OR_INPUT) && hasAnyFlags(usage, CommonUsage::IB_OR_CA | CommonUsage::VB_OR_DS),
- // exlusive
- };
- res = !(*std::max_element(std::begin(conflicts), std::end(conflicts)));
- } else if (type == ResourceType::TEXTURE) {
- uint32_t conflicts[] = {
- hasFlag(usage, CommonUsage::ROM) && hasFlag(access, MemoryAccess::WRITE_ONLY), // sampled texture has write access.
- hasAnyFlags(usage, CommonUsage::IB_OR_CA | CommonUsage::VB_OR_DS | CommonUsage::INDIRECT_OR_INPUT) && !hasFlag(visibility, ShaderStageFlags::FRAGMENT), // color/ds/input not in fragment
- hasFlag(usage, CommonUsage::INDIRECT_OR_INPUT) && !hasFlag(access, MemoryAccess::READ_ONLY), // input needs read
- hasAllFlags(usage, CommonUsage::ROM | CommonUsage::STORAGE), // storage ^ sampled
- hasFlag(usage, CommonUsage::COPY_SRC) && !hasAllFlags(MemoryAccess::READ_ONLY, access), // transfer src ==> read_only
- hasFlag(usage, CommonUsage::COPY_DST) && !hasAllFlags(MemoryAccess::WRITE_ONLY, access),
- hasFlag(usage, CommonUsage::INDIRECT_OR_INPUT) && !hasAnyFlags(usage, CommonUsage::IB_OR_CA | CommonUsage::VB_OR_DS), // input needs to specify color or ds // transfer dst ==> write_only
- hasAllFlags(usage, CommonUsage::COPY_SRC | CommonUsage::COPY_DST), // both src and dst
- };
- res = !(*std::max_element(std::begin(conflicts), std::end(conflicts)));
- }
- return res;
-}
-
-constexpr AccessFlags getAccessFlagsImpl(
- BufferUsage usage, MemoryUsage memUsage,
- MemoryAccess access,
- ShaderStageFlags visibility) noexcept {
- AccessFlags flags{AccessFlags::NONE};
- CommonUsage cmnUsage = bufferUsageToCommonUsage(usage);
- if (validateAccess(ResourceType::BUFFER, cmnUsage, access, visibility)) {
- uint32_t info = 0xFFFFFFFF;
- info &= ((OPERABLE(access) << 18) | IGNORE_MEMACCESS);
- info &= ((OPERABLE(memUsage) << 16) | IGNORE_MEMUSAGE);
- info &= ((OPERABLE(ResourceType::TEXTURE) << 14) | IGNORE_RESTYPE);
- info &= ((OPERABLE(visibility) << 8) | IGNORE_SHADERSTAGE);
- info &= OPERABLE(cmnUsage) | IGNORE_CMNUSAGE;
-
- for (const auto& elem : ACCESS_MAP) {
- auto testFlag = info & elem.mask;
- // hasKey
- if ((testFlag & elem.key) == elem.key) {
- flags |= elem.access;
- }
- }
-
- } else {
- flags = INVALID_ACCESS_FLAGS;
- }
- return flags;
-}
-
-constexpr AccessFlags getAccessFlagsImpl(
- TextureUsage usage,
- MemoryAccess access,
- ShaderStageFlags visibility) noexcept {
- AccessFlags flags{AccessFlags::NONE};
- CommonUsage cmnUsage = textureUsageToCommonUsage(usage);
- if (validateAccess(ResourceType::TEXTURE, cmnUsage, access, visibility)) {
- uint32_t info = 0xFFFFFFFF;
- info &= ((OPERABLE(access) << 18) | IGNORE_MEMACCESS);
- info &= ((OPERABLE(MemoryUsage::DEVICE) << 16) | IGNORE_MEMUSAGE);
- info &= ((OPERABLE(ResourceType::TEXTURE) << 14) | IGNORE_RESTYPE);
- info &= ((OPERABLE(visibility) << 8) | IGNORE_SHADERSTAGE);
- info &= OPERABLE(cmnUsage) | IGNORE_CMNUSAGE;
-
- for (const auto& elem : ACCESS_MAP) {
- auto testFlag = info & elem.mask;
- // hasKey
- if ((testFlag & elem.key) == elem.key) {
- flags |= elem.access;
- }
- }
- } else {
- flags = INVALID_ACCESS_FLAGS;
- }
- return flags;
-}
-
-} // namespace
-
-AccessFlags getAccessFlags(
- BufferUsage usage, MemoryUsage memUsage,
- MemoryAccess access,
- ShaderStageFlags visibility) noexcept {
- return getAccessFlagsImpl(usage, memUsage, access, visibility);
-}
-
-AccessFlags getAccessFlags(
- TextureUsage usage,
- MemoryAccess access,
- ShaderStageFlags visibility) noexcept {
- return getAccessFlagsImpl(usage, access, visibility);
-}
-
-namespace {
-
-constexpr AccessFlags getDeviceAccessFlagsImpl(
- TextureUsage usage,
- MemoryAccess access,
- ShaderStageFlags visibility) {
- // Special Present Usage
- if (usage == TextureUsage::NONE) {
- return AccessFlags::PRESENT;
- }
-
- // not read or write access
- if (access == MemoryAccess::NONE) {
- return INVALID_ACCESS_FLAGS;
- }
-
- // input attachment requires color or depth stencil
- if (hasAnyFlags(usage, TextureUsage::INPUT_ATTACHMENT) &&
- !hasAnyFlags(usage, TextureUsage::COLOR_ATTACHMENT | TextureUsage::DEPTH_STENCIL_ATTACHMENT)) {
- return INVALID_ACCESS_FLAGS;
- }
-
- const bool bWrite = hasAnyFlags(access, MemoryAccess::WRITE_ONLY);
- const bool bRead = hasAnyFlags(access, MemoryAccess::READ_ONLY);
-
- if (bWrite) { // single write
- const auto writeMask =
- TextureUsage::TRANSFER_DST |
- TextureUsage::STORAGE |
- TextureUsage::COLOR_ATTACHMENT |
- TextureUsage::DEPTH_STENCIL_ATTACHMENT;
-
- const auto usage1 = usage & writeMask;
- // see https://stackoverflow.com/questions/51094594/how-to-check-if-exactly-one-bit-is-set-in-an-int
- constexpr auto hasOnebit = [](uint32_t bits) -> bool {
- return bits && !(bits & (bits - 1));
- };
- if (!hasOnebit(static_cast(usage1))) {
- return INVALID_ACCESS_FLAGS;
- }
-
- const auto readMask =
- TextureUsage::SAMPLED |
- TextureUsage::TRANSFER_SRC;
-
- if (hasAnyFlags(usage, readMask)) {
- return INVALID_ACCESS_FLAGS;
- }
- }
-
- auto flags = AccessFlags::NONE;
-
- if (hasAnyFlags(usage, TextureUsage::COLOR_ATTACHMENT)) {
- if (hasAnyFlags(visibility, ShaderStageFlags::ALL & ~ShaderStageFlags::FRAGMENT)) {
- return INVALID_ACCESS_FLAGS;
- }
- if (bWrite) {
- flags |= AccessFlags::COLOR_ATTACHMENT_WRITE;
- }
- if (bRead) {
- flags |= AccessFlags::COLOR_ATTACHMENT_READ;
- }
- if (hasAnyFlags(usage, TextureUsage::INPUT_ATTACHMENT)) {
- if (!bRead) {
- return INVALID_ACCESS_FLAGS;
- }
- flags |= AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT;
- }
- if (bWrite) {
- return flags;
- }
- } else if (hasAnyFlags(usage, TextureUsage::DEPTH_STENCIL_ATTACHMENT)) {
- if (hasAnyFlags(visibility, ShaderStageFlags::ALL & ~ShaderStageFlags::FRAGMENT)) {
- return INVALID_ACCESS_FLAGS;
- }
- if (bWrite) {
- flags |= AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE;
- }
- if (bRead) {
- flags |= AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ;
- }
- if (hasAnyFlags(usage, TextureUsage::INPUT_ATTACHMENT)) {
- if (!bRead) {
- return INVALID_ACCESS_FLAGS;
- }
- flags |= AccessFlags::FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT;
- }
- if (bWrite) {
- return flags;
- }
- } else if (bWrite) {
- if (hasAnyFlags(usage, TextureUsage::SAMPLED)) {
- return INVALID_ACCESS_FLAGS;
- }
- const bool bUnorderedAccess = hasAnyFlags(usage, TextureUsage::STORAGE);
- const bool bCopyTarget = hasAnyFlags(usage, TextureUsage::TRANSFER_DST);
- if (!(bUnorderedAccess ^ bCopyTarget)) {
- return INVALID_ACCESS_FLAGS;
- }
- if (bCopyTarget) {
- if (bRead || hasAnyFlags(usage, TextureUsage::TRANSFER_SRC)) {
- return INVALID_ACCESS_FLAGS; // both copy source and target
- }
- flags |= AccessFlags::TRANSFER_WRITE;
- } else {
- if (hasAnyFlags(visibility, ShaderStageFlags::VERTEX)) {
- flags |= AccessFlags::VERTEX_SHADER_WRITE;
- if (bRead) {
- flags |= AccessFlags::VERTEX_SHADER_READ_TEXTURE;
- }
- } else if (hasAnyFlags(visibility, ShaderStageFlags::FRAGMENT)) {
- flags |= AccessFlags::FRAGMENT_SHADER_WRITE;
- if (bRead) {
- flags |= AccessFlags::FRAGMENT_SHADER_READ_TEXTURE;
- }
- } else if (hasAnyFlags(visibility, ShaderStageFlags::COMPUTE)) {
- flags |= AccessFlags::COMPUTE_SHADER_WRITE;
- if (bRead) {
- flags |= AccessFlags::COMPUTE_SHADER_READ_TEXTURE;
- }
- }
- }
- return flags;
- }
-
- if (bWrite) {
- return INVALID_ACCESS_FLAGS;
- }
-
- // ReadOnly
- if (hasAnyFlags(usage, TextureUsage::TRANSFER_SRC)) {
- flags |= AccessFlags::TRANSFER_READ;
- }
-
- if (hasAnyFlags(usage, TextureUsage::SAMPLED | TextureUsage::STORAGE)) {
- if (hasAnyFlags(visibility, ShaderStageFlags::VERTEX)) {
- flags |= AccessFlags::VERTEX_SHADER_READ_TEXTURE;
- }
- if (hasAnyFlags(visibility, ShaderStageFlags::FRAGMENT)) {
- flags |= AccessFlags::FRAGMENT_SHADER_READ_TEXTURE;
- }
- if (hasAnyFlags(visibility, ShaderStageFlags::COMPUTE)) {
- flags |= AccessFlags::COMPUTE_SHADER_READ_TEXTURE;
- }
- }
-
- return flags;
-}
-
-// auto res = getAccessFlags(
-// TextureUsage::TRANSFER_DST | TextureUsage::COLOR_ATTACHMENT, // cannot be sampled
-// MemoryAccess::WRITE_ONLY,
-// ShaderStageFlags::ALL);
-//
-// auto res2 = res;
-
-static_assert(
- (AccessFlags::VERTEX_SHADER_WRITE | AccessFlags::VERTEX_SHADER_READ_OTHER) ==
- getAccessFlagsImpl(
- TextureUsage::STORAGE,
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::VERTEX));
-
-static_assert(
- (AccessFlags::FRAGMENT_SHADER_WRITE | AccessFlags::FRAGMENT_SHADER_READ_OTHER) ==
- getAccessFlagsImpl(
- TextureUsage::STORAGE,
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::COMPUTE_SHADER_WRITE | AccessFlags::COMPUTE_SHADER_READ_OTHER) ==
- getAccessFlagsImpl(
- TextureUsage::STORAGE,
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::COMPUTE));
-
-static_assert(
- (AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT | AccessFlags::FRAGMENT_SHADER_READ_OTHER) ==
- getAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::STORAGE,
- MemoryAccess::READ_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::SAMPLED | TextureUsage::STORAGE,
- MemoryAccess::READ_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::TRANSFER_WRITE | AccessFlags::COLOR_ATTACHMENT_WRITE) ==
- getAccessFlagsImpl(
- TextureUsage::TRANSFER_DST | TextureUsage::COLOR_ATTACHMENT,
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::ALL));
-
-////////////////////////////////////
-
-// VERTEX_SHADER_WRITE
-static_assert(
- AccessFlags::VERTEX_SHADER_WRITE ==
- getDeviceAccessFlagsImpl(
- TextureUsage::STORAGE,
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::VERTEX));
-
-static_assert(
- (AccessFlags::VERTEX_SHADER_WRITE | AccessFlags::VERTEX_SHADER_READ_TEXTURE) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::STORAGE,
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::VERTEX));
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::STORAGE | TextureUsage::SAMPLED, // both storage write and sampling
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::VERTEX));
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::SAMPLED, // Sampled cannot be write
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::VERTEX));
-
-// FRAGMENT_SHADER_WRITE
-static_assert(
- AccessFlags::FRAGMENT_SHADER_WRITE ==
- getDeviceAccessFlagsImpl(
- TextureUsage::STORAGE,
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::FRAGMENT_SHADER_WRITE | AccessFlags::FRAGMENT_SHADER_READ_TEXTURE) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::STORAGE,
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::FRAGMENT));
-
-// COLOR_ATTACHMENT_WRITE
-static_assert(
- AccessFlags::COLOR_ATTACHMENT_WRITE ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT,
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT,
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::VERTEX)); // not fragment stage
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT | TextureUsage::SAMPLED, // both color attachment and sampled texture
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::COLOR_ATTACHMENT_WRITE | AccessFlags::COLOR_ATTACHMENT_READ) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT,
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- AccessFlags::COLOR_ATTACHMENT_READ ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT,
- MemoryAccess::READ_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
- MemoryAccess::READ_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::COLOR_ATTACHMENT_WRITE | AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
- MemoryAccess::WRITE_ONLY, // INPUT_ATTACHMENT needs read access
- ShaderStageFlags::FRAGMENT));
-
-// DEPTH_STENCIL_ATTACHMENT_WRITE
-static_assert(
- AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE ==
- getDeviceAccessFlagsImpl(
- TextureUsage::DEPTH_STENCIL_ATTACHMENT,
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::DEPTH_STENCIL_ATTACHMENT,
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::VERTEX)); // not fragment stage
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::DEPTH_STENCIL_ATTACHMENT | TextureUsage::SAMPLED, // both color attachment and sampled texture
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE | AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::DEPTH_STENCIL_ATTACHMENT,
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ ==
- getDeviceAccessFlagsImpl(
- TextureUsage::DEPTH_STENCIL_ATTACHMENT,
- MemoryAccess::READ_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::DEPTH_STENCIL_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
- MemoryAccess::READ_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE | AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::DEPTH_STENCIL_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::DEPTH_STENCIL_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
- MemoryAccess::WRITE_ONLY, // INPUT_ATTACHMENT needs read access
- ShaderStageFlags::FRAGMENT));
-
-// COMPUTE_SHADER_WRITE
-static_assert(
- AccessFlags::COMPUTE_SHADER_WRITE ==
- getDeviceAccessFlagsImpl(
- TextureUsage::STORAGE,
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::COMPUTE));
-static_assert(
- (AccessFlags::COMPUTE_SHADER_WRITE | AccessFlags::COMPUTE_SHADER_READ_TEXTURE) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::STORAGE,
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::COMPUTE));
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::STORAGE | TextureUsage::SAMPLED, // cannot be sampled
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::COMPUTE));
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::STORAGE | TextureUsage::SAMPLED, // cannot be sampled
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::COMPUTE));
-
-// TRANSFER_WRITE
-static_assert(
- AccessFlags::TRANSFER_WRITE ==
- getDeviceAccessFlagsImpl(
- TextureUsage::TRANSFER_DST,
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::ALL)); // ShaderStageFlags not used
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::TRANSFER_DST,
- MemoryAccess::READ_WRITE,
- ShaderStageFlags::ALL)); // ShaderStageFlags not used
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::TRANSFER_DST | TextureUsage::TRANSFER_SRC, // both source and target
- MemoryAccess::READ_WRITE, // both read and write
- ShaderStageFlags::ALL));
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::TRANSFER_DST | TextureUsage::TRANSFER_SRC, // both source and target
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::ALL));
-
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::TRANSFER_DST | TextureUsage::COLOR_ATTACHMENT, // cannot be sampled
- MemoryAccess::WRITE_ONLY,
- ShaderStageFlags::ALL));
-
-// Read
-// COLOR_ATTACHMENT_READ
-static_assert(
- INVALID_ACCESS_FLAGS ==
- getDeviceAccessFlagsImpl(
- TextureUsage::INPUT_ATTACHMENT, // INPUT_ATTACHMENT needs COLOR_ATTACHMENT or DEPTH_STENCIL_ATTACHMENT
- MemoryAccess::READ_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT | AccessFlags::FRAGMENT_SHADER_READ_TEXTURE) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::SAMPLED,
- MemoryAccess::READ_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT | AccessFlags::FRAGMENT_SHADER_READ_TEXTURE) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::STORAGE,
- MemoryAccess::READ_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT | AccessFlags::FRAGMENT_SHADER_READ_TEXTURE) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::SAMPLED | TextureUsage::STORAGE,
- MemoryAccess::READ_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-static_assert(
- (AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT | AccessFlags::TRANSFER_READ) ==
- getDeviceAccessFlagsImpl(
- TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::TRANSFER_SRC,
- MemoryAccess::READ_ONLY,
- ShaderStageFlags::FRAGMENT));
-
-} // namespace
-
-AccessFlags getDeviceAccessFlags(
- TextureUsage usage,
- MemoryAccess access,
- ShaderStageFlags visibility) {
- return getDeviceAccessFlagsImpl(usage, access, visibility);
-}
-
-} // namespace gfx
-
-} // namespace cc
+/****************************************************************************
+ Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
+
+ https://www.cocos.com/
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+****************************************************************************/
+
+#include "GFXBarrier.h"
+#include
+#include
+
+namespace cc {
+
+namespace gfx {
+
+namespace {
+
+template
+constexpr uint64_t setbit() {
+ return ((1ULL << indices) | ... | 0ULL);
+}
+
+template
+constexpr uint64_t setbits(const std::integer_sequence& intSeq) {
+ std::ignore = intSeq;
+ return setbit();
+}
+
+template
+constexpr uint64_t setbits() {
+ using index_seq = std::make_index_sequence;
+ return setbits(index_seq{});
+}
+
+template
+constexpr uint64_t setbitBetween() {
+ static_assert(first >= end);
+ return setbits() ^ setbits();
+}
+
+template
+constexpr uint8_t highestBitPosOffset() {
+ if constexpr (N == 0) {
+ return 0;
+ } else {
+ return highestBitPosOffset<(N >> 1)>() + 1;
+ }
+}
+
+enum class ResourceType : uint32_t {
+ UNKNOWN,
+ BUFFER,
+ TEXTURE,
+};
+
+enum class CommonUsage : uint32_t {
+ NONE = 0,
+ COPY_SRC = 1 << 1,
+ COPY_DST = 1 << 2,
+ ROM = 1 << 3, // sampled or UNIFORM
+ STORAGE = 1 << 4,
+ IB_OR_CA = 1 << 5,
+ VB_OR_DS = 1 << 6,
+ INDIRECT_OR_INPUT = 1 << 7,
+ SHADING_RATE = 1 << 8,
+
+ LAST_ONE = SHADING_RATE,
+};
+CC_ENUM_BITWISE_OPERATORS(CommonUsage);
+
+constexpr CommonUsage textureUsageToCommonUsage(TextureUsage usage) {
+ CommonUsage res{0};
+ if (hasFlag(usage, TextureUsage::TRANSFER_SRC)) {
+ res |= CommonUsage::COPY_SRC;
+ }
+ if (hasFlag(usage, TextureUsage::TRANSFER_DST)) {
+ res |= CommonUsage::COPY_DST;
+ }
+ if (hasFlag(usage, TextureUsage::SAMPLED)) {
+ res |= CommonUsage::ROM;
+ }
+ if (hasFlag(usage, TextureUsage::STORAGE)) {
+ res |= CommonUsage::STORAGE;
+ }
+ if (hasFlag(usage, TextureUsage::COLOR_ATTACHMENT)) {
+ res |= CommonUsage::IB_OR_CA;
+ }
+ if (hasFlag(usage, TextureUsage::DEPTH_STENCIL_ATTACHMENT)) {
+ res |= CommonUsage::VB_OR_DS;
+ }
+ if (hasFlag(usage, TextureUsage::INPUT_ATTACHMENT)) {
+ res |= CommonUsage::INDIRECT_OR_INPUT;
+ }
+ if (hasFlag(usage, TextureUsage::SHADING_RATE)) {
+ res |= CommonUsage::SHADING_RATE;
+ }
+ return res;
+}
+
+constexpr CommonUsage bufferUsageToCommonUsage(BufferUsage usage) {
+ CommonUsage res{0};
+ if (hasFlag(usage, BufferUsage::NONE)) {
+ res |= CommonUsage::NONE;
+ }
+ if (hasFlag(usage, BufferUsage::TRANSFER_SRC)) {
+ res |= CommonUsage::COPY_SRC;
+ }
+ if (hasFlag(usage, BufferUsage::TRANSFER_DST)) {
+ res |= CommonUsage::COPY_DST;
+ }
+ if (hasFlag(usage, BufferUsage::UNIFORM)) {
+ res |= CommonUsage::ROM;
+ }
+ if (hasFlag(usage, BufferUsage::STORAGE)) {
+ res |= CommonUsage::STORAGE;
+ }
+ if (hasFlag(usage, BufferUsage::INDEX)) {
+ res |= CommonUsage::IB_OR_CA;
+ }
+ if (hasFlag(usage, BufferUsage::VERTEX)) {
+ res |= CommonUsage::VB_OR_DS;
+ }
+ if (hasFlag(usage, BufferUsage::INDIRECT)) {
+ res |= CommonUsage::INDIRECT_OR_INPUT;
+ }
+ return res;
+}
+
+struct AccessElem {
+ uint32_t mask{0xFFFFFFFF};
+ uint32_t key{0xFFFFFFFF};
+ AccessFlags access{AccessFlags::NONE};
+ uint32_t mutex{0x0}; // optional mutually exclusive flag
+};
+
+#define OPERABLE(val) static_cast::type>(val)
+
+constexpr uint8_t COMMON_USAGE_COUNT = highestBitPosOffset();
+constexpr uint8_t SHADER_STAGE_RESERVE_COUNT = 6;
+constexpr uint8_t RESOURCE_TYPE_COUNT = 2;
+constexpr uint8_t MEM_TYPE_COUNT = 2;
+constexpr uint8_t ACCESS_TYPE_COUNT = 2;
+
+constexpr auto CMN_NONE = OPERABLE(CommonUsage::NONE);
+constexpr auto CMN_COPY_SRC = OPERABLE(CommonUsage::COPY_SRC);
+constexpr auto CMN_COPY_DST = OPERABLE(CommonUsage::COPY_DST);
+constexpr auto CMN_ROM = OPERABLE(CommonUsage::ROM);
+constexpr auto CMN_STORAGE = OPERABLE(CommonUsage::STORAGE);
+constexpr auto CMN_IB_OR_CA = OPERABLE(CommonUsage::IB_OR_CA);
+constexpr auto CMN_VB_OR_DS = OPERABLE(CommonUsage::VB_OR_DS);
+constexpr auto CMN_INDIRECT_OR_INPUT = OPERABLE(CommonUsage::INDIRECT_OR_INPUT);
+constexpr auto CMN_SHADING_RATE = OPERABLE(CommonUsage::SHADING_RATE);
+
+constexpr auto SHADER_STAGE_BIT_POPS = COMMON_USAGE_COUNT;
+constexpr auto SHADERSTAGE_NONE = 0;
+constexpr auto SHADERSTAGE_VERT = 1 << (0 + SHADER_STAGE_BIT_POPS);
+constexpr auto SHADERSTAGE_CTRL = 1 << (1 + SHADER_STAGE_BIT_POPS);
+constexpr auto SHADERSTAGE_EVAL = 1 << (2 + SHADER_STAGE_BIT_POPS);
+constexpr auto SHADERSTAGE_GEOM = 1 << (3 + SHADER_STAGE_BIT_POPS);
+constexpr auto SHADERSTAGE_FRAG = 1 << (4 + SHADER_STAGE_BIT_POPS);
+constexpr auto SHADERSTAGE_COMP = 1 << (5 + SHADER_STAGE_BIT_POPS);
+
+constexpr auto RESOURCE_TYPE_BIT_POS = COMMON_USAGE_COUNT + SHADER_STAGE_RESERVE_COUNT;
+constexpr auto RES_TEXTURE = OPERABLE(ResourceType::TEXTURE) << RESOURCE_TYPE_BIT_POS;
+constexpr auto RES_BUFFER = OPERABLE(ResourceType::BUFFER) << RESOURCE_TYPE_BIT_POS;
+
+constexpr auto MEM_TYPE_BIT_POS = COMMON_USAGE_COUNT + SHADER_STAGE_RESERVE_COUNT + RESOURCE_TYPE_COUNT;
+constexpr auto MEM_HOST = OPERABLE(MemoryUsage::HOST) << MEM_TYPE_BIT_POS;
+constexpr auto MEM_DEVICE = OPERABLE(MemoryUsage::DEVICE) << MEM_TYPE_BIT_POS;
+
+constexpr auto ACCESS_TYPE_BIT_POS = COMMON_USAGE_COUNT + SHADER_STAGE_RESERVE_COUNT + RESOURCE_TYPE_COUNT + MEM_TYPE_COUNT;
+constexpr auto ACCESS_WRITE = OPERABLE(MemoryAccess::WRITE_ONLY) << ACCESS_TYPE_BIT_POS;
+constexpr auto ACCESS_READ = OPERABLE(MemoryAccess::READ_ONLY) << ACCESS_TYPE_BIT_POS;
+
+constexpr uint8_t USED_BIT_COUNT = COMMON_USAGE_COUNT + SHADER_STAGE_RESERVE_COUNT + RESOURCE_TYPE_COUNT + MEM_TYPE_COUNT + ACCESS_TYPE_COUNT;
+// 20 and above :reserved
+// 18 ~ 19: MemoryAccess
+// 16 ~ 17: MemoryUsage
+// 14 ~ 15: ResourceType
+// 8 ~ 13: ShaderStageFlags
+// 0 ~ 7: CommonUsage
+
+constexpr uint32_t CARE_NONE = 0x0;
+constexpr uint32_t CARE_CMNUSAGE = setbitBetween();
+constexpr uint32_t CARE_SHADERSTAGE = setbitBetween();
+constexpr uint32_t CARE_RESTYPE = setbitBetween();
+constexpr uint32_t CARE_MEMUSAGE = setbitBetween();
+constexpr uint32_t CARE_MEMACCESS = setbitBetween();
+
+constexpr uint32_t IGNORE_NONE = 0xFFFFFFFF;
+constexpr uint32_t IGNORE_CMNUSAGE = ~CARE_CMNUSAGE;
+constexpr uint32_t IGNORE_SHADERSTAGE = ~CARE_SHADERSTAGE;
+constexpr uint32_t IGNORE_RESTYPE = ~CARE_RESTYPE;
+constexpr uint32_t IGNORE_MEMUSAGE = ~CARE_MEMUSAGE;
+constexpr uint32_t IGNORE_MEMACCESS = ~CARE_MEMACCESS;
+
+constexpr AccessElem ACCESS_MAP[] = {
+ {CARE_MEMACCESS,
+ 0x0,
+ AccessFlags::NONE},
+
+ {CARE_MEMUSAGE,
+ 0x0,
+ AccessFlags::NONE},
+
+ {CARE_RESTYPE | CARE_CMNUSAGE,
+ RES_BUFFER | CMN_INDIRECT_OR_INPUT,
+ AccessFlags::INDIRECT_BUFFER},
+
+ {CARE_RESTYPE | CARE_CMNUSAGE,
+ RES_BUFFER | CMN_IB_OR_CA,
+ AccessFlags::INDEX_BUFFER}, // buffer usage indicates what it is, so shader stage ignored.
+
+ {CARE_RESTYPE | CARE_CMNUSAGE,
+ ACCESS_READ | RES_BUFFER | CMN_VB_OR_DS,
+ AccessFlags::VERTEX_BUFFER}, // ditto
+
+ {IGNORE_MEMUSAGE,
+ ACCESS_READ | RES_BUFFER | SHADERSTAGE_VERT | CMN_ROM,
+ AccessFlags::VERTEX_SHADER_READ_UNIFORM_BUFFER},
+
+ {IGNORE_MEMUSAGE,
+ ACCESS_READ | RES_TEXTURE | SHADERSTAGE_VERT | CMN_ROM,
+ AccessFlags::VERTEX_SHADER_READ_TEXTURE},
+
+ {IGNORE_MEMUSAGE & IGNORE_RESTYPE,
+ ACCESS_READ | SHADERSTAGE_VERT | CMN_STORAGE,
+ AccessFlags::VERTEX_SHADER_READ_OTHER},
+
+ {IGNORE_MEMUSAGE,
+ ACCESS_READ | RES_BUFFER | SHADERSTAGE_FRAG | CMN_ROM,
+ AccessFlags::FRAGMENT_SHADER_READ_UNIFORM_BUFFER},
+
+ {IGNORE_MEMUSAGE,
+ ACCESS_READ | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_ROM,
+ AccessFlags::FRAGMENT_SHADER_READ_TEXTURE,
+ CMN_STORAGE},
+
+ {IGNORE_MEMUSAGE,
+ ACCESS_READ | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_IB_OR_CA | CMN_INDIRECT_OR_INPUT,
+ AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT},
+
+ {IGNORE_MEMUSAGE,
+ ACCESS_READ | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_VB_OR_DS | CMN_INDIRECT_OR_INPUT,
+ AccessFlags::FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT},
+
+ {IGNORE_MEMUSAGE & IGNORE_RESTYPE,
+ ACCESS_READ | SHADERSTAGE_FRAG | CMN_STORAGE,
+ AccessFlags::FRAGMENT_SHADER_READ_OTHER,
+ CMN_SHADING_RATE},
+
+ //{IGNORE_MEMUSAGE,
+ // ACCESS_READ | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_IB_OR_CA,
+ // AccessFlags::COLOR_ATTACHMENT_READ},
+
+ //{IGNORE_MEMUSAGE,
+ // ACCESS_READ | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_VB_OR_DS,
+ // AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ},
+
+ {IGNORE_MEMUSAGE,
+ ACCESS_READ | RES_BUFFER | SHADERSTAGE_COMP | CMN_ROM,
+ AccessFlags::COMPUTE_SHADER_READ_UNIFORM_BUFFER},
+
+ {IGNORE_MEMUSAGE,
+ ACCESS_READ | RES_TEXTURE | SHADERSTAGE_COMP | CMN_ROM,
+ AccessFlags::COMPUTE_SHADER_READ_TEXTURE},
+
+ // shading rate has its own flag
+ {CARE_MEMACCESS | CARE_SHADERSTAGE | CARE_CMNUSAGE,
+ ACCESS_READ | SHADERSTAGE_COMP | CMN_STORAGE,
+ AccessFlags::COMPUTE_SHADER_READ_OTHER},
+
+ {CARE_MEMACCESS | CARE_CMNUSAGE,
+ ACCESS_READ | CMN_COPY_SRC,
+ AccessFlags::TRANSFER_READ},
+
+ {CARE_MEMACCESS | CARE_MEMUSAGE,
+ ACCESS_READ | MEM_HOST,
+ AccessFlags::HOST_READ},
+
+ {CARE_MEMACCESS | CARE_SHADERSTAGE | CARE_CMNUSAGE,
+ ACCESS_READ | SHADERSTAGE_FRAG | CMN_SHADING_RATE,
+ AccessFlags::SHADING_RATE},
+
+ //{CARE_CMNUSAGE | CARE_RESTYPE,
+ // RES_TEXTURE | CMN_NONE,
+ // AccessFlags::PRESENT},
+
+ {CARE_MEMACCESS | CARE_SHADERSTAGE | CARE_CMNUSAGE,
+ ACCESS_WRITE | SHADERSTAGE_VERT | CMN_STORAGE,
+ AccessFlags::VERTEX_SHADER_WRITE},
+
+ {CARE_MEMACCESS | CARE_SHADERSTAGE | CARE_CMNUSAGE,
+ ACCESS_WRITE | SHADERSTAGE_FRAG | CMN_STORAGE,
+ AccessFlags::FRAGMENT_SHADER_WRITE},
+
+ {IGNORE_MEMUSAGE,
+ ACCESS_WRITE | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_IB_OR_CA,
+ AccessFlags::COLOR_ATTACHMENT_WRITE},
+
+ {IGNORE_NONE,
+ ACCESS_WRITE | MEM_DEVICE | RES_TEXTURE | SHADERSTAGE_FRAG | CMN_VB_OR_DS,
+ AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE},
+
+ {CARE_MEMACCESS | CARE_SHADERSTAGE | CARE_CMNUSAGE,
+ ACCESS_WRITE | SHADERSTAGE_COMP | CMN_STORAGE,
+ AccessFlags::COMPUTE_SHADER_WRITE},
+
+ {CARE_MEMACCESS | CARE_CMNUSAGE,
+ ACCESS_WRITE | CMN_COPY_DST,
+ AccessFlags::TRANSFER_WRITE},
+
+ {CARE_MEMACCESS | CARE_MEMUSAGE,
+ ACCESS_WRITE | MEM_HOST,
+ AccessFlags::HOST_WRITE},
+};
+
+constexpr bool validateAccess(ResourceType type, CommonUsage usage, MemoryAccess access, ShaderStageFlags visibility) {
+ bool res = true;
+ if (type == ResourceType::BUFFER) {
+ uint32_t conflicts[] = {
+ hasFlag(usage, CommonUsage::ROM) && hasFlag(access, MemoryAccess::WRITE_ONLY), // uniform has write access.
+ hasAnyFlags(usage, CommonUsage::IB_OR_CA | CommonUsage::VB_OR_DS) && !hasFlag(visibility, ShaderStageFlags::VERTEX), // color/ds/input not in fragment
+ hasAllFlags(usage, CommonUsage::ROM | CommonUsage::STORAGE), // storage ^ sampled
+ hasFlag(usage, CommonUsage::COPY_SRC) && hasAllFlags(MemoryAccess::READ_ONLY, access), // transfer src ==> read_only
+ hasFlag(usage, CommonUsage::COPY_DST) && hasAllFlags(MemoryAccess::WRITE_ONLY, access), // transfer dst ==> write_only
+ hasAllFlags(usage, CommonUsage::COPY_SRC | CommonUsage::COPY_DST), // both src and dst
+ hasFlag(usage, CommonUsage::VB_OR_DS) && hasAnyFlags(usage, CommonUsage::IB_OR_CA | CommonUsage::INDIRECT_OR_INPUT),
+ hasFlag(usage, CommonUsage::IB_OR_CA) && hasAnyFlags(usage, CommonUsage::VB_OR_DS | CommonUsage::INDIRECT_OR_INPUT),
+ hasFlag(usage, CommonUsage::INDIRECT_OR_INPUT) && hasAnyFlags(usage, CommonUsage::IB_OR_CA | CommonUsage::VB_OR_DS),
+ // exlusive
+ };
+ res = !(*std::max_element(std::begin(conflicts), std::end(conflicts)));
+ } else if (type == ResourceType::TEXTURE) {
+ uint32_t conflicts[] = {
+ hasAnyFlags(usage, CommonUsage::IB_OR_CA | CommonUsage::VB_OR_DS | CommonUsage::INDIRECT_OR_INPUT) && !hasFlag(visibility, ShaderStageFlags::FRAGMENT), // color/ds/input not in fragment
+ hasFlag(usage, CommonUsage::INDIRECT_OR_INPUT) && !hasFlag(access, MemoryAccess::READ_ONLY), // input needs read
+ hasAllFlags(usage, CommonUsage::IB_OR_CA | CommonUsage::STORAGE), // storage ^ sampled
+ hasFlag(usage, CommonUsage::COPY_SRC) && !hasAllFlags(MemoryAccess::READ_ONLY, access), // transfer src ==> read_only
+ hasFlag(usage, CommonUsage::COPY_DST) && !hasAllFlags(MemoryAccess::WRITE_ONLY, access),
+ hasFlag(usage, CommonUsage::INDIRECT_OR_INPUT) && !hasAnyFlags(usage, CommonUsage::IB_OR_CA | CommonUsage::VB_OR_DS), // input needs to specify color or ds // transfer dst ==> write_only
+ hasAllFlags(usage, CommonUsage::COPY_SRC | CommonUsage::COPY_DST), // both src and dst
+ };
+ res = !(*std::max_element(std::begin(conflicts), std::end(conflicts)));
+ }
+ return res;
+}
+
+constexpr AccessFlags getAccessFlagsImpl(
+ BufferUsage usage, MemoryUsage memUsage,
+ MemoryAccess access,
+ ShaderStageFlags visibility) noexcept {
+ AccessFlags flags{AccessFlags::NONE};
+ CommonUsage cmnUsage = bufferUsageToCommonUsage(usage);
+ if (validateAccess(ResourceType::BUFFER, cmnUsage, access, visibility)) {
+ uint32_t info = 0xFFFFFFFF;
+ info &= ((OPERABLE(access) << ACCESS_TYPE_BIT_POS) | IGNORE_MEMACCESS);
+ info &= ((OPERABLE(memUsage) << MEM_TYPE_BIT_POS) | IGNORE_MEMUSAGE);
+ info &= ((OPERABLE(ResourceType::TEXTURE) << RESOURCE_TYPE_BIT_POS) | IGNORE_RESTYPE);
+ info &= ((OPERABLE(visibility) << SHADER_STAGE_BIT_POPS) | IGNORE_SHADERSTAGE);
+ info &= OPERABLE(cmnUsage) | IGNORE_CMNUSAGE;
+
+ for (const auto& elem : ACCESS_MAP) {
+ auto testFlag = info & elem.mask;
+ // hasKey
+ if ((testFlag & elem.key) == elem.key) {
+ flags |= elem.access;
+ }
+ }
+
+ } else {
+ flags = INVALID_ACCESS_FLAGS;
+ }
+ return flags;
+}
+
+constexpr AccessFlags getAccessFlagsImpl(
+ TextureUsage usage,
+ MemoryAccess access,
+ ShaderStageFlags visibility) noexcept {
+ AccessFlags flags{AccessFlags::NONE};
+ CommonUsage cmnUsage = textureUsageToCommonUsage(usage);
+ if (validateAccess(ResourceType::TEXTURE, cmnUsage, access, visibility)) {
+ if (usage == gfx::TextureUsageBit::NONE) {
+ return gfx::AccessFlagBit::PRESENT;
+ }
+ uint32_t info = 0xFFFFFFFF;
+ info &= ((OPERABLE(access) << ACCESS_TYPE_BIT_POS) | IGNORE_MEMACCESS);
+ info &= ((OPERABLE(MemoryUsage::DEVICE) << MEM_TYPE_BIT_POS) | IGNORE_MEMUSAGE);
+ info &= ((OPERABLE(ResourceType::TEXTURE) << RESOURCE_TYPE_BIT_POS) | IGNORE_RESTYPE);
+ info &= ((OPERABLE(visibility) << (SHADER_STAGE_BIT_POPS)) | IGNORE_SHADERSTAGE);
+ info &= OPERABLE(cmnUsage) | IGNORE_CMNUSAGE;
+
+ for (const auto& elem : ACCESS_MAP) {
+ auto testFlag = info & elem.mask;
+ // hasKey && no mutex flag
+ if (((testFlag & elem.key) == elem.key) && ((testFlag & elem.mutex) == 0)) {
+ flags |= elem.access;
+ }
+ }
+ } else {
+ flags = INVALID_ACCESS_FLAGS;
+ }
+
+ // CC_ASSERT(flags != INVALID_ACCESS_FLAGS);
+ return flags;
+}
+
+} // namespace
+
+AccessFlags getAccessFlags(
+ BufferUsage usage, MemoryUsage memUsage,
+ MemoryAccess access,
+ ShaderStageFlags visibility) noexcept {
+ return getAccessFlagsImpl(usage, memUsage, access, visibility);
+}
+
+AccessFlags getAccessFlags(
+ TextureUsage usage,
+ MemoryAccess access,
+ ShaderStageFlags visibility) noexcept {
+ return getAccessFlagsImpl(usage, access, visibility);
+}
+
+namespace {
+
+constexpr AccessFlags getDeviceAccessFlagsImpl(
+ TextureUsage usage,
+ MemoryAccess access,
+ ShaderStageFlags visibility) {
+ // Special Present Usage
+ if (usage == TextureUsage::NONE) {
+ return AccessFlags::PRESENT;
+ }
+
+ // not read or write access
+ if (access == MemoryAccess::NONE) {
+ return INVALID_ACCESS_FLAGS;
+ }
+
+ // input attachment requires color or depth stencil
+ if (hasAnyFlags(usage, TextureUsage::INPUT_ATTACHMENT) &&
+ !hasAnyFlags(usage, TextureUsage::COLOR_ATTACHMENT | TextureUsage::DEPTH_STENCIL_ATTACHMENT)) {
+ return INVALID_ACCESS_FLAGS;
+ }
+
+ const bool bWrite = hasAnyFlags(access, MemoryAccess::WRITE_ONLY);
+ const bool bRead = hasAnyFlags(access, MemoryAccess::READ_ONLY);
+
+ if (bWrite) { // single write
+ const auto writeMask =
+ TextureUsage::TRANSFER_DST |
+ TextureUsage::STORAGE |
+ TextureUsage::COLOR_ATTACHMENT |
+ TextureUsage::DEPTH_STENCIL_ATTACHMENT;
+
+ const auto usage1 = usage & writeMask;
+ // see https://stackoverflow.com/questions/51094594/how-to-check-if-exactly-one-bit-is-set-in-an-int
+ constexpr auto hasOnebit = [](uint32_t bits) -> bool {
+ return bits && !(bits & (bits - 1));
+ };
+ if (!hasOnebit(static_cast(usage1))) {
+ return INVALID_ACCESS_FLAGS;
+ }
+
+ const auto readMask =
+ TextureUsage::SAMPLED |
+ TextureUsage::TRANSFER_SRC;
+
+ if (hasAnyFlags(usage, readMask)) {
+ return INVALID_ACCESS_FLAGS;
+ }
+ }
+
+ auto flags = AccessFlags::NONE;
+
+ if (hasAnyFlags(usage, TextureUsage::COLOR_ATTACHMENT)) {
+ if (hasAnyFlags(visibility, ShaderStageFlags::ALL & ~ShaderStageFlags::FRAGMENT)) {
+ return INVALID_ACCESS_FLAGS;
+ }
+ if (bWrite) {
+ flags |= AccessFlags::COLOR_ATTACHMENT_WRITE;
+ }
+ if (bRead) {
+ flags |= AccessFlags::COLOR_ATTACHMENT_READ;
+ }
+ if (hasAnyFlags(usage, TextureUsage::INPUT_ATTACHMENT)) {
+ if (!bRead) {
+ return INVALID_ACCESS_FLAGS;
+ }
+ flags |= AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT;
+ }
+ if (bWrite) {
+ return flags;
+ }
+ } else if (hasAnyFlags(usage, TextureUsage::DEPTH_STENCIL_ATTACHMENT)) {
+ if (hasAnyFlags(visibility, ShaderStageFlags::ALL & ~ShaderStageFlags::FRAGMENT)) {
+ return INVALID_ACCESS_FLAGS;
+ }
+ if (bWrite) {
+ flags |= AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE;
+ }
+ if (bRead) {
+ flags |= AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ;
+ }
+ if (hasAnyFlags(usage, TextureUsage::INPUT_ATTACHMENT)) {
+ if (!bRead) {
+ return INVALID_ACCESS_FLAGS;
+ }
+ flags |= AccessFlags::FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT;
+ }
+ if (bWrite) {
+ return flags;
+ }
+ } else if (bWrite) {
+ if (hasAnyFlags(usage, TextureUsage::SAMPLED)) {
+ return INVALID_ACCESS_FLAGS;
+ }
+ const bool bUnorderedAccess = hasAnyFlags(usage, TextureUsage::STORAGE);
+ const bool bCopyTarget = hasAnyFlags(usage, TextureUsage::TRANSFER_DST);
+ if (!(bUnorderedAccess ^ bCopyTarget)) {
+ return INVALID_ACCESS_FLAGS;
+ }
+ if (bCopyTarget) {
+ if (bRead || hasAnyFlags(usage, TextureUsage::TRANSFER_SRC)) {
+ return INVALID_ACCESS_FLAGS; // both copy source and target
+ }
+ flags |= AccessFlags::TRANSFER_WRITE;
+ } else {
+ if (hasAnyFlags(visibility, ShaderStageFlags::VERTEX)) {
+ flags |= AccessFlags::VERTEX_SHADER_WRITE;
+ if (bRead) {
+ flags |= AccessFlags::VERTEX_SHADER_READ_TEXTURE;
+ }
+ } else if (hasAnyFlags(visibility, ShaderStageFlags::FRAGMENT)) {
+ flags |= AccessFlags::FRAGMENT_SHADER_WRITE;
+ if (bRead) {
+ flags |= AccessFlags::FRAGMENT_SHADER_READ_TEXTURE;
+ }
+ } else if (hasAnyFlags(visibility, ShaderStageFlags::COMPUTE)) {
+ flags |= AccessFlags::COMPUTE_SHADER_WRITE;
+ if (bRead) {
+ flags |= AccessFlags::COMPUTE_SHADER_READ_TEXTURE;
+ }
+ }
+ }
+ return flags;
+ }
+
+ if (bWrite) {
+ return INVALID_ACCESS_FLAGS;
+ }
+
+ // ReadOnly
+ if (hasAnyFlags(usage, TextureUsage::TRANSFER_SRC)) {
+ flags |= AccessFlags::TRANSFER_READ;
+ }
+
+ if (hasAnyFlags(usage, TextureUsage::SAMPLED | TextureUsage::STORAGE)) {
+ if (hasAnyFlags(visibility, ShaderStageFlags::VERTEX)) {
+ flags |= AccessFlags::VERTEX_SHADER_READ_TEXTURE;
+ }
+ if (hasAnyFlags(visibility, ShaderStageFlags::FRAGMENT)) {
+ flags |= AccessFlags::FRAGMENT_SHADER_READ_TEXTURE;
+ }
+ if (hasAnyFlags(visibility, ShaderStageFlags::COMPUTE)) {
+ flags |= AccessFlags::COMPUTE_SHADER_READ_TEXTURE;
+ }
+ }
+
+ return flags;
+}
+
+static_assert(
+ (AccessFlags::VERTEX_SHADER_WRITE | AccessFlags::VERTEX_SHADER_READ_OTHER) ==
+ getAccessFlagsImpl(
+ TextureUsage::STORAGE,
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::VERTEX));
+
+static_assert(
+ (AccessFlags::FRAGMENT_SHADER_WRITE | AccessFlags::FRAGMENT_SHADER_READ_OTHER) ==
+ getAccessFlagsImpl(
+ TextureUsage::STORAGE,
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::COMPUTE_SHADER_WRITE | AccessFlags::COMPUTE_SHADER_READ_OTHER) ==
+ getAccessFlagsImpl(
+ TextureUsage::STORAGE,
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::COMPUTE));
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::STORAGE,
+ MemoryAccess::READ_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::SAMPLED | TextureUsage::STORAGE,
+ MemoryAccess::READ_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::TRANSFER_WRITE | AccessFlags::COLOR_ATTACHMENT_WRITE) ==
+ getAccessFlagsImpl(
+ TextureUsage::TRANSFER_DST | TextureUsage::COLOR_ATTACHMENT,
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::ALL));
+
+////////////////////////////////////
+
+// VERTEX_SHADER_WRITE
+static_assert(
+ AccessFlags::VERTEX_SHADER_WRITE ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::STORAGE,
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::VERTEX));
+
+static_assert(
+ (AccessFlags::VERTEX_SHADER_WRITE | AccessFlags::VERTEX_SHADER_READ_TEXTURE) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::STORAGE,
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::VERTEX));
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::STORAGE | TextureUsage::SAMPLED, // both storage write and sampling
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::VERTEX));
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::SAMPLED, // Sampled cannot be write
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::VERTEX));
+
+// FRAGMENT_SHADER_WRITE
+static_assert(
+ AccessFlags::FRAGMENT_SHADER_WRITE ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::STORAGE,
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::FRAGMENT_SHADER_WRITE | AccessFlags::FRAGMENT_SHADER_READ_TEXTURE) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::STORAGE,
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::FRAGMENT));
+
+// COLOR_ATTACHMENT_WRITE
+static_assert(
+ AccessFlags::COLOR_ATTACHMENT_WRITE ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT,
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT,
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::VERTEX)); // not fragment stage
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT | TextureUsage::SAMPLED, // both color attachment and sampled texture
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::COLOR_ATTACHMENT_WRITE | AccessFlags::COLOR_ATTACHMENT_READ) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT,
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ AccessFlags::COLOR_ATTACHMENT_READ ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT,
+ MemoryAccess::READ_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
+ MemoryAccess::READ_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::COLOR_ATTACHMENT_WRITE | AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
+ MemoryAccess::WRITE_ONLY, // INPUT_ATTACHMENT needs read access
+ ShaderStageFlags::FRAGMENT));
+
+// DEPTH_STENCIL_ATTACHMENT_WRITE
+static_assert(
+ AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::DEPTH_STENCIL_ATTACHMENT,
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::DEPTH_STENCIL_ATTACHMENT,
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::VERTEX)); // not fragment stage
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::DEPTH_STENCIL_ATTACHMENT | TextureUsage::SAMPLED, // both color attachment and sampled texture
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE | AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::DEPTH_STENCIL_ATTACHMENT,
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::DEPTH_STENCIL_ATTACHMENT,
+ MemoryAccess::READ_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::DEPTH_STENCIL_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
+ MemoryAccess::READ_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE | AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::DEPTH_STENCIL_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::DEPTH_STENCIL_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT,
+ MemoryAccess::WRITE_ONLY, // INPUT_ATTACHMENT needs read access
+ ShaderStageFlags::FRAGMENT));
+
+// COMPUTE_SHADER_WRITE
+static_assert(
+ AccessFlags::COMPUTE_SHADER_WRITE ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::STORAGE,
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::COMPUTE));
+static_assert(
+ (AccessFlags::COMPUTE_SHADER_WRITE | AccessFlags::COMPUTE_SHADER_READ_TEXTURE) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::STORAGE,
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::COMPUTE));
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::STORAGE | TextureUsage::SAMPLED, // cannot be sampled
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::COMPUTE));
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::STORAGE | TextureUsage::SAMPLED, // cannot be sampled
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::COMPUTE));
+
+// TRANSFER_WRITE
+static_assert(
+ AccessFlags::TRANSFER_WRITE ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::TRANSFER_DST,
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::ALL)); // ShaderStageFlags not used
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::TRANSFER_DST,
+ MemoryAccess::READ_WRITE,
+ ShaderStageFlags::ALL)); // ShaderStageFlags not used
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::TRANSFER_DST | TextureUsage::TRANSFER_SRC, // both source and target
+ MemoryAccess::READ_WRITE, // both read and write
+ ShaderStageFlags::ALL));
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::TRANSFER_DST | TextureUsage::TRANSFER_SRC, // both source and target
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::ALL));
+
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::TRANSFER_DST | TextureUsage::COLOR_ATTACHMENT, // cannot be sampled
+ MemoryAccess::WRITE_ONLY,
+ ShaderStageFlags::ALL));
+
+// Read
+// COLOR_ATTACHMENT_READ
+static_assert(
+ INVALID_ACCESS_FLAGS ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::INPUT_ATTACHMENT, // INPUT_ATTACHMENT needs COLOR_ATTACHMENT or DEPTH_STENCIL_ATTACHMENT
+ MemoryAccess::READ_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT | AccessFlags::FRAGMENT_SHADER_READ_TEXTURE) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::SAMPLED,
+ MemoryAccess::READ_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT | AccessFlags::FRAGMENT_SHADER_READ_TEXTURE) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::STORAGE,
+ MemoryAccess::READ_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT | AccessFlags::FRAGMENT_SHADER_READ_TEXTURE) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::SAMPLED | TextureUsage::STORAGE,
+ MemoryAccess::READ_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+static_assert(
+ (AccessFlags::COLOR_ATTACHMENT_READ | AccessFlags::FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT | AccessFlags::TRANSFER_READ) ==
+ getDeviceAccessFlagsImpl(
+ TextureUsage::COLOR_ATTACHMENT | TextureUsage::INPUT_ATTACHMENT | TextureUsage::TRANSFER_SRC,
+ MemoryAccess::READ_ONLY,
+ ShaderStageFlags::FRAGMENT));
+
+} // namespace
+
+AccessFlags getDeviceAccessFlags(
+ TextureUsage usage,
+ MemoryAccess access,
+ ShaderStageFlags visibility) {
+ return getDeviceAccessFlagsImpl(usage, access, visibility);
+}
+
+} // namespace gfx
+
+} // namespace cc
diff --git a/native/cocos/renderer/gfx-base/GFXCommandBuffer.h b/native/cocos/renderer/gfx-base/GFXCommandBuffer.h
index 5b2ef2bb5d..c16065c74b 100644
--- a/native/cocos/renderer/gfx-base/GFXCommandBuffer.h
+++ b/native/cocos/renderer/gfx-base/GFXCommandBuffer.h
@@ -62,6 +62,7 @@ public:
virtual void updateBuffer(Buffer *buff, const void *data, uint32_t size) = 0;
virtual void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) = 0;
virtual void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) = 0;
+ virtual void copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) = 0;
virtual void execute(CommandBuffer *const *cmdBuffs, uint32_t count) = 0;
virtual void dispatch(const DispatchInfo &info) = 0;
virtual void beginQuery(QueryPool *queryPool, uint32_t id) = 0;
@@ -69,6 +70,9 @@ public:
virtual void resetQueryPool(QueryPool *queryPool) = 0;
virtual void completeQueryPool(QueryPool *queryPool) {}
+ using CustomCommand = std::function;
+ virtual void customCommand(CustomCommand &&cmd) {}
+
// barrier: excutionBarrier
// bufferBarriers: array of BufferBarrier*, descriptions of access of buffers
// buffers: array of MTL/VK/GLES buffers
diff --git a/native/cocos/renderer/gfx-base/GFXDef-common.h b/native/cocos/renderer/gfx-base/GFXDef-common.h
index fe4f40fe04..932b991291 100644
--- a/native/cocos/renderer/gfx-base/GFXDef-common.h
+++ b/native/cocos/renderer/gfx-base/GFXDef-common.h
@@ -36,6 +36,8 @@
#undef Status
#endif
+#define CC_USE_PIPELINE_CACHE 0
+
/**
* Some general guide lines:
* Always use explicit numeric types rather than `int`, `long`, etc. for a stable memory layout
@@ -96,6 +98,7 @@ using IndexList = ccstd::vector;
constexpr uint32_t MAX_ATTACHMENTS = 4U;
constexpr uint32_t INVALID_BINDING = ~0U;
constexpr uint32_t SUBPASS_EXTERNAL = ~0U;
+constexpr ccstd::hash_t INVALID_SHADER_HASH = 0xFFFFFFFFU;
// Although the standard is not limited, some devices do not support up to 65536 queries
constexpr uint32_t DEFAULT_MAX_QUERY_OBJECTS = 32767;
@@ -471,14 +474,17 @@ enum class TextureUsageBit : uint32_t {
COLOR_ATTACHMENT = 0x10,
DEPTH_STENCIL_ATTACHMENT = 0x20,
INPUT_ATTACHMENT = 0x40,
+ SHADING_RATE = 0x80,
};
using TextureUsage = TextureUsageBit;
CC_ENUM_BITWISE_OPERATORS(TextureUsageBit);
enum class TextureFlagBit : uint32_t {
NONE = 0,
- GEN_MIPMAP = 0x1, // Generate mipmaps using bilinear filter
- GENERAL_LAYOUT = 0x2, // For inout framebuffer attachments
+ GEN_MIPMAP = 0x1, // Generate mipmaps using bilinear filter
+ GENERAL_LAYOUT = 0x2, // For inout framebuffer attachments
+ EXTERNAL_OES = 0x4, // External oes texture
+ EXTERNAL_NORMAL = 0x8, // External normal texture
};
using TextureFlags = TextureFlagBit;
CC_ENUM_BITWISE_OPERATORS(TextureFlagBit);
@@ -490,6 +496,7 @@ enum class FormatFeatureBit : uint32_t {
LINEAR_FILTER = 0x4, // Allow linear filtering when sampling in shaders or blitting
STORAGE_TEXTURE = 0x8, // Allow storage reads & writes in shaders
VERTEX_ATTRIBUTE = 0x10, // Allow usages as vertex input attributes
+ SHADING_RATE = 0x20, // Allow usages as shading rate
};
using FormatFeature = FormatFeatureBit;
CC_ENUM_BITWISE_OPERATORS(FormatFeatureBit);
@@ -664,6 +671,8 @@ enum class AccessFlagBit : uint32_t {
TRANSFER_WRITE = 1 << 24, // Written as the destination of a transfer operation
HOST_PREINITIALIZED = 1 << 25, // Data pre-filled by host before device access starts
HOST_WRITE = 1 << 26, // Written on the host
+
+ SHADING_RATE = 1 << 27, // Read as a shading rate image
};
CC_ENUM_BITWISE_OPERATORS(AccessFlagBit);
using AccessFlags = AccessFlagBit;
@@ -844,6 +853,8 @@ struct DeviceCaps {
Size maxComputeWorkGroupCount;
bool supportQuery{false};
+ bool supportVariableRateShading{false};
+ bool supportSubPassShading{false};
float clipSpaceMinZ{-1.F};
float screenSpaceSignY{1.F};
@@ -1255,6 +1266,7 @@ struct ShaderInfo {
UniformTextureList textures;
UniformStorageImageList images;
UniformInputAttachmentList subpassInputs;
+ ccstd::hash_t hash = INVALID_SHADER_HASH;
EXPOSE_COPY_FN(ShaderInfo)
};
@@ -1308,6 +1320,7 @@ struct SubpassInfo {
uint32_t depthStencil{INVALID_BINDING};
uint32_t depthStencilResolve{INVALID_BINDING};
+ uint32_t shadingRate{INVALID_BINDING};
ResolveMode depthResolveMode{ResolveMode::NONE};
ResolveMode stencilResolveMode{ResolveMode::NONE};
diff --git a/native/cocos/renderer/gfx-base/GFXShader.cpp b/native/cocos/renderer/gfx-base/GFXShader.cpp
index 031d8cf5de..06e074c9ac 100644
--- a/native/cocos/renderer/gfx-base/GFXShader.cpp
+++ b/native/cocos/renderer/gfx-base/GFXShader.cpp
@@ -46,7 +46,7 @@ void Shader::initialize(const ShaderInfo &info) {
_textures = info.textures;
_images = info.images;
_subpassInputs = info.subpassInputs;
-
+ _hash = info.hash;
doInit(info);
}
diff --git a/native/cocos/renderer/gfx-base/GFXShader.h b/native/cocos/renderer/gfx-base/GFXShader.h
index af853d1c99..c66395ecb6 100644
--- a/native/cocos/renderer/gfx-base/GFXShader.h
+++ b/native/cocos/renderer/gfx-base/GFXShader.h
@@ -63,6 +63,7 @@ protected:
UniformTextureList _textures;
UniformStorageImageList _images;
UniformInputAttachmentList _subpassInputs;
+ ccstd::hash_t _hash = 0;
};
} // namespace gfx
diff --git a/native/cocos/renderer/gfx-base/GFXUtil.cpp b/native/cocos/renderer/gfx-base/GFXUtil.cpp
new file mode 100644
index 0000000000..84bede7137
--- /dev/null
+++ b/native/cocos/renderer/gfx-base/GFXUtil.cpp
@@ -0,0 +1,34 @@
+/****************************************************************************
+ Copyright (c) 2023 Xiamen Yaji Software Co., Ltd.
+
+ http://www.cocos.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+****************************************************************************/
+
+#include "GFXUtil.h"
+#include "platform/FileUtils.h"
+
+namespace cc::gfx {
+
+ccstd::string getPipelineCacheFolder() {
+ return FileUtils::getInstance()->getWritablePath();
+}
+
+} // namespace cc::gfx
diff --git a/native/cocos/renderer/gfx-base/GFXUtil.h b/native/cocos/renderer/gfx-base/GFXUtil.h
new file mode 100644
index 0000000000..d90703177f
--- /dev/null
+++ b/native/cocos/renderer/gfx-base/GFXUtil.h
@@ -0,0 +1,34 @@
+/****************************************************************************
+ Copyright (c) 2023 Xiamen Yaji Software Co., Ltd.
+
+ http://www.cocos.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+****************************************************************************/
+
+#pragma once
+
+#include "base/std/container/string.h"
+
+namespace cc::gfx {
+
+// FileUtils `enum class Status conflicts` with `#define Status int` in Xlib.h
+ccstd::string getPipelineCacheFolder();
+
+} // namespace cc::gfx
diff --git a/native/cocos/renderer/gfx-empty/EmptyCommandBuffer.cpp b/native/cocos/renderer/gfx-empty/EmptyCommandBuffer.cpp
index 0524a3cfbe..8db04e5f6f 100644
--- a/native/cocos/renderer/gfx-empty/EmptyCommandBuffer.cpp
+++ b/native/cocos/renderer/gfx-empty/EmptyCommandBuffer.cpp
@@ -96,6 +96,9 @@ void EmptyCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Tex
void EmptyCommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) {
}
+void EmptyCommandBuffer::copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) {
+}
+
void EmptyCommandBuffer::dispatch(const DispatchInfo &info) {
}
diff --git a/native/cocos/renderer/gfx-empty/EmptyCommandBuffer.h b/native/cocos/renderer/gfx-empty/EmptyCommandBuffer.h
index 8b07f79dda..f83d684b09 100644
--- a/native/cocos/renderer/gfx-empty/EmptyCommandBuffer.h
+++ b/native/cocos/renderer/gfx-empty/EmptyCommandBuffer.h
@@ -51,6 +51,7 @@ public:
void updateBuffer(Buffer *buff, const void *data, uint32_t size) override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) override;
void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) override;
+ void copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) override;
void execute(CommandBuffer *const *cmdBuffs, uint32_t count) override;
void dispatch(const DispatchInfo &info) override;
void pipelineBarrier(const GeneralBarrier *barrier, const BufferBarrier *const *bufferBarriers, const Buffer *const *buffers, uint32_t bufferCount, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint32_t textureBarrierCount) override;
diff --git a/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.cpp b/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.cpp
index 686b844da4..5ee07a69a7 100644
--- a/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.cpp
+++ b/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.cpp
@@ -312,6 +312,10 @@ void GLES2CommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Tex
}
}
+void GLES2CommandBuffer::copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) {
+ // should not copy texture in a secondary command buffer
+}
+
void GLES2CommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) {
GLES2CmdBlitTexture *cmd = _cmdAllocator->blitTextureCmdPool.alloc();
if (srcTexture) cmd->gpuTextureSrc = static_cast(srcTexture)->gpuTexture();
diff --git a/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.h b/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.h
index 187cb905e6..20e948ecbc 100644
--- a/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.h
+++ b/native/cocos/renderer/gfx-gles2/GLES2CommandBuffer.h
@@ -64,6 +64,7 @@ public:
void updateBuffer(Buffer *buff, const void *data, uint32_t size) override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) override;
void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) override;
+ void copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) override;
void execute(CommandBuffer *const *cmdBuffs, uint32_t count) override;
void dispatch(const DispatchInfo &info) override {}
void pipelineBarrier(const GeneralBarrier *barrier, const BufferBarrier *const *bufferBarriers, const Buffer *const *buffers, uint32_t bufferCount, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint32_t textureBarrierCount) override {}
diff --git a/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp b/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp
index f12f942314..6006261814 100644
--- a/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp
+++ b/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp
@@ -2968,6 +2968,9 @@ void cmdFuncGLES2CopyTextureToBuffers(GLES2Device *device, GLES2GPUTexture *gpuT
}
}
+void cmdFuncGLES2CopyTexture(GLES2Device *device, GLES2GPUTexture *gpuTextureSrc, GLES2GPUTexture *gpuTextureDst, const TextureCopy *regions, uint32_t count) {
+}
+
void cmdFuncGLES2BlitTexture(GLES2Device *device, GLES2GPUTexture *gpuTextureSrc, GLES2GPUTexture *gpuTextureDst, const TextureBlit *regions, uint32_t count, Filter filter) {
GLES2GPUStateCache *cache = device->stateCache();
diff --git a/native/cocos/renderer/gfx-gles2/GLES2Commands.h b/native/cocos/renderer/gfx-gles2/GLES2Commands.h
index 5cbba6a578..e87736708f 100644
--- a/native/cocos/renderer/gfx-gles2/GLES2Commands.h
+++ b/native/cocos/renderer/gfx-gles2/GLES2Commands.h
@@ -231,6 +231,12 @@ void cmdFuncGLES2CopyTextureToBuffers(GLES2Device *device,
const BufferTextureCopy *regions,
uint32_t count);
+void cmdFuncGLES2CopyTexture(GLES2Device *device,
+ GLES2GPUTexture *gpuTextureSrc,
+ GLES2GPUTexture *gpuTextureDst,
+ const TextureCopy *regions,
+ uint32_t count);
+
void cmdFuncGLES2BlitTexture(GLES2Device *device,
GLES2GPUTexture *gpuTextureSrc,
GLES2GPUTexture *gpuTextureDst,
diff --git a/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.cpp b/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.cpp
index 2930fdb8d6..6336745e10 100644
--- a/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.cpp
+++ b/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.cpp
@@ -149,6 +149,28 @@ void GLES2PrimaryCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffe
}
}
+void GLES2PrimaryCommandBuffer::copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) {
+ GLES2GPUTexture *gpuTextureSrc = nullptr;
+ GLES2GPUTexture *gpuTextureDst = nullptr;
+ if (srcTexture) gpuTextureSrc = static_cast(srcTexture)->gpuTexture();
+ if (dstTexture) gpuTextureDst = static_cast(dstTexture)->gpuTexture();
+ ccstd::vector blitRegions(count);
+ for (uint32_t i = 0; i < count; ++i) {
+ auto &blit = blitRegions[i];
+ const auto © = regions[i];
+
+ blit.srcSubres = copy.srcSubres;
+ blit.dstSubres = copy.dstSubres;
+
+ blit.srcOffset = copy.srcOffset;
+ blit.dstOffset = copy.dstOffset;
+
+ blit.srcExtent = copy.extent;
+ blit.dstExtent = copy.extent;
+ }
+ cmdFuncGLES2BlitTexture(GLES2Device::getInstance(), gpuTextureSrc, gpuTextureDst, blitRegions.data(), count, Filter::POINT);
+}
+
void GLES2PrimaryCommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) {
GLES2GPUTexture *gpuTextureSrc = nullptr;
GLES2GPUTexture *gpuTextureDst = nullptr;
diff --git a/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.h b/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.h
index e7248bdf9f..358b3de968 100644
--- a/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.h
+++ b/native/cocos/renderer/gfx-gles2/GLES2PrimaryCommandBuffer.h
@@ -45,6 +45,7 @@ public:
void updateBuffer(Buffer *buff, const void *data, uint32_t size) override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) override;
void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) override;
+ void copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) override;
void execute(CommandBuffer *const *cmdBuffs, uint32_t count) override;
protected:
diff --git a/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.cpp b/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.cpp
index ad230a430d..6066660b98 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.cpp
+++ b/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.cpp
@@ -299,6 +299,10 @@ void GLES3CommandBuffer::updateBuffer(Buffer *buff, const void *data, uint32_t s
}
}
+void GLES3CommandBuffer::copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) {
+ // should not copy texture in a secondary command buffer
+}
+
void GLES3CommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) {
GLES3CmdBlitTexture *cmd = _cmdAllocator->blitTextureCmdPool.alloc();
if (srcTexture) cmd->gpuTextureSrc = static_cast(srcTexture)->gpuTexture();
diff --git a/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.h b/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.h
index 0153f6b14d..5050ac8933 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.h
+++ b/native/cocos/renderer/gfx-gles3/GLES3CommandBuffer.h
@@ -62,6 +62,7 @@ public:
void updateBuffer(Buffer *buff, const void *data, uint32_t size) override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) override;
void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) override;
+ void copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) override;
void execute(CommandBuffer *const *cmdBuffs, uint32_t count) override;
void dispatch(const DispatchInfo &info) override;
void pipelineBarrier(const GeneralBarrier *barrier, const BufferBarrier *const *bufferBarriers, const Buffer *const * /*buffers*/, uint32_t bufferBarrierCount, const TextureBarrier *const *textureBarriers, const Texture *const * /*textures*/, uint32_t textureBarrierCount) override;
diff --git a/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp b/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp
index 1424ad1507..f394082a01 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp
+++ b/native/cocos/renderer/gfx-gles3/GLES3Commands.cpp
@@ -24,12 +24,14 @@
#include "GLES3Commands.h"
#include "GLES3Device.h"
+#include "GLES3PipelineCache.h"
#include "GLES3QueryPool.h"
#include "GLES3Std.h"
#include "base/StringUtil.h"
#include "gfx-base/GFXDef-common.h"
#include "gfx-gles-common/GLESCommandPool.h"
#include "gfx-gles3/GLES3GPUObjects.h"
+#include "gfx-gles3/states/GLES3Sampler.h"
#define BUFFER_OFFSET(idx) (static_cast(0) + (idx))
@@ -828,7 +830,11 @@ void cmdFuncGLES3CreateTexture(GLES3Device *device, GLES3GPUTexture *gpuTexture)
}
if (gpuTexture->glTexture) {
- gpuTexture->glTarget = GL_TEXTURE_EXTERNAL_OES;
+ if (hasFlag(gpuTexture->flags, TextureFlagBit::EXTERNAL_OES)) {
+ gpuTexture->glTarget = GL_TEXTURE_EXTERNAL_OES;
+ } else {
+ gpuTexture->glTarget = GL_TEXTURE_2D;
+ }
return;
}
@@ -934,7 +940,7 @@ void cmdFuncGLES3DestroyTexture(GLES3Device *device, GLES3GPUTexture *gpuTexture
glTexture = 0;
}
}
- if (gpuTexture->glTarget != GL_TEXTURE_EXTERNAL_OES) {
+ if (!hasFlag(gpuTexture->flags, TextureFlagBit::EXTERNAL_OES) && !hasFlag(gpuTexture->flags, TextureFlagBit::EXTERNAL_NORMAL)) {
GL_CHECK(glDeleteTextures(1, &gpuTexture->glTexture));
}
gpuTexture->glTexture = 0;
@@ -951,7 +957,10 @@ void cmdFuncGLES3DestroyTexture(GLES3Device *device, GLES3GPUTexture *gpuTexture
}
void cmdFuncGLES3ResizeTexture(GLES3Device *device, GLES3GPUTexture *gpuTexture) {
- if (gpuTexture->memoryless || gpuTexture->glTarget == GL_TEXTURE_EXTERNAL_OES) return;
+ if (gpuTexture->memoryless || hasFlag(gpuTexture->flags, TextureFlagBit::EXTERNAL_OES) ||
+ hasFlag(gpuTexture->flags, TextureFlagBit::EXTERNAL_NORMAL)) {
+ return;
+ }
if (gpuTexture->glSamples <= 1) {
// immutable by default
@@ -1028,8 +1037,25 @@ GLuint GLES3GPUSampler::getGLSampler(uint16_t minLod, uint16_t maxLod) {
return _cache[hash];
}
-// NOLINTNEXTLINE(google-readability-function-size, readability-function-size)
-void cmdFuncGLES3CreateShader(GLES3Device *device, GLES3GPUShader *gpuShader) {
+bool cmdFuncGLES3CreateProgramByBinary(GLES3Device *device, GLES3GPUShader *gpuShader, GLES3GPUPipelineLayout *pipelineLayout) {
+ auto *pipelineCache = device->pipelineCache();
+ if (pipelineCache == nullptr || gpuShader->hash == INVALID_SHADER_HASH) {
+ return false;
+ }
+
+ ccstd::hash_t hash = gpuShader->hash;
+ ccstd::hash_combine(hash, pipelineLayout->hash);
+
+ auto *item = pipelineCache->fetchBinary(gpuShader->name, hash);
+ if (item != nullptr) {
+ GL_CHECK(gpuShader->glProgram = glCreateProgram());
+ GL_CHECK(glProgramBinary(gpuShader->glProgram, item->format, item->data.data(), item->data.size()));
+ return true;
+ }
+ return false;
+}
+
+bool cmdFuncGLES3CreateProgramBySource(GLES3Device *device, GLES3GPUShader *gpuShader, GLES3GPUPipelineLayout *pipelineLayout) {
GLenum glShaderStage = 0;
ccstd::string shaderStageStr;
GLint status;
@@ -1055,7 +1081,7 @@ void cmdFuncGLES3CreateShader(GLES3Device *device, GLES3GPUShader *gpuShader) {
}
default: {
CC_ABORT();
- return;
+ return false;
}
}
GL_CHECK(gpuStage.glShader = glCreateShader(glShaderStage));
@@ -1079,7 +1105,7 @@ void cmdFuncGLES3CreateShader(GLES3Device *device, GLES3GPUShader *gpuShader) {
CC_FREE(logs);
GL_CHECK(glDeleteShader(gpuStage.glShader));
gpuStage.glShader = 0;
- return;
+ return false;
}
}
@@ -1115,10 +1141,33 @@ void cmdFuncGLES3CreateShader(GLES3Device *device, GLES3GPUShader *gpuShader) {
CC_LOG_ERROR(logs);
CC_FREE(logs);
- return;
+ return false;
}
}
+ auto *cache = device->pipelineCache();
+ if (cache != nullptr && gpuShader->hash != INVALID_SHADER_HASH) {
+ GLint binaryLength = 0;
+ GL_CHECK(glGetProgramiv(gpuShader->glProgram, GL_PROGRAM_BINARY_LENGTH, &binaryLength));
+ GLsizei length = 0;
+ IntrusivePtr binary = ccnew GLES3GPUProgramBinary();
+ binary->name = gpuShader->name;
+ binary->hash = gpuShader->hash;
+ ccstd::hash_combine(binary->hash, pipelineLayout->hash);
+ binary->data.resize(binaryLength);
+ GL_CHECK(glGetProgramBinary(gpuShader->glProgram, binaryLength, &length, &binary->format, binary->data.data()));
+ cache->addBinary(binary);
+ }
+ return true;
+}
+
+// NOLINTNEXTLINE(google-readability-function-size, readability-function-size)
+void cmdFuncGLES3CreateShader(GLES3Device *device, GLES3GPUShader *gpuShader, GLES3GPUPipelineLayout *pipelineLayout) {
+ if (!cmdFuncGLES3CreateProgramByBinary(device, gpuShader, pipelineLayout)) {
+ if (!cmdFuncGLES3CreateProgramBySource(device, gpuShader, pipelineLayout)) {
+ return;
+ }
+ }
CC_LOG_INFO("Shader '%s' compilation succeeded.", gpuShader->name.c_str());
GLint attrMaxLength = 0;
@@ -2516,7 +2565,8 @@ void cmdFuncGLES3BindState(GLES3Device *device, GLES3GPUPipelineState *gpuPipeli
for (size_t u = 0; u < glSamplerTexture.units.size(); u++, gpuDescriptor++) {
auto unit = static_cast(glSamplerTexture.units[u]);
- if (!gpuDescriptor->gpuTextureView || !gpuDescriptor->gpuTextureView->gpuTexture || !gpuDescriptor->gpuSampler) {
+ auto *sampler = gpuDescriptor->gpuSampler ? gpuDescriptor->gpuSampler : static_cast(device->getSampler({}))->gpuSampler();
+ if (!gpuDescriptor->gpuTextureView || !gpuDescriptor->gpuTextureView->gpuTexture || !sampler) {
// CC_LOG_ERROR("Sampler texture '%s' at binding %d set %d index %d is not bounded",
// glSamplerTexture.name.c_str(), glSamplerTexture.set, glSamplerTexture.binding, u);
continue;
@@ -2539,7 +2589,7 @@ void cmdFuncGLES3BindState(GLES3Device *device, GLES3GPUPipelineState *gpuPipeli
cache->glTextures[unit] = glTexture;
}
- GLuint glSampler = gpuDescriptor->gpuSampler->getGLSampler(minLod, maxLod);
+ GLuint glSampler = sampler->getGLSampler(minLod, maxLod);
if (cache->glSamplers[unit] != glSampler) {
GL_CHECK(glBindSampler(unit, glSampler));
cache->glSamplers[unit] = glSampler;
diff --git a/native/cocos/renderer/gfx-gles3/GLES3Commands.h b/native/cocos/renderer/gfx-gles3/GLES3Commands.h
index 9546b77047..38f9a19815 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3Commands.h
+++ b/native/cocos/renderer/gfx-gles3/GLES3Commands.h
@@ -246,7 +246,7 @@ void cmdFuncGLES3ResizeBuffer(GLES3Device *device, GLES3GPUBuffer *gpuBuffer);
void cmdFuncGLES3CreateTexture(GLES3Device *device, GLES3GPUTexture *gpuTexture);
void cmdFuncGLES3DestroyTexture(GLES3Device *device, GLES3GPUTexture *gpuTexture);
void cmdFuncGLES3ResizeTexture(GLES3Device *device, GLES3GPUTexture *gpuTexture);
-void cmdFuncGLES3CreateShader(GLES3Device *device, GLES3GPUShader *gpuShader);
+void cmdFuncGLES3CreateShader(GLES3Device *device, GLES3GPUShader *gpuShader, GLES3GPUPipelineLayout *pipelineLayout);
void cmdFuncGLES3DestroyShader(GLES3Device *device, GLES3GPUShader *gpuShader);
void cmdFuncGLES3CreateRenderPass(GLES3Device *device, GLES3GPURenderPass *gpuRenderPass);
void cmdFuncGLES3DestroyRenderPass(GLES3Device *device, GLES3GPURenderPass *gpuRenderPass);
diff --git a/native/cocos/renderer/gfx-gles3/GLES3DescriptorSetLayout.cpp b/native/cocos/renderer/gfx-gles3/GLES3DescriptorSetLayout.cpp
index 494fdd44f2..06d1e2acd9 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3DescriptorSetLayout.cpp
+++ b/native/cocos/renderer/gfx-gles3/GLES3DescriptorSetLayout.cpp
@@ -26,6 +26,7 @@
#include "GLES3Commands.h"
#include "GLES3DescriptorSetLayout.h"
+#include "states/GLES3Sampler.h"
namespace cc {
namespace gfx {
@@ -45,12 +46,21 @@ void GLES3DescriptorSetLayout::doInit(const DescriptorSetLayoutInfo & /*info*/)
_gpuDescriptorSetLayout->descriptorIndices = _descriptorIndices;
_gpuDescriptorSetLayout->bindings = _bindings;
+ auto &hash = _gpuDescriptorSetLayout->hash;
for (auto &binding : _bindings) {
if (hasAnyFlags(binding.descriptorType, DESCRIPTOR_DYNAMIC_TYPE)) {
for (uint32_t j = 0U; j < binding.count; j++) {
_gpuDescriptorSetLayout->dynamicBindings.push_back(binding.binding);
}
}
+
+ ccstd::hash_combine(hash, binding.binding);
+ ccstd::hash_combine(hash, binding.descriptorType);
+ ccstd::hash_combine(hash, binding.count);
+ ccstd::hash_combine(hash, binding.stageFlags);
+ for (auto &sampler : binding.immutableSamplers) {
+ ccstd::hash_combine(hash, sampler->getHash());
+ }
}
}
diff --git a/native/cocos/renderer/gfx-gles3/GLES3Device.cpp b/native/cocos/renderer/gfx-gles3/GLES3Device.cpp
index 4874be7bd1..65aeb6158e 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3Device.cpp
+++ b/native/cocos/renderer/gfx-gles3/GLES3Device.cpp
@@ -33,6 +33,7 @@
#include "GLES3Framebuffer.h"
#include "GLES3GPUObjects.h"
#include "GLES3InputAssembler.h"
+#include "GLES3PipelineCache.h"
#include "GLES3PipelineLayout.h"
#include "GLES3PipelineState.h"
#include "GLES3PrimaryCommandBuffer.h"
@@ -222,6 +223,11 @@ bool GLES3Device::doInit(const DeviceInfo & /*info*/) {
_gpuStateCache->initialize(_caps.maxTextureUnits, _caps.maxImageUnits, _caps.maxUniformBufferBindings, _caps.maxShaderStorageBufferBindings, _caps.maxVertexAttributes);
+#if CC_USE_PIPELINE_CACHE
+ _pipelineCache = std::make_unique();
+ _pipelineCache->init();
+#endif
+
CC_LOG_INFO("GLES3 device initialized.");
CC_LOG_INFO("RENDERER: %s", _renderer.c_str());
CC_LOG_INFO("VENDOR: %s", _vendor.c_str());
@@ -249,6 +255,8 @@ void GLES3Device::doDestroy() {
CC_SAFE_DESTROY_AND_DELETE(_queryPool)
CC_SAFE_DESTROY_AND_DELETE(_queue)
CC_SAFE_DESTROY_AND_DELETE(_gpuContext)
+
+ _pipelineCache.reset();
}
void GLES3Device::acquire(Swapchain *const *swapchains, uint32_t count) {
diff --git a/native/cocos/renderer/gfx-gles3/GLES3Device.h b/native/cocos/renderer/gfx-gles3/GLES3Device.h
index 1e2a916f87..5eed7ca400 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3Device.h
+++ b/native/cocos/renderer/gfx-gles3/GLES3Device.h
@@ -39,6 +39,7 @@ class GLES3GPUStateCache;
class GLES3GPUFramebufferHub;
struct GLES3GPUConstantRegistry;
class GLES3GPUFramebufferCacheMap;
+class GLES3PipelineCache;
class CC_GLES3_API GLES3Device final : public Device {
public:
@@ -76,6 +77,7 @@ public:
inline GLES3GPUFramebufferHub *framebufferHub() const { return _gpuFramebufferHub; }
inline GLES3GPUConstantRegistry *constantRegistry() const { return _gpuConstantRegistry; }
inline GLES3GPUFramebufferCacheMap *framebufferCacheMap() const { return _gpuFramebufferCacheMap; }
+ inline GLES3PipelineCache *pipelineCache() const { return _pipelineCache.get(); }
inline bool checkExtension(const ccstd::string &extension) const {
return std::any_of(_extensions.begin(), _extensions.end(), [&extension](auto &ext) {
@@ -135,6 +137,7 @@ protected:
GLES3GPUFramebufferHub *_gpuFramebufferHub{nullptr};
GLES3GPUConstantRegistry *_gpuConstantRegistry{nullptr};
GLES3GPUFramebufferCacheMap *_gpuFramebufferCacheMap{nullptr};
+ std::unique_ptr _pipelineCache;
ccstd::vector _swapchains;
diff --git a/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h b/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h
index d5bf276fdd..75cf6509ab 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h
+++ b/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h
@@ -23,11 +23,13 @@
#pragma once
#include
+#include
#include "base/Macros.h"
#include "base/std/container/unordered_map.h"
#include "gfx-base/GFXDef-common.h"
#include "gfx-base/GFXDef.h"
+#include "gfx-base/GFXDeviceObject.h"
#include "gfx-gles-common/GLESCommandPool.h"
#include "GLES3Std.h"
@@ -279,6 +281,7 @@ struct GLES3GPUShader {
GLES3GPUShaderStageList gpuStages;
GLuint glProgram = 0;
+ ccstd::hash_t hash = INVALID_SHADER_HASH;
GLES3GPUInputList glInputs;
GLES3GPUUniformBufferList glBuffers;
GLES3GPUUniformSamplerTextureList glSamplerTextures;
@@ -396,6 +399,7 @@ struct GLES3GPUDescriptorSetLayout {
ccstd::vector bindingIndices;
ccstd::vector descriptorIndices;
uint32_t descriptorCount = 0U;
+ ccstd::hash_t hash = 0U;
};
using GLES3GPUDescriptorSetLayoutList = ccstd::vector;
@@ -406,7 +410,8 @@ struct GLES3GPUPipelineLayout {
ccstd::vector> dynamicOffsetIndices;
ccstd::vector dynamicOffsetOffsets;
ccstd::vector dynamicOffsets;
- uint32_t dynamicOffsetCount;
+ uint32_t dynamicOffsetCount = 0U;
+ ccstd::hash_t hash = 0U;
};
struct GLES3GPUPipelineState {
@@ -673,5 +678,12 @@ private:
ccstd::unordered_map> _framebuffers;
};
+struct GLES3GPUProgramBinary : public GFXDeviceObject {
+ ccstd::string name;
+ ccstd::hash_t hash = 0;
+ GLenum format;
+ std::vector data;
+};
+
} // namespace gfx
} // namespace cc
diff --git a/native/cocos/renderer/gfx-gles3/GLES3PipelineCache.cpp b/native/cocos/renderer/gfx-gles3/GLES3PipelineCache.cpp
new file mode 100644
index 0000000000..b094eb1ea3
--- /dev/null
+++ b/native/cocos/renderer/gfx-gles3/GLES3PipelineCache.cpp
@@ -0,0 +1,215 @@
+/****************************************************************************
+ Copyright (c) 2023 Xiamen Yaji Software Co., Ltd.
+
+ http://www.cocos.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+****************************************************************************/
+
+#include "GLES3PipelineCache.h"
+
+#include
+
+#include "base/BinaryArchive.h"
+
+#include "GLES3GPUObjects.h"
+#include "gfx-base/GFXUtil.h"
+
+namespace cc::gfx {
+
+//#define PIPELINE_CACHE_FORCE_INCREMENTAL
+
+#if defined(_WIN32) && !defined(PIPELINE_CACHE_FORCE_INCREMENTAL)
+ #define PIPELINE_CACHE_FULL
+#else
+ #define PIPELINE_CACHE_INCREMENTAL
+#endif
+
+namespace {
+const char *fileName = "/pipeline_cache_gles3.bin";
+const uint32_t MAGIC = 0x4343474C; // "CCGL"
+const uint32_t VERSION = 1;
+
+void saveHeader(BinaryOutputArchive &archive) {
+ archive.save(MAGIC);
+ archive.save(VERSION);
+}
+
+void saveItem(BinaryOutputArchive &archive, GLES3GPUProgramBinary *binary) {
+ archive.save(binary->format);
+ archive.save(static_cast(binary->name.size()));
+ archive.save(static_cast(binary->data.size()));
+ archive.save(binary->hash);
+ archive.save(binary->name.data(), static_cast(binary->name.size()));
+ archive.save(binary->data.data(), static_cast(binary->data.size()));
+ CC_LOG_INFO("Save program cache success, name %s.", binary->name.c_str());
+}
+
+} // namespace
+
+GLES3PipelineCache::GLES3PipelineCache() {
+ _savePath = getPipelineCacheFolder() + fileName;
+}
+
+GLES3PipelineCache::~GLES3PipelineCache() { // NOLINT
+#ifdef PIPELINE_CACHE_FULL
+ saveCacheFull();
+#endif
+}
+
+bool GLES3PipelineCache::loadCache() {
+ std::ifstream stream(_savePath, std::ios::binary);
+ if (!stream.is_open()) {
+ CC_LOG_INFO("Load program cache, no cached files.");
+ return false;
+ }
+
+ uint32_t magic = 0;
+ uint32_t version = 0;
+
+ BinaryInputArchive archive(stream);
+ auto loadResult = archive.load(magic);
+ loadResult &= archive.load(version);
+
+ if (magic != MAGIC || version < VERSION) {
+ // false means invalid cache, need to discard the file content.
+ return false;
+ }
+
+ uint32_t cachedItemNum = 0;
+ GLenum format = GL_NONE;
+ while (loadResult && archive.load(format)) {
+ ++cachedItemNum;
+
+ // name length
+ uint32_t nameLength = 0;
+ loadResult &= archive.load(nameLength);
+
+ // data length
+ uint32_t dataLength = 0;
+ loadResult &= archive.load(dataLength);
+
+ // skip length if not valid.
+ if (!checkProgramFormat(format)) {
+ archive.move(dataLength + nameLength + sizeof(GLES3GPUProgramBinary::hash));
+ continue;
+ }
+
+ auto *binary = ccnew GLES3GPUProgramBinary();
+ binary->format = format;
+ binary->name.resize(nameLength, 0);
+ binary->data.resize(dataLength, 0);
+
+ // hash
+ loadResult &= archive.load(binary->hash);
+
+ // name
+ loadResult &= archive.load(binary->name.data(), nameLength);
+
+ // data
+ loadResult &= archive.load(binary->data.data(), dataLength);
+
+ _programCaches.emplace(binary->name, binary);
+ }
+
+ // If the number of cached items does not equal the number of loaded items, it may be necessary to update the cache.
+ _dirty = cachedItemNum != _programCaches.size();
+ CC_LOG_INFO("Load program cache success. records %u, loaded %u", cachedItemNum, _programCaches.size());
+ return true;
+}
+
+void GLES3PipelineCache::saveCacheIncremental(GLES3GPUProgramBinary *binary) {
+ std::ofstream stream(_savePath, std::ios::binary | std::ios::app);
+ if (!stream.is_open()) {
+ CC_LOG_INFO("Save program cache failed.");
+ return;
+ }
+ BinaryOutputArchive archive(stream);
+ saveItem(archive, binary);
+}
+
+void GLES3PipelineCache::saveCacheFull() {
+ if (!_dirty) {
+ return;
+ }
+ std::ofstream stream(_savePath, std::ios::binary);
+ if (!stream.is_open()) {
+ CC_LOG_INFO("Save program cache failed.");
+ return;
+ }
+ BinaryOutputArchive archive(stream);
+ saveHeader(archive);
+
+ for (auto &pair : _programCaches) {
+ auto &binary = pair.second;
+ saveItem(archive, binary);
+ }
+ _dirty = false;
+}
+
+void GLES3PipelineCache::init() {
+ GLint shaderBinaryFormats = 0;
+ GL_CHECK(glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &shaderBinaryFormats));
+
+ _programBinaryFormats.resize(shaderBinaryFormats);
+ GL_CHECK(glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, _programBinaryFormats.data()));
+
+ bool success = loadCache();
+ if (!success) {
+ // discard cache content.
+ std::ofstream stream(_savePath, std::ios::binary | std::ios::trunc);
+#ifdef PIPELINE_CACHE_INCREMENTAL
+ if (stream.is_open()) {
+ BinaryOutputArchive archive(stream);
+ saveHeader(archive);
+ }
+#endif
+ }
+}
+
+void GLES3PipelineCache::addBinary(GLES3GPUProgramBinary *binary) {
+ _programCaches[binary->name] = binary;
+#ifdef PIPELINE_CACHE_INCREMENTAL
+ saveCacheIncremental(binary);
+#endif
+ _dirty = true;
+}
+
+GLES3GPUProgramBinary *GLES3PipelineCache::fetchBinary(const ccstd::string &key, ccstd::hash_t hash) {
+ auto iter = _programCaches.find(key);
+ if (iter == _programCaches.end()) {
+ return nullptr;
+ }
+
+ // if hash not match, re-generate program binary.
+ if (iter->second->hash != hash) {
+ _programCaches.erase(iter);
+ return nullptr;
+ }
+
+ return iter->second;
+}
+
+bool GLES3PipelineCache::checkProgramFormat(GLuint format) const {
+ return std::any_of(_programBinaryFormats.begin(), _programBinaryFormats.end(), [format](const auto &fmt) {
+ return format == fmt;
+ });
+}
+
+} // namespace cc::gfx
diff --git a/native/cocos/renderer/gfx-gles3/GLES3PipelineCache.h b/native/cocos/renderer/gfx-gles3/GLES3PipelineCache.h
new file mode 100644
index 0000000000..64c98798d3
--- /dev/null
+++ b/native/cocos/renderer/gfx-gles3/GLES3PipelineCache.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+ Copyright (c) 2023 Xiamen Yaji Software Co., Ltd.
+
+ http://www.cocos.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+****************************************************************************/
+
+#pragma once
+
+#include "GLES3GPUObjects.h"
+#include "base/Ptr.h"
+#include "base/RefCounted.h"
+#include "base/std/container/string.h"
+#include "base/std/container/unordered_map.h"
+#include "base/std/container/vector.h"
+
+namespace cc {
+class BinaryOutputArchive;
+}
+
+namespace cc::gfx {
+class GLES3GPUShader;
+
+class GLES3PipelineCache : public RefCounted {
+public:
+ GLES3PipelineCache();
+ ~GLES3PipelineCache() override;
+
+ void init();
+
+ void addBinary(GLES3GPUProgramBinary *binary);
+ GLES3GPUProgramBinary *fetchBinary(const ccstd::string &key, ccstd::hash_t hash);
+ bool checkProgramFormat(GLuint format) const;
+
+private:
+ bool loadCache();
+ void saveCacheFull();
+ void saveCacheIncremental(GLES3GPUProgramBinary *binary);
+
+ ccstd::vector _programBinaryFormats;
+ ccstd::unordered_map> _programCaches;
+ ccstd::string _savePath;
+ bool _dirty = false;
+};
+
+} // namespace cc::gfx
diff --git a/native/cocos/renderer/gfx-gles3/GLES3PipelineLayout.cpp b/native/cocos/renderer/gfx-gles3/GLES3PipelineLayout.cpp
index 9387f08257..338beeeb33 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3PipelineLayout.cpp
+++ b/native/cocos/renderer/gfx-gles3/GLES3PipelineLayout.cpp
@@ -44,6 +44,7 @@ void GLES3PipelineLayout::doInit(const PipelineLayoutInfo & /*info*/) {
_gpuPipelineLayout = ccnew GLES3GPUPipelineLayout;
uint32_t offset = 0U;
+ auto &hash = _gpuPipelineLayout->hash;
_gpuPipelineLayout->dynamicOffsetIndices.resize(_setLayouts.size());
for (uint32_t i = 0U; i < _setLayouts.size(); i++) {
DescriptorSetLayout *setLayout = _setLayouts[i];
@@ -59,6 +60,8 @@ void GLES3PipelineLayout::doInit(const PipelineLayoutInfo & /*info*/) {
_gpuPipelineLayout->dynamicOffsetOffsets.push_back(static_cast(offset));
_gpuPipelineLayout->setLayouts.push_back(gpuSetLayout);
offset += dynamicCount;
+
+ ccstd::hash_combine(hash, gpuSetLayout->hash);
}
_gpuPipelineLayout->dynamicOffsetOffsets.push_back(static_cast(offset));
_gpuPipelineLayout->dynamicOffsetCount = static_cast(offset);
diff --git a/native/cocos/renderer/gfx-gles3/GLES3PipelineState.cpp b/native/cocos/renderer/gfx-gles3/GLES3PipelineState.cpp
index 636d9b6e13..13847c96e3 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3PipelineState.cpp
+++ b/native/cocos/renderer/gfx-gles3/GLES3PipelineState.cpp
@@ -25,6 +25,7 @@
#include "GLES3Std.h"
#include "GLES3Commands.h"
+#include "GLES3Device.h"
#include "GLES3PipelineLayout.h"
#include "GLES3PipelineState.h"
#include "GLES3RenderPass.h"
@@ -50,6 +51,21 @@ const GLenum GLE_S3_PRIMITIVES[] = {
GL_NONE,
};
+namespace {
+
+void initGpuShader(GLES3GPUShader *gpuShader, GLES3GPUPipelineLayout *gpuPipelineLayout) {
+ cmdFuncGLES3CreateShader(GLES3Device::getInstance(), gpuShader, gpuPipelineLayout);
+ CC_ASSERT(gpuShader->glProgram);
+
+ // Clear shader source after they're uploaded to GPU
+ for (auto &stage : gpuShader->gpuStages) {
+ stage.source.clear();
+ stage.source.shrink_to_fit();
+ }
+}
+
+} // namespace
+
GLES3PipelineState::GLES3PipelineState() {
_typedID = generateObjectID();
}
@@ -61,11 +77,15 @@ GLES3PipelineState::~GLES3PipelineState() {
void GLES3PipelineState::doInit(const PipelineStateInfo & /*info*/) {
_gpuPipelineState = ccnew GLES3GPUPipelineState;
_gpuPipelineState->glPrimitive = GLE_S3_PRIMITIVES[static_cast(_primitive)];
- _gpuPipelineState->gpuShader = static_cast(_shader)->gpuShader();
_gpuPipelineState->rs = _rasterizerState;
_gpuPipelineState->dss = _depthStencilState;
_gpuPipelineState->bs = _blendState;
_gpuPipelineState->gpuPipelineLayout = static_cast(_pipelineLayout)->gpuPipelineLayout();
+ _gpuPipelineState->gpuShader = static_cast(_shader)->gpuShader();
+ if (_gpuPipelineState->gpuShader->glProgram == 0) {
+ initGpuShader(_gpuPipelineState->gpuShader, _gpuPipelineState->gpuPipelineLayout);
+ }
+
if (_renderPass) _gpuPipelineState->gpuRenderPass = static_cast(_renderPass)->gpuRenderPass();
for (uint32_t i = 0; i < 31; i++) {
diff --git a/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.cpp b/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.cpp
index 90bd448774..6617e0b81d 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.cpp
+++ b/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.cpp
@@ -141,6 +141,29 @@ void GLES3PrimaryCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffe
}
}
+void GLES3PrimaryCommandBuffer::copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) {
+ GLES3GPUTexture *gpuTextureSrc = nullptr;
+ GLES3GPUTexture *gpuTextureDst = nullptr;
+ if (srcTexture) gpuTextureSrc = static_cast(srcTexture)->gpuTexture();
+ if (dstTexture) gpuTextureDst = static_cast(dstTexture)->gpuTexture();
+
+ ccstd::vector blitRegions(count);
+ for (uint32_t i = 0; i < count; ++i) {
+ auto &blit = blitRegions[i];
+ const auto © = regions[i];
+
+ blit.srcSubres = copy.srcSubres;
+ blit.dstSubres = copy.dstSubres;
+
+ blit.srcOffset = copy.srcOffset;
+ blit.dstOffset = copy.dstOffset;
+
+ blit.srcExtent = copy.extent;
+ blit.dstExtent = copy.extent;
+ }
+ cmdFuncGLES3BlitTexture(GLES3Device::getInstance(), gpuTextureSrc, gpuTextureDst, blitRegions.data(), count, Filter::POINT);
+}
+
void GLES3PrimaryCommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) {
GLES3GPUTexture *gpuTextureSrc = nullptr;
GLES3GPUTexture *gpuTextureDst = nullptr;
diff --git a/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.h b/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.h
index 69312a1ef7..79d82f6bd3 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.h
+++ b/native/cocos/renderer/gfx-gles3/GLES3PrimaryCommandBuffer.h
@@ -48,6 +48,7 @@ public:
void dispatch(const DispatchInfo &info) override;
void pipelineBarrier(const GeneralBarrier *barrier, const BufferBarrier *const *bufferBarriers, const Buffer *const * /*buffers*/, uint32_t bufferBarrierCount, const TextureBarrier *const *textureBarriers, const Texture *const * /*textures*/, uint32_t textureBarrierCount) override;
void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) override;
+ void copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) override;
void beginQuery(QueryPool *queryPool, uint32_t id) override;
void endQuery(QueryPool *queryPool, uint32_t id) override;
void resetQueryPool(QueryPool *queryPool) override;
diff --git a/native/cocos/renderer/gfx-gles3/GLES3Shader.cpp b/native/cocos/renderer/gfx-gles3/GLES3Shader.cpp
index fcb48b7c51..4d1a7a261f 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3Shader.cpp
+++ b/native/cocos/renderer/gfx-gles3/GLES3Shader.cpp
@@ -27,6 +27,7 @@
#include "GLES3Commands.h"
#include "GLES3Device.h"
#include "GLES3Shader.h"
+#include "base/std/hash/hash_fwd.hpp"
namespace cc {
namespace gfx {
@@ -39,25 +40,7 @@ GLES3Shader::~GLES3Shader() {
destroy();
}
-namespace {
-
-void initGpuShader(GLES3GPUShader *gpuShader) {
- cmdFuncGLES3CreateShader(GLES3Device::getInstance(), gpuShader);
- CC_ASSERT(gpuShader->glProgram);
-
- // Clear shader source after they're uploaded to GPU
- for (auto &stage : gpuShader->gpuStages) {
- stage.source.clear();
- stage.source.shrink_to_fit();
- }
-}
-
-} // namespace
-
GLES3GPUShader *GLES3Shader::gpuShader() const {
- if (!_gpuShader->glProgram) {
- initGpuShader(_gpuShader);
- }
return _gpuShader;
}
@@ -72,6 +55,7 @@ void GLES3Shader::doInit(const ShaderInfo & /*info*/) {
_gpuShader->textures = _textures;
_gpuShader->images = _images;
_gpuShader->subpassInputs = _subpassInputs;
+ _gpuShader->hash = _hash;
for (const auto &stage : _stages) {
GLES3GPUShaderStage gpuShaderStage = {stage.stage, stage.source};
_gpuShader->gpuStages.emplace_back(std::move(gpuShaderStage));
diff --git a/native/cocos/renderer/gfx-gles3/GLES3Texture.cpp b/native/cocos/renderer/gfx-gles3/GLES3Texture.cpp
index bc681b0a36..a4c729b678 100644
--- a/native/cocos/renderer/gfx-gles3/GLES3Texture.cpp
+++ b/native/cocos/renderer/gfx-gles3/GLES3Texture.cpp
@@ -56,7 +56,18 @@ void GLES3Texture::doInit(const TextureInfo & /*info*/) {
_gpuTexture->flags = _info.flags;
_gpuTexture->size = _size;
_gpuTexture->isPowerOf2 = math::isPowerOfTwo(_info.width) && math::isPowerOfTwo(_info.height);
- _gpuTexture->glTexture = static_cast(reinterpret_cast(_info.externalRes));
+
+ bool hasExternalFlag = hasFlag(_gpuTexture->flags, TextureFlagBit::EXTERNAL_NORMAL) ||
+ hasFlag(_gpuTexture->flags, TextureFlagBit::EXTERNAL_OES);
+ if (_info.externalRes && !hasExternalFlag) {
+ // compatibility
+ _gpuTexture->flags = _gpuTexture->flags | TextureFlagBit::EXTERNAL_OES;
+ hasExternalFlag = true;
+ }
+
+ if (hasExternalFlag) {
+ _gpuTexture->glTexture = static_cast(reinterpret_cast(_info.externalRes));
+ }
cmdFuncGLES3CreateTexture(GLES3Device::getInstance(), _gpuTexture);
diff --git a/native/cocos/renderer/gfx-metal/MTLCommandBuffer.h b/native/cocos/renderer/gfx-metal/MTLCommandBuffer.h
index 8994dcc010..7567af5316 100644
--- a/native/cocos/renderer/gfx-metal/MTLCommandBuffer.h
+++ b/native/cocos/renderer/gfx-metal/MTLCommandBuffer.h
@@ -72,6 +72,7 @@ public:
void updateBuffer(Buffer *buff, const void *data, uint32_t size) override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) override;
void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) override;
+ void copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) override;
void execute(CommandBuffer *const *cmdBuffs, uint32_t count) override;
void dispatch(const DispatchInfo &info) override;
void pipelineBarrier(const GeneralBarrier *barrier, const BufferBarrier *const *bufferBarriers, const Buffer *const *buffers, uint32_t bufferBarrierCount, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint32_t textureBarrierCount) override;
@@ -84,7 +85,7 @@ public:
inline CCMTLGPUCommandBufferObject *gpuCommandBufferObj() const { return _gpuCommandBufferObj; }
void afterCommit();
-
+
void signalFence();
void waitFence();
@@ -119,8 +120,8 @@ protected:
CCMTLSemaphore *_texCopySemaphore = nullptr;
std::bitset _colorAppearedBefore;
-
- CCMTLSemaphore* _inFlightSem{nullptr};
+
+ CCMTLSemaphore *_inFlightSem{nullptr};
int32_t _currentFbWidth = 0;
int32_t _currentFbHeight = 0;
diff --git a/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm b/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm
index 2e61e7d473..08d679cc70 100644
--- a/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm
+++ b/native/cocos/renderer/gfx-metal/MTLCommandBuffer.mm
@@ -70,7 +70,7 @@ void CCMTLCommandBuffer::doInit(const CommandBufferInfo &info) {
void CCMTLCommandBuffer::doDestroy() {
CC_SAFE_DELETE(_texCopySemaphore);
-
+
if(_inFlightSem) {
_inFlightSem->syncAll();
CC_SAFE_DELETE(_inFlightSem);
@@ -756,12 +756,13 @@ void CCMTLCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Tex
auto bytesPerRowForTarget = formatSize(convertedFormat, targetWidth, 1, 1);
auto bytesPerImageForTarget = formatSize(convertedFormat, static_cast(targetSize.width), static_cast(targetSize.height), static_cast(targetSize.depth));
+ auto alignment = formatSize(convertedFormat, 1, 1, 1);
if(textureType == TextureType::TEX1D || textureType == TextureType::TEX1D_ARRAY || mtlTexture->isPVRTC()) {
bytesPerRowForTarget = 0;
}
- if(textureType != TextureType::TEX3D || mtlTexture->isPVRTC()) {
+ if(textureType == TextureType::TEX2D || mtlTexture->isPVRTC()) {
bytesPerImageForTarget = 0;
}
@@ -770,7 +771,7 @@ void CCMTLCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Tex
auto bufferBytesPerImage = region.texExtent.depth * bufferBytesPerRow;
auto macroPixelHeight = targetHeight / blockSize.second;
-
+
auto copyFunc = [&](const uint8_t * const buffer, const MTLRegion& mtlRegion, uint32_t size, uint32_t slice, uint8_t depth) {
if(dstTexture.storageMode != MTLStorageModePrivate || mtlTexture->isPVRTC()) {
ccstd::vector data(size);
@@ -785,9 +786,11 @@ void CCMTLCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Tex
} else {
CCMTLGPUBuffer stagingBuffer;
stagingBuffer.instanceSize = bufferSliceSize;
- _mtlDevice->gpuStagingBufferPool()->alloc(&stagingBuffer);
+ _mtlDevice->gpuStagingBufferPool()->alloc(&stagingBuffer, alignment);
memcpy(stagingBuffer.mappedData, buffer, bufferSliceSize);
-
+
+ CC_ASSERT(stagingBuffer.startOffset % alignment == 0);
+
[encoder copyFromBuffer:stagingBuffer.mtlBuffer sourceOffset:stagingBuffer.startOffset sourceBytesPerRow:bytesPerRowForTarget sourceBytesPerImage:bytesPerImageForTarget sourceSize:mtlRegion.size toTexture:dstTexture destinationSlice:slice destinationLevel:region.texSubres.mipLevel destinationOrigin:mtlRegion.origin];
}
};
@@ -804,7 +807,7 @@ void CCMTLCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Tex
{targetOffset.x, targetOffset.y, d},
{targetWidth, targetHeight, 1}
};
-
+
copyFunc(convertedData, mtlRegion, bufferSliceSize, l, d);
if (format == Format::RGB8 || format == Format::RGB32F) {
@@ -820,7 +823,7 @@ void CCMTLCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Tex
{targetOffset.x, targetOffset.y + h, d},
{targetWidth, blockSize.second, 1}
};
-
+
copyFunc(convertedData, mtlRegion, bytesPerRowForTarget, l, d);
if (format == Format::RGB8 || format == Format::RGB32F) {
@@ -920,6 +923,24 @@ void CCMTLCommandBuffer::bindDescriptorSets() {
}
}
+void CCMTLCommandBuffer::copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) {
+ ccstd::vector blitRegions(count);
+ for (uint32_t i = 0; i < count; ++i) {
+ auto &blit = blitRegions[i];
+ auto © = regions[i];
+
+ blit.srcSubres = copy.srcSubres;
+ blit.dstSubres = copy.dstSubres;
+
+ blit.srcOffset = copy.srcOffset;
+ blit.dstOffset = copy.dstOffset;
+
+ blit.srcExtent = copy.extent;
+ blit.dstExtent = copy.extent;
+ }
+ blitTexture(srcTexture, dstTexture, blitRegions.data(), count, Filter::POINT);
+}
+
void CCMTLCommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) {
if (srcTexture && dstTexture && regions) {
id cmdBuffer = getMTLCommandBuffer();
@@ -1144,7 +1165,7 @@ void CCMTLCommandBuffer::signalFence() {
void CCMTLCommandBuffer::waitFence() {
_inFlightSem->wait();
_inFlightSem->signal();
-
+
}
} // namespace gfx
diff --git a/native/cocos/renderer/gfx-validator/CommandBufferValidator.cpp b/native/cocos/renderer/gfx-validator/CommandBufferValidator.cpp
index 54ce001655..abae179830 100644
--- a/native/cocos/renderer/gfx-validator/CommandBufferValidator.cpp
+++ b/native/cocos/renderer/gfx-validator/CommandBufferValidator.cpp
@@ -418,6 +418,36 @@ void CommandBufferValidator::copyBuffersToTexture(const uint8_t *const *buffers,
_actor->copyBuffersToTexture(buffers, textureValidator->getActor(), regions, count);
}
+void CommandBufferValidator::copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) {
+ CC_ASSERT(isInited());
+ CC_ASSERT(srcTexture && static_cast(srcTexture)->isInited());
+ CC_ASSERT(dstTexture && static_cast(dstTexture)->isInited());
+ const auto &srcInfo = srcTexture->getInfo();
+ const auto &dstInfo = dstTexture->getInfo();
+
+ CC_ASSERT(!_insideRenderPass);
+
+ for (uint32_t i = 0; i < count; ++i) {
+ const auto ®ion = regions[i];
+ CC_ASSERT(region.srcOffset.x + region.extent.width <= srcInfo.width);
+ CC_ASSERT(region.srcOffset.y + region.extent.height <= srcInfo.height);
+ CC_ASSERT(region.srcOffset.z + region.extent.depth <= srcInfo.depth);
+
+ CC_ASSERT(region.dstOffset.x + region.extent.width <= dstInfo.width);
+ CC_ASSERT(region.dstOffset.y + region.extent.height <= dstInfo.height);
+ CC_ASSERT(region.dstOffset.z + region.extent.depth <= dstInfo.depth);
+ }
+
+ /////////// execute ///////////
+
+ Texture *actorSrcTexture = nullptr;
+ Texture *actorDstTexture = nullptr;
+ if (srcTexture) actorSrcTexture = static_cast(srcTexture)->getActor();
+ if (dstTexture) actorDstTexture = static_cast(dstTexture)->getActor();
+
+ _actor->copyTexture(actorSrcTexture, actorDstTexture, regions, count);
+}
+
void CommandBufferValidator::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) {
CC_ASSERT(isInited());
CC_ASSERT(srcTexture && static_cast(srcTexture)->isInited());
@@ -534,5 +564,9 @@ void CommandBufferValidator::completeQueryPool(QueryPool *queryPool) {
_actor->completeQueryPool(actorQueryPool);
}
+void CommandBufferValidator::customCommand(CustomCommand &&cmd) {
+ _actor->customCommand(std::move(cmd));
+}
+
} // namespace gfx
} // namespace cc
diff --git a/native/cocos/renderer/gfx-validator/CommandBufferValidator.h b/native/cocos/renderer/gfx-validator/CommandBufferValidator.h
index bba2baaeb5..f7b0ee5274 100644
--- a/native/cocos/renderer/gfx-validator/CommandBufferValidator.h
+++ b/native/cocos/renderer/gfx-validator/CommandBufferValidator.h
@@ -57,6 +57,7 @@ public:
void updateBuffer(Buffer *buff, const void *data, uint32_t size) override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) override;
void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) override;
+ void copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) override;
void execute(CommandBuffer *const *cmdBuffs, uint32_t count) override;
void dispatch(const DispatchInfo &info) override;
void pipelineBarrier(const GeneralBarrier *barrier, const BufferBarrier *const *bufferBarriers, const Buffer *const *buffers, uint32_t bufferBarrierCount, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint32_t textureBarrierCount) override;
@@ -64,6 +65,7 @@ public:
void endQuery(QueryPool *queryPool, uint32_t id) override;
void resetQueryPool(QueryPool *queryPool) override;
void completeQueryPool(QueryPool *queryPool) override;
+ void customCommand(CustomCommand &&cmd) override;
uint32_t getNumDrawCalls() const override { return _actor->getNumDrawCalls(); }
uint32_t getNumInstances() const override { return _actor->getNumInstances(); }
diff --git a/native/cocos/renderer/gfx-validator/DeviceValidator.cpp b/native/cocos/renderer/gfx-validator/DeviceValidator.cpp
index e32faa094a..651f1545a2 100644
--- a/native/cocos/renderer/gfx-validator/DeviceValidator.cpp
+++ b/native/cocos/renderer/gfx-validator/DeviceValidator.cpp
@@ -295,6 +295,10 @@ TextureBarrier *DeviceValidator::getTextureBarrier(const TextureBarrierInfo &inf
return _actor->getTextureBarrier(info);
}
+BufferBarrier *DeviceValidator::getBufferBarrier(const BufferBarrierInfo &info) {
+ return _actor->getBufferBarrier(info);
+}
+
void DeviceValidator::copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint32_t count) {
auto *textureValidator = static_cast(dst);
textureValidator->sanityCheck();
diff --git a/native/cocos/renderer/gfx-validator/DeviceValidator.h b/native/cocos/renderer/gfx-validator/DeviceValidator.h
index 8864950dd9..111737a086 100644
--- a/native/cocos/renderer/gfx-validator/DeviceValidator.h
+++ b/native/cocos/renderer/gfx-validator/DeviceValidator.h
@@ -39,6 +39,7 @@ public:
using Device::copyBuffersToTexture;
using Device::createBuffer;
+ using Device::createBufferBarrier;
using Device::createCommandBuffer;
using Device::createDescriptorSet;
using Device::createDescriptorSetLayout;
@@ -77,6 +78,7 @@ public:
Sampler *getSampler(const SamplerInfo &info) override;
GeneralBarrier *getGeneralBarrier(const GeneralBarrierInfo &info) override;
TextureBarrier *getTextureBarrier(const TextureBarrierInfo &info) override;
+ BufferBarrier *getBufferBarrier(const BufferBarrierInfo &info) override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint32_t count) override;
void copyTextureToBuffers(Texture *src, uint8_t *const *buffers, const BufferTextureCopy *region, uint32_t count) override;
diff --git a/native/cocos/renderer/gfx-validator/FramebufferValidator.cpp b/native/cocos/renderer/gfx-validator/FramebufferValidator.cpp
index f7344e1b72..bf6c868d47 100644
--- a/native/cocos/renderer/gfx-validator/FramebufferValidator.cpp
+++ b/native/cocos/renderer/gfx-validator/FramebufferValidator.cpp
@@ -59,7 +59,7 @@ void FramebufferValidator::doInit(const FramebufferInfo &info) {
const auto &desc = info.renderPass->getColorAttachments()[i];
const auto *tex = info.colorTextures[i];
CC_ASSERT(tex && static_cast(tex)->isInited());
- CC_ASSERT(hasAnyFlags(tex->getInfo().usage, TextureUsageBit::COLOR_ATTACHMENT | TextureUsageBit::DEPTH_STENCIL_ATTACHMENT));
+ CC_ASSERT(hasAnyFlags(tex->getInfo().usage, TextureUsageBit::COLOR_ATTACHMENT | TextureUsageBit::DEPTH_STENCIL_ATTACHMENT | TextureUsageBit::SHADING_RATE));
CC_ASSERT(tex->getFormat() == desc.format);
}
if (info.depthStencilTexture) {
diff --git a/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.cpp b/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.cpp
index b7c4b42688..b9d15c0368 100644
--- a/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.cpp
+++ b/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.cpp
@@ -508,6 +508,50 @@ void CCVKCommandBuffer::copyBuffersToTexture(const uint8_t *const *buffers, Text
cmdFuncCCVKCopyBuffersToTexture(CCVKDevice::getInstance(), buffers, static_cast(texture)->gpuTexture(), regions, count, _gpuCommandBuffer);
}
+void CCVKCommandBuffer::copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) {
+ VkImageAspectFlags srcAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ VkImageAspectFlags dstAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ VkImage srcImage = VK_NULL_HANDLE;
+ VkImage dstImage = VK_NULL_HANDLE;
+
+ auto getImage = [](Texture * texture) -> auto {
+ CCVKGPUTexture *gpuTexture = static_cast(texture)->gpuTexture();
+ return gpuTexture->swapchain ? std::pair{gpuTexture->aspectMask, gpuTexture->swapchainVkImages[gpuTexture->swapchain->curImageIndex]} : std::pair{gpuTexture->aspectMask, gpuTexture->vkImage};
+ };
+
+ std::tie(srcAspectMask, srcImage) = getImage(srcTexture);
+ std::tie(dstAspectMask, dstImage) = getImage(dstTexture);
+
+ ccstd::vector copyRegions(count, VkImageCopy{});
+ for (uint32_t i = 0U; i < count; ++i) {
+ const TextureCopy ®ion = regions[i];
+ auto ©Region = copyRegions[i];
+
+ copyRegion.srcSubresource.aspectMask = srcAspectMask;
+ copyRegion.srcSubresource.mipLevel = region.srcSubres.mipLevel;
+ copyRegion.srcSubresource.baseArrayLayer = region.srcSubres.baseArrayLayer;
+ copyRegion.srcSubresource.layerCount = region.srcSubres.layerCount;
+
+ copyRegion.dstSubresource.aspectMask = dstAspectMask;
+ copyRegion.dstSubresource.mipLevel = region.dstSubres.mipLevel;
+ copyRegion.dstSubresource.baseArrayLayer = region.dstSubres.baseArrayLayer;
+ copyRegion.dstSubresource.layerCount = region.dstSubres.layerCount;
+
+ copyRegion.srcOffset.x = region.srcOffset.x;
+ copyRegion.srcOffset.y = region.srcOffset.y;
+ copyRegion.srcOffset.z = region.srcOffset.z;
+
+ copyRegion.dstOffset.x = region.dstOffset.x;
+ copyRegion.dstOffset.y = region.dstOffset.y;
+ copyRegion.dstOffset.z = region.dstOffset.z;
+
+ copyRegion.extent.width = region.extent.width;
+ copyRegion.extent.height = region.extent.height;
+ copyRegion.extent.depth = region.extent.depth;
+ }
+ vkCmdCopyImage(_gpuCommandBuffer->vkCommandBuffer, srcImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dstImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, count, copyRegions.data());
+}
+
void CCVKCommandBuffer::blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) {
VkImageAspectFlags srcAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
VkImageAspectFlags dstAspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
@@ -843,5 +887,9 @@ void CCVKCommandBuffer::resetQueryPool(QueryPool *queryPool) {
vkQueryPool->_ids.clear();
}
+void CCVKCommandBuffer::customCommand(CustomCommand &&cmd) {
+ cmd(reinterpret_cast(_gpuCommandBuffer->vkCommandBuffer));
+}
+
} // namespace gfx
} // namespace cc
diff --git a/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.h b/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.h
index d020660040..32b497cd09 100644
--- a/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.h
+++ b/native/cocos/renderer/gfx-vulkan/VKCommandBuffer.h
@@ -57,12 +57,14 @@ public:
void updateBuffer(Buffer *buffer, const void *data, uint32_t size) override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint32_t count) override;
void blitTexture(Texture *srcTexture, Texture *dstTexture, const TextureBlit *regions, uint32_t count, Filter filter) override;
+ void copyTexture(Texture *srcTexture, Texture *dstTexture, const TextureCopy *regions, uint32_t count) override;
void execute(CommandBuffer *const *cmdBuffs, uint32_t count) override;
void dispatch(const DispatchInfo &info) override;
void pipelineBarrier(const GeneralBarrier *barrier, const BufferBarrier *const *bufferBarriers, const Buffer *const *buffers, uint32_t bufferBarrierCount, const TextureBarrier *const *textureBarriers, const Texture *const *textures, uint32_t textureBarrierCount) override;
void beginQuery(QueryPool *queryPool, uint32_t id) override;
void endQuery(QueryPool *queryPool, uint32_t id) override;
void resetQueryPool(QueryPool *queryPool) override;
+ void customCommand(CustomCommand &&cmd) override;
protected:
friend class CCVKQueue;
diff --git a/native/cocos/renderer/gfx-vulkan/VKCommands.cpp b/native/cocos/renderer/gfx-vulkan/VKCommands.cpp
index f685779d76..1f9d102e2e 100644
--- a/native/cocos/renderer/gfx-vulkan/VKCommands.cpp
+++ b/native/cocos/renderer/gfx-vulkan/VKCommands.cpp
@@ -33,6 +33,7 @@
#include "VKCommands.h"
#include "VKDevice.h"
#include "VKGPUObjects.h"
+#include "VKPipelineCache.h"
#include "gfx-base/GFXDef.h"
#include "states/VKBufferBarrier.h"
#include "states/VKGeneralBarrier.h"
@@ -190,6 +191,8 @@ void cmdFuncCCVKCreateTexture(CCVKDevice *device, CCVKGPUTexture *gpuTexture) {
}
}
gpuTexture->memoryless = true;
+ } else if (hasFlag(gpuTexture->flags, TextureFlagBit::EXTERNAL_OES) || hasFlag(gpuTexture->flags, TextureFlagBit::EXTERNAL_NORMAL)) {
+ gpuTexture->vkImage = gpuTexture->externalVKImage;
} else {
createFn(&gpuTexture->vkImage, &gpuTexture->vmaAllocation);
}
@@ -294,6 +297,7 @@ struct AttachmentStatistics final {
DEPTH = 0x4,
DEPTH_RESOLVE = 0x8,
INPUT = 0x10,
+ SHADING_RATE = 0x20,
};
struct SubpassRef final {
VkImageLayout layout{VK_IMAGE_LAYOUT_UNDEFINED};
@@ -355,6 +359,7 @@ void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRende
static ccstd::vector endAccessInfos;
static ccstd::vector attachmentStatistics;
static SubpassDependencyManager dependencyManager;
+ ccstd::vector shadingRateReferences;
const size_t colorAttachmentCount = gpuRenderPass->colorAttachments.size();
const size_t hasDepth = gpuRenderPass->depthStencilAttachment.format != Format::UNKNOWN ? 1 : 0;
@@ -362,6 +367,7 @@ void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRende
gpuRenderPass->clearValues.resize(colorAttachmentCount + hasDepth);
beginAccessInfos.resize(colorAttachmentCount + hasDepth);
endAccessInfos.resize(colorAttachmentCount + hasDepth);
+ shadingRateReferences.resize(gpuRenderPass->subpasses.size(), {VK_STRUCTURE_TYPE_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR});
for (size_t i = 0U; i < colorAttachmentCount; ++i) {
const auto &attachment{gpuRenderPass->colorAttachments[i]};
@@ -484,6 +490,14 @@ void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRende
attachmentReferences.push_back({VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2, nullptr, subpassInfo.depthStencilResolve, layout, aspect});
}
+ if (subpassInfo.shadingRate != INVALID_BINDING && subpassInfo.shadingRate < colorAttachmentCount) {
+ // layout is guaranteed
+ attachmentDescriptions[subpassInfo.shadingRate].initialLayout = VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR;
+ attachmentDescriptions[subpassInfo.shadingRate].finalLayout = VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR;
+ const ColorAttachment &desc = gpuRenderPass->colorAttachments[subpassInfo.shadingRate];
+ attachmentReferences.push_back({VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2, nullptr, subpassInfo.shadingRate, VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR, VK_IMAGE_ASPECT_COLOR_BIT});
+ }
+
gpuRenderPass->sampleCounts.push_back(sampleCount);
}
@@ -545,6 +559,13 @@ void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRende
resolveDesc.pDepthStencilResolveAttachment = attachmentReferences.data() + offset++;
desc.pNext = &resolveDesc;
}
+
+ if (subpassInfo.shadingRate != INVALID_BINDING) {
+ VkFragmentShadingRateAttachmentInfoKHR &attachment = shadingRateReferences[i];
+ attachment.pFragmentShadingRateAttachment = attachmentReferences.data() + offset++;
+ attachment.shadingRateAttachmentTexelSize = {16, 16}; // todo
+ desc.pNext = &attachment;
+ }
}
size_t dependencyCount = gpuRenderPass->dependencies.size();
@@ -646,6 +667,11 @@ void cmdFuncCCVKCreateRenderPass(CCVKDevice *device, CCVKGPURenderPass *gpuRende
updateLifeCycle(statistics, j, subpass.pInputAttachments[k].layout, AttachmentStatistics::SubpassUsage::INPUT);
}
}
+ const auto *vrsDesc = static_cast