当前位置: 首页 > news >正文

OpenGL学习笔记-Blending

  混合方程中,Csource是片段着色器输出的颜色向量(the color output of the fragment shader),其权重为Fsource。Cdestination是当前存储在color buffer中的颜色向量(the color vector that is currently stored in the color buffer),其权重为Fdestination。Csource和Cdestination由OpenGL自动设置,但Fsource和Fdestination需要由我们进行设置(The source and destination colors will automatically be set by OpenGL, but the source and destination factor can be set to a value of our choosing)。当OpenGL渲染一个片段时,会根据混合方程对上述两个颜色向量进行加权组合(whenever OpenGL renders a fragment, it combines the current fragment’s color with the fragment color currently in the color buffer),Cresult是加权组合后的结果,将保存到color buffer中,并且会将Cdestination覆盖掉。
在这里插入图片描述
  要想实现混合的效果,需要先使能混合:

glEnable(GL_BLEND);

  然后设置混合方程中的Fsource和Fdestination,一种常用的设置如下:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  glBlendFunc函数的原型如下,上述设置的含义是:Fsource取Csource的alpha分量,Fdestination取(1-Csource的alpha分量)。

void glBlendFunc(GLenum sfactor, GLenum dfactor);

  完成渲染后,需要将混合关闭:

glDisable(GL_BLEND);

  一个简单的例子:图1是待混合的两个片段,图2是混合方程,图3是混合得到的结果。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

http://www.lryc.cn/news/277172.html

相关文章:

  • 支持 input 函数的在线 python 运行环境 - 基于队列
  • 欧拉Euler release 21.10 (LTS-SP2)升级openssh至9版本记录
  • php 数组中的元素进行排列组合
  • Python从入门到网络爬虫(OS模块详解)
  • 人机交互不是人机融合智能
  • RabbitMQ解决消息丢失以及重复消费问题
  • docker 安装redis集群
  • 锂电池制造设备中分布式IO模块优势
  • Android Room数据库升级Migration解决方案
  • 离线安装docker和docker-compose
  • 奇怪的事情记录:外置网卡和外置显示器不兼容
  • 【大数据进阶第三阶段之Hive学习笔记】Hive基础入门
  • 第三代量子计算机交付,中国芯片开辟新道路,光刻机难挡中国芯
  • react native中使用tailwind并配置自动补全
  • 数据分析——火车信息
  • Bert-vits2最终版Bert-vits2-2.3云端训练和推理(Colab免费GPU算力平台)
  • Asp .Net Web应用程序(.Net Framework4.8)网站发布到IIS
  • vue element plus Typography 排版
  • 理论U3 决策树
  • Redis 常用操作
  • c# 使用Null合并操作符例子
  • 【Docker】docker部署conda并激活环境
  • HarmonyOS@Link装饰器:父子双向同步
  • 【idea】idea插件编写教程,博主原创idea插件 欢迎下载
  • 深入理解 Hadoop (四)HDFS源码剖析
  • 【Vue3+React18+TS4】1-1 : 课程介绍与学习指南
  • Nacos与Eureka的区别详解
  • 【算法刷题】Day28
  • 深入了解pnpm:一种高效的包管理工具
  • QEMU源码全解析 —— PCI设备模拟(1)