MCPcopy Create free account
hub / github.com/ImageEngine/cortex / expandRamp

Function expandRamp

src/IECoreScene/ShaderNetworkAlgo.cpp:820–854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818
819template<typename Ramp>
820int expandRamp( const InternedString &name, const Ramp &ramp, CompoundDataMap &newParameters, const std::string &shaderName )
821{
822 StringDataPtr basisData = new StringData();
823 std::string &basis = basisData->writable();
824
825 typedef TypedData< vector<typename Ramp::XType> > XTypedVectorData;
826 typename XTypedVectorData::Ptr positionsData = new XTypedVectorData();
827 auto &positions = positionsData->writable();
828 positions.reserve( ramp.points.size() );
829 typedef TypedData< vector<typename Ramp::YType> > YTypedVectorData;
830 typename YTypedVectorData::Ptr valuesData = new YTypedVectorData();
831 auto &values = valuesData->writable();
832
833 ramp.toOSL( basis, positions, values );
834
835 auto [ positionsSuffix, floatValuesSuffix, colorValuesSuffix, basisSuffix, countSuffix ] = lookupRampParameterSuffixes( shaderName );
836
837 newParameters[ name.string() + *positionsSuffix ] = positionsData;
838 if constexpr( std::is_same_v< typename Ramp::YType, float > )
839 {
840 newParameters[ name.string() + *floatValuesSuffix ] = valuesData;
841 }
842 else
843 {
844 newParameters[ name.string() + *colorValuesSuffix ] = valuesData;
845 }
846 newParameters[ name.string() + *basisSuffix ] = basisData;
847
848 if( countSuffix )
849 {
850 newParameters[ name.string() + *countSuffix ] = new IntData( positionsData->readable().size() );
851 }
852
853 return positionsData->readable().size();
854}
855
856void ensureParametersCopy(
857 const IECore::CompoundDataMap &parameters,

Callers 1

expandRampsMethod · 0.85

Calls 5

toOSLMethod · 0.80
readableMethod · 0.80
writableMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected