游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1772|回复: 2

使用Effect时出现的问题(龙书第19章)

[复制链接]

21

主题

39

帖子

41

积分

注册会员

Rank: 2

积分
41
发表于 2011-4-26 15:51:00 | 显示全部楼层 |阅读模式
这是龙书第19章的练习,根据提供的代码,新建了一个工程,但是运行时出现了如下的错误,是怎么回事?

...\tooneffect.fx(45.16):error x3025:global variables are implicitly constant,enable compatibility mode to
allow modification

21

主题

39

帖子

41

积分

注册会员

Rank: 2

积分
41
 楼主| 发表于 2011-4-26 15:56:00 | 显示全部楼层

Re: 使用Effect时出现的问题(龙书第19章)

附件如下:
重复了。。。怎么删除多余的?

1

主题

11

帖子

11

积分

新手上路

Rank: 1

积分
11
发表于 2011-4-26 21:03:00 | 显示全部楼层

Re:使用Effect时出现的问题(龙书第19章)

这个论坛之前有人说过了·······

error X3025: global variables are implicitly constant, enable compatibility mode to allow modification

全局变量是extern也是常量,在shader里面不能修改,但可以从宿主程序里改。
以前的编译器没有强制这一点,新DirectX版本强化了这一要求。





解决方法:

extern的值不能修改  也就是说错误是因为该shader修改了。
new一个vector/float4 然后把不能修改的赋值

源程序代码相关部分替换示例代码:

//////////////////////////////////////////////////////////////////////////////////////
    float4 LD=LightDirection;

    LD.w = 0.0f;
    input.normal.w   = 0.0f;
    LD   = mul(LD, WorldViewMatrix);
    input.normal     = mul(input.normal, WorldViewMatrix);

    //
    // Compute the 1D texture coordinate for toon rendering.
    //
    float u = dot(LD, input.normal);
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-6-7 19:39

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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