- Home /
Problem is not reproducible or outdated
What's happening to my colour outputs from my shader?
Hello, I have the following simplified Shader, which outputs grey rgb(0.5,0.5,0.5) - I have tried it in both linear and gamma modes of rendering and when I screenshot I get RGBs of 174.174.174 (linear mode) or 109.109.109 (gamma mode), when it should really be 128.128.128. For my application I need to render pixels exactly without any correction, from a shader, but I can't work out how to do this - is there a setting I am missing somewhere? Any help much appreciated!
Shader "Custom/ColourDemo"
{
Properties {}
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f
{
float4 grabPos : TEXCOORD0;
float4 pos : SV_POSITION;
};
v2f vert(appdata_base v) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.grabPos = ComputeGrabScreenPos(o.pos);
return o;
}
float4 frag(v2f i) : SV_Target
{
float4 output = float4(0.5,0.5,0.5,1);
return output;
}
ENDCG
}
}
}
I have created an empty project with your shader. The gamma space shows value of 127, and the linear space shows 187. I assume your problem will not persist in a new project, will it?
No I'm still getting 109 - Although I am applying it to a material on a quad, how did you test the shader? It's for a 2d game...
I've also tested it with a sprite renderer and get the same.
The issue was with the program i was testing colours with. I tested it with GI$$anonymous$$P and the colours were being produced correctly....
hahaha that's good to know! Shit happens, glad it's fixed
For sampling pixel colors I use this little app called Colorblind Assistant. I've been using it for years. And you don't have to be colorblind to use it hehe
Cheers!
Follow this Question
Related Questions
Difference between Gamma Correction and RenderSettings.ambientLight 0 Answers
Linear Color Space washed out in android URP build. 2 Answers
Unity Linear color space causing over blurr on sprite 0 Answers
UnityWebRequest.GetTexture returns incorrect Linear or Gamma or whatever 1 Answer
How to force to use Gamma Space instead of Linear Space? 1 Answer