Godot Version
4.3
Question
I have a project using compute shaders to generate procedural textures. This uses the Texture2DRD resource. However, I have an issue with colour spaces.
Most textures are in sRBG and require converting to linear to be used properly in the shader calculations otherwise the maths gets pretty wonky.
This is fine for the textures I am reading in as when converting a Texture resource to a rendering device RID I can specify if the RenderingDevice should treat the texture as sRGB (or even just run a step to convert in myself).
i.e.
static func from_texture(texture: Texture, srgb := false,) -> RID:
return RenderingServer.texture_get_rd_texture(texture.get_rid(), srgb)
However the issues arise when the texture I am generating and assigning to the Texture2DRD is itself being used - if used in a 3D context it is fine (assuming I have properly converted all it’s parts to linear before multiplying them) and the texture on the GPU is linear and looks correct, however, when viewed in 2D it is clearly too dark as it has been converted from sRBG to linear despite already being linear.
I would like to be able to mark by generated Texture2DRD as linear somehow so the rendering knows not to try and convert it but I don’t know if I can.
I know I could convert it to sRGB once all the calculations are complete but then it’d be wrong in 3D - I figure there must be something that determines if a texture will be converted, since for certain Image formats it may or may not be converted (I don’t have an Image here though just a Texture on the RD). I know there is a marker on the vulcan side, but I don’t know if/how to access that from godot.
Does anyone know what the any solution is here?
Any help much appreciated.