Skip to content

Commit

Permalink
fix: For projects using the built-in render pipeline in gamma color s…
Browse files Browse the repository at this point in the history
…pace, vertex colors are now applied in the correct color space
  • Loading branch information
atteneder committed Apr 22, 2022
1 parent e906a9f commit c5b72d8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- (Export) Removed error messages about non-matching Profiler calls (#357)
- (Export) Re-encoded (blitted) textures are in correct sRGB color space, even when the project is in linear color space (#353)
- (Export) Removed incorrect color space conversion on normal maps (#346)
- For projects using the built-in render pipeline in gamma color space, vertex colors are now applied in the correct color space

## [4.6.0] - 2022-02-23
### Added
Expand Down
15 changes: 15 additions & 0 deletions Runtime/Shader/Built-In/glTFIncludes/glTFUnityStandardCore.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,12 @@ VertexOutputForwardBase vertForwardBase (VertexInput v)
#endif

UNITY_TRANSFER_FOG_COMBINED_WITH_EYE_VEC(o,o.pos);
#ifdef UNITY_COLORSPACE_GAMMA
o.color.rgb = LinearToGammaSpace(v.color.rgb);
o.color.a = v.color.a;
#else
o.color = v.color;
#endif
o.pointSize = 1;
return o;
}
Expand Down Expand Up @@ -637,7 +642,12 @@ VertexOutputForwardAdd vertForwardAdd (VertexInput v)
#endif

UNITY_TRANSFER_FOG_COMBINED_WITH_EYE_VEC(o, o.pos);
#ifdef UNITY_COLORSPACE_GAMMA
o.color.rgb = LinearToGammaSpace(v.color.rgb);
o.color.a = v.color.a;
#else
o.color = v.color;
#endif
o.pointSize = 1;
return o;
}
Expand Down Expand Up @@ -765,7 +775,12 @@ VertexOutputDeferred vertDeferred (VertexInput v)
o.tangentToWorldAndPackedData[2].w = viewDirForParallax.z;
#endif

#ifdef UNITY_COLORSPACE_GAMMA
o.color.rgb = LinearToGammaSpace(v.color.rgb);
o.color.a = v.color.a;
#else
o.color = v.color;
#endif
o.pointSize = 1;

return o;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ VertexOutputBaseSimple vertForwardBaseSimple (VertexInput v)
{
UNITY_SETUP_INSTANCE_ID(v);
VertexOutputBaseSimple o;
#ifdef UNITY_COLORSPACE_GAMMA
o.color.rgb = LinearToGammaSpace(v.color.rgb);
o.color.a = v.color.a;
#else
o.color = v.color;
#endif
UNITY_INITIALIZE_OUTPUT(VertexOutputBaseSimple, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ struct v2f_meta
v2f_meta vert_meta (VertexInput v)
{
v2f_meta o;
#ifdef UNITY_COLORSPACE_GAMMA
o.color.rgb = LinearToGammaSpace(v.color.rgb);
o.color.a = v.color.a;
#else
o.color = v.color;
#endif
o.pos = UnityMetaVertexPosition(v.vertex, v.uv1.xy, v.uv2.xy, unity_LightmapST, unity_DynamicLightmapST);

o.uv.xy = TexCoordsSingle((_MainTexUVChannel==0)?v.uv0:v.uv1,_MainTex);
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Shader/Built-In/glTFUnlit.shader
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ SubShader {
o.texcoord = TexCoordsSingle((_MainTexUVChannel==0)?v.texcoord0:v.texcoord1, _MainTex);

UNITY_TRANSFER_FOG(o,o.vertex);
#ifdef UNITY_COLORSPACE_GAMMA
o.color.rgb = LinearToGammaSpace(v.color.rgb);
o.color.a = v.color.a;
#else
o.color = v.color;
#endif
o.pointSize = 1;
return o;
}
Expand Down

0 comments on commit c5b72d8

Please sign in to comment.