浏览代码

libobs: Add color spaces to deinterlace shaders

jpark37 3 年之前
父节点
当前提交
c455aaedba

+ 51 - 1
libobs/data/deinterlace_base.effect

@@ -16,8 +16,11 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include "color.effect"
+
 uniform float4x4 ViewProj;
 uniform texture2d image;
+uniform float multiplier;
 
 uniform texture2d previous_image;
 uniform float2 dimensions;
@@ -264,7 +267,30 @@ VertData VSDefault(VertData v_in)
 	return vert_out;
 }
 
-#define TECHNIQUE(rgba_ps) \
+#define TECHNIQUE(rgba_ps, rgba_ps_multiply, rgba_ps_tonemap, rgba_ps_multiply_tonemap) \
+float4 rgba_ps_multiply(VertData v_in) : TARGET \
+{ \
+	float4 rgba = rgba_ps(v_in); \
+	rgba.rgb *= multiplier; \
+	return rgba; \
+} \
+float4 rgba_ps_tonemap(VertData v_in) : TARGET \
+{ \
+	float4 rgba = rgba_ps(v_in); \
+	rgba.rgb = rec709_to_rec2020(rgba.rgb); \
+	rgba.rgb = reinhard(rgba.rgb); \
+	rgba.rgb = rec2020_to_rec709(rgba.rgb); \
+	return rgba; \
+} \
+float4 rgba_ps_multiply_tonemap(VertData v_in) : TARGET \
+{ \
+	float4 rgba = rgba_ps(v_in); \
+	rgba.rgb *= multiplier; \
+	rgba.rgb = rec709_to_rec2020(rgba.rgb); \
+	rgba.rgb = reinhard(rgba.rgb); \
+	rgba.rgb = rec2020_to_rec709(rgba.rgb); \
+	return rgba; \
+} \
 technique Draw \
 { \
 	pass \
@@ -272,4 +298,28 @@ technique Draw \
 		vertex_shader = VSDefault(v_in); \
 		pixel_shader  = rgba_ps(v_in); \
 	} \
+} \
+technique DrawMultiply \
+{ \
+	pass \
+	{ \
+		vertex_shader = VSDefault(v_in); \
+		pixel_shader  = rgba_ps_multiply(v_in); \
+	} \
+} \
+technique DrawTonemap \
+{ \
+	pass \
+	{ \
+		vertex_shader = VSDefault(v_in); \
+		pixel_shader  = rgba_ps_tonemap(v_in); \
+	} \
+} \
+technique DrawMultiplyTonemap \
+{ \
+	pass \
+	{ \
+		vertex_shader = VSDefault(v_in); \
+		pixel_shader  = rgba_ps_multiply_tonemap(v_in); \
+	} \
 }

+ 1 - 1
libobs/data/deinterlace_blend.effect

@@ -18,4 +18,4 @@
 
 #include "deinterlace_base.effect"
 
-TECHNIQUE(PSBlendRGBA);
+TECHNIQUE(PSBlendRGBA, PSBlendRGBA_multiply, PSBlendRGBA_tonemap, PSBlendRGBA_multiply_tonemap);

+ 1 - 1
libobs/data/deinterlace_blend_2x.effect

@@ -18,4 +18,4 @@
 
 #include "deinterlace_base.effect"
 
-TECHNIQUE(PSBlendRGBA_2x);
+TECHNIQUE(PSBlendRGBA_2x, PSBlendRGBA_2x_multiply, PSBlendRGBA_2x_tonemap, PSBlendRGBA_2x_multiply_tonemap);

+ 1 - 1
libobs/data/deinterlace_discard.effect

@@ -18,4 +18,4 @@
 
 #include "deinterlace_base.effect"
 
-TECHNIQUE(PSDiscardRGBA);
+TECHNIQUE(PSDiscardRGBA, PSDiscardRGBA_multiply, PSDiscardRGBA_tonemap, PSDiscardRGBA_multiply_tonemap);

+ 1 - 1
libobs/data/deinterlace_discard_2x.effect

@@ -18,4 +18,4 @@
 
 #include "deinterlace_base.effect"
 
-TECHNIQUE(PSDiscardRGBA_2x);
+TECHNIQUE(PSDiscardRGBA_2x, PSDiscardRGBA_2x_multiply, PSDiscardRGBA_2x_tonemap, PSDiscardRGBA_2x_multiply_tonemap);

+ 1 - 1
libobs/data/deinterlace_linear.effect

@@ -18,4 +18,4 @@
 
 #include "deinterlace_base.effect"
 
-TECHNIQUE(PSLinearRGBA);
+TECHNIQUE(PSLinearRGBA, PSLinearRGBA_multiply, PSLinearRGBA_tonemap, PSLinearRGBA_multiply_tonemap);

+ 1 - 1
libobs/data/deinterlace_linear_2x.effect

@@ -18,4 +18,4 @@
 
 #include "deinterlace_base.effect"
 
-TECHNIQUE(PSLinearRGBA_2x);
+TECHNIQUE(PSLinearRGBA_2x, PSLinearRGBA_2x_multiply, PSLinearRGBA_2x_tonemap, PSLinearRGBA_2x_multiply_tonemap);

+ 1 - 1
libobs/data/deinterlace_yadif.effect

@@ -18,4 +18,4 @@
 
 #include "deinterlace_base.effect"
 
-TECHNIQUE(PSYadifMode0RGBA);
+TECHNIQUE(PSYadifMode0RGBA, PSYadifMode0RGBA_multiply, PSYadifMode0RGBA_tonemap, PSYadifMode0RGBA_multiply_tonemap);

+ 1 - 1
libobs/data/deinterlace_yadif_2x.effect

@@ -18,4 +18,4 @@
 
 #include "deinterlace_base.effect"
 
-TECHNIQUE(PSYadifMode0RGBA_2x);
+TECHNIQUE(PSYadifMode0RGBA_2x, PSYadifMode0RGBA_2x_multiply, PSYadifMode0RGBA_2x_tonemap, PSYadifMode0RGBA_2x_multiply_tonemap);