Remove unneeded pow in transparent.frag

It's only used in 2d rendering so no srgb sampling is needed
This commit is contained in:
Benau 2022-09-08 15:24:40 +08:00
parent efcdd79d42
commit 155b73d452
2 changed files with 5 additions and 17 deletions

View File

@ -1,25 +1,13 @@
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
uniform float custom_alpha;
in vec2 uv;
in vec4 color;
out vec4 FragColor;
void main()
{
vec4 Color = texture(tex, uv);
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
Color.xyz = pow(Color.xyz, vec3(2.2));
#endif
#endif
Color.xyz *= pow(color.xyz, vec3(2.2));
Color.a *= color.a;
Color *= color;
// Premultiply alpha
FragColor = vec4(Color.rgb * (Color.a * custom_alpha), Color.a * custom_alpha);
FragColor = vec4(Color.rgb * Color.a, Color.a);
}

View File

@ -27,14 +27,14 @@
#include "utils/cpp2011.hpp"
// ============================================================================
class Primitive2DList : public TextureShader<Primitive2DList, 1, float, core::vector2df>
class Primitive2DList : public TextureShader<Primitive2DList, 1, core::vector2df>
{
public:
Primitive2DList()
{
loadProgram(OBJECT, GL_VERTEX_SHADER, "primitive2dlist.vert",
GL_FRAGMENT_SHADER, "transparent.frag");
assignUniforms("custom_alpha", "fullscreen");
assignUniforms("fullscreen");
assignSamplerNames(0, "tex", ST_BILINEAR_FILTERED);
} // Primitive2DList
}; //Primitive2DList
@ -503,7 +503,7 @@ void draw2DVertexPrimitiveList(video::ITexture *tex, const void* vertices,
VertexUtils::bindVertexArrayAttrib(vType);
Primitive2DList::getInstance()->use();
Primitive2DList::getInstance()->setUniforms(1.0f,
Primitive2DList::getInstance()->setUniforms(
core::vector2df(float(irr_driver->getActualScreenSize().Width),
float(irr_driver->getActualScreenSize().Height)));
Primitive2DList::getInstance()->setTextureUnits(tex->getTextureHandler());