Developing Games on Intel Graphics
If you are gaming on graphics integrated in your Intel Processor, this is the place for you! Find answers to your questions or post your issues with PC games
543 Discussions

OpenGL mix() function not working correctly with Minecraft shaders.

djmrFunnyMan
New Contributor II
696 Views

This is a continuation from https://community.intel.com/t5/Developing-Games-on-Intel/Driver-level-bugs-causing-issues-in-Minecraft-amp-OpenGL-shaders/td-p/1664368 which will be split into 3 separate reports.

The issue:

The OpenGL mix() function seems to not work correctly.

It produces NaN's in situations where AMD and Nvidia cards don't have such issues.
In this particular case the line of code affected is line 21 in blocklightColors.glsl (in the attached shaderpacks.zip)

 

vec3 torchBlockSpecialLightColor = mix(vec3(2.0, 0.87, 0.27), fireSpecialLightColor, 0.75);

 


Rudimentary investegation:

Doing this will fix the issue and make it behave as expected. This fix makes zero sense however as clamp(0.75, 0.0, 1.0) should do absolutely nothing to the 0.75

 

 

vec3 torchBlockSpecialLightColor = mix(vec3(2.0, 0.87, 0.27), fireSpecialLightColor, clamp01(0.75));  //this works as expected

 

 

clamp01 is just a simple function that looks like this (it's in commonFunctions.glsl)

 

 

float clamp01(float x) {
    return clamp(x, 0.0, 1.0);
}

 

 

What makes even less sense is that, not using the function and directly doing clamp(0.75, 0.0, 1.0) results in different broken behaviour (also a NaN but it doesn't spread over the entire screen anymore)

 

 

vec3 torchBlockSpecialLightColor = mix(vec3(2.0, 0.87, 0.27), fireSpecialLightColor, clamp(0.75, 0.0, 1.0));  //this is broken

 

 

This makes precisely zero sense as clamp01 is just clamp(x , 0.0, 1.0) so there should be absolutely no difference between the two.

The suspected culprit is malfunctioning constant folding.

Reproduction Steps

Preparation:
- Install Iris & Sodium for 1.21.4 : https://github.com/IrisShaders/Iris/blob/multiloader-new/docs/guide.md
- Unpack the shaderpacks.zip inside the (...)\AppData\Roaming\.minecraft folder
- Unpack the Driver Bug Test.zip inside the \AppData\Roaming\.minecraft\saves folder
- Go into options>video settings>shaderpacks and select "complementary unbound 5.4 + euphoria patches 1.5.2"
- Press apply

Reproduction:

- Open the Driver Bug Test world in-game
- Step on the pressure plate that says "NaN apocalypse"
- Press the button to place a torch

0 Kudos
1 Reply
karen_intel
Moderator
629 Views

@djmrFunnyMan thanks for splitting the cases.
I'll check this one too

Stay tuned

Karen

0 Kudos
Reply