Photoshop 混合模式到没有着色器的 OpenGL ES [英] Photoshop blending mode to OpenGL ES without shaders

查看:26
本文介绍了Photoshop 混合模式到没有着色器的 OpenGL ES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的 OpenGL ES 1.1 代码(没有着色器)中模仿 Photoshop 混合模式(乘法"、屏幕"等).

I need to imitate Photoshop blending modes ("multiply", "screen" etc.) in my OpenGL ES 1.1 code (without shaders).

有一些文档介绍了如何使用 HLSL:

There are some docs on how to do this with HLSL:

我至少需要工作屏幕模式.

I need at least working Screen mode.

我可以看看固定管道上的任何实现吗?

Are there any implementations on fixed pipeline I may look at?

推荐答案

大多数 Photoshop 混合模式都基于 Porter-Duff 混合模式.

Most photoshop blend-modes are based upon the Porter-Duff blendmodes.

这些要求您的所有图像(纹理、渲染缓冲区)都在预乘颜色空间中.这通常是通过将所有像素值与 alpha 值相乘,然后将它们存储到纹理中来完成的.例如.在非预乘颜色空间中,完全透明的像素看起来像黑色.如果您不熟悉这种色彩空间,请花一两个小时在网上阅读有关它的信息.这是一个简洁而良好的概念,对于类似 Photoshop 的构图是必需的.

These requires that all your images (textures, renderbuffer) are in premultiplied color-space. This is usually done by multiplying all pixel-values with the alpha-value before storing them in a texture. E.g. a full transparent pixel will look like black in non-premultiplied color space. If you're unfamiliar with this color-space spend an hour or two reading about it on the web. It's a neat and good concept and required for photoshop-like compositions.

无论如何 - 一旦您拥有该格式的图像,您就可以使用以下方法启用 SCREEN:

Anyway - once you have your images in that format you can enable SCREEN using:

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR)

使用 OpenGL|ES 管道无法实现完整的 MULTIPLY 模式.如果您只使用完全不透明的像素,您可以使用以下方法伪造它:

The full MULTIPLY mode is not possible with the OpenGL|ES pipeline. If you only work with full opaque pixels you can fake it using:

glBlendFunc(GL_ZERO, GL_SRC_COLOR)

但是,纹理和帧缓冲区中透明像素的结果将是错误的.

The results for transparent pixels either in your texture and your framebuffer will be wrong though.

这篇关于Photoshop 混合模式到没有着色器的 OpenGL ES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆