轻量封装WebGPU渲染系统示例<22>

编程入门 行业动态 更新时间:2024-10-26 20:29:44

轻量封装WebGPU渲染系统<a href=https://www.elefans.com/category/jswz/34/1770116.html style=示例<22>"/>

轻量封装WebGPU渲染系统示例<22>

当前示例源码github地址:

.ts

当前示例运行效果:

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

export class RTTTest {private mRscene = new RendererScene();initialize(): void {console.log("RTTTest::initialize() ...");this.applyRTT();this.initScene();}private applyRTT(): void {let rc = this.mRscene;// rtt texture proxy descriptorlet rttTex = { uuid: "rtt0", rttTexture: {} };// define a rtt pass color colorAttachment0let colorAttachments = [{texture: rttTex,// green clear background colorclearValue: { r: 0.1, g: 0.9, b: 0.1, a: 1.0 },loadOp: "clear",storeOp: "store"}];// create a separate rtt rendering passlet rPass = rc.createRTTPass({ colorAttachments });const diffuseTex = { diffuse: { url: "static/assets/default.jpg", flipY: true } };let extent = [-0.5, -0.5, 0.8, 0.8];let rttEntity = new FixScreenPlaneEntity({ extent, textures: [diffuseTex] }).setColor([1.0, 0.0, 0.0]);// 往pass中添加可渲染对象rPass.addEntity(rttEntity);// 使用rtt纹理extent = [0.3, 0.3, 0.6, 0.6];let entity = new FixScreenPlaneEntity({ extent, flipY: true, textures: [{ diffuse: rttTex }] });rc.addEntity(entity);}private initScene(): void {const rc = this.mRscene;const diffuseTex = { diffuse: { url: "static/assets/default.jpg", flipY: true } };let extent = [-0.9, 0.0, 0.5, 0.5];let entity = new FixScreenPlaneEntity({ extent }).setColor([0.2, 0.5, 0.7]);rc.addEntity(entity);extent = [-0.8, -0.8, 0.8, 0.8];entity = new FixScreenPlaneEntity({ extent, textures: [diffuseTex] }).setColor([0.1, 0.3, 0.9]);rc.addEntity(entity);}run(): void {this.mRscene.run();}
}

更多推荐

轻量封装WebGPU渲染系统示例<22>

本文发布于:2023-11-15 17:01:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1603146.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:示例   系统   WebGPU

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!