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

📄 slang_common_builtin.gc

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 GC
📖 第 1 页 / 共 3 页
字号:
/* * Mesa 3-D graphics library * Version:  6.5 * * Copyright (C) 2006  Brian Paul   All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *///// From Shader Spec, ver. 1.10, rev. 59////bp: XXX these will probably go away since the value needs to be//determined at runtime and may vary from one GLcontext to another...const int gl_MaxLights = 8;const int gl_MaxClipPlanes = 6;const int gl_MaxTextureUnits = 8;const int gl_MaxTextureCoords = 8;const int gl_MaxVertexAttribs = 16;const int gl_MaxVertexUniformComponents = 512;const int gl_MaxVaryingFloats = 32;const int gl_MaxVertexTextureImageUnits = 0;const int gl_MaxCombinedTextureImageUnits = 2;const int gl_MaxTextureImageUnits = 2;const int gl_MaxFragmentUniformComponents = 64;const int gl_MaxDrawBuffers = 1;uniform mat4 gl_ModelViewMatrix;uniform mat4 gl_ProjectionMatrix;uniform mat4 gl_ModelViewProjectionMatrix;uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];uniform mat3 gl_NormalMatrix;uniform mat3 __NormalMatrixTranspose;  // Mesa onlyuniform mat4 gl_ModelViewMatrixInverse;uniform mat4 gl_ProjectionMatrixInverse;uniform mat4 gl_ModelViewProjectionMatrixInverse;uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];uniform mat4 gl_ModelViewMatrixTranspose;uniform mat4 gl_ProjectionMatrixTranspose;uniform mat4 gl_ModelViewProjectionMatrixTranspose;uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];uniform mat4 gl_ModelViewMatrixInverseTranspose;uniform mat4 gl_ProjectionMatrixInverseTranspose;uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];uniform float gl_NormalScale;struct gl_DepthRangeParameters {    float near;    float far;    float diff;};uniform gl_DepthRangeParameters gl_DepthRange;uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];struct gl_PointParameters {    float size;    float sizeMin;    float sizeMax;    float fadeThresholdSize;    float distanceConstantAttenuation;    float distanceLinearAttenuation;    float distanceQuadraticAttenuation;};uniform gl_PointParameters gl_Point;struct gl_MaterialParameters {    vec4 emission;    vec4 ambient;    vec4 diffuse;    vec4 specular;    float shininess;};uniform gl_MaterialParameters gl_FrontMaterial;uniform gl_MaterialParameters gl_BackMaterial;struct gl_LightSourceParameters {    vec4 ambient;    vec4 diffuse;    vec4 specular;    vec4 position;    vec4 halfVector;    vec3 spotDirection;    float spotExponent;    float spotCutoff;    float spotCosCutoff;    float constantAttenuation;    float linearAttenuation;    float quadraticAttenuation;};uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];struct gl_LightModelParameters {    vec4 ambient;};uniform gl_LightModelParameters gl_LightModel;struct gl_LightModelProducts {    vec4 sceneColor;};uniform gl_LightModelProducts gl_FrontLightModelProduct;uniform gl_LightModelProducts gl_BackLightModelProduct;struct gl_LightProducts {    vec4 ambient;    vec4 diffuse;    vec4 specular;};uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];struct gl_FogParameters {    vec4 color;    float density;    float start;    float end;    float scale;};uniform gl_FogParameters gl_Fog;//// 8.1 Angle and Trigonometry Functions////// radiansfloat radians(const float deg){   const float c = 3.1415926 / 180.0;   __asm vec4_multiply __retVal, deg, c;}vec2 radians(const vec2 deg){   const float c = 3.1415926 / 180.0;   __asm vec4_multiply __retVal.xy, deg.xy, c.xx;}vec3 radians(const vec3 deg){   const float c = 3.1415926 / 180.0;   __asm vec4_multiply __retVal.xyz, deg.xyz, c.xxx;}vec4 radians(const vec4 deg){   const float c = 3.1415926 / 180.0;   __asm vec4_multiply __retVal, deg, c.xxxx;}//// degreesfloat degrees(const float rad){   const float c = 180.0 / 3.1415926;   __asm vec4_multiply __retVal, rad, c;}vec2 degrees(const vec2 rad){   const float c = 180.0 / 3.1415926;   __asm vec4_multiply __retVal.xy, rad.xy, c.xx;}vec3 degrees(const vec3 rad){   const float c = 180.0 / 3.1415926;   __asm vec4_multiply __retVal.xyz, rad.xyz, c.xxx;}vec4 degrees(const vec4 rad){   const float c = 180.0 / 3.1415926;   __asm vec4_multiply __retVal, rad, c.xxxx;}//// sinfloat sin(const float radians){   __asm float_sine __retVal, radians;}vec2 sin(const vec2 radians){   __asm float_sine __retVal.x, radians.x;   __asm float_sine __retVal.y, radians.y;}vec3 sin(const vec3 radians){   __asm float_sine __retVal.x, radians.x;   __asm float_sine __retVal.y, radians.y;   __asm float_sine __retVal.z, radians.z;}vec4 sin(const vec4 radians){   __asm float_sine __retVal.x, radians.x;   __asm float_sine __retVal.y, radians.y;   __asm float_sine __retVal.z, radians.z;   __asm float_sine __retVal.w, radians.w;}//// cosfloat cos(const float radians){   __asm float_cosine __retVal, radians;}vec2 cos(const vec2 radians){   __asm float_cosine __retVal.x, radians.x;   __asm float_cosine __retVal.y, radians.y;}vec3 cos(const vec3 radians){   __asm float_cosine __retVal.x, radians.x;   __asm float_cosine __retVal.y, radians.y;   __asm float_cosine __retVal.z, radians.z;}vec4 cos(const vec4 radians){   __asm float_cosine __retVal.x, radians.x;   __asm float_cosine __retVal.y, radians.y;   __asm float_cosine __retVal.z, radians.z;   __asm float_cosine __retVal.w, radians.w;}//// tanfloat tan(const float angle){   const float s = sin(angle);   const float c = cos(angle);   return s / c;}vec2 tan(const vec2 angle){   const vec2 s = sin(angle);   const vec2 c = cos(angle);   return s / c;}vec3 tan(const vec3 angle){   const vec3 s = sin(angle);   const vec3 c = cos(angle);   return s / c;}vec4 tan(const vec4 angle){   const vec4 s = sin(angle);   const vec4 c = cos(angle);   return s / c;}float asin(const float x){   const float a0 = 1.5707288;  // PI/2?   const float a1 = -0.2121144;   const float a2 = 0.0742610;   //const float a3 = -0.0187293;   const float halfPi = 3.1415926 * 0.5;   const float y = abs(x);   // three terms seem to be enough:   __retVal = (halfPi - sqrt(1.0 - y) * (a0 + y * (a1 + a2 * y))) * sign(x);   // otherwise, try four:   //__retVal = (halfPi - sqrt(1.0 - y) * (a0 + y * (a1 + y * (a2 + y * a3)))) * sign(x);}vec2 asin(const vec2 v){   __retVal.x = asin(v.x);   __retVal.y = asin(v.y);}vec3 asin(const vec3 v){   __retVal.x = asin(v.x);   __retVal.y = asin(v.y);   __retVal.z = asin(v.z);}vec4 asin(const vec4 v){   __retVal.x = asin(v.x);   __retVal.y = asin(v.y);   __retVal.z = asin(v.z);   __retVal.w = asin(v.w);}float acos(const float x){   const float halfPi = 3.1415926 * 0.5;   __retVal = halfPi - asin(x);}vec2 acos(const vec2 v){   __retVal.x = acos(v.x);   __retVal.y = acos(v.y);}vec3 acos(const vec3 v){   __retVal.x = acos(v.x);   __retVal.y = acos(v.y);   __retVal.z = acos(v.z);}vec4 acos(const vec4 v){   __retVal.x = acos(v.x);   __retVal.y = acos(v.y);   __retVal.z = acos(v.z);   __retVal.w = acos(v.w);}float atan(const float x){   __retVal = asin(x * inversesqrt(x * x + 1.0));}vec2 atan(const vec2 y_over_x){   __retVal.x = atan(y_over_x.x);   __retVal.y = atan(y_over_x.y);}vec3 atan(const vec3 y_over_x){   __retVal.x = atan(y_over_x.x);   __retVal.y = atan(y_over_x.y);   __retVal.z = atan(y_over_x.z);}vec4 atan(const vec4 y_over_x){   __retVal.x = atan(y_over_x.x);   __retVal.y = atan(y_over_x.y);   __retVal.z = atan(y_over_x.z);   __retVal.w = atan(y_over_x.w);}float atan(const float y, const float x){   float r;   if (abs(x) > 1.0e-4) {      r = atan(y / x);      if (x < 0.0) {         r = r + sign(y) * 3.141593;      }   }   else {      r = sign(y) * 1.5707965;  // pi/2   }   return r;}vec2 atan(const vec2 u, const vec2 v){   __retVal.x = atan(u.x, v.x);   __retVal.y = atan(u.y, v.y);}vec3 atan(const vec3 u, const vec3 v){   __retVal.x = atan(u.x, v.x);   __retVal.y = atan(u.y, v.y);   __retVal.z = atan(u.z, v.z);}vec4 atan(const vec4 u, const vec4 v){   __retVal.x = atan(u.x, v.x);   __retVal.y = atan(u.y, v.y);   __retVal.z = atan(u.z, v.z);   __retVal.w = atan(u.w, v.w);}//// 8.2 Exponential Functions////// powfloat pow(const float a, const float b){   __asm float_power __retVal, a, b;}vec2 pow(const vec2 a, const vec2 b){   __asm float_power __retVal.x, a.x, b.x;   __asm float_power __retVal.y, a.y, b.y;}vec3 pow(const vec3 a, const vec3 b){   __asm float_power __retVal.x, a.x, b.x;   __asm float_power __retVal.y, a.y, b.y;   __asm float_power __retVal.z, a.z, b.z;}vec4 pow(const vec4 a, const vec4 b){   __asm float_power __retVal.x, a.x, b.x;   __asm float_power __retVal.y, a.y, b.y;   __asm float_power __retVal.z, a.z, b.z;   __asm float_power __retVal.w, a.w, b.w;}//// expfloat exp(const float a){   // NOTE: log2(e) = 1.44269502   float t = a * 1.44269502;   __asm float_exp2 __retVal, t;}vec2 exp(const vec2 a){   vec2 t = a * 1.44269502;   __asm float_exp2 __retVal.x, t.x;   __asm float_exp2 __retVal.y, t.y;}vec3 exp(const vec3 a){   vec3 t = a * 1.44269502;   __asm float_exp2 __retVal.x, t.x;   __asm float_exp2 __retVal.y, t.y;   __asm float_exp2 __retVal.z, t.z;}vec4 exp(const vec4 a){   vec4 t = a * 1.44269502;   __asm float_exp2 __retVal.x, t.x;   __asm float_exp2 __retVal.y, t.y;   __asm float_exp2 __retVal.z, t.z;   __asm float_exp2 __retVal.w, t.w;}//// log2float log2(const float x){   __asm float_log2 __retVal, x;}vec2 log2(const vec2 v){   __asm float_log2 __retVal.x, v.x;   __asm float_log2 __retVal.y, v.y;}vec3 log2(const vec3 v){   __asm float_log2 __retVal.x, v.x;   __asm float_log2 __retVal.y, v.y;   __asm float_log2 __retVal.z, v.z;}vec4 log2(const vec4 v){   __asm float_log2 __retVal.x, v.x;   __asm float_log2 __retVal.y, v.y;   __asm float_log2 __retVal.z, v.z;   __asm float_log2 __retVal.w, v.w;}//// log  (natural log)float log(const float x){   // note:  logBaseB(x) = logBaseN(x) / logBaseN(B)   // compute log(x) = log2(x) / log2(e)   // c = 1.0 / log2(e) = 0.693147181   const float c = 0.693147181;   return log2(x) * c;}vec2 log(const vec2 v){   const float c = 0.693147181;   return log2(v) * c;}vec3 log(const vec3 v){   const float c = 0.693147181;   return log2(v) * c;}vec4 log(const vec4 v){   const float c = 0.693147181;   return log2(v) * c;}//// exp2float exp2(const float a){   __asm float_exp2 __retVal, a;}vec2 exp2(const vec2 a){   __asm float_exp2 __retVal.x, a.x;   __asm float_exp2 __retVal.y, a.y;}vec3 exp2(const vec3 a){   __asm float_exp2 __retVal.x, a.x;   __asm float_exp2 __retVal.y, a.y;   __asm float_exp2 __retVal.z, a.z;}vec4 exp2(const vec4 a){   __asm float_exp2 __retVal.x, a.x;   __asm float_exp2 __retVal.y, a.y;   __asm float_exp2 __retVal.z, a.z;   __asm float_exp2 __retVal.w, a.w;}//// sqrtfloat sqrt(const float x){   float r;   __asm float_rsq r, x;   __asm float_rcp __retVal, r;}vec2 sqrt(const vec2 v){   float r;   __asm float_rsq r, v.x;   __asm float_rcp __retVal.x, r;   __asm float_rsq r, v.y;   __asm float_rcp __retVal.y, r;}vec3 sqrt(const vec3 v){   float r;   __asm float_rsq r, v.x;   __asm float_rcp __retVal.x, r;   __asm float_rsq r, v.y;   __asm float_rcp __retVal.y, r;   __asm float_rsq r, v.z;   __asm float_rcp __retVal.z, r;}

⌨️ 快捷键说明

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