nm_notex_ps.hlsl
上传用户:xhbjoy
上传日期:2014-10-07
资源大小:38068k
文件大小:2k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. /******************************************************************************
  2. Copyright (c) W.J. van der Laan
  3. Permission is hereby granted, free of charge, to any person obtaining a copy of 
  4. this software  and associated documentation files (the "Software"), to deal in 
  5. the Software without restriction, including without limitation the rights to use, 
  6. copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
  7. Software, and to permit persons to whom the Software is furnished to do so, subject 
  8. to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all copies 
  10. or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
  12. INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
  13. PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
  14. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
  15. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE 
  16. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. ******************************************************************************/
  18. /** Deferred shading framework
  19. // W.J. :wumpus: van der Laan 2005 //
  20. Material shader: Single colour normal mapped
  21. */
  22. sampler Tex0: register(s0);
  23. struct OUTPUT
  24. {
  25. float4 color0 : COLOR0; // Diffuse color + ?
  26. float4 color1 : COLOR1; // Normal + depth
  27. };
  28. float3 colour;
  29. float specularity;
  30. OUTPUT main(
  31. float3 normal: TEXCOORD0,
  32. float4 texCoord0: TEXCOORD1,
  33. float depth: TEXCOORD2,
  34. float3 tangent: TEXCOORD3,
  35. float3 binormal: TEXCOORD4
  36. )
  37. {
  38. OUTPUT output;
  39. // Frame for normal mapping
  40. float3x3 rotation = float3x3(tangent, binormal, normal);
  41. float3 texnormal = (tex2D(Tex0, texCoord0)-0.5)*2;
  42. output.color0.rgb = colour;
  43. output.color0.a = specularity;
  44. output.color1.xyz = normalize(mul(texnormal,rotation)); // Do normalisation here, saves an operation per light
  45. output.color1.w = depth;
  46. return output;
  47. }