首页 \ 问答 \ 混合问题从OpenGLES 1.0移植到2.0(iOS)(Blending issue porting from OpenGLES 1.0 to 2.0 (iOS))

混合问题从OpenGLES 1.0移植到2.0(iOS)(Blending issue porting from OpenGLES 1.0 to 2.0 (iOS))

我正在将一个非常简单的代码从OpenGLES 1.0移植到OpenGLES 2.0。

在原始版本中,我启用了混合功能

glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

我在ES 2.0实现中使用相同的代码,因为我需要将新渲染的四边形与渲染缓冲区中的内容混合(我保留渲染缓冲区,我无法重新渲染场景)。

我正在使用纹理(显示从中心到外部的径向渐变的alpha值,alpha从1变为0)作为alpha蒙版,仅包含具有不同alpha值的白色像素。 我给我的顶点相同的颜色说红色,alpha为100/255。 我的背景是透明的黑色。 在那之下,我有一个纯白色的表面(UIView)。 我渲染4个四边形。

OpenGLES 1.0的结果(期望的结果) 在此处输入图像描述

我的观察告诉我片段着色器应该只是:

gl_FragColor = DestinationColor * texture2D(Texture, TexCoordOut);

(我通过尝试不同的顶点和纹理值来得出这个结论。这也是我在一些教程中读到的。)

我正在尝试编写一些OpenGL 2.0代码(包括顶点+片段着色器),它会给我与OpenGLES 1.0完全相同的结果,仅此而已。 除了在纹理上应用顶点颜色之外,我不需要/想要在片段着色器中进行任何类型的混合。 使用简单着色器,这是我得到的结果: 在此处输入图像描述

我几乎尝试了*,+,mix的每一个组合,但我无法重现相同的结果。 这是我到目前为止最接近的,但这绝对不是正确的(这也没有任何意义)

varying lowp vec4 DestinationColor;
varying lowp vec2 TexCoordOut;
uniform sampler2D Texture;

void main(void) {
    lowp vec4 texture0Color = texture2D(Texture, TexCoordOut);
    gl_FragColor.rgb = mix(texture0Color.rgb, DestinationColor.rgb, texture0Color.a);
    gl_FragColor.a = texture0Color.a * DestinationColor.a;
}

这个着色器给了我以下内容: 在此处输入图像描述


I'm porting a very simple piece of code from OpenGLES 1.0 to OpenGLES 2.0.

In the original version, I have blending enabled with

glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

I'm using the same code in my ES 2.0 implementation as I need to blend the newly rendered quads with what was in the render buffer (I'm retaining the render buffer, I can't re-render the scene).

I'm using a texture (alpha values displaying a radial gradient from center to the outside, alpha goes from 1 to 0) that serves as an alpha mask, containing only white pixels with different alpha values. I give my vertices the same color say red with alpha of 100/255. My background is transparent black. Below that, I have a plain white surface (UIView). I render 4 quads.

Result with OpenGLES 1.0 (desired result) enter image description here

My observations tells me that the fragment shader should simply be:

gl_FragColor = DestinationColor * texture2D(Texture, TexCoordOut);

(I got to that conclusion by trying different values for my vertices and the texture. That's also what I've read on some tutorials.)

I'm trying to write some OpenGL 2.0 code (including vertex + fragment shaders) that would give me the exact same result as in OpenGLES 1.0, nothing more, nothing less. I don't need/want to do any kind of blending in the fragment shader except applying the vertex color on the texture. Using the simple shader, here's the result I got: enter image description here

I tried pretty much every combination of *, +, mix I could think of but I couldn't reproduce the same result. This is the closest I got so far, but that's definitely not the right one (and that doesn't make any sense either)

varying lowp vec4 DestinationColor;
varying lowp vec2 TexCoordOut;
uniform sampler2D Texture;

void main(void) {
    lowp vec4 texture0Color = texture2D(Texture, TexCoordOut);
    gl_FragColor.rgb = mix(texture0Color.rgb, DestinationColor.rgb, texture0Color.a);
    gl_FragColor.a = texture0Color.a * DestinationColor.a;
}

This shader gives me the following: enter image description here


原文:https://stackoverflow.com/questions/17457327
更新时间:2023-01-16 16:01

最满意答案

您的插入查询不起作用,因为您最后忘记了a)。

mysql_query("INSERT INTO auction_bundle 
   (`purchaser_id`,`amount`,`order_number`,`date`) VALUES (".$id.",".$totalamount.",".$ordernumber.",NOW()");

应该:

mysql_query("INSERT INTO auction_bundle 
   (`purchaser_id`,`amount`,`order_number`,`date`) VALUES (".$id.",".$totalamount.",".$ordernumber.",NOW())");

Your insert query doesn't work because your forgot a ) at the end.

mysql_query("INSERT INTO auction_bundle 
   (`purchaser_id`,`amount`,`order_number`,`date`) VALUES (".$id.",".$totalamount.",".$ordernumber.",NOW()");

Should be:

mysql_query("INSERT INTO auction_bundle 
   (`purchaser_id`,`amount`,`order_number`,`date`) VALUES (".$id.",".$totalamount.",".$ordernumber.",NOW())");

相关问答

更多
  • 这不是CodeIgniter的限制,而是数据库客户端库的限制。 即, mysql_query()一次只能执行一个查询。 根据客户的不同,有其他选择, 即, mysqli_multi_query() This is not a limitation of CodeIgniter but rather of the database client libraries. I.e., mysql_query() can only execute a single query at a time. Depending ...
  • 例如这样: import org.apache.spark.sql.functions.sum val df = sc.parallelize(Seq( (412, 0), (0, 25), (412, 25), (0, 25) )).toDF("columnA", "columnB") df.agg( sum(($"columnA" === 412).cast("long")).alias("columnA"), sum(($"columnB" === 25).ca ...
  • 这种方法对mongodb不好。你应该创建一个包含所有数据的集合,并且只进行一次查询。 这非常重要,因为: 没有交易 没有连接 一个文档只有原子操作 您将无法使用聚合框架 如果无法迁移到一个集合模式,那么您可能应该执行以下操作: var _ = require("underscore")._; function get_all(cb) { stops.find({}, function(err, stps, cb) { stop_time.find({ ...
  • 我不认为你会得到任何非常干净的东西,但是这样的东西可能会起作用: SELECT * from $Table t INNER JOIN ( SELECT COUNT(DISTINCT Topic) as TotalTopics FROM $Table ) s ON 1 = 1 INNER JOIN ( SELECT COUNT(DISTINCT Title) as TotalTitles FROM $Table ) f ON 1 = 1 WHERE ( Active IS NOT NULL ...
  • Mysql有sysvar_max_connections系统参数来处理它。 Mysql have sysvar_max_connections system parameter that is handling this.
  • 您的插入查询不起作用,因为您最后忘记了a)。 mysql_query("INSERT INTO auction_bundle (`purchaser_id`,`amount`,`order_number`,`date`) VALUES (".$id.",".$totalamount.",".$ordernumber.",NOW()"); 应该: mysql_query("INSERT INTO auction_bundle (`purchaser_id`,`amount`,`order_n ...
  • 我也说“这取决于”,但我倾向于并行。 可能不应该具有比CPU核心数更多的并行性。 我很少看到一个系统咀嚼所有CPU内核 - 除非它没有足够好的索引。 也就是说,在提出问题之前修复索引。 如果数据大于可以缓存的数据,则排队可能会更快,因为您可能有一个阻塞点 - I / O. 如果不断更改表,请关闭查询缓存。 您的目标是尽早在页面上获得一些结果(可能是人机界面的目标),在除了一个AJAX被叫者(不是调用者)之外的所有人中添加一个小延迟。 如果可以同时计算多个页面,事情会变得更加复杂。 例如,您无法真正控制并行性 ...
  • 喜欢这样吗? SELECT *, (result.total + result._total) / 2 AS rate FROM ( SELECT date, SUM(CASE WHEN data.valid = 1 THEN 1 ELSE 0 END) AS ontime, SUM(CASE WHEN data.valid = 0 THEN 1 ELSE 0 END) AS late, COUNT(*) AS tota ...
  • 要回答标题中的问题“它们同时或同时运行”,答案是同时进行的。 拥有多个crons将需要他们知道某个过程是否完整。 这可能会变得混乱。 将此文件放在一个文件中即可。 您可能希望设置最长执行时间以确保脚本不会超时。 找到你的php.ini文件并查找:max_execution_time = xxx(seconds) 如果需要,可以将其更改为更高的值。 max_execution_time = 240是4分钟 您还可以查看mysql事务以仅在所有进程完成时提交更改。 http://dev.mysql.com/do ...
  • 我假设您有一台SAS服务器,并且您从本地计算机上启动了查询。 (如果你不在本地工作它不是一个问题,你可以在本地机器上为一个spawner做一个rsubmit)即使使用SAS / Base,也可以通过单个代码三个连接同时启动3个查询。 我在这里假设您不想共享工作库并且是完全独立的查询 option autosignon=yes; option sascmd="!sascmd"; * some random data; data prova1; do i=1 to 20000000; x=rand(' ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)