【问题标题】:GLSL : why this bloomEffect and gloomEffect code output only black & white image?GLSL:为什么这个bloomEffect 和gloomEffect 代码只输出黑白图像?
【发布时间】:2018-06-20 11:10:11
【问题描述】:

当我在 android/iOS 下使用 TbloomEffectTgloomEffect (Delphi 组件)(因此使用 openGL)时,它只产生 黑白 输出 :( 在 windows (DX11) 下它是工作正常。我猜这是 delphi 源代码中的一个错误,但我在下面从原始 delphi 源中提取的原始 GLSL 代码中找不到什么问题:

TgloomEffect 使用:

varying vec4 TEX0;
vec4 _ret_0;
vec3 _TMP4;
float _TMP3;
vec3 _x0014;
vec3 _TMP15;
float _grey0022;
float _grey0028;
vec3 _TMP35;
uniform float _GloomIntensity;
uniform float _BaseIntensity;
uniform float _GloomSaturation;
uniform float _BaseSaturation;
uniform sampler2D _Input;
void main()
{
    vec4 _color1;
    vec3 _base;
    vec3 _gloom;
    vec3 _TMP10;
    _color1 = texture2D(_Input, TEX0.xy);
    _base = 1.0 - _color1.xyz/_color1.w;
    _x0014 = (_base - 2.50000000E-001)/7.50000000E-001;
    _TMP4 = min(vec3( 1.0, 1.0, 1.0), _x0014);
    _TMP15 = max(vec3( 0.0, 0.0, 0.0), _TMP4);
    _grey0022 = dot(_TMP15, vec3( 3.00000012E-001, 5.89999974E-001, 1.09999999E-001));
    _TMP3 = _grey0022 + _GloomSaturation*(_TMP15.x - _grey0022);
    _gloom = vec3(_TMP3, _TMP3, _TMP3)*_GloomIntensity;
    _grey0028 = dot(_base, vec3( 3.00000012E-001, 5.89999974E-001, 1.09999999E-001));
    _TMP3 = _grey0028 + _BaseSaturation*(_base.x - _grey0028);
    _base = vec3(_TMP3, _TMP3, _TMP3)*_BaseIntensity;
    _TMP4 = min(vec3( 1.0, 1.0, 1.0), _gloom);
    _TMP35 = max(vec3( 0.0, 0.0, 0.0), _TMP4);
    _base = _base*(1.0 - _TMP35);
    _TMP10 = (1.0 - (_base + _gloom))*_color1.w;
    _ret_0 = vec4(_TMP10.x, _TMP10.y, _TMP10.z, _color1.w);
    gl_FragColor = _ret_0;
    return;
} 

TBloomEffect 使用:

varying vec4 TEX0;
vec4 _ret_0;
vec3 _TMP5;
float _TMP4;
vec3 _TMP3;
vec3 _TMP14;
vec3 _x0015;
float _grey0021;
float _grey0027;
vec3 _TMP34;
uniform float _BloomIntensity;
uniform float _BaseIntensity;
uniform float _BloomSaturation;
uniform float _BaseSaturation;
uniform sampler2D _Input;
void main()
{
    vec4 _color1;
    vec3 _base;
    vec3 _bloom;
    vec3 _TMP11;
    _color1 = texture2D(_Input, TEX0.xy);
    _base = _color1.xyz/_color1.w;
    _x0015 = (_base - 2.50000000E-001)/7.50000000E-001;
    _TMP3 = min(vec3( 1.0, 1.0, 1.0), _x0015);
    _TMP14 = max(vec3( 0.0, 0.0, 0.0), _TMP3);
    _grey0021 = dot(_TMP14, vec3( 3.00000012E-001, 5.89999974E-001, 1.09999999E-001));
    _TMP4 = _grey0021 + _BloomSaturation*(_TMP14.x - _grey0021);
    _bloom = vec3(_TMP4, _TMP4, _TMP4)*_BloomIntensity;
    _grey0027 = dot(_base, vec3( 3.00000012E-001, 5.89999974E-001, 1.09999999E-001));
    _TMP4 = _grey0027 + _BaseSaturation*(_base.x - _grey0027);
    _base = vec3(_TMP4, _TMP4, _TMP4)*_BaseIntensity;
    _TMP5 = min(vec3( 1.0, 1.0, 1.0), _bloom);
    _TMP34 = max(vec3( 0.0, 0.0, 0.0), _TMP5);
    _base = _base*(1.0 - _TMP34);
    _TMP11 = (_base + _bloom)*_color1.w;
    _ret_0 = vec4(_TMP11.x, _TMP11.y, _TMP11.z, _color1.w);
    gl_FragColor = _ret_0;
    return;
} 

这两个 GLSL 代码只输出黑白有什么问题?

【问题讨论】:

  • 请停止使用 Delphi 标签发布非 Delphi 代码。要么显示等效的 Delphi 代码,要么正确标记它
  • @DaveNottage:它是直接从delphi源代码中提取的(单元FMX.Filter.Standard),也许你不知道,但Delphi广泛使用openGL ...
  • 这并没有让我说的话变得不那么真实。如果您要将其标记为 Delphi,请发布 Delphi 代码
  • @DaveNottage:delphi 组件 TbloomEffect / TGloomEffect 是否有效?那么它是不是一个delphi错误? ...所以当我谈到 delphi 组件中的错误时,你想要添加的标签?
  • 如果您的 cmets 指出您已使用 some elsehex 代码 转换为 GLSL,这会有所帮助。

标签: opengl-es shader glsles


【解决方案1】:

因为 delphi 中的一个错误 ...

好的代码是:

varying vec4 TEX0;
vec4 _ret_0;
vec3 _TMP4;
vec3 _TMP3;
vec3 _x0014;
vec3 _TMP15;
float _grey0022;
float _grey0028;
vec3 _TMP35;
uniform float _GloomIntensity;
uniform float _BaseIntensity;
uniform float _GloomSaturation;
uniform float _BaseSaturation;
uniform sampler2D _Input;
void main()
{
    vec4 _color1;
    vec3 _base;
    vec3 _gloom;
    vec3 _TMP10;

    _color1 = texture2D(_Input, TEX0.xy);
    _base = 1.0 - _color1.xyz/_color1.w;
    _x0014 = (_base - 0.25)/0.75;
    _TMP4 = min(vec3( 1.0, 1.0, 1.0), _x0014);
    _TMP15 = max(vec3( 0.0, 0.0, 0.0), _TMP4);

    _grey0022 = dot(_TMP15, vec3( 0.3, 0.59, 0.11));
    _TMP3 = vec3(_grey0022, _grey0022, _grey0022) + _GloomSaturation*(_TMP15 - vec3(_grey0022, _grey0022, _grey0022));
    _gloom = _TMP3*_GloomIntensity;

    _grey0028 = dot(_base, vec3( 0.3, 0.59, 0.11));
    _TMP3 = vec3(_grey0028, _grey0028, _grey0028) + _BaseSaturation*(_base - vec3(_grey0028, _grey0028, _grey0028));
    _base = _TMP3*_BaseIntensity;

    _TMP4 = min(vec3( 1.0, 1.0, 1.0), _gloom);
    _TMP35 = max(vec3( 0.0, 0.0, 0.0), _TMP4);

    _base = _base*(1.0 - _TMP35);
    _TMP10 = (1.0 - (_base + _gloom))*_color1.w;
    _ret_0 = vec4(_TMP10.x, _TMP10.y, _TMP10.z, _color1.w);

    gl_FragColor = _ret_0;
    return;
} 

【讨论】:

    猜你喜欢
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 2012-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-20
    相关资源
    最近更新 更多