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
}
}
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
}
}
相关文章推荐
- varnish配置语法(应用)
- 基于PHP与Ajax的表单验证功能
- 查看iOS真机日志
- Linux下RPM软件包的安装及卸载
- 大讲台谈Hive常见的问题及解决方案(二)
- 高性能网络编程(1)—accept建立连接(转载,作者:陶辉)
- SQL复制表结构和数据
- 数组去重
- 堆栈的思考
- cocos 语法错误:“namespace”
- 外修语言 内修算法 加油啊
- html5 file调用一般处理程序上传图片
- 大讲台谈hive(中篇)
- 根据海子blog经过手动验证思考的 final关键字总结
- C# system.web.ui生成html
- 百度地图SnapshotReadyCallback截屏
- 吃完饭继续来码字了 C++ 析构函数 传值,this指针
- 自定义类型转换器
- 打破Android应用65K方法数魔咒
- Android4.0-Fragment框架实现方式剖析