Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Invalidating shader binary cache
- Debug: building generic shader permutation with macro: GENERIC_2D
- Warn: Source for shader program generic2D:
- 0: #version 460 core
- 1: #define HAVE_ARB_texture_gather 1
- 2: #define HAVE_EXT_gpu_shader4 1
- 3: #define HAVE_ARB_gpu_shader5 1
- 4: #define HAVE_ARB_uniform_buffer_object 1
- 5: #extension GL_ARB_bindless_texture : require
- 6: #define HAVE_ARB_bindless_texture 1
- 7: #define HAVE_ARB_shader_draw_parameters 1
- 8: #define HAVE_ARB_shader_storage_buffer_object 1
- 9: #extension GL_ARB_gpu_shader_int64 : require
- 10: #define HAVE_ARB_gpu_shader_int64 1
- 11: #define IN in
- 12: #define OUT(mode) mode out
- 13: #define textureCube texture
- 14: #define texture2D texture
- 15: #define texture2DProj textureProj
- 16: #define texture3D texture
- 17: OUT(flat) int in_drawID;
- 18: OUT(flat) int in_baseInstance;
- 19: #ifndef r_precomputedLighting
- 20: #define r_precomputedLighting 1
- 21: #endif
- 22: #ifndef r_vertexSkinning
- 23: #define r_vertexSkinning 1
- 24: #endif
- 25: const int MAX_GLSL_BONES = 256;
- 26: #ifndef r_halfLambertLighting
- 27: #define r_halfLambertLighting 1
- 28: #endif
- 29: #ifndef r_rimLighting
- 30: #define r_rimLighting 1
- 31: #endif
- 32: const float r_RimExponent = 3.00000000e+00;
- 33: #ifndef r_normalMapping
- 34: #define r_normalMapping 1
- 35: #endif
- 36: #ifndef r_liquidMapping
- 37: #define r_liquidMapping 1
- 38: #endif
- 39: #ifndef r_specularMapping
- 40: #define r_specularMapping 1
- 41: #endif
- 42: #ifndef r_physicalMapping
- 43: #define r_physicalMapping 1
- 44: #endif
- 45: #ifndef r_glowMapping
- 46: #define r_glowMapping 1
- 47: #endif
- 48: #ifndef GENERIC_2D
- 49: #define GENERIC_2D 1
- 50: #endif
- 51: #define drawID gl_DrawIDARB
- 52: #define baseInstance gl_BaseInstanceARB
- 53:
- 54: #ifndef TEXTURE_RG
- 55: #define TEXTURE_RG 1
- 56: #endif
- 57: #ifndef UNIFORM_BUFFER_OBJECT
- 58: #define UNIFORM_BUFFER_OBJECT 1
- 59: #endif
- 60: #ifndef TEXTURE_INTEGER
- 61: #define TEXTURE_INTEGER 1
- 62: #endif
- 63: #ifndef r_AmbientScale
- 64: #define r_AmbientScale 1.00000000e+00
- 65: #endif
- 66: #ifndef r_SpecularScale
- 67: #define r_SpecularScale 1.00000000e+00
- 68: #endif
- 69: #ifndef r_zNear
- 70: #define r_zNear 3.00000000e+00
- 71: #endif
- 72: #ifndef M_PI
- 73: #define M_PI 3.14159274e+00
- 74: #endif
- 75: #ifndef MAX_SHADOWMAPS
- 76: #define MAX_SHADOWMAPS 5
- 77: #endif
- 78: #ifndef MAX_REF_LIGHTS
- 79: #define MAX_REF_LIGHTS 1024
- 80: #endif
- 81: #ifndef TILE_SIZE
- 82: #define TILE_SIZE 16
- 83: #endif
- 84: #ifndef r_FBufSize
- 85: #define r_FBufSize vec2(2.56000000e+03, 1.44000000e+03)
- 86: #endif
- 87: #ifndef r_tileStep
- 88: #define r_tileStep vec2(6.24999963e-03, 1.11111114e-02)
- 89: #endif
- 90: #ifdef HAVE_ARB_shader_draw_parameters
- 91: #define SETUP_SHADER_PARMS SetShaderParameters();
- 92: void SetShaderParameters() {
- 93: in_drawID = drawID;
- 94: in_baseInstance = baseInstance;
- 95: }
- 96: #else
- 97: #define SETUP_SHADER_PARMS //Unavailable
- 98: #endif
- 99: /*
- 100: ===========================================================================
- 101: Copyright (C) 2010 Robert Beckebans <trebor_7@users.sourceforge.net>
- 102:
- 103: This file is part of XreaL source code.
- 104:
- 105: XreaL source code is free software; you can redistribute it
- 106: and/or modify it under the terms of the GNU General Public License as
- 107: published by the Free Software Foundation; either version 2 of the License,
- 108: or (at your option) any later version.
- 109:
- 110: XreaL source code is distributed in the hope that it will be
- 111: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- 112: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 113: GNU General Public License for more details.
- 114:
- 115: You should have received a copy of the GNU General Public License
- 116: along with XreaL source code; if not, write to the Free Software
- 117: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- 118: ===========================================================================
- 119: */
- 120: // vertexSimple_vp.glsl - simple vertex fetch
- 121:
- 122: struct localBasis {
- 123: vec3 normal;
- 124: vec3 tangent, binormal;
- 125: };
- 126:
- 127: vec3 QuatTransVec(in vec4 quat, in vec3 vec) {
- 128: vec3 tmp = 2.0 * cross( quat.xyz, vec );
- 129: return vec + quat.w * tmp + cross( quat.xyz, tmp );
- 130: }
- 131:
- 132: void QTangentToLocalBasis( in vec4 qtangent, out localBasis LB ) {
- 133: LB.normal = QuatTransVec( qtangent, vec3( 0.0, 0.0, 1.0 ) );
- 134: LB.tangent = QuatTransVec( qtangent, vec3( 1.0, 0.0, 0.0 ) );
- 135: LB.tangent *= sign( qtangent.w );
- 136: LB.binormal = QuatTransVec( qtangent, vec3( 0.0, 1.0, 0.0 ) );
- 137: }
- 138:
- 139: #if !defined(USE_VERTEX_ANIMATION) && !defined(USE_VERTEX_SKINNING) && !defined(USE_VERTEX_SPRITE)
- 140:
- 141: IN vec3 attr_Position;
- 142: IN vec4 attr_Color;
- 143: IN vec4 attr_QTangent;
- 144: IN vec4 attr_TexCoord0;
- 145:
- 146: void VertexFetch(out vec4 position,
- 147: out localBasis normalBasis,
- 148: out vec4 color,
- 149: out vec2 texCoord,
- 150: out vec2 lmCoord)
- 151: {
- 152: position = vec4( attr_Position, 1.0 );
- 153: QTangentToLocalBasis( attr_QTangent, normalBasis );
- 154: color = attr_Color;
- 155: texCoord = attr_TexCoord0.xy;
- 156: lmCoord = attr_TexCoord0.zw;
- 157: }
- 158: #endif
- 159: /*
- 160: ===========================================================================
- 161: Copyright (C) 2009-2011 Robert Beckebans <trebor_7@users.sourceforge.net>
- 162:
- 163: This file is part of XreaL source code.
- 164:
- 165: XreaL source code is free software; you can redistribute it
- 166: and/or modify it under the terms of the GNU General Public License as
- 167: published by the Free Software Foundation; either version 2 of the License,
- 168: or (at your option) any later version.
- 169:
- 170: XreaL source code is distributed in the hope that it will be
- 171: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- 172: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 173: GNU General Public License for more details.
- 174:
- 175: You should have received a copy of the GNU General Public License
- 176: along with XreaL source code; if not, write to the Free Software
- 177: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- 178: ===========================================================================
- 179: */
- 180: // vertexSkinning_vp.glsl - GPU vertex skinning for skeletal meshes
- 181:
- 182: #if defined(USE_VERTEX_SKINNING)
- 183:
- 184: IN vec3 attr_Position;
- 185: IN vec2 attr_TexCoord0;
- 186: IN vec4 attr_Color;
- 187: IN vec4 attr_QTangent;
- 188: IN vec4 attr_BoneFactors;
- 189:
- 190: // even elements are rotation quat, odd elements are translation + scale (in .w)
- 191: uniform vec4 u_Bones[ 2 * MAX_GLSL_BONES ];
- 192:
- 193: void VertexFetch(out vec4 position,
- 194: out localBasis LB,
- 195: out vec4 color,
- 196: out vec2 texCoord,
- 197: out vec2 lmCoord)
- 198: {
- 199: const float scale = 1.0 / 256.0;
- 200: const float weightScale = 1.0 / 255.0;
- 201: localBasis inLB;
- 202:
- 203: // Unpack data from "bone factors". This used to have the index in the high byte and the weight
- 204: // in the low byte, which may seem a bit more logical, but it triggered issues with some
- 205: // Nvidia shader compilers (https://github.com/DaemonEngine/Daemon/issues/472).
- 206: vec4 ipart = floor( attr_BoneFactors * scale );
- 207: vec4 fpart = attr_BoneFactors * scale - ipart;
- 208: // idx = 2 times the original bone index (the index input to boneFactor)
- 209: ivec4 idx = ivec4( fpart * 512.0 );
- 210: vec4 weights = ipart * weightScale;
- 211:
- 212: vec4 quat = u_Bones[ idx.x ];
- 213: vec4 trans = u_Bones[ idx.x + 1 ];
- 214:
- 215: QTangentToLocalBasis( attr_QTangent, inLB );
- 216:
- 217: position.xyz = weights.x * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
- 218: LB.normal = weights.x * (QuatTransVec( quat, inLB.normal ));
- 219: LB.tangent = weights.x * (QuatTransVec( quat, inLB.tangent ));
- 220: LB.binormal = weights.x * (QuatTransVec( quat, inLB.binormal ));
- 221:
- 222: quat = u_Bones[ idx.y ];
- 223: trans = u_Bones[ idx.y + 1 ];
- 224:
- 225: position.xyz += weights.y * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
- 226: LB.normal += weights.y * (QuatTransVec( quat, inLB.normal ));
- 227: LB.tangent += weights.y * (QuatTransVec( quat, inLB.tangent ));
- 228: LB.binormal += weights.y * (QuatTransVec( quat, inLB.binormal ));
- 229:
- 230: quat = u_Bones[ idx.z ];
- 231: trans = u_Bones[ idx.z + 1 ];
- 232:
- 233: position.xyz += weights.z * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
- 234: LB.normal += weights.z * (QuatTransVec( quat, inLB.normal ));
- 235: LB.tangent += weights.z * (QuatTransVec( quat, inLB.tangent ));
- 236: LB.binormal += weights.z * (QuatTransVec( quat, inLB.binormal ));
- 237:
- 238: quat = u_Bones[ idx.w ];
- 239: trans = u_Bones[ idx.w + 1 ];
- 240:
- 241: position.xyz += weights.w * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
- 242: LB.normal += weights.w * (QuatTransVec( quat, inLB.normal ));
- 243: LB.tangent += weights.w * (QuatTransVec( quat, inLB.tangent ));
- 244: LB.binormal += weights.w * (QuatTransVec( quat, inLB.binormal ));
- 245:
- 246: position.w = 1.0;
- 247: LB.normal = normalize(LB.normal);
- 248: LB.tangent = normalize(LB.tangent);
- 249: LB.binormal = normalize(LB.binormal);
- 250:
- 251: color = attr_Color;
- 252: texCoord = attr_TexCoord0;
- 253: lmCoord = attr_TexCoord0;
- 254: }
- 255: #endif
- 256: /*
- 257: ===========================================================================
- 258: Copyright (C) 2010 Robert Beckebans <trebor_7@users.sourceforge.net>
- 259:
- 260: This file is part of XreaL source code.
- 261:
- 262: XreaL source code is free software; you can redistribute it
- 263: and/or modify it under the terms of the GNU General Public License as
- 264: published by the Free Software Foundation; either version 2 of the License,
- 265: or (at your option) any later version.
- 266:
- 267: XreaL source code is distributed in the hope that it will be
- 268: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- 269: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 270: GNU General Public License for more details.
- 271:
- 272: You should have received a copy of the GNU General Public License
- 273: along with XreaL source code; if not, write to the Free Software
- 274: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- 275: ===========================================================================
- 276: */
- 277: // vertexAnimation_vp.glsl - interpolates .md3/.mdc vertex animations
- 278:
- 279: #if defined(USE_VERTEX_ANIMATION)
- 280:
- 281: IN vec3 attr_Position;
- 282: IN vec4 attr_Color;
- 283: IN vec4 attr_QTangent;
- 284: IN vec2 attr_TexCoord0;
- 285: IN vec3 attr_Position2;
- 286: IN vec4 attr_QTangent2;
- 287:
- 288: uniform float u_VertexInterpolation;
- 289:
- 290: void VertexAnimation_P_N( vec3 fromPosition, vec3 toPosition,
- 291: vec4 fromQTangent, vec4 toQTangent,
- 292: float frac,
- 293: inout vec4 position, inout vec3 normal)
- 294: {
- 295: vec3 fromNormal = QuatTransVec( fromQTangent, vec3( 0.0, 0.0, 1.0 ) );
- 296: vec3 toNormal = QuatTransVec( toQTangent, vec3( 0.0, 0.0, 1.0 ) );
- 297:
- 298: position.xyz = 512.0 * mix(fromPosition, toPosition, frac);
- 299: position.w = 1;
- 300:
- 301: normal = normalize(mix(fromNormal, toNormal, frac));
- 302: }
- 303:
- 304: void VertexFetch(out vec4 position,
- 305: out localBasis LB,
- 306: out vec4 color,
- 307: out vec2 texCoord,
- 308: out vec2 lmCoord)
- 309: {
- 310: localBasis fromLB, toLB;
- 311:
- 312: QTangentToLocalBasis( attr_QTangent, fromLB );
- 313: QTangentToLocalBasis( attr_QTangent2, toLB );
- 314:
- 315: position.xyz = 512.0 * mix(attr_Position, attr_Position2, u_VertexInterpolation);
- 316: position.w = 1;
- 317:
- 318: LB.normal = normalize(mix(fromLB.normal, toLB.normal, u_VertexInterpolation));
- 319: LB.tangent = normalize(mix(fromLB.tangent, toLB.tangent, u_VertexInterpolation));
- 320: LB.binormal = normalize(mix(fromLB.binormal, toLB.binormal, u_VertexInterpolation));
- 321:
- 322: color = attr_Color;
- 323: texCoord = attr_TexCoord0;
- 324: lmCoord = attr_TexCoord0;
- 325: }
- 326: #endif
- 327: /*
- 328: ===========================================================================
- 329: Copyright (C) 2010 Robert Beckebans <trebor_7@users.sourceforge.net>
- 330:
- 331: This file is part of XreaL source code.
- 332:
- 333: XreaL source code is free software; you can redistribute it
- 334: and/or modify it under the terms of the GNU General Public License as
- 335: published by the Free Software Foundation; either version 2 of the License,
- 336: or (at your option) any later version.
- 337:
- 338: XreaL source code is distributed in the hope that it will be
- 339: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- 340: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 341: GNU General Public License for more details.
- 342:
- 343: You should have received a copy of the GNU General Public License
- 344: along with XreaL source code; if not, write to the Free Software
- 345: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- 346: ===========================================================================
- 347: */
- 348: // vertexSprite_vp.glsl - sprite vertex fetch
- 349:
- 350: #if defined(USE_VERTEX_SPRITE)
- 351:
- 352: IN vec3 attr_Position;
- 353: IN vec4 attr_Color;
- 354: IN vec4 attr_TexCoord0;
- 355: IN vec4 attr_Orientation;
- 356:
- 357: uniform vec3 u_ViewOrigin;
- 358: uniform vec3 u_ViewUp;
- 359:
- 360: float depthScale;
- 361:
- 362: void VertexFetch(out vec4 position,
- 363: out localBasis normalBasis,
- 364: out vec4 color,
- 365: out vec2 texCoord,
- 366: out vec2 lmCoord)
- 367: {
- 368: vec2 corner;
- 369: float radius = attr_Orientation.w;
- 370: vec3 normal = normalize( u_ViewOrigin - attr_Position ), up, left;
- 371: float s, c; // sin & cos of rotation factor
- 372:
- 373: corner = sign( attr_TexCoord0.zw );
- 374:
- 375: if( radius <= 0.0 ) {
- 376: // autosprite2 mode, attr_Orientation.xyz contains the up-vector
- 377: up = attr_Orientation.xyz;
- 378: left = radius * normalize( cross( up, normal ) );
- 379: position = vec4( attr_Position + corner.y * left, 1.0 );
- 380: } else {
- 381: // autosprite mode, attr_Orientation.x contains the rotation angle
- 382: left = normalize( cross( u_ViewUp, normal ) );
- 383: up = cross( left, normal );
- 384:
- 385: s = radius * sin( radians( attr_Orientation.x ) );
- 386: c = radius * cos( radians( attr_Orientation.x ) );
- 387:
- 388: // rotate left and up vectors
- 389: vec3 leftOrig = left;
- 390: left = c * left + s * up;
- 391: up = c * up - s * leftOrig;
- 392:
- 393: left *= corner.x;
- 394: up *= corner.y;
- 395:
- 396: position = vec4( attr_Position + left + up, 1.0 );
- 397: }
- 398: normalBasis.normal = normal;
- 399: normalBasis.tangent = normalize( up );
- 400: normalBasis.binormal = normalize( left );
- 401:
- 402: texCoord = 0.5 * corner + 0.5; //attr_TexCoord0.xy;
- 403: lmCoord = abs( attr_TexCoord0.zw );
- 404: color = attr_Color;
- 405:
- 406: depthScale = 2.0 * radius;
- 407: }
- 408: #endif
- 409: /*
- 410: ===========================================================================
- 411: Copyright (C) 2006-2011 Robert Beckebans <trebor_7@users.sourceforge.net>
- 412:
- 413: This file is part of XreaL source code.
- 414:
- 415: XreaL source code is free software; you can redistribute it
- 416: and/or modify it under the terms of the GNU General Public License as
- 417: published by the Free Software Foundation; either version 2 of the License,
- 418: or (at your option) any later version.
- 419:
- 420: XreaL source code is distributed in the hope that it will be
- 421: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- 422: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 423: GNU General Public License for more details.
- 424:
- 425: You should have received a copy of the GNU General Public License
- 426: along with XreaL source code; if not, write to the Free Software
- 427: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- 428: ===========================================================================
- 429: */
- 430:
- 431: /* generic_vp.glsl */
- 432:
- 433: uniform mat4 u_TextureMatrix;
- 434: #if !defined(USE_VERTEX_SPRITE)
- 435: uniform vec3 u_ViewOrigin;
- 436: #endif
- 437:
- 438: uniform float u_Time;
- 439:
- 440: uniform vec4 u_ColorModulate;
- 441: uniform vec4 u_Color;
- 442: #if defined(USE_TCGEN_ENVIRONMENT)
- 443: uniform mat4 u_ModelMatrix;
- 444: #endif
- 445: uniform mat4 u_ModelViewProjectionMatrix;
- 446:
- 447: #if defined(USE_VERTEX_SPRITE)
- 448: OUT(smooth) vec2 var_FadeDepth;
- 449: uniform mat4 u_ProjectionMatrixTranspose;
- 450: #elif defined(USE_DEPTH_FADE)
- 451: uniform float u_DepthScale;
- 452: OUT(smooth) vec2 var_FadeDepth;
- 453: #endif
- 454:
- 455: OUT(smooth) vec2 var_TexCoords;
- 456: OUT(smooth) vec4 var_Color;
- 457:
- 458: void DeformVertex( inout vec4 pos,
- 459: inout vec3 normal,
- 460: inout vec2 st,
- 461: inout vec4 color,
- 462: in float time);
- 463:
- 464: void main()
- 465: {
- 466: vec4 position;
- 467: localBasis LB;
- 468: vec4 color;
- 469: vec2 texCoord, lmCoord;
- 470:
- 471: VertexFetch( position, LB, color, texCoord, lmCoord );
- 472: color = color * u_ColorModulate + u_Color;
- 473:
- 474: DeformVertex( position,
- 475: LB.normal,
- 476: texCoord,
- 477: color,
- 478: u_Time);
- 479:
- 480: // transform vertex position into homogenous clip-space
- 481: gl_Position = u_ModelViewProjectionMatrix * position;
- 482:
- 483: // transform texcoords
- 484: #if defined(USE_TCGEN_ENVIRONMENT)
- 485: {
- 486: // TODO: Explain why only the rotational part of u_ModelMatrix is relevant
- 487: position.xyz = mat3(u_ModelMatrix) * position.xyz;
- 488:
- 489: vec3 viewer = normalize(u_ViewOrigin - position.xyz);
- 490:
- 491: float d = dot(LB.normal, viewer);
- 492:
- 493: vec3 reflected = LB.normal * 2.0 * d - viewer;
- 494:
- 495: var_TexCoords = 0.5 + vec2(0.5, -0.5) * reflected.yz;
- 496: }
- 497: #elif defined(USE_TCGEN_LIGHTMAP)
- 498: var_TexCoords = (u_TextureMatrix * vec4(lmCoord, 0.0, 1.0)).xy;
- 499: #else
- 500: var_TexCoords = (u_TextureMatrix * vec4(texCoord, 0.0, 1.0)).xy;
- 501: #endif
- 502:
- 503: #if defined(USE_DEPTH_FADE)
- 504: // compute z of end of fading effect
- 505: vec4 fadeDepth = u_ModelViewProjectionMatrix * (position - u_DepthScale * vec4(LB.normal, 0.0));
- 506: var_FadeDepth = fadeDepth.zw;
- 507: #elif defined(USE_VERTEX_SPRITE)
- 508: vec4 fadeDepth = u_ModelViewProjectionMatrix * (position - depthScale * vec4(LB.normal, 0.0));
- 509: var_FadeDepth = fadeDepth.zw;
- 510: #endif
- 511:
- 512: var_Color = color;
- 513:
- 514: SETUP_SHADER_PARMS
- 515: }
- Warn: Compile log:
- 0:94(14): error: `gl_DrawIDARB' undeclared
- 0:95(20): error: `gl_BaseInstanceARB' undeclared
- Warn: Unhandled exception (15ShaderException): Couldn't compile vertex shader: generic2D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement