轻量封装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();
	}
}
相关推荐
三维频道3 小时前
压铸件尺寸检测与模具监测方案 / 3D Scanning for Die-casting QC & Mold Monitoring
人工智能·计算机视觉·3d·尺寸检测·xtom·压铸件·模具优化
aini_lovee3 小时前
LIS3DH低功耗加速度传感器驱动程序
3d
三维频道3 小时前
注塑件变形怎么调优?全尺寸3D检测如何助力精密注塑“减废增效”
3d·制造·智能制造·3d扫描仪·新拓三维·注塑模具质检·三维尺寸偏差分析
AI前沿资讯3 小时前
2026年3D动画制作工具推荐:从传统工作流到AI一站式创作
人工智能·3d
bryant_meng20 小时前
【3D】Stereo Matching learning notes
计算机视觉·3d·双目匹配
三维频道1 天前
工业级三维扫描实测:汽车灯具复杂结构件的全尺寸 3D 测量方案分析
java·人工智能·python·数码相机·3d·汽车·汽车轻量化制造
MapVillage1 天前
3D Gaussian Splats 高斯泼溅技术
3d
杀生丸学AI1 天前
【三维重建】Neural Gabor Splatting:基于神经Gabor的增强型3DGS(高频表面重建)
3d·aigc·扩散模型·视觉大模型·点云分割·高斯泼溅·空间智能
a1117761 天前
Web3D 在线3D模型骨骼动画编辑器(开源 Reze Studio)
前端·3d·开源·html
Hody911 天前
【XR技术介绍】AI快速扫描3D场景技术全景解析:水平、路径与技术选型
人工智能·3d·xr