Implement runtime detection of srgb bindless fix
This commit is contained in:
parent
a3b8494ad5
commit
5878cb35ec
@ -22,7 +22,9 @@ void main(void)
|
|||||||
{
|
{
|
||||||
vec4 color = texture(Albedo, uv);
|
vec4 color = texture(Albedo, uv);
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
color.xyz = pow(color.xyz, vec3(2.2));
|
color.xyz = pow(color.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
vec4 detail = texture(Detail, uv_bis);
|
vec4 detail = texture(Detail, uv_bis);
|
||||||
color *= detail;
|
color *= detail;
|
||||||
|
@ -33,7 +33,9 @@ void main(void)
|
|||||||
|
|
||||||
vec4 color = texture(Albedo, uv);
|
vec4 color = texture(Albedo, uv);
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
color.xyz = pow(color.xyz, vec3(2.2));
|
color.xyz = pow(color.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (color.a < 0.5) discard;
|
if (color.a < 0.5) discard;
|
||||||
vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.);
|
vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.);
|
||||||
|
@ -17,7 +17,9 @@ void main(void)
|
|||||||
{
|
{
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
vec4 color = texture(handle, uv);
|
vec4 color = texture(handle, uv);
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
color.xyz = pow(color.xyz, vec3(2.2));
|
color.xyz = pow(color.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
vec4 detail = texture(secondhandle, uv_bis);
|
vec4 detail = texture(secondhandle, uv_bis);
|
||||||
#else
|
#else
|
||||||
vec4 color = texture(Albedo, uv);
|
vec4 color = texture(Albedo, uv);
|
||||||
|
@ -35,7 +35,9 @@ void main(void)
|
|||||||
|
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
vec4 color = texture(handle, uv);
|
vec4 color = texture(handle, uv);
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
color.xyz = pow(color.xyz, vec3(2.2));
|
color.xyz = pow(color.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
vec4 color = texture(Albedo, uv);
|
vec4 color = texture(Albedo, uv);
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,7 +14,10 @@ vec3 getLightFactor(float specMapValue);
|
|||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
vec4 col = pow(texture(handle, uv), vec4(2.2));
|
vec4 col = texture(handle, uv);
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
|
col.xyz = pow(col.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
vec4 col = texture(Albedo, uv);
|
vec4 col = texture(Albedo, uv);
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,7 +14,9 @@ void main(void)
|
|||||||
{
|
{
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
vec4 col = texture(handle, uv);
|
vec4 col = texture(handle, uv);
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
col.xyz = pow(col.xyz, vec3(2.2));
|
col.xyz = pow(col.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
vec4 col = texture(tex, uv);
|
vec4 col = texture(tex, uv);
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,7 +23,9 @@ void main() {
|
|||||||
r.y = - r.y;
|
r.y = - r.y;
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
vec4 detail0 = texture(handle, r.xy / m + .5);
|
vec4 detail0 = texture(handle, r.xy / m + .5);
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
detail0.xyz = pow(detail0.xyz, vec3(2.2));
|
detail0.xyz = pow(detail0.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
vec4 detail0 = texture(tex, r.xy / m + .5);
|
vec4 detail0 = texture(tex, r.xy / m + .5);
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,7 +15,9 @@ void main(void)
|
|||||||
{
|
{
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
vec4 col = texture(handle, uv);
|
vec4 col = texture(handle, uv);
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
col.xyz = pow(col.xyz, vec3(2.2));
|
col.xyz = pow(col.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
vec4 col = texture(Albedo, uv);
|
vec4 col = texture(Albedo, uv);
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,7 +13,10 @@ vec3 getLightFactor(float specMapValue);
|
|||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
vec4 col = pow(texture(Albedo, uv), vec4(2.2));
|
vec4 col = texture(Albedo, uv);
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
|
col.xyz = pow(col.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
vec4 col = texture(Albedo, uv);
|
vec4 col = texture(Albedo, uv);
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,7 +12,9 @@ void main(void)
|
|||||||
{
|
{
|
||||||
vec4 col = texture(tex, uv);
|
vec4 col = texture(tex, uv);
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
col.xyz = pow(col.xyz, vec3(2.2));
|
col.xyz = pow(col.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||||
if (col.a < 0.5) discard;
|
if (col.a < 0.5) discard;
|
||||||
|
@ -26,7 +26,9 @@ void main() {
|
|||||||
r.y = - r.y;
|
r.y = - r.y;
|
||||||
vec4 detail0 = texture(tex, r.xy / m + .5);
|
vec4 detail0 = texture(tex, r.xy / m + .5);
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
detail0.xyz = pow(detail0.xyz, vec3(2.2));
|
detail0.xyz = pow(detail0.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
vec3 LightFactor = getLightFactor(1.);
|
vec3 LightFactor = getLightFactor(1.);
|
||||||
|
|
||||||
|
@ -14,7 +14,9 @@ void main(void)
|
|||||||
{
|
{
|
||||||
vec4 col = texture(Albedo, uv);
|
vec4 col = texture(Albedo, uv);
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
col.xyz = pow(col.xyz, vec3(2.2));
|
col.xyz = pow(col.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||||
if (col.a * color.a < 0.5) discard;
|
if (col.a * color.a < 0.5) discard;
|
||||||
|
@ -33,10 +33,12 @@ void main() {
|
|||||||
vec4 detail3 = texture(tex_detail3, uv);
|
vec4 detail3 = texture(tex_detail3, uv);
|
||||||
vec4 detail4 = vec4(0.0);
|
vec4 detail4 = vec4(0.0);
|
||||||
#ifdef GL_ARB_bindless_texture
|
#ifdef GL_ARB_bindless_texture
|
||||||
|
#ifdef SRGBBindlessFix
|
||||||
detail0.xyz = pow(detail0.xyz, vec3(2.2));
|
detail0.xyz = pow(detail0.xyz, vec3(2.2));
|
||||||
detail1.xyz = pow(detail1.xyz, vec3(2.2));
|
detail1.xyz = pow(detail1.xyz, vec3(2.2));
|
||||||
detail2.xyz = pow(detail2.xyz, vec3(2.2));
|
detail2.xyz = pow(detail2.xyz, vec3(2.2));
|
||||||
detail3.xyz = pow(detail3.xyz, vec3(2.2));
|
detail3.xyz = pow(detail3.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vec4 splatted = splatting.r * detail0 +
|
vec4 splatted = splatting.r * detail0 +
|
||||||
|
@ -333,6 +333,8 @@ GLuint LoadShader(const char * file, unsigned type)
|
|||||||
Code += "#define UBO_DISABLED\n";
|
Code += "#define UBO_DISABLED\n";
|
||||||
if (irr_driver->hasVSLayerExtension())
|
if (irr_driver->hasVSLayerExtension())
|
||||||
Code += "#define VSLayer\n";
|
Code += "#define VSLayer\n";
|
||||||
|
if (irr_driver->needsRGBBindlessWorkaround())
|
||||||
|
Code += "#define SRGBBindlessFix\n";
|
||||||
Code += LoadHeader();
|
Code += LoadHeader();
|
||||||
if (Stream.is_open())
|
if (Stream.is_open())
|
||||||
{
|
{
|
||||||
|
@ -470,6 +470,7 @@ void IrrDriver::initDevice()
|
|||||||
|
|
||||||
m_need_ubo_workaround = false;
|
m_need_ubo_workaround = false;
|
||||||
m_need_rh_workaround = false;
|
m_need_rh_workaround = false;
|
||||||
|
m_need_srgb_workaround = false;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// Fix for Intel Sandy Bridge on Windows which supports GL up to 3.1 only
|
// Fix for Intel Sandy Bridge on Windows which supports GL up to 3.1 only
|
||||||
if (strstr((const char *)glGetString(GL_VENDOR), "Intel") != NULL && (GLMajorVersion == 3 && GLMinorVersion == 1))
|
if (strstr((const char *)glGetString(GL_VENDOR), "Intel") != NULL && (GLMajorVersion == 3 && GLMinorVersion == 1))
|
||||||
@ -478,6 +479,10 @@ void IrrDriver::initDevice()
|
|||||||
// Fix for Nvidia and instanced RH
|
// Fix for Nvidia and instanced RH
|
||||||
if (strstr((const char *)glGetString(GL_VENDOR), "NVIDIA") != NULL)
|
if (strstr((const char *)glGetString(GL_VENDOR), "NVIDIA") != NULL)
|
||||||
m_need_rh_workaround = true;
|
m_need_rh_workaround = true;
|
||||||
|
|
||||||
|
// Fix for AMD and bindless sRGB textures
|
||||||
|
if (strstr((const char *)glGetString(GL_VENDOR), "AMD") != NULL)
|
||||||
|
m_need_srgb_workaround = true;
|
||||||
}
|
}
|
||||||
m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1));
|
m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1));
|
||||||
|
|
||||||
|
@ -202,6 +202,7 @@ private:
|
|||||||
bool hasBaseInstance;
|
bool hasBaseInstance;
|
||||||
bool m_need_ubo_workaround;
|
bool m_need_ubo_workaround;
|
||||||
bool m_need_rh_workaround;
|
bool m_need_rh_workaround;
|
||||||
|
bool m_need_srgb_workaround;
|
||||||
/** The irrlicht device. */
|
/** The irrlicht device. */
|
||||||
IrrlichtDevice *m_device;
|
IrrlichtDevice *m_device;
|
||||||
/** Irrlicht scene manager. */
|
/** Irrlicht scene manager. */
|
||||||
@ -294,6 +295,11 @@ public:
|
|||||||
return m_need_rh_workaround;
|
return m_need_rh_workaround;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool needsRGBBindlessWorkaround() const
|
||||||
|
{
|
||||||
|
return m_need_srgb_workaround;
|
||||||
|
}
|
||||||
|
|
||||||
bool hasARB_base_instance() const
|
bool hasARB_base_instance() const
|
||||||
{
|
{
|
||||||
return hasBaseInstance;
|
return hasBaseInstance;
|
||||||
|
Loading…
Reference in New Issue
Block a user