- Home /
Question by
FelixTheWolfrick · Apr 26, 2021 at 08:51 PM ·
shadersshader programmingshader writinghlslmatrix4x4
How to multiply a float4x4 and a float4 in unity shaders?
I'm trying to make a post-processing shader to simulate what a colorblind person would see. In glsl you should just need to multiply the color by a mat4 but unity shaders doesn't have this since I think it uses hlsl. I've been trying to figure out how to do it in Unity Shaders but can't figure it out. Right now the error I get is "type mismatch" on line 55 which is (float4 col = tex2D(_MainTex, i.uv);) Does anyone know how to do this? Thanks in advance.
sampler2D _MainTex;
float4x4 _Tritanopia = {
0.97, 0.11, -0.08, 0.0,
0.02, 0.82, 0.16, 0.0,
-0.06, 0.88, 0.18, 0.0,
0.0, 0.0, 0.0, 1.0
};
float4 frag (v2f i) : SV_Target
{
float4 col = tex2D(_MainTex, i.uv);
// just invert the colors
col = col * _Tritanopia;
return col;
}
ENDCG
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613032905im_/https://answers.unity.com/themes/thub/images/avi.jpg)