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

📄 slang_common_builtin.gc

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 GC
📖 第 1 页 / 共 3 页
字号:
//// reflectfloat reflect(const float I, const float N){   return I - 2.0 * dot(N, I) * N;}vec2 reflect(const vec2 I, const vec2 N){   return I - 2.0 * dot(N, I) * N;}vec3 reflect(const vec3 I, const vec3 N){   return I - 2.0 * dot(N, I) * N;}vec4 reflect(const vec4 I, const vec4 N){   return I - 2.0 * dot(N, I) * N;}//// refractfloat refract(const float I, const float N, const float eta){   float n_dot_i = dot(N, I);   float k = 1.0 - eta * eta * (1.0 - n_dot_i * n_dot_i);   float retval;   if (k < 0.0)      retval = 0.0;   else      retval = eta * I - (eta * n_dot_i + sqrt(k)) * N;   return retval;}vec2 refract(const vec2 I, const vec2 N, const float eta){   float n_dot_i = dot(N, I);   float k = 1.0 - eta * eta * (1.0 - n_dot_i * n_dot_i);   vec2 retval;   if (k < 0.0)      retval = vec2(0.0);   else      retval = eta * I - (eta * n_dot_i + sqrt(k)) * N;   return retval;}vec3 refract(const vec3 I, const vec3 N, const float eta){   float n_dot_i = dot(N, I);   float k = 1.0 - eta * eta * (1.0 - n_dot_i * n_dot_i);   vec3 retval;   if (k < 0.0)      retval = vec3(0.0);   else      retval = eta * I - (eta * n_dot_i + sqrt(k)) * N;   return retval;}vec4 refract(const vec4 I, const vec4 N, const float eta){   float n_dot_i = dot(N, I);   float k = 1.0 - eta * eta * (1.0 - n_dot_i * n_dot_i);   vec4 retval;   if (k < 0.0)      retval = vec4(0.0);   else      retval = eta * I - (eta * n_dot_i + sqrt(k)) * N;   return retval;}//// 8.5 Matrix Functions//mat2 matrixCompMult (mat2 m, mat2 n) {    return mat2 (m[0] * n[0], m[1] * n[1]);}mat3 matrixCompMult (mat3 m, mat3 n) {    return mat3 (m[0] * n[0], m[1] * n[1], m[2] * n[2]);}mat4 matrixCompMult (mat4 m, mat4 n) {    return mat4 (m[0] * n[0], m[1] * n[1], m[2] * n[2], m[3] * n[3]);}//// 8.6 Vector Relational Functions////// lessThanbvec2 lessThan(const vec2 u, const vec2 v){   __asm vec4_slt __retVal.xy, u, v;}bvec3 lessThan(const vec3 u, const vec3 v){   __asm vec4_slt __retVal.xyz, u, v;}bvec4 lessThan(const vec4 u, const vec4 v){   __asm vec4_slt __retVal, u, v;}bvec2 lessThan(const ivec2 u, const ivec2 v){   __asm vec4_slt __retVal.xy, u, v;}bvec3 lessThan(const ivec3 u, const ivec3 v){   __asm vec4_slt __retVal.xyz, u, v;}bvec4 lessThan(const ivec4 u, const ivec4 v){   __asm vec4_slt __retVal, u, v;}//// lessThanEqualbvec2 lessThanEqual(const vec2 u, const vec2 v){   __asm vec4_sle __retVal.xy, u, v;}bvec3 lessThanEqual(const vec3 u, const vec3 v){   __asm vec4_sle __retVal.xyz, u, v;}bvec4 lessThanEqual(const vec4 u, const vec4 v){   __asm vec4_sle __retVal, u, v;}bvec2 lessThanEqual(const ivec2 u, const ivec2 v){   __asm vec4_sle __retVal.xy, u, v;}bvec3 lessThanEqual(const ivec3 u, const ivec3 v){   __asm vec4_sle __retVal.xyz, u, v;}bvec4 lessThanEqual(const ivec4 u, const ivec4 v){   __asm vec4_sle __retVal, u, v;}//// greaterThanbvec2 greaterThan(const vec2 u, const vec2 v){   __asm vec4_sgt __retVal.xy, u, v;}bvec3 greaterThan(const vec3 u, const vec3 v){   __asm vec4_sgt __retVal.xyz, u, v;}bvec4 greaterThan(const vec4 u, const vec4 v){   __asm vec4_sgt __retVal, u, v;}bvec2 greaterThan(const ivec2 u, const ivec2 v){   __asm vec4_sgt __retVal.xy, u.xy, v.xy;}bvec3 greaterThan(const ivec3 u, const ivec3 v){   __asm vec4_sgt __retVal.xyz, u, v;}bvec4 greaterThan(const ivec4 u, const ivec4 v){   __asm vec4_sgt __retVal, u, v;}//// greaterThanEqualbvec2 greaterThanEqual(const vec2 u, const vec2 v){   __asm vec4_sge __retVal.xy, u, v;}bvec3 greaterThanEqual(const vec3 u, const vec3 v){   __asm vec4_sge __retVal.xyz, u, v;}bvec4 greaterThanEqual(const vec4 u, const vec4 v){   __asm vec4_sge __retVal, u, v;}bvec2 greaterThanEqual(const ivec2 u, const ivec2 v){   __asm vec4_sge __retVal.xy, u, v;}bvec3 greaterThanEqual(const ivec3 u, const ivec3 v){   __asm vec4_sge __retVal.xyz, u, v;}bvec4 greaterThanEqual(const ivec4 u, const ivec4 v){   __asm vec4_sge __retVal, u, v;}//// equalbvec2 equal(const vec2 u, const vec2 v){   __asm vec4_seq __retVal.xy, u, v;}bvec3 equal(const vec3 u, const vec3 v){   __asm vec4_seq __retVal.xyz, u, v;}bvec4 equal(const vec4 u, const vec4 v){   __asm vec4_seq __retVal, u, v;}bvec2 equal(const ivec2 u, const ivec2 v){   __asm vec4_seq __retVal.xy, u, v;}bvec3 equal(const ivec3 u, const ivec3 v){   __asm vec4_seq __retVal.xyz, u, v;}bvec4 equal(const ivec4 u, const ivec4 v){   __asm vec4_seq __retVal, u, v;}bvec2 equal(const bvec2 u, const bvec2 v){   __asm vec4_seq __retVal.xy, u, v;}bvec3 equal(const bvec3 u, const bvec3 v){   __asm vec4_seq __retVal.xyz, u, v;}bvec4 equal(const bvec4 u, const bvec4 v){   __asm vec4_seq __retVal, u, v;}//// notEqualbvec2 notEqual(const vec2 u, const vec2 v){   __asm vec4_sne __retVal.xy, u, v;}bvec3 notEqual(const vec3 u, const vec3 v){   __asm vec4_sne __retVal.xyz, u, v;}bvec4 notEqual(const vec4 u, const vec4 v){   __asm vec4_sne __retVal, u, v;}bvec2 notEqual(const ivec2 u, const ivec2 v){   __asm vec4_sne __retVal.xy, u, v;}bvec3 notEqual(const ivec3 u, const ivec3 v){   __asm vec4_sne __retVal.xyz, u, v;}bvec4 notEqual(const ivec4 u, const ivec4 v){   __asm vec4_sne __retVal, u, v;}bvec2 notEqual(const bvec2 u, const bvec2 v){   __asm vec4_sne __retVal.xy, u, v;}bvec3 notEqual(const bvec3 u, const bvec3 v){   __asm vec4_sne __retVal.xyz, u, v;}bvec4 notEqual(const bvec4 u, const bvec4 v){   __asm vec4_sne __retVal, u, v;}//// anybool any(const bvec2 v){   float sum;   __asm vec4_add sum.x, v.x, v.y;   __asm vec4_sne __retVal.x, sum.x, 0.0;}bool any(const bvec3 v){   float sum;   __asm vec4_add sum.x, v.x, v.y;   __asm vec4_add sum.x, sum.x, v.z;   __asm vec4_sne __retVal.x, sum.x, 0.0;}bool any(const bvec4 v){   float sum;   __asm vec4_add sum.x, v.x, v.y;   __asm vec4_add sum.x, sum.x, v.z;   __asm vec4_add sum.x, sum.x, v.w;   __asm vec4_sne __retVal.x, sum.x, 0.0;}//// allbool all (const bvec2 v){   float prod;   __asm vec4_multiply prod, v.x, v.y;   __asm vec4_sne __retVal, prod, 0.0;}bool all (const bvec3 v){   float prod;   __asm vec4_multiply prod, v.x, v.y;   __asm vec4_multiply prod, prod, v.z;   __asm vec4_sne __retVal, prod, 0.0;}bool all (const bvec4 v){   float prod;   __asm vec4_multiply prod, v.x, v.y;   __asm vec4_multiply prod, prod, v.z;   __asm vec4_multiply prod, prod, v.w;   __asm vec4_sne __retVal, prod, 0.0;}//// notbvec2 not (const bvec2 v){   __asm vec4_seq __retVal.xy, v, 0.0;}bvec3 not (const bvec3 v){   __asm vec4_seq __retVal.xyz, v, 0.0;}bvec4 not (const bvec4 v){   __asm vec4_seq __retVal, v, 0.0;}//// Texture Lookup Functions  (for both fragment and vertex shaders)vec4 texture1D(const sampler1D sampler, const float coord){   __asm vec4_tex1d __retVal, sampler, coord;}vec4 texture1DProj(const sampler1D sampler, const vec2 coord){   // need to swizzle .y into .w   __asm vec4_texp1d __retVal, sampler, coord.xyyy;}vec4 texture1DProj(const sampler1D sampler, const vec4 coord){   __asm vec4_texp1d __retVal, sampler, coord;}vec4 texture2D(const sampler2D sampler, const vec2 coord){   __asm vec4_tex2d __retVal, sampler, coord;}vec4 texture2DProj(const sampler2D sampler, const vec3 coord){   // need to swizzle 'z' into 'w'.   __asm vec4_texp2d __retVal, sampler, coord.xyzz;}vec4 texture2DProj(const sampler2D sampler, const vec4 coord){   __asm vec4_texp2d __retVal, sampler, coord;}vec4 texture3D(const sampler3D sampler, const vec3 coord){   __asm vec4_tex3d __retVal, sampler, coord;}vec4 texture3DProj(const sampler3D sampler, const vec4 coord){   __asm vec4_texp3d __retVal, sampler, coord;}vec4 textureCube(const samplerCube sampler, const vec3 coord){   __asm vec4_texcube __retVal, sampler, coord;}vec4 shadow1D(const sampler1DShadow sampler, const vec3 coord){   __asm vec4_tex1d __retVal, sampler, coord;}vec4 shadow1DProj(const sampler1DShadow sampler, const vec4 coord){   // .s and .p will be divided by .q   __asm vec4_texp1d __retVal, sampler, coord;}vec4 shadow2D(const sampler2DShadow sampler, const vec3 coord){   __asm vec4_tex2d __retVal, sampler, coord;}vec4 shadow2DProj(const sampler2DShadow sampler, const vec4 coord){   // .s, .t and .p will be divided by .q   __asm vec4_texp2d __retVal, sampler, coord;}//// GL_ARB_texture_rectangle:vec4 texture2DRect(const sampler2DRect sampler, const vec2 coord){   __asm vec4_tex_rect __retVal, sampler, coord;}vec4 texture2DRectProj(const sampler2DRect sampler, const vec3 coord){   // need to swizzle .y into .w   __asm vec4_texp_rect __retVal, sampler, coord.xyzz;}vec4 texture2DRectProj(const sampler2DRect sampler, const vec4 coord){   __asm vec4_texp_rect __retVal, sampler, ccoord;}vec4 shadow2DRect(const sampler2DRectShadow sampler, const vec3 coord){   __asm vec4_tex_rect __retVal, sampler, coord;}vec4 shadow2DRectProj(const sampler2DRectShadow sampler, const vec4 coord){   __asm vec4_texp_rect __retVal, sampler, coord;}//// 8.9 Noise Functions//// AUTHOR: Stefan Gustavson (stegu@itn.liu.se), Nov 26, 2005//float noise1(const float x){   __asm float_noise1 __retVal, x;}float noise1(const vec2 x){    __asm float_noise2 __retVal, x;}float noise1(const vec3 x){    __asm float_noise3 __retVal, x;}float noise1(const vec4 x){    __asm float_noise4 __retVal, x;}vec2 noise2(const float x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + 19.34);}vec2 noise2(const vec2 x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + vec2(19.34, 7.66));}vec2 noise2(const vec3 x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + vec3(19.34, 7.66, 3.23));}vec2 noise2(const vec4 x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + vec4(19.34, 7.66, 3.23, 2.77));}vec3 noise3(const float x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + 19.34);   __retVal.z = noise1(x + 5.47);}vec3 noise3(const vec2 x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + vec2(19.34, 7.66));   __retVal.z = noise1(x + vec2(5.47, 17.85));}vec3 noise3(const vec3 x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + vec3(19.34, 7.66, 3.23));   __retVal.z = noise1(x + vec3(5.47, 17.85, 11.04));}vec3 noise3(const vec4 x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + vec4(19.34, 7.66, 3.23, 2.77));   __retVal.z = noise1(x + vec4(5.47, 17.85, 11.04, 13.19));}vec4 noise4(const float x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + 19.34);   __retVal.z = noise1(x + 5.47);   __retVal.w = noise1(x + 23.54);}vec4 noise4(const vec2 x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + vec2 (19.34, 7.66));   __retVal.z = noise1(x + vec2 (5.47, 17.85));   __retVal.w = noise1(x + vec2 (23.54, 29.11));}vec4 noise4(const vec3 x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + vec3(19.34, 7.66, 3.23));   __retVal.z = noise1(x + vec3(5.47, 17.85, 11.04));   __retVal.w = noise1(x + vec3(23.54, 29.11, 31.91));}vec4 noise4(const vec4 x){   __retVal.x = noise1(x);   __retVal.y = noise1(x + vec4(19.34, 7.66, 3.23, 2.77));   __retVal.z = noise1(x + vec4(5.47, 17.85, 11.04, 13.19));   __retVal.w = noise1(x + vec4(23.54, 29.11, 31.91, 37.48));}

⌨️ 快捷键说明

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