本文整理汇总了C++中ShaderNode类的典型用法代码示例。如果您正苦于以下问题:C++ ShaderNode类的具体用法?C++ ShaderNode怎么用?C++ ShaderNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ShaderNode类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShaderNode
ShaderNode* ShaderNode::shaderNodeWithVertex(const char *vert, const char *frag)
{
ShaderNode *node = new ShaderNode();
node->initWithVertex(vert, frag);
node->autorelease();
return node;
}
示例2: ShaderNode
ShaderNode* ShaderNode::createWithWH(float w, float h)
{
ShaderNode* result = new ShaderNode();
if (result && result->initWithWH(w, h))
result->autorelease();
else {
delete result;
result = nullptr;
}
return result;
}
示例3: ShaderNode
ShaderNode* ShaderNode::shaderNodeWithVertex(const char *vert, const char *frag)
{
ShaderNode* shader = new ShaderNode();
if (shader && shader->initWithVertex(vert, frag))
{
shader->autorelease();
return shader;
}
CC_SAFE_DELETE(shader);
return nullptr;
}
示例4: setInputPortConnectionItem
void ShaderNodeUI::setInputPortConnectionItem(unsigned int index, ShaderConnectionUI* pItem)
{
m_aInputPortConnectionItems[index] = pItem;
// set the internal connection output nodes as well...
if (pItem && pItem->getSourceNode() && pItem->getSourceNodePortIndex() != -1)
{
ShaderNode* pActualSourceNode = pItem->getSourceNode()->getActualNode();
std::vector<ShaderNode::OutputShaderPort>& outPorts = pActualSourceNode->getOutputPorts();
unsigned int sourcePortIndex = pItem->getSourceNodePortIndex();
}
}
示例5: init
bool ShaderPlasma::init()
{
if (ShaderTestDemo::init())
{
ShaderNode *sn = ShaderNode::shaderNodeWithVertex("Shaders/example_Plasma.vsh", "Shaders/example_Plasma.fsh");
CCSize s = CCDirector::sharedDirector()->getWinSize();
sn->setPosition(ccp(s.width/2, s.height/2));
addChild(sn);
return true;
}
return false;
}
示例6: ShaderGraph
void BlenderSync::sync_lamps(bool update_all)
{
shader_map.set_default(scene->default_light);
/* lamp loop */
BL::BlendData::lamps_iterator b_lamp;
for(b_data.lamps.begin(b_lamp); b_lamp != b_data.lamps.end(); ++b_lamp) {
Shader *shader;
/* test if we need to sync */
if(shader_map.sync(&shader, *b_lamp) || update_all) {
ShaderGraph *graph = new ShaderGraph();
/* create nodes */
if(b_lamp->use_nodes() && b_lamp->node_tree()) {
shader->name = b_lamp->name().c_str();
BL::ShaderNodeTree b_ntree(b_lamp->node_tree());
add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree);
}
else {
float strength = 1.0f;
if(b_lamp->type() == BL::Lamp::type_POINT ||
b_lamp->type() == BL::Lamp::type_SPOT ||
b_lamp->type() == BL::Lamp::type_AREA)
{
strength = 100.0f;
}
EmissionNode *emission = new EmissionNode();
emission->color = get_float3(b_lamp->color());
emission->strength = strength;
graph->add(emission);
ShaderNode *out = graph->output();
graph->connect(emission->output("Emission"), out->input("Surface"));
}
shader->set_graph(graph);
shader->tag_update(scene);
}
}
}
示例7: server_update
void ShaderManager::server_update(::OctaneEngine::OctaneClient *server, Scene *scene, Progress& progress) {
if(!need_update) return;
size_t cnt = scene->shaders.size();
if(!cnt) return;
for(size_t i = 0; i < cnt; ++i) {
Shader *shader = scene->shaders[i];
if(!shader->need_update) continue;
if(!shader->graph) continue;
for(list<ShaderNode*>::iterator it = shader->graph->nodes.begin(); it != shader->graph->nodes.end(); ++it) {
ShaderNode *node = *it;
if(node->input("Surface")) continue;
node->load_to_server(server);
}
shader->need_update = false;
}
need_update = false;
} //server_update()
示例8: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
ShaderNode *sn = ShaderNode::create("shaders/flame.vsh", "shaders/flame.fsh");
sn->setPosition(Point(visibleSize.width/2, visibleSize.height/2));
sn->setContentSize(Size(visibleSize.width, visibleSize.height));
addChild(sn);
//
// Sprite* sprite = Sprite::create("HelloWorld.png");
// sprite->setPosition(Point(visibleSize.width/2, visibleSize.height/2));
// addChild(sprite);
return true;
}
示例9: isNodeSupported
bool isNodeSupported(MString typeName, ShaderNode& sn, MObject& shaderObject)
{
std::string tn(typeName.asChar());
if(mtm_findShaderTypeByName(tn, sn))
{
sn.shaderObject = shaderObject;
sn.mayaName = getObjectName(shaderObject);
sn.setPlugShaderName();
return true;
}
logger.debug(MString("Shader type ") + typeName + " not yet supported");
return false;
}
示例10: mtm_readShaderDefs
bool mtm_readShaderDefs()
{
std::string homeDir = getenv("MTM_HOME");
std::string shaderDefFile = homeDir + "/ressources/shaderDefinitions.txt";
std::ifstream shaderFile(shaderDefFile.c_str());
if( !shaderFile.good())
{
logger.error(MString("Unable to open shaderInfoFile ") + MString(shaderDefFile.c_str()));
shaderFile.close();
return false;
}
String line;
StringArray stringArray;
ShaderNode currentNode;
int lineNumber = -1;
do{
std::getline(shaderFile, line);
lineNumber++;
if( line.length() > 0 )
{
// get rid of any spaces and newlines
line = pystring::strip(line);
if( line.length() == 0)
continue;
line = pystring::replace(line, " ", "");
// filtering comments
if(pystring::startswith(line, "#"))
continue;
if( pystring::count(line, ":") > 0)
{
pystring::split(line, stringArray, ":");
}
if(pystring::startswith(line, "name"))
{
if( stringArray.size() > 1 )
{
currentNode.mayaName = MString(stringArray[1].c_str());
currentNode.mayaTypeName = currentNode.mayaName;
currentNode.internalTypeName = currentNode.mayaName.substring(1,currentNode.mayaName.length() - 1);
}
}
if(pystring::startswith(line, "shader_start"))
{
if( stringArray.size() > 1 )
{
ShaderNode sn;
if(mtm_findShaderNodeByName(stringArray[1], sn))
{
logger.debug(MString("Found parent Node ") + sn.mayaTypeName);
currentNode = sn; // simply copy existing node into this and continue to build
}
}
}
if(pystring::startswith(line, "inatt"))
{
if( stringArray.size() > 3 )
{
currentNode.addInPlug(stringArray[1], stringArray[2], stringArray[3]);
}else{
logger.error(MString("Error: not enough arguments in line ") + lineNumber + "! Expecting 4 Values, got " + (int)stringArray.size());
}
}
if(pystring::startswith(line, "outatt"))
{
if( stringArray.size() > 2 )
{
currentNode.addOutPlug(stringArray[1], stringArray[2]);
}else{
logger.error(MString("Error: not enough arguments in line ") + lineNumber + "! Expecting 3 Values, got " + (int)stringArray.size());
}
}
// there exist some special pass through attributes like displacement in a displacementShader. These are in and output attributes with
// the same name. Bad for me...
if(pystring::startswith(line, "inoutatt"))
{
if( stringArray.size() > 2 )
{
currentNode.addOutPlug(stringArray[1], stringArray[2]);
currentNode.outPlugs[currentNode.outPlugs.size() - 1].isInOut = true;
}else{
logger.error(MString("Error: not enough arguments in line ") + lineNumber + "! Expecting 3 Values, got " + (int)stringArray.size());
}
}
if(pystring::endswith(line, "shader_end"))
{
mtm_ShaderDefinitions.push_back(currentNode);
// clean new node
currentNode = ShaderNode();
}
}
}while(!shaderFile.eof());
//.........这里部分代码省略.........