Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在Foundry Nuke中使用着色器_C++_Shader_Nuke - Fatal编程技术网

C++ 在Foundry Nuke中使用着色器

C++ 在Foundry Nuke中使用着色器,c++,shader,nuke,C++,Shader,Nuke,有没有办法在插件中应用着色器 我正在尝试实现抗锯齿,但所有尝试都失败:\使用以下简单方法: #include <fstream> #include <sstream> #include "DDImage/Knobs.h" #include "DDImage/DDMath.h" #include "DDImage/ViewerContext.h" #include "DDImage/Iop.h" #include "DDImage/PixelIop.h" #include

有没有办法在插件中应用着色器

我正在尝试实现抗锯齿,但所有尝试都失败:\

使用以下简单方法:

#include <fstream>
#include <sstream>

#include "DDImage/Knobs.h"
#include "DDImage/DDMath.h"
#include "DDImage/ViewerContext.h"
#include "DDImage/Iop.h"
#include "DDImage/PixelIop.h"
#include "DDImage/Row.h"

using namespace DD::Image;

////////////////////////////////////////////////////////////////
/// GPU File Shader Op.

class GPUFileShader : public DD::Image::PixelIop
{

    const char* shaderFile_;
    std::string currShaderFile_;
    std::string shader_;
    int version_;
    int currVersion_;

    const char* gpuEngine_body() const
    {
        return shader_.c_str();
    }

    void pixel_engine(const Row& in, int y, int x, int r, ChannelMask channels, Row& out)
    {
        foreach(z, channels) {
            const float* inptr = in[z] + x;
            const float* END = inptr + (r - x);
            float* outptr = out.writable(z) + x;
            while (inptr < END)
                *outptr++ = *inptr++;
        }
    }

    void in_channels(int, DD::Image::ChannelSet& c) const { } // return c unchanged

public:
    GPUFileShader(Node* node)
        : PixelIop(node)
        , shaderFile_(0)
        , version_(0)
        , currVersion_(0)
    { }

    void knobs(Knob_Callback f)
    {
        File_knob(f, &shaderFile_, "shader_file", "OpenGL Shading Language file");
    }

    void _validate(bool)
    {
        if (!shaderFile_)
            return;

        if (version_ != currVersion_ || currShaderFile_ != std::string(shaderFile_)) {
            std::ifstream ifs(shaderFile_);
            if (!ifs) {
                Iop::error("Error reading shader file.");
                return;
            }
            std::stringstream str;
            std::copy(std::istreambuf_iterator<char>(ifs), std::istreambuf_iterator<char>(), std::ostreambuf_iterator<char>(str));
            shader_ = str.str();
            currVersion_ = version_;
            currShaderFile_.assign(shaderFile_);
        }

        copy_info(0);
    }

    static const DD::Image::Op::Description d;
    const char* Class() const { return d.name; }
    const char* node_help() const { return "GPU Op which gets initialised from a file. Customise for proprietary formats. Default assumes OpenGL shading language code."; }

};

static Op* GPUFileShader_c(Node* node) { return new GPUFileShader(node); }
const Op::Description GPUFileShader::d("GPUFileShader", GPUFileShader_c);
#包括
#包括
#包括“D图像/旋钮.h”
#包括“DDImage/DDMath.h”
#包括“DDImage/ViewerContext.h”
#包括“DDImage/Iop.h”
#包括“DDImage/PixelIop.h”
#包括“D图像/行.h”
使用名称空间DD::Image;
////////////////////////////////////////////////////////////////
///GPU文件着色器Op。
类GPUFileShader:public DD::Image::PixelIop
{
常量字符*着色器文件;
std::字符串currShaderFile;
字符串着色器;
int版本;
int currVersion;
常量char*gpuEngine_body()常量
{
返回着色器_u.c_str();
}
无效像素_引擎(常量行和输入、整数y、整数x、整数r、通道掩码通道、行和输出)
{
foreach(z,通道){
常量浮点*inptr=in[z]+x;
常量浮点*END=inptr+(r-x);
float*outptr=out.writable(z)+x;
while(inptr