⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shader.h

📁 基于GPU进行快速科学计算
💻 H
字号:
/******************************************************************************\

  Copyright 2005 The University of North Carolina at Chapel Hill.
  All Rights Reserved.

  Permission to use, copy, modify and distribute this software and its
  documentation for educational, research and non-profit purposes, without
  fee, and without a written agreement is hereby granted, provided that the
  above copyright notice and the following three paragraphs appear in all
  copies. Any use in a commercial organization requires a separate license.

  IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE LIABLE
  TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
  ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA HAVE BEEN
  ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.


  Permission to use, copy, modify and distribute this software and its
  documentation for educational, research and non-profit purposes, without
  fee, and without a written agreement is hereby granted, provided that the
  above copyright notice and the following three paragraphs appear in all
  copies.

  THE UNIVERSITY OF NORTH CAROLINA SPECIFICALLY DISCLAIM ANY WARRANTIES,
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN
  "AS IS" BASIS, AND THE UNIVERSITY OF NORTH CAROLINA HAS NO OBLIGATION TO
  PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.


   ---------------------------------
  |Please send all BUG REPORTS to:  |
  |                                 |
  |   geom@cs.unc.edu               |
  |                                 |
   ---------------------------------


  The authors may be contacted via:

  US Mail:         N. Govindaraju or D. Manocha
                       Department of Computer Science
                       Sitterson Hall, CB #3175
                       University of North Carolina
                       Chapel Hill, NC 27599-3175

\*****************************************************************************/
/******************************************************************************\

  Copyright 2005 The University of North Carolina at Chapel Hill.
  All Rights Reserved.

  Permission to use, copy, modify and distribute this software and its
  documentation for educational, research and non-profit purposes, without
  fee, and without a written agreement is hereby granted, provided that the
  above copyright notice and the following three paragraphs appear in all
  copies. Any use in a commercial organization requires a separate license.

  IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE LIABLE
  TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
  ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA HAVE BEEN
  ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.


  Permission to use, copy, modify and distribute this software and its
  documentation for educational, research and non-profit purposes, without
  fee, and without a written agreement is hereby granted, provided that the
  above copyright notice and the following three paragraphs appear in all
  copies.

  THE UNIVERSITY OF NORTH CAROLINA SPECIFICALLY DISCLAIM ANY WARRANTIES,
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN
  "AS IS" BASIS, AND THE UNIVERSITY OF NORTH CAROLINA HAS NO OBLIGATION TO
  PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.


   ---------------------------------
  |Please send all BUG REPORTS to:  |
  |                                 |
  |   geom@cs.unc.edu               |
  |                                 |
   ---------------------------------


  The authors may be contacted via:

  US Mail:         N. Govindaraju, N. Raghuvanshi or D. Manocha
                       Department of Computer Science
                       Sitterson Hall, CB #3175
                       University of North Carolina
                       Chapel Hill, NC 27599-3175

\*****************************************************************************/

char copyfptext[]="!!ARBfp1.0\n"
"OPTION ATI_draw_buffers;\n"
"PARAM c[1] = { program.local[0] };\n"
"TEX result.color[1], fragment.texcoord[0], texture[3], RECT;\n"
"TEX result.color, fragment.texcoord[0], texture[2], RECT;\n"
"END\n";


char fullscreenfft1ststagetext[]="!!ARBfp1.0\n"
"OPTION ATI_draw_buffers;\n"
"PARAM c[1] = { { 0.5, -1, 1 } };\n"
"TEMP R0;\n"
"TEMP R1;\n"
"TEMP R2;\n"
"TEMP R3;\n"
"FRC R0.x, fragment.texcoord[0].y;\n"
"ADD R0.z, R0.x, -c[0].x;\n"
"MOV R1.xy, fragment.texcoord[2];\n"
"ADD R0.xy, fragment.texcoord[1], R1;\n"
"CMP R1.w, -R0.z, c[0].y, c[0].z;\n"
"CMP R2.xy, R1.w, R0, fragment.texcoord[1];\n"
"ADD R1.xy, fragment.texcoord[0], R1;\n"
"FRC R1.z, fragment.texcoord[0].x;\n"
"ADD R3.x, R1.z, -c[0];\n"
"CMP R2.zw, R1.w, R1.xyxy, fragment.texcoord[0].xyxy;\n"
"CMP R3.x, -R3, c[0].y, c[0].z;\n"
"TEX R0, R2, texture[3], RECT;\n"
"TEX R1, R2.zwzw, texture[3], RECT;\n"
"CMP R1.xy, -R3.x, R1, R1.zwzw;\n"
"CMP R0.xy, -R3.x, R0, R0.zwzw;\n"
"MAD result.color[1], R0.xxyy, c[0].zyzy, R1.xxyy;\n"
"TEX R0, R2.zwzw, texture[2], RECT;\n"
"CMP R0.xy, -R3.x, R0, R0.zwzw;\n"
"TEX R1, R2, texture[2], RECT;\n"
"CMP R0.zw, -R3.x, R1.xyxy, R1;\n"
"MAD result.color, R0.zzww, c[0].zyzy, R0.xxyy;\n"
"END\n";

char fullscreenfft2ndstagefptext[]="!!ARBfp1.0\n"
"OPTION ATI_draw_buffers;\n"
"PARAM c[1] = { { 0.5, -1, 1 } };\n"
"TEMP R0;\n"
"TEMP R1;\n"
"TEMP R2;\n"
"TEMP R3;\n"
"TEMP R4;\n"
"FRC R0.z, fragment.texcoord[0].y;\n"
"ADD R1.x, R0.z, -c[0];\n"
"MOV R0.xy, fragment.texcoord[2];\n"
"ADD R0.zw, fragment.texcoord[0].xyxy, R0.xyxy;\n"
"CMP R2.y, -R1.x, c[0], c[0].z;\n"
"CMP R0.zw, R2.y, R0, fragment.texcoord[0].xyxy;\n"
"FRC R2.x, fragment.texcoord[0];\n"
"ADD R3.x, R2, -c[0];\n"
"ADD R0.xy, fragment.texcoord[1], R0;\n"
"CMP R0.xy, R2.y, R0, fragment.texcoord[1];\n"
"CMP R4.z, -R3.x, c[0].y, c[0];\n"
"TEX R1, R0.zwzw, texture[2], RECT;\n"
"TEX R2, R0, texture[2], RECT;\n"
"CMP R4.xy, -R4.z, R2, R2.zwzw;\n"
"CMP R1.xy, -R4.z, R1, R1.zwzw;\n"
"MUL R2, fragment.texcoord[3].xyxy, c[0].zzyy;\n"
"MAD R3, R4.xyxy, R2, R1.xyxy;\n"
"TEX R1, R0.zwzw, texture[3], RECT;\n"
"TEX R0, R0, texture[3], RECT;\n"
"CMP R1.xy, -R4.z, R1, R1.zwzw;\n"
"CMP R4.zw, -R4.z, R0.xyxy, R0;\n"
"MUL R0, fragment.texcoord[4].xyxy, c[0].zzyy;\n"
"MAD R1, R4.zwzw, R2, R1.xyxy;\n"
"MAD result.color[1], R4.xyxy, R0, R1;\n"
"MAD result.color, -R4.zwzw, R0, R3;\n"
"END\n";

//column-aligned addition
char fftstages3_to_rowwidthfptext[]="!!ARBfp1.0\n"
"OPTION ATI_draw_buffers;\n"
"PARAM c[1] = { { 0.5 } };\n"
"TEMP R0;\n"
"TEMP R1;\n"
"TEMP R2;\n"
"TEMP R3;\n"
"TEMP R4;\n"
"TEMP R5;\n"
"TEMP R6;\n"
"FRC R0.x, fragment.texcoord[0].y;\n"
"MOV R6.yz, fragment.texcoord[0];\n"
"MOV R0.y, fragment.texcoord[0].x;\n"
"ADD R0.x, R0, -c[0];\n"
"CMP R6.x, -R0, fragment.texcoord[1], R0.y;\n"
"TEX R2, R6.xzzw, texture[2], RECT;\n"
"SIN R4.x, fragment.texcoord[1].y;\n"
"SIN R4.y, fragment.texcoord[1].z;\n"
"SIN R4.w, fragment.texcoord[2].y;\n"
"SIN R4.z, fragment.texcoord[2].x;\n"
"MUL R0, R2, R4;\n"
"TEX R1, R6.xzzw, texture[3], RECT;\n"
"COS R3.x, fragment.texcoord[1].y;\n"
"COS R3.y, fragment.texcoord[1].z;\n"
"COS R3.z, fragment.texcoord[2].x;\n"
"COS R3.w, fragment.texcoord[2].y;\n"
"MAD R5, R1, R3, R0;\n"
"TEX R0, R6, texture[3], RECT;\n"
"MUL R1, R1, R4;\n"
"ADD result.color[3], R0, -R5;\n"
"ADD result.color[1], R0, R5;\n"
"MAD R0, R2, R3, -R1;\n"
"TEX R1, R6, texture[2], RECT;\n"
"ADD result.color[2], R1, -R0;\n"
"ADD result.color, R1, R0;\n"
"END\n";

char fftstages_twicerowwidth_to_n_fptext[]="!!ARBfp1.0\n"
"OPTION ATI_draw_buffers;\n"
"PARAM c[1] = { program.local[0] };\n"
"TEMP R0;\n"
"TEMP R1;\n"
"TEMP R2;\n"
"TEMP R3;\n"
"TEMP R4;\n"
"TEMP R5;\n"
"TEX R1, fragment.texcoord[1], texture[3], RECT;\n"
"COS R4.x, fragment.texcoord[3].x;\n"
"COS R4.y, fragment.texcoord[3].y;\n"
"COS R4.z, fragment.texcoord[4].x;\n"
"COS R4.w, fragment.texcoord[4].y;\n"
"TEX R2, fragment.texcoord[0], texture[3], RECT;\n"
"TEX R0, fragment.texcoord[1], texture[2], RECT;\n"
"SIN R3.x, fragment.texcoord[3].x;\n"
"SIN R3.y, fragment.texcoord[3].y;\n"
"SIN R3.z, fragment.texcoord[4].x;\n"
"SIN R3.w, fragment.texcoord[4].y;\n"
"MAD R5, -R1, R4, R2;\n"
"MAD result.color[3], -R0, R3, R5;\n"
"MAD R5, R1, R4, R2;\n"
"TEX R2, fragment.texcoord[0], texture[2], RECT;\n"
"MAD result.color[1], R0, R3, R5;\n"
"MAD R5, -R0, R4, R2;\n"
"MAD R0, R0, R4, R2;\n"
"MAD result.color[2], R1, R3, R5;\n"
"MAD result.color, -R1, R3, R0;\n"
"END\n";
//for the single quad for all rows of size Width
char fullscreenrowwidthfptext[]="!!ARBfp1.0\n"
"OPTION ATI_draw_buffers;\n"
"PARAM c[1] = { { 0.5, -1, 1 } };\n"
"TEMP R0;\n"
"TEMP R1;\n"
"TEMP R2;\n"
"TEMP R3;\n"
"TEMP R4;\n"
"TEMP R5;\n"
"TEMP R6;\n"
"FRC R6.x, fragment.texcoord[0].y;\n"
"ADD R6.x, R6, -c[0];\n"
"TEX R0, fragment.texcoord[1], texture[3], RECT;\n"
"TEX R1, fragment.texcoord[1], texture[2], RECT;\n"
"SIN R4.x, fragment.texcoord[3].x;\n"
"SIN R4.y, fragment.texcoord[3].y;\n"
"SIN R4.w, fragment.texcoord[4].y;\n"
"SIN R4.z, fragment.texcoord[4].x;\n"
"MUL R2, R1, R4;\n"
"COS R3.x, fragment.texcoord[3].x;\n"
"COS R3.y, fragment.texcoord[3].y;\n"
"COS R3.z, fragment.texcoord[4].x;\n"
"COS R3.w, fragment.texcoord[4].y;\n"
"MAD R5, R0, R3, R2;\n"
"TEX R2, fragment.texcoord[0], texture[3], RECT;\n"
"CMP R6.x, -R6, c[0].y, c[0].z;\n"
"MAD result.color[1], R6.x, R5, R2;\n"
"MUL R2, R0, R4;\n"
"TEX R0, fragment.texcoord[0], texture[2], RECT;\n"
"MAD R1, R1, R3, -R2;\n"
"MAD result.color, R6.x, R1, R0;\n"
"END\n";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -