USD着色之USD的材质具有的属性


  • 网站研运

    最近在研究USD材质和着色,稍微看了一下USD材质的相关属性。大致了解了USD材质的相关属性。看来USD的材质节点网络是相当复杂的。通过材质的连接,可以做到属性程序化生成。

    具体来说相当复杂,这里先贴个图吧。
    1.png

    它支持下面的材质:

    clearcoat
    clearcoatRoughness
    diffuseColor
    displacement
    emissiveColor
    ior
    metallic
    normal
    occlusion
    opacity
    roughness
    specularColor
    useSpecularWorkflow
    

    这就是我们在USD的例子中进行修改得到的测试文件:

    #usda 1.0
    (
        upAxis = "Y"
    )
    
    def Xform "TexModel" (
        kind = "component"
    )
    {
        def Mesh "card"
        {
            float3[] extent = [(-430, -145, 0), (430, 145, 0)]
            int[] faceVertexCounts = [4]
            int[] faceVertexIndices = [0, 1, 2, 3]
            rel material:binding = </TexModel/boardMat>
            point3f[] points = [(-430, -145, 0), (430, -145, 0), (430, 145, 0), (-430, 145, 0)]
            texCoord2f[] primvars:st = [(0, 0), (1, 0), (1, 1), (0, 1)] (
                interpolation = "varying"
            )
        }
    
        def Material "boardMat"
        {
            token inputs:frame:stPrimvarName = "st"
            token outputs:surface.connect = </TexModel/boardMat/PBRShader.outputs:surface>
    
            def Shader "PBRShader"
            {
                uniform token info:id = "UsdPreviewSurface"
                color3f inputs:diffuseColor.connect = </TexModel/boardMat/diffuseTexture.outputs:rgb>
                float inputs:metallic = 0
                float inputs:roughness = 0.4
                float inputs:opacity = 1
                //float inputs:ior = 0.1
                float inputs:clearcoat = 0.6
                float inputs:clearcoatRoughness = 1
                token outputs:surface
            }
    
            def Shader "stReader"
            {
                uniform token info:id = "UsdPrimvarReader_float2"
                token inputs:varname.connect = </TexModel/boardMat.inputs:frame:stPrimvarName>
                float2 outputs:result
            }
    
            def Shader "diffuseTexture"
            {
                uniform token info:id = "UsdUVTexture"
                asset inputs:file = @USDLogoLrg.png@
                float2 inputs:st.connect = </TexModel/boardMat/stReader.outputs:result>
                float3 outputs:rgb
            }
        }
    }
    

    BTW:我们是用PyCharm做USD的开发哦。有关USD更多的知识我可以稍后整理出来。


Log in to reply
 

走马观花

最近的回复

  • 诶 没有Linux吗??

    read more
  • 萌梦 男孩,女孩,和蛋

    menghome.png

    read more
  • 设计模式-工厂模式

    使用qt/qml来演示设计模式效果,便于学习理解

    1)定义创建对象的接口,封装对象的创建
    2)使具体化类的工作延迟到工厂子类中

    bg.png
    image.png

    1. 工厂类

    createProduct使用了参数来选择要创建哪个产品

    #ifndef FACTORY_H #define FACTORY_H #include <QObject> class Product; class QString; class Factory: public QObject { Q_OBJECT public: virtual ~Factory() = 0; virtual Product* createProduct(QString type) = 0; protected: Factory(); }; class ConcreteFactory: public Factory { Q_OBJECT public: ~ConcreteFactory(); ConcreteFactory(); public slots: Product* createProduct(QString type); }; #endif // FACTORY_H #include "factory.h" #include "product.h" #include <QtQml/qqml.h> Factory::~Factory() { } Factory::Factory() { qmlRegisterType<Product>("Product", 1, 0, "Product"); } ConcreteFactory::~ConcreteFactory() { } ConcreteFactory::ConcreteFactory() { } Product *ConcreteFactory::createProduct(QString type) { if(type == "boy") return static_cast<Product *>(new ConcreteProduct1()); else if(type == "girl") return static_cast<Product *>(new ConcreteProduct2()); return static_cast<Product *>(new ConcreteProduct1()); } 2 产品类

    一个产品是萌梦男,一个产品是萌梦女

    #ifndef PRODUCT_H #define PRODUCT_H #include <QObject> class Product: public QObject { Q_OBJECT public: virtual ~Product() = 0; Q_PROPERTY(QString icon READ icon NOTIFY iconChanged) QString m_icon; QString icon() const { return m_icon; } signals: void iconChanged(QString icon); protected: Product(); signals: public slots: }; class ConcreteProduct1: public Product { Q_OBJECT public: ~ConcreteProduct1(); ConcreteProduct1(); }; class ConcreteProduct2: public Product { Q_OBJECT public: ~ConcreteProduct2(); ConcreteProduct2(); }; #endif // PRODUCT_H #include "product.h" Product::~Product() { } Product::Product() { } ConcreteProduct1::~ConcreteProduct1() { } ConcreteProduct1::ConcreteProduct1() { m_icon = "qrc:/images/boy.png"; } ConcreteProduct2::~ConcreteProduct2() { } ConcreteProduct2::ConcreteProduct2() { m_icon = "qrc:/images/girl.png"; } 3. main.qml

    使用timer,canvas,listview等实现一个自动化生产的动画效果

    源代码

    Fork me on Gitee

    read more
  • blender建模 章鱼
    捕获2.PNG 😵

    read more

关注我们

微博
QQ群