Пример #1
0
	void Renderer::shader_volume(
		const liqShader &shader, 
		const std::vector<liqTokenPointer> &tokenPointerArray
		)
	{
		CM_TRACE_FUNC("Renderer::shader_volume("<<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() );

		//RiAtmosphereV ( const_cast<char *>(shader.getShaderFileName().c_str()), shaderParamCount,  tokenArray.get(), pointerArray.get() );
		switch ( shader.volume_type )
		{
		case VOLUME_TYPE_INTERIOR:
			if ( shader.useVisiblePoints ){
				//RiVPInteriorV ( const_cast<char *>(shader.getShaderFileName().c_str()), shaderParamCount, tokenArray.get(), pointerArray.get() ); 
				RiArchiveRecord( RI_COMMENT, "RiVPInteriorV is not implemented in maya2renderer, useVisiblePoints is added by ymesh in r777" );
			}else{
				RiInteriorV ( const_cast<char *>(shader.getShaderFileName().c_str()), shaderParamCount, tokenArray.get(), pointerArray.get() ); 
			}break;
		case VOLUME_TYPE_EXTERIOR:
			if ( shader.useVisiblePoints ){
				RiArchiveRecord( RI_COMMENT, "useVisiblePoints is added by ymesh in r777" );
#ifdef GENERIC            
				RiVPExteriorV ( const_cast<char *>(shader.getShaderFileName().c_str()), shaderParamCount, tokenArray.get(), pointerArray.get() );
#else
				// Atleast Prman 16.x haven't this function
				RiExteriorV ( const_cast<char *>(shader.getShaderFileName().c_str()), shaderParamCount, tokenArray.get(), pointerArray.get() );  
#endif  
			}else{
				RiExteriorV ( const_cast<char *>(shader.getShaderFileName().c_str()), shaderParamCount, tokenArray.get(), pointerArray.get() ); 
			}break;
		case VOLUME_TYPE_ATMOSPHERE:
		default:
			if ( shader.useVisiblePoints ){
				//RiVPAtmosphereV ( const_cast<char *>(shader.getShaderFileName().c_str()), shaderParamCount, tokenArray.get(), pointerArray.get() ); 
				RiArchiveRecord( RI_COMMENT, "RiVPAtmosphereV is not implemented in maya2renderer, useVisiblePoints is added by ymesh in r777" );
			}else{
				RiAtmosphereV ( const_cast<char *>(shader.getShaderFileName().c_str()), shaderParamCount, tokenArray.get(), pointerArray.get() ); 
			}break;
		}
	}
Пример #2
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
    
    
    
    
    
    
    
    
    
    
}