Shader problem with HDR in Default Rendering Pipeline

I feel like I’ve already asked some obvious questions but I’m still learning.

I have a simple stars shader that works ok with the default rendering pipeline:


even though the pipeline darkens it, its still manageable.

but when I use the default rendering pipeline with HDR textures set to true:


the scene is suddenly brightened and the shader starts looking odd.

and for other shaders as well:


I have no clue what’s going on. Is there some way to stop this? Or should I forget about using HDR textures?

this is the playground: https://playground.babylonjs.com/#74E01A#5

1 Like

If you turn HDR on on your pipeline yopu are supposed to output pixel in your shader in linear space (and not gamma space)

In this case we recommend to add a pixel conversion at the end of your pixel shader to output the pixel in linear space

For the background you can call scene.createDefaultEnvironment() which will create a skybox with a BackgroundMaterial that will fix the background color

2 Likes

That was fast. thanks for replying. I’ll look into that right now.

I researched on it and found that opengl uses sRGB color space by default. then I researched more and found this: GLSL-Color-Spaces/ColorSpaces.inc.glsl at master · tobspr/GLSL-Color-Spaces · GitHub

and its working well:

thanks for your help.

2 Likes