void Renderer::shader_displacement(
		const liqShader &shader,
		const std::vector<liqTokenPointer> &tokenPointerArray
		)
	{
		CM_TRACE_FUNC("Renderer::shader_displacement("<<shader.getName()<<", tokenPointerArray)");

		int shaderParamCount = tokenPointerArray.size() - 1;
		boost::scoped_array< liqToken > tokenArray( new liqToken[ tokenPointerArray.size() ] );
		boost::scoped_array< liqPointer > pointerArray( new liqPointer[ tokenPointerArray.size() ] );
		assignTokenArrays( tokenPointerArray.size(), &tokenPointerArray[ 0 ], tokenArray.get(), pointerArray.get() );

		RiDisplacementV( const_cast<char *>(shader.getShaderFileName().c_str()), shaderParamCount, tokenArray.get(), pointerArray.get());

	}
Beispiel #2
0
RtVoid
RiDisplatement(const char *name, ...)
{
    RtInt      n;
    va_list    args;
    RtToken   *tokens;
    RtPointer *params;

    va_start(args, name);

    n = ri_util_paramlist_build(args, &tokens, &params);

    va_end(args);

    RiDisplacementV(name, n, tokens, params);

    ri_util_paramlist_free(tokens, params);
}
Beispiel #3
0
void WriteMaterial(Mat::MaterialFlatten & materialInput, ProcArgs & args)
{
    if (materialInput.empty())
    {
        return;
    }
    
    std::vector<std::string> shaderTypes;
    materialInput.getShaderTypesForTarget("prman", shaderTypes);
    
    
    Mat::MaterialFlatten::ParameterEntryVector paramEntries;
    
    
    ISampleSelector sampleSelector(args.frame / args.fps);
    
    for (std::vector<std::string>::iterator I = shaderTypes.begin();
            I != shaderTypes.end(); ++I)
    {
        const std::string & shaderType = (*I);
        
        std::string shaderName;
        if (!materialInput.getShader("prman", shaderType, shaderName))
        {
            continue;
        }
        
        if (shaderName.empty())
        {
            continue;
        }
        
        ParamListBuilder plb;
        
        materialInput.getShaderParameters("prman", shaderType, paramEntries);
        
        for (Mat::MaterialFlatten::ParameterEntryVector::iterator I =
                paramEntries.begin(); I != paramEntries.end(); ++I)
        {
            //TODO
            Mat::MaterialFlatten::ParameterEntry & entry = (*I);
            
            //#float, double, point, vector, #color, matrix, normal, #string
            
            if (entry.header->isScalar())
            {
                //no ints in RenderMan shaders, make everything a float
                
                if (Abc::IFloatProperty::matches(*entry.header))
                {
                    AddScalarPropertyAsFloatToParamListBuilder<
                            Abc::IFloatProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "float",
                                    plb);
                }
                else if (Abc::IC3fProperty::matches(*entry.header))
                {
                    AddScalarPropertyAsFloatToParamListBuilder<
                            Abc::IC3fProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "color",
                                    plb);
                }
                else if (Abc::IStringProperty::matches(*entry.header))
                {
                    AddScalarPropertyAsStringToParamListBuilder<
                            Abc::IStringProperty>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    plb);
                }
                else if (Abc::IInt32Property::matches(*entry.header))
                {
                    AddScalarPropertyAsFloatToParamListBuilder<
                            Abc::IInt32Property, Abc::uint32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "float",
                                    plb);
                }
                else if (Abc::IBoolProperty::matches(*entry.header))
                {
                    AddScalarPropertyAsFloatToParamListBuilder<
                            Abc::IBoolProperty, Abc::bool_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "float",
                                    plb);
                }
                else if (Abc::IN3fProperty::matches(*entry.header))
                {
                    AddScalarPropertyAsFloatToParamListBuilder<
                            Abc::IN3fProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "normal",
                                    plb);
                }
                else if (Abc::IM44fProperty::matches(*entry.header))
                {
                    AddScalarPropertyAsFloatToParamListBuilder<
                            Abc::IM44fProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "matrix",
                                    plb);
                }
                else if (Abc::IP3fProperty::matches(*entry.header))
                {
                    AddScalarPropertyAsFloatToParamListBuilder<
                            Abc::IP3fProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "point",
                                    plb);
                }
                else if (Abc::IV3fProperty::matches(*entry.header))
                {
                    AddScalarPropertyAsFloatToParamListBuilder<
                            Abc::IV3fProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "vector",
                                    plb);
                }
                
            }
            else if (entry.header->isArray())
            {
                if (Abc::IFloatArrayProperty::matches(*entry.header))
                {
                    AddArrayPropertyAsFloatToParamListBuilder<
                            Abc::IFloatArrayProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "float",
                                    plb);
                }
                else if (Abc::IC3fArrayProperty::matches(*entry.header))
                {
                    AddArrayPropertyAsFloatToParamListBuilder<
                            Abc::IC3fArrayProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "color",
                                    plb);
                }
                else if (Abc::IP3fArrayProperty::matches(*entry.header))
                {
                    AddArrayPropertyAsFloatToParamListBuilder<
                            Abc::IP3fArrayProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "point",
                                    plb);
                }
                else if (Abc::IStringArrayProperty::matches(*entry.header))
                {
                    AddArrayPropertyAsStringToParamListBuilder<
                            Abc::IStringArrayProperty>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    plb);
                }
                else if (Abc::IV3fArrayProperty::matches(*entry.header))
                {
                    AddArrayPropertyAsFloatToParamListBuilder<
                            Abc::IV3fArrayProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "vector",
                                    plb);
                }
                else if (Abc::IN3fArrayProperty::matches(*entry.header))
                {
                    AddArrayPropertyAsFloatToParamListBuilder<
                            Abc::IN3fArrayProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "normal",
                                    plb);
                }
                else if (Abc::IM44fArrayProperty::matches(*entry.header))
                {
                    AddArrayPropertyAsFloatToParamListBuilder<
                            Abc::IM44fArrayProperty, Abc::float32_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "matrix",
                                    plb);
                }
                else if (Abc::IBoolArrayProperty::matches(*entry.header))
                {
                    AddArrayPropertyAsFloatToParamListBuilder<
                            Abc::IBoolArrayProperty, Abc::bool_t>(
                                    entry.parent,
                                    *entry.header,
                                    sampleSelector,
                                    entry.name,
                                    "float",
                                    plb);
                }
                
                
            }
            else
            {
                //skip
            }
        }
        
        if (shaderType == "surface")
        {
            RiSurfaceV(const_cast<RtToken>(shaderName.c_str()),
                    plb.n(), plb.nms(), plb.vals());
        }
        else if (shaderType == "displacement")
        {
            RiDisplacementV(const_cast<RtToken>(shaderName.c_str()),
                    plb.n(), plb.nms(), plb.vals());
        
        }
        else if (shaderType == "interior")
        {
            RiInteriorV(const_cast<RtToken>(shaderName.c_str()),
                    plb.n(), plb.nms(), plb.vals());
        }
        else if (shaderType == "exterior")
        {
            RiExteriorV(const_cast<RtToken>(shaderName.c_str()),
                    plb.n(), plb.nms(), plb.vals());
        }
        else
        {
            std::string coshaderName = shaderType; 
            
            if (shaderType.size() > 9 && shaderType.substr(0, 9) == "coshader_")
            {
                coshaderName = shaderType.substr(9);
            }
            
            RiShader(const_cast<RtToken>(shaderName.c_str()),
                    const_cast<RtToken>(coshaderName.c_str()),
                            plb.n(), plb.nms(), plb.vals());
        }
        
    }
    
    //surface
    //displacement
    //interior
    //exterior
    //coshaders
    
    
    
    
    
    
    
    
    
    
}