QT3D how to use shader with QPhongMaterial



  • auto myEffect =new Qt3DRender::QEffect(MapMaterial);
    auto t1= new Qt3DRender::QTechnique(myEffect);
    auto graphicsApiFilter = t1->graphicsApiFilter();
    auto glpass = new Qt3DRender::QRenderPass(myEffect);
    glpass->setShaderProgram(program);

    t1->addRenderPass(glpass);
    auto keys = new Qt3DRender::QFilterKey();
    keys->setName("renderingStyle");
    keys->setValue("forward");
    
    graphicsApiFilter->setApi(Qt3DRender::QGraphicsApiFilter::OpenGL);
    graphicsApiFilter->setProfile(Qt3DRender::QGraphicsApiFilter::CoreProfile);
    graphicsApiFilter->setMajorVersion(3);
    graphicsApiFilter->setMinorVersion(1);
    myEffect->addTechnique(t1);
     renderer->setVerticesPerPatch(3);
    renderer->setGeometry(geometry); 
    renderer->setPrimitiveType(renderer->Triangles);
    geometry->setParent(entity);
    entity->addComponent(renderer);
    

    MapMaterial->setEffect(myEffect);

     entity->addComponent(MapMaterial);
    

    it is my snipet but it dont work.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.