Hi, i was doing a screen shader and i noticed how the color of my effect was a little off. First i thought i was something to do with my effect but after a bit of tinkering i discovered that if i have the most simple screen shader possible that only renders a single given color returns the wrong color all the time.
I tried using different types (fixed half and float) and it did nothing
then i tried change the color space and i noticed that if the color space is linear the color always gets brighter and if it’s gamma it always gets darker
here’s a simple screen shader for you to try it:
Shader "Hidden/Test" {
SubShader {
Tags { "RenderEffect"="Opaque" }
Pass {
ZTest Off Cull Off ZWrite Off Blend Off Lighting Off
Fog { Mode off }
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert_img
#pragma fragment frag
half4 _TestColor;
half4 frag(v2f_img i) : COLOR
{
return _TestColor;
}
ENDCG
}
}
}
and the script (you’ll need screen shaders pro assets imported):
using UnityEngine;
[RequireComponent (typeof(Camera))]
[ExecuteInEditMode]
public class Test : ImageEffectBase {
public Color color;
void OnRenderImage (RenderTexture source, RenderTexture destination){
material.SetColor("_TestColor", color);
Graphics.Blit (source, destination, material);
}
}
You can reproduce the problem by setting a camera and pick a test color somewhere in the middle of the brightness value, then keep using the color picker and pick the color from the Game view and you’ll see the color values decreasing or increasing depending of your color space
what i’m a doing wrong, how can i stop this? is this a bug?