Guest User

Untitled

a guest
May 22nd, 2018
118
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ]cl_renderer "rd-rend2"
  2. cl_renderer will be changed upon restarting.
  3. ]vid_restart
  4. ----- Initializing Renderer ----
  5. Trying to load "rd-rend2_i386.so" from "."...
  6. ----- R_Init -----
  7. SDL using driver "x11"
  8. Initializing display
  9. Display aspect: 1.779
  10. ...setting mode -1: 1366 768
  11. Using 24 color bits, 24 depth, 8 stencil display.
  12. Available modes: '640x360 720x405 864x486 960x540 1024x576 1366x768 680x384 640x480 800x600 1024x768'
  13. Initializing OpenGL 3.2 functions
  14. ...using GLSL version 4.50
  15. GL_RENDERER: Mesa DRI Intel(R) HD Graphics 520 (Skylake GT2) x86/MMX/SSE2
  16. Initializing OpenGL extensions
  17. ...GL_S3_s3tc available
  18. ...no tc preference specified
  19. .....using GL_S3_s3tc
  20. ...GL_EXT_texture_filter_anisotropic available
  21. ...using GL_EXT_texture_filter_anisotropic
  22. ...GL_EXT_texture_compression_latc not found
  23. ...ignoring GL_ARB_texture_compression_bptc
  24. ...using GL_ARB_texture_storage
  25. ...ignoring GL_ARB_buffer_storage
  26. ...ignoring GL_ARB_debug_output
  27. ...using GL_ARB_timer_query
  28. ------- R_InitVBOs -------
  29. ------- FBO_Init -------
  30. ------- GLSL_InitGPUShaders -------
  31. #version 150 core
  32. #ifndef M_PI
  33. #define M_PI 3.14159265358979323846
  34. #endif
  35. #ifndef deformGen_t
  36. #define deformGen_t
  37. #define DEFORM_NONE 0
  38. #define DEFORM_WAVE 1
  39. #define DEFORM_NORMALS 2
  40. #define DEFORM_BULGE 3
  41. #define DEFORM_MOVE 4
  42. #define DEFORM_PROJECTION_SHADOW 5
  43. #define WF_NONE 0
  44. #define WF_SIN 1
  45. #define WF_SQUARE 2
  46. #define WF_TRIANGLE 3
  47. #define WF_SAWTOOTH 4
  48. #define WF_INVERSE_SAWTOOTH 5
  49. #endif
  50. #ifndef tcGen_t
  51. #define tcGen_t
  52. #define TCGEN_LIGHTMAP 2
  53. #define TCGEN_LIGHTMAP1 3
  54. #define TCGEN_LIGHTMAP2 4
  55. #define TCGEN_LIGHTMAP3 5
  56. #define TCGEN_TEXTURE 6
  57. #define TCGEN_ENVIRONMENT_MAPPED 7
  58. #define TCGEN_FOG 8
  59. #define TCGEN_VECTOR 9
  60. #endif
  61. #ifndef colorGen_t
  62. #define colorGen_t
  63. #define CGEN_LIGHTING_DIFFUSE 11
  64. #endif
  65. #ifndef alphaGen_t
  66. #define alphaGen_t
  67. #define AGEN_LIGHTING_SPECULAR 6
  68. #define AGEN_PORTAL 8
  69. #endif
  70. #ifndef texenv_t
  71. #define texenv_t
  72. #define TEXENV_MODULATE 8448
  73. #define TEXENV_ADD 260
  74. #define TEXENV_REPLACE 7681
  75. #endif
  76. #define ALPHA_TEST_GT0 1
  77. #define ALPHA_TEST_LT128 2
  78. #define ALPHA_TEST_GE128 3
  79. #d
  80. efine ALPHA_TEST_GE192 4
  81. #ifndef r_FBufScale
  82. #define r_FBufScale vec2(0.000732, 0.001302)
  83. #endif
  84. #line 1
  85. in vec3 attr_Position;
  86. in vec3 attr_Normal;
  87.  
  88. in vec2 attr_TexCoord0;
  89.  
  90. #if defined(USE_VERTEX_ANIMATION)
  91. in vec3 attr_Position2;
  92. in vec3 attr_Normal2;
  93. #elif defined(USE_SKELETAL_ANIMATION)
  94. in uvec4 attr_BoneIndexes;
  95. in vec4 attr_BoneWeights;
  96. #endif
  97.  
  98. #if defined(USE_DEFORM_VERTEXES)
  99. uniform int u_DeformType;
  100. uniform int u_DeformFunc;
  101. uniform float u_DeformParams[7];
  102. #endif
  103.  
  104. uniform float u_Time;
  105. uniform mat4 u_ModelMatrix;
  106. uniform mat4 u_ModelViewProjectionMatrix;
  107.  
  108. #if defined(USE_VERTEX_ANIMATION)
  109. uniform float u_VertexLerp;
  110. #elif defined(USE_SKELETAL_ANIMATION)
  111. uniform mat4x3 u_BoneMatrices[20];
  112. #endif
  113.  
  114. uniform vec4 u_Color;
  115.  
  116. out vec3 var_WSPosition;
  117.  
  118. #if defined(USE_DEFORM_VERTEXES)
  119. float GetNoiseValue( float x, float y, float z, float t )
  120. {
  121. // Variation on the 'one-liner random function'.
  122. // Not sure if this is still 'correctly' random
  123. return fract( sin( dot(
  124. vec4( x, y, z, t ),
  125. vec4( 12.9898, 78
  126. .233, 12.9898, 78.233 )
  127. )) * 43758.5453 );
  128. }
  129.  
  130. float CalculateDeformScale( in int func, in float time, in float phase, in float frequency )
  131. {
  132. float value = phase + time * frequency;
  133.  
  134. switch ( func )
  135. {
  136. case WF_SIN:
  137. return sin(value * 2.0 * M_PI);
  138. case WF_SQUARE:
  139. return sign(0.5 - fract(value));
  140. case WF_TRIANGLE:
  141. return abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0;
  142. case WF_SAWTOOTH:
  143. return fract(value);
  144. case WF_INVERSE_SAWTOOTH:
  145. return 1.0 - fract(value);
  146. default:
  147. return 0.0;
  148. }
  149. }
  150.  
  151. vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)
  152. {
  153. switch ( u_DeformType )
  154. {
  155. default:
  156. {
  157. return pos;
  158. }
  159.  
  160. case DEFORM_BULGE:
  161. {
  162. float bulgeHeight = u_DeformParams[1]; // amplitude
  163. float bulgeWidth = u_DeformParams[2]; // phase
  164. float bulgeSpeed = u_DeformParams[3]; // frequency
  165.  
  166. float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed );
  167.  
  168. return pos + normal * scale * bulgeHeight;
  169. }
  170.  
  171. case DEFORM_WAVE:
  172. {
  173. float base = u_Defor
  174. mParams[0];
  175. float amplitude = u_DeformParams[1];
  176. float phase = u_DeformParams[2];
  177. float frequency = u_DeformParams[3];
  178. float spread = u_DeformParams[4];
  179.  
  180. float offset = dot( pos.xyz, vec3( spread ) );
  181. float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency );
  182.  
  183. return pos + normal * (base + scale * amplitude);
  184. }
  185.  
  186. case DEFORM_MOVE:
  187. {
  188. float base = u_DeformParams[0];
  189. float amplitude = u_DeformParams[1];
  190. float phase = u_DeformParams[2];
  191. float frequency = u_DeformParams[3];
  192. vec3 direction = vec3( u_DeformParams[4], u_DeformParams[5], u_DeformParams[6] );
  193.  
  194. float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency );
  195.  
  196. return pos + direction * (base + scale * amplitude);
  197. }
  198.  
  199. case DEFORM_PROJECTION_SHADOW:
  200. {
  201. vec3 ground = vec3(
  202. u_DeformParams[0],
  203. u_DeformParams[1],
  204. u_DeformParams[2]);
  205. float groundDist = u_DeformParams[3];
  206. vec3 lightDir = vec3(
  207. u_DeformParams[4],
  208. u_DeformParams[5],
  209. u_Deform
  210. Params[6]);
  211.  
  212. float d = dot( lightDir, ground );
  213.  
  214. lightDir = lightDir * max( 0.5 - d, 0.0 ) + ground;
  215. d = 1.0 / dot( lightDir, ground );
  216.  
  217. vec3 lightPos = lightDir * d;
  218.  
  219. return pos - lightPos * dot( pos, ground ) + groundDist;
  220. }
  221. }
  222. }
  223.  
  224. vec3 DeformNormal( const in vec3 position, const in vec3 normal )
  225. {
  226. if ( u_DeformType != DEFORM_NORMALS )
  227. {
  228. return normal;
  229. }
  230.  
  231. float amplitude = u_DeformParams[1];
  232. float frequency = u_DeformParams[3];
  233.  
  234. vec3 outNormal = normal;
  235. const float scale = 0.98;
  236.  
  237. outNormal.x += amplitude * GetNoiseValue(
  238. position.x * scale,
  239. position.y * scale,
  240. position.z * scale,
  241. u_Time * frequency );
  242.  
  243. outNormal.y += amplitude * GetNoiseValue(
  244. 100.0 * position.x * scale,
  245. position.y * scale,
  246. position.z * scale,
  247. u_Time * frequency );
  248.  
  249. outNormal.z += amplitude * GetNoiseValue(
  250. 200.0 * position.x * scale,
  251. position.y * scale,
  252. position.z * scale,
  253. u_Time * frequency );
  254.  
  255. return outNormal;
  256. }
  257. #endif
  258.  
  259. void main()
  260. {
  261. #if defined(USE_VERTEX_ANIMATION)
  262. vec3 position
  263. = mix(attr_Position, attr_Position2, u_VertexLerp);
  264. vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp);
  265. normal = normalize(normal - vec3(0.5));
  266. #elif defined(USE_SKELETAL_ANIMATION)
  267. vec4 position4 = vec4(0.0);
  268. vec4 normal4 = vec4(0.0);
  269. vec4 originalPosition = vec4(attr_Position, 1.0);
  270. vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0);
  271.  
  272. for (int i = 0; i < 4; i++)
  273. {
  274. uint boneIndex = attr_BoneIndexes[i];
  275.  
  276. mat4 boneMatrix = mat4(
  277. vec4(u_BoneMatrices[boneIndex][0], 0.0),
  278. vec4(u_BoneMatrices[boneIndex][1], 0.0),
  279. vec4(u_BoneMatrices[boneIndex][2], 0.0),
  280. vec4(u_BoneMatrices[boneIndex][3], 1.0)
  281. );
  282.  
  283. position4 += (boneMatrix * originalPosition) * attr_BoneWeights[i];
  284. normal4 += (boneMatrix * originalNormal) * attr_BoneWeights[i];
  285. }
  286.  
  287. vec3 position = position4.xyz;
  288. vec3 normal = normalize(normal4.xyz);
  289. #else
  290. vec3 position = attr_Position;
  291. vec3 normal = attr_Normal * 2.0 - vec3(1.0);
  292. #endif
  293.  
  294. #if defined(USE_DEFORM_VERTEXES)
  295. position = DeformPosition(position, no
  296. rmal, attr_TexCoord0.st);
  297. normal = DeformNormal( position, normal );
  298. #endif
  299.  
  300. gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
  301.  
  302. var_WSPosition = (u_ModelMatrix * vec4(position, 1.0)).xyz;
  303. }
  304.  
  305. leTextures.w;uniform vec4 u_Color;
  306. #if defined(USE_ALPHA_TEST)
  307. uniform int u_AlphaTestType;
  308. #endif
  309.  
  310. uniform vec4 u_FogPlane;
  311. uniform float u_FogDepthToOpaque;
  312. uniform bool u_FogHasPlane;
  313. uniform vec3 u_ViewOrigin;
  314. in vec3 var_WSPosition;
  315.  
  316. out vec4 out_Color;
  317. out vec4 out_Glow;
  318.  
  319. float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float depthToOpaque, in bool hasPlane)
  320. {
  321. // line: x = o + tv
  322. // plane: (x . n) + d = 0
  323. // intersects: dot(o + tv, n) + d = 0
  324. // dot(o + tv, n) = -d
  325. // dot(o, n) + t*dot(n, v) = -d
  326. // t = -(d + dot(o, n)) / dot(n, v)
  327. vec3 V = position - viewOrigin;
  328.  
  329. // fogPlane is inverted in tr_bsp for some reason.
  330. float t = -(fogPlane.w + dot(viewOrigin, -fogPlane.xyz)) / dot(V, -fogPlane.xyz);
  331.  
  332. bool inFog = ((dot(viewOrigin, fo
  333. gPlane.xyz) - fogPlane.w) >= 0.0) || !hasPlane;
  334. bool intersects = (t > 0.0 && t <= 1.0);
  335.  
  336. // this is valid only when t > 0.0. When t < 0.0, then intersection point is behind
  337. // the camera, meaning we're facing away from the fog plane, which probably means
  338. // we're inside the fog volume.
  339. vec3 intersectsAt = viewOrigin + t*V;
  340.  
  341. float distToVertexFromIntersection = distance(intersectsAt, position);
  342. float distToVertexFromViewOrigin = distance(viewOrigin, position);
  343.  
  344. float distToVertex = mix(distToVertexFromViewOrigin,
  345. distToVertexFromIntersection,
  346. !inFog && intersects);
  347.  
  348. float z = depthToOpaque * distToVertex;
  349. return 1.0 - clamp(exp(-(z * z)), 0.0, 1.0);
  350. }
  351.  
  352. void main()
  353. {
  354. float fog = CalcFog(u_ViewOrigin, var_WSPosition, u_FogPlane, u_FogDepthToOpaque, u_FogHasPlane);
  355. out_Color.rgb = u_Color.rgb;
  356. out_Color.a = sqrt(clamp(fog, 0.0, 1.0));
  357.  
  358. #if defined(USE_ALPHA_TEST)
  359. if (u_AlphaTestType == ALPHA_TEST_GT0)
  360. {
  361. if (out_Color.a == 0.0)
  362. discard;
  363. }
  364. else if (u_AlphaTestType == ALPHA_TE
  365. ST_LT128)
  366. {
  367. if (out_Color.a >= 0.5)
  368. discard;
  369. }
  370. else if (u_AlphaTestType == ALPHA_TEST_GE128)
  371. {
  372. if (out_Color.a < 0.5)
  373. discard;
  374. }
  375. else if (u_AlphaTestType == ALPHA_TEST_GE192)
  376. {
  377. if (out_Color.a < 0.75)
  378. discard;
  379. }
  380. #endif
  381.  
  382. #if defined(USE_GLOW_BUFFER)
  383. out_Glow = out_Color;
  384. #else
  385. out_Glow = vec4(0.0);
  386. #endif
  387. }
  388. rgb;
  389. ambientColor = vec3 (0.0);
  390. attenuation = 1.0;
  391. #elif defined(USE_LIGHT_VECTOR)
  392. lightColor = u_DirectedLight * var_Color.rgb;
  393. ambientColor = u_AmbientLight * var_Color.rgb;
  394. attenuation = CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist);
  395. #elif defined(USE_LIGHT_VERTEX)
  396. lightColor = var_Color.rgb;
  397. ambientColor = vec3 (0.0);
  398. attenuation = 1.0;
  399. #endif
  400.  
  401. N = CalcNormal(var_Normal.xyz, texCoords, tangentToWorld);
  402. L /= sqrt(sqrLightDist);
  403.  
  404. #if defined(USE_SHADOWMAP)
  405. vec2 shadowTex = gl_FragCoord.xy * r_FBufScale;
  406. float shadowValue = texture(u_ShadowMap, shadowTex).r;
  407.  
  408. // surfaces not facing the light are always shadowed
  409. vec3 primaryL
  410. ightDir = normalize(var_PrimaryLightDir.xyz);
  411. shadowValue = mix(0.0, shadowValue, dot(N, primaryLightDir) > 0.0);
  412.  
  413. #if defined(SHADOWMAP_MODULATE)
  414. lightColor = mix(u_PrimaryLightAmbient * lightColor, lightColor, shadowValue);
  415. #endif
  416. #endif
  417.  
  418. #if defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX)
  419. ambientColor = lightColor;
  420. float surfNL = clamp(dot(N, L), 0.0, 1.0);
  421.  
  422. // Scale the incoming light to compensate for the baked-in light angle
  423. // attenuation.
  424. lightColor /= max(surfNL, 0.25);
  425.  
  426. // Recover any unused light as ambient, in case attenuation is over 4x or
  427. // light is below the surface
  428. ambientColor = clamp(ambientColor - lightColor * surfNL, 0.0, 1.0);
  429. #endif
  430.  
  431. vec4 specular = vec4(1.0);
  432. #if defined(USE_SPECULARMAP)
  433. specular = texture(u_SpecularMap, texCoords);
  434. //specular.rgb = sRGBToLinear(specular.rgb);
  435. #endif
  436. specular *= u_SpecularScale;
  437.  
  438. // diffuse is actually base color, and red of specular is metalness
  439. const vec3 DIELECTRIC_SPECULAR = vec3(0.04);
  440. const vec3 METAL_DIFFUS
  441. E = vec3(0.0);
  442.  
  443. float metalness = specular.r;
  444. float roughness = max(specular.a, 0.02);
  445. specular.rgb = mix(DIELECTRIC_SPECULAR, diffuse.rgb, metalness);
  446. diffuse.rgb = mix(diffuse.rgb, METAL_DIFFUSE, metalness);
  447.  
  448. vec3 H = normalize(L + E);
  449. float NE = abs(dot(N, E)) + 1e-5;
  450. float NL = clamp(dot(N, L), 0.0, 1.0);
  451. float LH = clamp(dot(L, H), 0.0, 1.0);
  452.  
  453. vec3 Fd = CalcDiffuse(diffuse.rgb, NE, NL, LH, roughness);
  454. vec3 Fs = vec3(0.0);
  455.  
  456. #if defined(USE_LIGHT_VECTOR)
  457. float NH = clamp(dot(N, H), 0.0, 1.0);
  458.  
  459. Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, roughness);
  460. #endif
  461.  
  462. vec3 reflectance = Fd + Fs;
  463.  
  464. out_Color.rgb = lightColor * reflectance * (attenuation * NL);
  465. out_Color.rgb += ambientColor * diffuse.rgb;
  466.  
  467. #if defined(USE_PRIMARY_LIGHT)
  468. vec3 L2 = normalize(var_PrimaryLightDir.xyz);
  469. vec3 H2 = normalize(L2 + E);
  470. float NL2 = clamp(dot(N, L2), 0.0, 1.0);
  471. float L2H2 = clamp(dot(L2, H2), 0.0, 1.0);
  472. float NH2 = clamp(dot(N, H2), 0.0, 1.0);
  473.  
  474. reflectance = CalcDiff
  475. use(diffuse.rgb, NE, NL2, L2H2, roughness);
  476. reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, L2H2, roughness);
  477.  
  478. lightColor = u_PrimaryLightColor * var_Color.rgb;
  479. #if defined(USE_SHADOWMAP)
  480. lightColor *= shadowValue;
  481. #endif
  482.  
  483. out_Color.rgb += lightColor * reflectance * NL2;
  484. #endif
  485.  
  486. out_Color.rgb += CalcIBLContribution(roughness, N, E, viewDir, NE, specular.rgb);
  487.  
  488. #else
  489. lightColor = var_Color.rgb;
  490. #if defined(USE_LIGHTMAP)
  491. lightColor *= lightmapColor.rgb;
  492. #endif
  493.  
  494. out_Color.rgb = diffuse.rgb * lightColor;
  495. #endif
  496.  
  497. out_Color.a = diffuse.a * var_Color.a;
  498.  
  499. #if defined(USE_GLOW_BUFFER)
  500. out_Glow = out_Color;
  501. #else
  502. out_Glow = vec4(0.0);
  503. #endif
  504. }
  505.  
  506. compile log:
  507. 0:300(3): preprocessor error: #elif without #if
  508.  
  509. 0:304(3): preprocessor error: #elif without #if
  510.  
  511. 0:308(3): preprocessor error: #endif without #if
  512.  
  513. 0:394(1): preprocessor error: #else without #if
  514.  
  515. 0:401(1): preprocessor error: #endif without #if
  516.  
  517.  
  518. RE_Shutdown( 1 )
  519. Closing SDL audio device...
  520. SDL audio device shut down.
  521. Couldn't compile shaderAutomatically freeing 3712 blocks making up 6313646 bytes
RAW Paste Data