OGRE Material Script Sample

//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

        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

    }

}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值