您的位置:首页 > 其它

OGRE Material Script Sample

2015-08-06 13:55 211 查看
//Sample 0
Example_Basic.cg文件

//
...
void basicPassthroughNormal_v(float4 position : POSITION,

float3 normal  : NORMAL,
 out float4 oPosition : POSITION,
 out float3 oNormal  : TEXCOORD0,
 uniform float4x4
worldViewProj)
{

oPosition = mul(worldViewProj, position);
oNormal = normal;

}

// Basic fragment program to display 3d uv

float4 showuvdir3d_p (float4 position : POSITION, float3 uv : TEXCOORD0) : COLOR

{
float3 n = normalize(uv);
return float4(n.x, n.y, n.z, 1);

}

material文件
vertex_program
Examples/ShowNormals_v cg
{

source Example_Basic.cg
//见上边
entry_point basicPassthroughNormal_v  
//source 文件的入口函数
profiles vs_2_0 arbvp1
//Cg如何将程序编译为低级的汇编程序
default_params
{

param_named_auto
worldViewProj worldviewproj_matrix

}

}

fragment_programExamples/ShowUVdir3D cg

{

source Example_Basic.cg
entry_point showuvdir3d_p
profiles ps_2_0 arbfp1

}

material Examples/ShowNormals

{

technique
{

pass

{

vertex_program_ref Examples/ShowNormals_v  //this can also be the full name of a glsl file, eg. Ogre/BasicVertexPrograms/AmbientOneTexture

{

//put shader uniform parameters her//param_named_auto ambient ambient_light_colour//param_named ambient float4 1 1 1 1

}

fragment_program_ref
Examples/ShowUVdir3D

{

//put shader uniform parameters here

}

}

}

}

//Sample 1

material walls/funkywall1
{
    // first, preferred technique. 固定功能着色(fixed-function shading)管线
    technique
    {
        // first pass

4000
        pass
        {
            ambient 0.5 0.5 0.5
            diffuse 1.0 1.0 1.0

            // Texture unit 0
            texture_unit 
            {
                texture wibbly.jpg
                scroll_anim 0.1 0.0
                wave_xform scale sine 0.0 0.7 0.0 1.0
            }
            // Texture unit 1 (this is a multitexture pass)
            texture_unit
            {
                texture wobbly.png
                rotate_anim 0.25
                colour_op add
            }
        }
    }

    // Second technique, can be used as a fallback or LOD level
    technique
    {
        // .. and so on
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: