游戏开发论坛

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

FX Composer2 draw a texture onto the plane

[复制链接]

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
发表于 2008-3-17 23:49:00 | 显示全部楼层 |阅读模式
I add geometry(the plane) in the Direct3D9 window in FX Composer2.
I assign my "technique2D" to the plane, but I cannot see the texure on the plane.
The "techniaue2D" is the technique of using 2D Coordinate to draw a quad with Texture in a plane.
The "techniaue3D" is the technique of using 3D Coordinate to draw a quad with Texture in a plane.

Could someone tell me how to solve it?

That is my complete source code and FX Composer2 project:
http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/%e5%85%ac%e9%96%8b/Draw2D%20Akira%20FullWindowRegion%20with%20Shader.rar

bool m_bUse3D_Way=false;//<===use 3d coordinate to draw a quad
bool m_bUseShader=true;//<===whether using shader

The four situations of "m_bUse3D_Way" and "m_bUseShader" (true,false) is all right in my C++ program.

My "technique3D" can draw successfully the plane with a texture in FX Composer2. But the "technique2D" seems to be difficult to dtaw the plane with texture. I think my seeting in FX Composer2 maybe have some problems. Could somebody download my source code and FX Composer2 project and help me to find the setting in FX Composer2 project.


  1. texture TestBaseTexture;
  2. sampler tex_2d = sampler_state
  3. {
  4.     Texture = <TestBaseTexture>;
  5.     MinFilter = LINEAR;
  6.     MagFilter = LINEAR;
  7.     MipFilter = NONE;

  8.     AddressU = Clamp;
  9.     AddressV = Clamp;
  10. };

  11. float4x4 WorldViewProj : WorldViewProjection;

  12. struct AK_VS_IN_3D
  13. {
  14.     float4 v4_pos_in: POSITION; // incoming vertex pos
  15.     float2 v2_tc: TEXCOORD0; // incoming texture coordinates
  16. };

  17. struct AK_VS_IN_2D
  18. {
  19.     float2 v2_pos_in: POSITION; // incoming vertex pos
  20.     float2 v2_tc: TEXCOORD0; // incoming texture coordinates
  21. };

  22. struct Ps_TC_IN {
  23.     float4 v4_pos_prj: POSITION;
  24.     float2 v2_tc: TEXCOORD0;
  25. };

  26. struct Ps_DEFAULT_OUT {
  27.     float4 color: COLOR; // output color
  28. };

  29. Ps_TC_IN VsTexture_3D(AK_VS_IN_3D IN)
  30. {
  31.     Ps_TC_IN OUT=(Ps_TC_IN)0;
  32.     OUT.v4_pos_prj=mul(IN.v4_pos_in,WorldViewProj);
  33.   OUT.v2_tc=IN.v2_tc;
  34.     return OUT;
  35. }

  36. Ps_TC_IN VsTexture_2D(AK_VS_IN_2D IN)
  37. {
  38.     Ps_TC_IN OUT=(Ps_TC_IN)0;
  39.     OUT.v4_pos_prj=float4(IN.v2_pos_in, 0, 1);
  40.     OUT.v2_tc=IN.v2_pos_in;
  41.     return OUT;
  42. }

  43. Ps_DEFAULT_OUT PsTexture(Ps_TC_IN IN)
  44. {
  45.     Ps_DEFAULT_OUT OUT;
  46.     OUT.color = tex2D(tex_2d, IN.v2_tc.xy);
  47.     return OUT;
  48. }

  49. technique technique3D {
  50.     pass p0 {
  51.      VertexShader = compile vs_3_0 VsTexture_3D();
  52.      PixelShader = compile ps_3_0 PsTexture();
  53.     }
  54. }

  55. technique technique2D {
  56.     pass p0 {
  57.      VertexShader = compile vs_3_0 VsTexture_2D();
  58.      PixelShader = compile ps_3_0 PsTexture();
  59.     }
  60. }
复制代码

sf_2008317234921.rar

95.48 KB, 下载次数:

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-20 11:09

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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