轻量封装WebGPU渲染系统示例<24>- Rendering Pass Graph基本用法(源码)

当前示例源码github地址:

https://github.com/vilyLei/voxwebgpu/blob/feature/rendering/src/voxgpu/sample/PassNodeGraphTest.ts

此示例基于此渲染系统实现,当前示例TypeScript源码如下:

javascript 复制代码
class PassGraph extends WGRPassNodeGraph {
	constructor() { super(); }
	runBegin(): void {
		super.runBegin();
	}
	run(): void {
		let pass = this.passes[0];
		for (let i = 0; i < 16; ++i) {
			pass.colorAttachments[0].clearEnabled = i < 1;
			pass.render();
		}
	}
}

export class PassNodeGraphTest {
	private mRscene = new RendererScene();

	initialize(): void {

		let multisampleEnabled = true;
		let depthTestEnabled = false;
		let rpassparam = { multisampleEnabled, depthTestEnabled };
		this.mRscene.initialize({ rpassparam });
		this.initEvent();
		this.initScene();
	}

	private applyNewRPass(texUUID: string, entities: FixScreenPlaneEntity[], clearColor: ColorDataType, extent = [0.4, 0.3, 0.5, 0.5]): void {

		let rs = this.mRscene;
		let rttTex = { diffuse: { uuid: texUUID, rttTexture: {} } };
		let colorAttachments = [
			{
				texture: rttTex,
				clearValue: clearColor,
				loadOp: "clear",
				storeOp: "store"
			}
		];
		let rPass = rs.renderer.appendRenderPass({ separate: true, colorAttachments });
		for (let i = 0; i < entities.length; ++i) {
			rPass.addEntity(entities[i]);
		}

		let graph = new PassGraph();
		graph.passes = [rPass];
		rs.setPassNodeGraph(graph);

		let entity = new FixScreenPlaneEntity({ extent, flipY: true, textures: [rttTex] });
		rs.addEntity(entity);
	}
	private initEvent(): void {
		const rs = this.mRscene;
		new MouseInteraction().initialize(rs, 0, false).setAutoRunning(true);
	}
	private initScene(): void {

		const rs = this.mRscene;
		let entity: FixScreenPlaneEntity;

		const diffuseTex = { diffuse: { url: "static/assets/guangyun_40.png", flipY: true } };

		let blendModes = ['add'];
		let entities: FixScreenPlaneEntity[] = [];
		entity = new FixScreenPlaneEntity({ extent: [-0.8, -0.8, 0.8, 0.8], textures: [diffuseTex], blendModes });
		entity.setColor([0.9, 0.3, 0.9]);
		rs.addEntity(entity);
		entities.push(entity);

		this.applyNewRPass('rtt0', entities, [0.2, 0.2, 0.2, 1.0], [-0.2, 0.1, 0.8, 0.8]);
	}

	run(): void {
		this.mRscene.run();
	}
}
相关推荐
谷谷地图下载器17 小时前
全球、台湾省的无水印·街景数据(离线数据),专为可视化项目定制,支持国产化
javascript·c++·3d·arcgis·sqlite
福建佰胜张工19 小时前
3DX-RAY 便携式 X 射线系统系列技术解析与应用指南
3d·智能手机·自动化
大江东去浪淘尽千古风流人物20 小时前
【SharpSLAM】无人机高速飞行下的物体级视觉 SLAM:GAN 去模糊与 3D 重建联合优化
生成对抗网络·3d·无人机·slam·3d重建·deepsdf·去模糊
福建佰胜张工21 小时前
3DX-RAY 生产线系统 MDXi-NT 技术解析与应用指南
人工智能·3d·自动化
朗迪锋21 小时前
数字孪生如何成为工人安全的“隐形护甲”?
人工智能·安全·3d·数字孪生·数智孪生
jiayong2321 小时前
3D 建模、虚拟仿真需要哪些技术
3d·3d建模·虚拟仿真
jiayong231 天前
3D 建模、虚拟仿真、数字孪生 从 0 开始到完成:三条实操路线
3d·3d建模·数字孪生·虚拟仿真
jiayong231 天前
概念、区别与联系:数字孪生、虚拟仿真、3D 建模
3d·数字孪生·虚幻引擎·虚拟仿真·3d 建模
CG_MAGIC2 天前
V-Ray灯光系统详解:穹顶灯、面光与IES光域网
3d·贴图·效果图·建模教程·渲云渲染
AI前沿资讯2 天前
2026年AI 3D赛道新势力崛起:一体化创作平台成主流,V2Fun凭全流程能力突围
人工智能·3d