游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1766|回复: 0

关于OGRE使用HLSL的问题

[复制链接]

3

主题

4

帖子

8

积分

新手上路

Rank: 1

积分
8
发表于 2009-10-6 07:59:00 | 显示全部楼层 |阅读模式
HLSL脚本

static float3 vLight={-0.12f,0.4f,0.4f};
extern matrix mWVP;
struct CVS_INPUT
{
float4 Position : POSITION; //float4
float3 Normal : NORMAL; //float3
float2 TexCoord : TEXCOORD0;
};
struct CVS_OUTPUT
{
float4 Position : POSITION;
float3 Texcoord : TEXCOORD0;
};

CVS_OUTPUT vs_main( CVS_INPUT Input)
{
CVS_OUTPUT Output = (CVS_OUTPUT)0;
Output.Position = mul(mWVP, Input.Position );

float3 light = normalize(vLight);
float3 normal = normalize(Input.Normal);
Output.Texcoord =float3(Input.TexCoord,0);
float ndl = float(saturate(dot(light, normal)));
Output.Texcoord.z=ndl;
return Output;
}
------------------------------------
file: CartoonRenderPS.hlsl:

sampler Texture :register(s1);
sampler CelMap :register(s0);
struct PS_INPUT
{
float3 TexCoord : TEXCOORD0;
};

float4 ps_main( PS_INPUT Input ) : COLOR0
{

float4 ndl=tex2D(CelMap, float2(Input.TexCoord.z,0.5f));
float4 rnt=tex2D(Texture, Input.TexCoord);
return rnt*ndl.x;
}
------------------------------
材质脚本


vertex_program Test/HeaderVS hlsl
{
source CartoonRenderVS.hlsl
entry_point vs_main
target vs_2_0

default_params
{
param_named_auto mWVP worldviewproj_matrix
}
}
fragment_program Test/HeaderPS hlsl
{
source CartoonRenderPS.hlsl
entry_point ps_main
target ps_2_0
}

material Test/Header
{
technique
{
pass
{
//lighting off
depth_write off
vertex_program_ref Test/HeaderVS
{
}
fragment_program_ref Test/HeaderPS
{
}

texture_unit Texture
{
tex_coord_set 0
texture clouds.jpg
tex_address_mode clamp
filtering none

}
texture_unit CelMap
{
tex_coord_set 1
CartoonRenderShader.bmp
tex_address_mode clamp
filtering none

}

}
}
}


使用:

Ogre::Entity* ent;
ent = pScence->createEntity("head", "ogrehead.mesh");
ent->setMaterialName("Test/Header");
ent->getMesh().get()->getSubMesh(0)->setBuildEdgesEnabled(TRUE);
pScence->getRootSceneNode()->createChildSceneNode()->attachObject(ent);

没用啊 模型连纹理都没了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-20 06:34

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表