You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//!HOOK MAIN
//!BIND HOOKED
//!DESC Levels
// Define levels adjustment parameters
#define input_low 16.0
#define input_high 235.0
#define gamma 1.0
#define output_low 16.0
#define output_high 235.0
vec4 hook() {
vec4 color = HOOKED_texOff(0);
// Normalize input and output parameters to [0, 1] range
float input_low_norm = input_low / 255.0;
float input_high_norm = input_high / 255.0;
float output_low_norm = output_low / 255.0;
float output_high_norm = output_high / 255.0;
// Apply input low/high levels
vec3 normalized = (color.rgb - input_low_norm) / (input_high_norm - input_low_norm);
// Ensure values are within the [0, 1] range before gamma correction
normalized = clamp(normalized, 0.0, 1.0);
// Apply gamma correction using 1/gamma
vec3 gamma_corrected = pow(normalized, vec3(1.0 / gamma));
// Apply output low/high levels
vec3 adjusted_output = gamma_corrected * (output_high_norm - output_low_norm) + output_low_norm;
// Ensure values are within the [0, 1] range
color.rgb = clamp(adjusted_output, 0.0, 1.0);
return color;
}
through:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
import sys
import os
core = vs.core
# Import scripts folder
scriptPath = 'F:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# loading plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
# Import scripts
import validate
# Source: 'G:\TestClips&Co\files\test.avi'
# Current color space: YUV420P8, bit depth: 8, resolution: 640x352, frame rate: 25fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
# Loading G:\TestClips&Co\files\test.avi using LWLibavSource
clip = core.lsmas.LWLibavSource(source="G:/TestClips&Co/files/test.avi", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
frame = clip.get_frame(0)
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip=clip, _Matrix=5)
# setting color transfer (170), if it is not set.
if validate.transferIsInvalid(clip):
clip = core.std.SetFrameProps(clip=clip, _Transfer=6)
# setting color primaries info (to 470), if it is not set.
if validate.primariesIsInvalid(clip):
clip = core.std.SetFrameProps(clip=clip, _Primaries=5)
# setting color range to TV (limited) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)
# making sure frame rate is set to 25fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# making sure the detected scan type is set (detected: progressive)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=0) # progressive
# adjusting color space from YUV420P8 to YUV444P16 for vsGLSLLevels
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/Levels.glsl") as glslf:
glsl = glslf.read()
clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
# adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
# set output frame rate to 25fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# output
clip.set_output()
I expected the filtered and the unfiltered version to be identical, which they are not.
Is there a bug in vs-placebo? Am I using it wrong? Is there a bug in my shader code?
The text was updated successfully, but these errors were encountered:
So the shader needs to me rewritten to assume YUV input to work with placebo.Shader or is there a mistake in the shader that it doesn't work with RGB as intended?
Using:
through:
I expected the filtered and the unfiltered version to be identical, which they are not.

Is there a bug in vs-placebo? Am I using it wrong? Is there a bug in my shader code?
The text was updated successfully, but these errors were encountered: