Sunshine/assets/shaders/directx/ConvertUVPS.hlsl

33 lines
939 B
HLSL
Raw Normal View History

2021-05-02 20:35:19 +00:00
Texture2D image : register(t0);
2021-04-30 18:01:15 +00:00
2021-05-02 20:35:19 +00:00
SamplerState def_sampler : register(s0);
2021-04-30 18:01:15 +00:00
2021-05-02 20:35:19 +00:00
struct FragTexWide {
float3 uuv : TEXCOORD0;
2021-04-30 18:01:15 +00:00
};
2021-05-03 20:06:55 +00:00
cbuffer ColorMatrix : register(b0) {
float4 color_vec_y;
float4 color_vec_u;
float4 color_vec_v;
2021-05-08 10:03:58 +00:00
float2 range_y;
float2 range_uv;
2021-05-03 20:06:55 +00:00
};
2021-04-30 18:01:15 +00:00
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
2021-05-06 10:00:39 +00:00
float2 main_ps(FragTexWide input) : SV_Target
2021-04-30 18:01:15 +00:00
{
2021-05-02 20:35:19 +00:00
float3 rgb_left = image.Sample(def_sampler, input.uuv.xz).rgb;
float3 rgb_right = image.Sample(def_sampler, input.uuv.yz).rgb;
float3 rgb = (rgb_left + rgb_right) * 0.5;
float u = dot(color_vec_u.xyz, rgb) + color_vec_u.w;
float v = dot(color_vec_v.xyz, rgb) + color_vec_v.w;
2021-05-03 20:06:55 +00:00
2021-05-08 10:03:58 +00:00
u = u * range_uv.x + range_uv.y;
v = v * range_uv.x + range_uv.y;
return float2(u, v * 224.0f/256.0f + 0.0625);
2021-04-30 18:01:15 +00:00
}