// // Copyright 2018 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //
out vec4 pos_varying; out vec3 normal_varying; out vec4 color_varying;
flat out vec4 color_varying_flat; out vec4 texcoord0_varying; out vec4 texcoord1_varying; out vec4 texcoord2_varying; out vec4 texcoord3_varying;
float posDot(vec3 a, vec3 b)
{
return max(dot(a, b), 0.0);
}
// Avoid calculating point size stuff // if we are not rendering points. if (point_rasterization)
{
gl_PointSize = calcPointSize(ndcPos);
} else
{
gl_PointSize = pointsize;
}
in vec4 pos_varying; in vec3 normal_varying; in vec4 color_varying;
flat in vec4 color_varying_flat; in vec4 texcoord0_varying; in vec4 texcoord1_varying; in vec4 texcoord2_varying; in vec4 texcoord3_varying;
// User clip plane /////////////////////////////////////////////////////////////
uniform vec4 clip_planes[kMaxClipPlanes];
// Logic Op ////////////////////////////////////////////////////////////////////
// Format is: // - 4x4 bits depicting the bit width of each channel of color output // - 4 bits for the op based on LogicalOperation's packing
uniform highp uint logic_op;
// Point rasterization//////////////////////////////////////////////////////////
// applyLogicOp takes logic-op information from a packed uniform and applies it to the color // attachment using framebuffer fetch. See the description of logic_op above for the format of the // uniform. // // In particular, 4 bits in logic_op (at offset 16) contain the packed logical operation (of // LogicalOperation type). Based on the selected operation, the formula specified in the spec is // applied (applied as bitwise operations on unorm values).
constexpr char kGLES1DrawFShaderLogicOpFramebufferFetchEnabled[] = R"(
vec4 applyLogicOp(vec4 currentFragment)
{
vec4 previousFragment = frag_color;
switch (logic_op >> 16u & 0xFu)
{ case kAnd:
result = src & dst;
break; case kAndInverted:
result = ~src & dst;
break; case kAndReverse:
result = src & ~dst;
break; case kClear:
result = uvec4(0);
break; case kCopy:
result = src;
break; case kCopyInverted:
result = ~src;
break; case kEquiv:
result = ~(src ^ dst);
break; case kInvert:
result = ~dst;
break; case kNand:
result = ~(src & dst);
break; case kNoop:
result = dst;
break; case kNor:
result = ~(src | dst);
break; case kOr:
result = src | dst;
break; case kOrInverted:
result = ~src | dst;
break; case kOrReverse:
result = src | ~dst;
break; case kSet:
result = channelMasks;
break; case kXor:
result = src ^ dst;
break;
}
result &= channelMasks;
// Avoid division by zero for formats without alpha
channelMasks.a = max(channelMasks.a, 1u);
switch (unit)
{ case 0: if (enable_texture_2d[0])
{
res = texture(tex_sampler0, gl_PointCoord.xy);
}
break; case 1: if (enable_texture_2d[1])
{
res = texture(tex_sampler1, gl_PointCoord.xy);
}
break; case 2: if (enable_texture_2d[2])
{
res = texture(tex_sampler2, gl_PointCoord.xy);
}
break; case 3: if (enable_texture_2d[3])
{
res = texture(tex_sampler3, gl_PointCoord.xy);
}
break;
default:
break;
}
switch (srcnRgb)
{ case kTexture:
op = textureColor;
break; case kConstant:
op = textureEnvColor;
break; case kPrimaryColor:
op = vertexColor;
break; case kPrevious:
op = texturePrevColor;
break;
default:
op = texturePrevColor;
break;
}
switch (opnRgb)
{ case kSrcColor:
res = op.rgb;
break; case kOneMinusSrcColor:
res = 1.0 - op.rgb;
break; case kSrcAlpha:
res = vec3(op.a, op.a, op.a);
break; case kOneMinusSrcAlpha:
res = vec3(1.0 - op.a, 1.0 - op.a, 1.0 - op.a);
break;
default:
break;
}
switch (srcn)
{ case kTexture:
op = textureColor;
break; case kConstant:
op = textureEnvColor;
break; case kPrimaryColor:
op = vertexColor;
break; case kPrevious:
op = texturePrevColor;
break;
default:
op = texturePrevColor;
break;
}
switch (opn)
{ case kSrcAlpha:
res = op.a;
break; case kOneMinusSrcAlpha:
res = 1.0 - op.a;
break;
default:
break;
}
return res;
}
vec4 textureCombine(int combineRgb,
int combineAlpha,
int src0Rgb,
int src0Alpha,
int src1Rgb,
int src1Alpha,
int src2Rgb,
int src2Alpha,
int op0Rgb,
int op0Alpha,
int op1Rgb,
int op1Alpha,
int op2Rgb,
int op2Alpha,
vec4 textureEnvColor,
float rgbScale,
float alphaScale,
vec4 vertexColor,
vec4 texturePrevColor,
vec4 textureColor)
{
vec4 textureFunction(int unit,
int texFormat,
int envMode,
int combineRgb,
int combineAlpha,
int src0Rgb,
int src0Alpha,
int src1Rgb,
int src1Alpha,
int src2Rgb,
int src2Alpha,
int op0Rgb,
int op0Alpha,
int op1Rgb,
int op1Alpha,
int op2Rgb,
int op2Alpha,
vec4 textureEnvColor,
float rgbScale,
float alphaScale,
vec4 vertexColor,
vec4 texturePrevColor,
vec4 textureColor)
{
if (!isTextureUnitEnabled(unit))
{
return texturePrevColor;
}
vec4 res;
switch (envMode)
{ case kReplace:
switch (texFormat)
{ case kAlpha:
res.rgb = texturePrevColor.rgb;
res.a = textureColor.a;
break; case kRGBA: case kLuminanceAlpha:
res.rgba = textureColor.rgba;
break; case kRGB: case kLuminance:
default:
res.rgb = textureColor.rgb;
res.a = texturePrevColor.a;
break;
}
break; case kModulate:
switch (texFormat)
{ case kAlpha:
res.rgb = texturePrevColor.rgb;
res.a = texturePrevColor.a * textureColor.a;
break; case kRGBA: case kLuminanceAlpha:
res.rgba = texturePrevColor.rgba * textureColor.rgba;
break; case kRGB: case kLuminance:
default:
res.rgb = texturePrevColor.rgb * textureColor.rgb;
res.a = texturePrevColor.a;
break;
}
break; case kDecal:
switch (texFormat)
{ case kRGB:
res.rgb = textureColor.rgb;
res.a = texturePrevColor.a;
break; case kRGBA:
res.rgb = texturePrevColor.rgb * (1.0 - textureColor.a) +
textureColor.rgb * textureColor.a;
res.a = texturePrevColor.a;
break; case kAlpha: case kLuminance: case kLuminanceAlpha:
default:
res.rgb = texturePrevColor.rgb * textureColor.rgb;
res.a = texturePrevColor.a;
break;
}
break; case kBlend:
switch (texFormat)
{ case kAlpha:
res.rgb = texturePrevColor.rgb;
res.a = textureColor.a * texturePrevColor.a;
break; case kLuminance: case kRGB:
res.rgb = texturePrevColor.rgb * (1.0 - textureColor.rgb) +
textureEnvColor.rgb * textureColor.rgb;
res.a = texturePrevColor.a;
break; case kLuminanceAlpha: case kRGBA:
default:
res.rgb = texturePrevColor.rgb * (1.0 - textureColor.rgb) +
textureEnvColor.rgb * textureColor.rgb;
res.a = textureColor.a * texturePrevColor.a;
break;
}
break; case kAdd:
switch (texFormat)
{ case kAlpha:
res.rgb = texturePrevColor.rgb;
res.a = textureColor.a * texturePrevColor.a;
break; case kLuminance: case kRGB:
res.rgb = texturePrevColor.rgb + textureColor.rgb;
res.a = texturePrevColor.a;
break; case kLuminanceAlpha: case kRGBA:
default:
res.rgb = texturePrevColor.rgb + textureColor.rgb;
res.a = textureColor.a * texturePrevColor.a;
break;
}
break; case kCombine:
res = textureCombine(combineRgb, combineAlpha, src0Rgb, src0Alpha, src1Rgb, src1Alpha,
src2Rgb, src2Alpha, op0Rgb, op0Alpha, op1Rgb, op1Alpha, op2Rgb,
op2Alpha, textureEnvColor, rgbScale, alphaScale, vertexColor,
texturePrevColor, textureColor);
res.rgb *= rgbScale;
res.a *= alphaScale;
break;
default:
break;
}
return clamp(res, 0.0, 1.0);
}
)";
constexpr char kGLES1DrawFShaderMain[] = R"(
void main()
{ if (enable_clip_planes && !enable_draw_texture)
{ if (!doClipPlaneTest())
{
discard;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.