• 每天花30分钟看OGRE(14)试验模型边缘高亮


    15.试验模型边缘高亮

    为什么只能看到绿色的呢?

    Vertex_program没起作用?

    注释掉vs还不行。

    找到原因了,原来是被绿色盖住了。

    void edgeHighLight_vp(float4 position : POSITION,

    float3 normal : NORMAL,

    out float4 oPosition : POSITION,

    uniform float4x4 worldViewProj)

    {

    //oPosition = float4(position.xyz + normal * 0.6f, 1);

    oPosition = float4(position.x + 70.0f, position.yzw);

    oPosition = mul(worldViewProj, oPosition);

    }

    改了后就能看到两个pass都绘制了。

    clip_image002

    并不是没有法线,noramls true

    clip_image004

    改成cull_hardware anticlockwise就正常了。这个就是原因了!

    clip_image006

     放在Example.meterial里

    代码
    vertex_program Examples/EdgeHighLightVS hlsl
    {
        source EdgeHighLightVS.hlsl
        entry_point edgeHighLight_vp
        target vs_1_1
        
        default_params
        {
            param_named_auto worldViewProj worldviewproj_matrix
        }
    }

    fragment_program Examples
    /EdgeHighLightPS hlsl
    {
        source EdgeHighLightPS.hlsl
        entry_point edgeHighLight_fp
        target ps_2_0
        
        default_params
        {
        }
    }

    material Examples
    /EnvMappedRustySteelEdgeHighLight
    {
        technique
        {    
            pass
            {
                cull_hardware anticlockwise
                
                vertex_program_ref Examples
    /EdgeHighLightVS
                {
                }
                
                fragment_program_ref Examples
    /EdgeHighLightPS
                {
                }
            }
            
            pass
            {
                cull_hardware none
                
    //polygon_mode wireframe
                
                texture_unit
                {
                    texture RustySteel.jpg
                }

                texture_unit
                {
                    texture spheremap.png
                    colour_op_ex add src_texture src_current
                    colour_op_multipass_fallback one one
                    env_map spherical
                }
            }
        }
    }

     EdgeHighLightVS.hlsl

     代码

    void edgeHighLight_vp(float4 position : POSITION,
                          float3 normal      : NORMAL,
                              
                          
    out float4 oPosition : POSITION,
                          uniform float4x4 worldViewProj)
    {
        oPosition 
    = float4(position.xyz + normal * 0.6f1);
        
    //oPosition = float4(position.x, position.yzw);
        oPosition = mul(worldViewProj, oPosition);
    }

     EdgeHighLightPS.hlsl

     void edgeHighLight_fp(out float4 colour : COLOR)

    {

    colour = float4(0, 1, 0, 1);

    }


    代码
        // Just override the mandatory create scene method
        void createScene(void)
        {
            
    // Set ambient light
            mSceneMgr->setAmbientLight(ColourValue(0.50.50.5));
            
    // Create a point light
            Light* l = mSceneMgr->createLight("MainLight");
            
    // Accept default settings: point light, white diffuse, just set position
            
    // NB I could attach the light to a SceneNode if I wanted it to move automatically with
            
    //  other objects, but I don't
            l->setPosition(20,80,50);
            Entity 
    *ent = mSceneMgr->createEntity("head""ogrehead.mesh");
            
    // Set material loaded from Example.material
            ent->setMaterialName("Examples/EnvMappedRustySteelEdgeHighLight"); 
            
    // Add entity to the root scene node
            mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);      
        }

    Reference:

     物件的边缘高亮(Entity edge highlight)

  • 相关阅读:
    EffectiveJava(18)接口优先于抽象类
    EffectiveJava(17)要么为继承而设计,要么禁止继承
    EffectiveJava(16)复合优先于继承
    EffectiveJava(15)强化对象和域的不可变性
    EffectiveJava(14)在公有类中使用访问方法而非公有域
    EffectiveJava(13)使类和成员的可访问性最小化
    CentOS 6 安装 MySQL 8.0.+
    Gradle sync failed: Cannot set the value of read-only property 'outputFile'
    Error:Execution failed for task ':xutils:mergeDebugAndroidTestResources'. > No slave process to proc
    Error:All flavors must now belong to a named flavor dimension.
  • 原文地址:https://www.cnblogs.com/lai3d/p/1653128.html
Copyright © 2020-2023  润新知