码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 轻量封装WebGPU渲染系统示例<22>- 渲染到纹理(RTT)(源码)


    (便捷)易用性,灵活性,正确性,在用户直接接触的层面,比性能或者专业性要重要得多。如何才能做到使用丝滑的感觉呢?书到用时方恨少,来来去去很烧脑。

    当前示例源码github地址:

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

    当前示例运行效果:

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

    1. export class RTTTest {
    2. private mRscene = new RendererScene();
    3. initialize(): void {
    4. console.log("RTTTest::initialize() ...");
    5. this.applyRTT();
    6. this.initScene();
    7. }
    8. private applyRTT(): void {
    9. let rc = this.mRscene;
    10. // rtt texture proxy descriptor
    11. let rttTex = { uuid: "rtt0", rttTexture: {} };
    12. // define a rtt pass color colorAttachment0
    13. let colorAttachments = [
    14. {
    15. texture: rttTex,
    16. // green clear background color
    17. clearValue: { r: 0.1, g: 0.9, b: 0.1, a: 1.0 },
    18. loadOp: "clear",
    19. storeOp: "store"
    20. }
    21. ];
    22. // create a separate rtt rendering pass
    23. let rPass = rc.createRTTPass({ colorAttachments });
    24. const diffuseTex = { diffuse: { url: "static/assets/default.jpg", flipY: true } };
    25. let extent = [-0.5, -0.5, 0.8, 0.8];
    26. let rttEntity = new FixScreenPlaneEntity({ extent, textures: [diffuseTex] }).setColor([1.0, 0.0, 0.0]);
    27. // 往pass中添加可渲染对象
    28. rPass.addEntity(rttEntity);
    29. // 使用rtt纹理
    30. extent = [0.3, 0.3, 0.6, 0.6];
    31. let entity = new FixScreenPlaneEntity({ extent, flipY: true, textures: [{ diffuse: rttTex }] });
    32. rc.addEntity(entity);
    33. }
    34. private initScene(): void {
    35. const rc = this.mRscene;
    36. const diffuseTex = { diffuse: { url: "static/assets/default.jpg", flipY: true } };
    37. let extent = [-0.9, 0.0, 0.5, 0.5];
    38. let entity = new FixScreenPlaneEntity({ extent }).setColor([0.2, 0.5, 0.7]);
    39. rc.addEntity(entity);
    40. extent = [-0.8, -0.8, 0.8, 0.8];
    41. entity = new FixScreenPlaneEntity({ extent, textures: [diffuseTex] }).setColor([0.1, 0.3, 0.9]);
    42. rc.addEntity(entity);
    43. }
    44. run(): void {
    45. this.mRscene.run();
    46. }
    47. }

  • 相关阅读:
    iptables、firewalld防火墙详解
    MySql Workbench数据库导出和导入
    32位单片机PY32F040,主频72M,外设丰富,支持断码LCD
    docker安装oracle
    【计算机图形学】基础 - Colorization using Optimization
    1.0 Zookeeper 教程
    第一章 计算机系统概述 八、虚拟机
    (附源码)springboot嘉应房地产公司质量管理系统 毕业设计 453100
    基于花朵授粉算法的无线传感器网络部署优化附Matlab代码
    selenium不定位元素直接使用键盘操作(如弹框操作)
  • 原文地址:https://blog.csdn.net/vily_lei/article/details/134321921
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号