轻量封装WebGPU渲染系统示例<27>- 浮点RTT纹理(源码)

当前示例源码github地址:

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

当前示例运行效果:

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

javascript 复制代码
const floatRTT = { diffuse: { uuid: "rtt0", rttTexture: {}, format: 'rgba16float' } };

export class FloatRTT {

	private mRscene = new RendererScene();

	initialize(): void {
		console.log("FloatRTT::initialize() ...");

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

		this.initScene();
	}

	private applyRTTPass(extent: number[]): void {
		let rs = this.mRscene;

		let shaderSrc = {
			vert: { code: vertWGSL, uuid: "vert" },
			frag: { code: fragCalc, uuid: "calcFrag" }
		};
		const attachment = {
			texture: floatRTT,
			clearValue: [0.1, 0.1, 0.1, 1.0]
		};
		const colorAttachments = [attachment];

		let rPass = rs.createRenderPass({ separate: true, colorAttachments });

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

		let rttEntity = new FixScreenPlaneEntity({ extent: [-1, -1, 2, 2], textures: [diffuseTex], shaderSrc, shadinguuid: "floatRTT" });
		rPass.addEntity(rttEntity);

		shaderSrc = {
			vert: { code: vertWGSL, uuid: "vert" },
			frag: { code: fragRead, uuid: "readFrag" }
		};

		// display float rtt rendering result
		extent = [-0.8, -0.8, 1.6, 1.6];
		let entity = new FixScreenPlaneEntity({ extent, flipY: true, textures: [floatRTT], shaderSrc, shadinguuid: "calcColor" });
		rs.addEntity(entity);

		// display origin image
		extent = [-0.95, -0.95, 0.6, 0.6];
		entity = new FixScreenPlaneEntity({ extent, flipY: false, textures: [diffuseTex]});
		rs.addEntity(entity);
	}
	private initScene(): void {
		this.applyRTTPass( [-1, -1, 2, 2] );
	}

	run(): void {
		this.mRscene.run();
	}
}
相关推荐
Yao.Li1 小时前
PVN3D 训练与评估代码流程详解
人工智能·3d
云飞云共享云桌面2 小时前
8人SolidWorks研发共享一台服务器——性能算力共享智能按需分配
运维·服务器·网络·数据库·3d·电脑
Aevget5 小时前
CAD格式转换引擎HOOPS Exchange v2026.2.0:计算镶嵌能力升级,释放3D数据处理新潜力
3d·hoops·hoops exchange·cad格式转换·数据格式转化
syncon121 天前
手机内藏式触控高分子分散液晶结构的光学复合结构及液晶线路激光修复原理
科技·3d·制造
动恰客流管家1 天前
动恰3DV3丨 数据修正,破解客流失真断层,精准还原真实客流
大数据·人工智能·3d·性能优化
哈__1 天前
ReactNative项目OpenHarmony三方库集成实战:react-native-amap3d(推荐使用react-native-maps)
react native·react.js·3d
山科智能信息处理实验室2 天前
RENO:面向 3D LiDAR 点云的实时神经压缩
人工智能·3d
Yao.Li2 天前
基于 BOP 格式构建 PVN3D 自定义训练数据集技术文档
3d
sin°θ_陈2 天前
前馈式3D Gaussian Splatting 研究地图(路线三):大重建模型如何进入 3DGS——GRM、GS-LRM 与 Long-LRM 的方法转向
3d·aigc·gpu算力·三维重建·空间计算·3dgs·空间智能
sin°θ_陈2 天前
前馈式3D Gaussian Splatting 研究地图(路线二):几何优先的前馈式 3DGS——前馈式 3DGS 如何重新拥抱多视图几何
深度学习·3d·webgl·三维重建·空间计算·3dgs·空间智能