混合问题从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)
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:
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:
原文:https://stackoverflow.com/questions/17457327
最满意答案
您的插入查询不起作用,因为您最后忘记了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中的多个查询(Multiple queries in mongoDB)[2023-03-20]
这种方法对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.
-
运行多个查询和一次(Run Multiple queries and one time)[2024-02-25]
您的插入查询不起作用,因为您最后忘记了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被叫者(不是调用者)之外的所有人中添加一个小延迟。 如果可以同时计算多个页面,事情会变得更加复杂。 例如,您无法真正控制并行性 ...
-
不同表中的多个查询(Multiple Queries in different table)[2022-04-20]
喜欢这样吗? 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(' ...