Advertisement
Guest User

Untitled

a guest
Jun 14th, 2015
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.91 KB | None | 0 0
  1.  
  2. C:\mame>mame64 mario
  3. ../../../../../src/osd/modules/opengl/gl_shader_tool.c:358: GL Error: object 0x8
  4. compilation failed
  5. ../../../../../src/osd/modules/opengl/gl_shader_tool.c:358 glInfoLog: Fragment s
  6. hader failed to compile with the following errors:
  7. ERROR: 0:236: error(#131) Syntax error: pre-mature EOF parse error
  8. ERROR: error(#273) 1 compilation errors. No code generated
  9.  
  10.  
  11. failed to process shader: <//
  12. // PUBLIC DOMAIN CRT STYLED SCAN-LINE SHADER
  13. //
  14. // by Timothy Lottes
  15. //
  16. // This is more along the style of a really good CGA arcade monitor.
  17. // With RGB inputs instead of NTSC.
  18. // The shadow mask example has the mask rotated 90 degrees for less chromatic ab
  19. erration.
  20. //
  21. // Left it unoptimized to show the theory behind the algorithm.
  22. //
  23. // It is an example what I personally would want as a display option for pixel a
  24. rt games.
  25. // Please take and use, change, or whatever.
  26.  
  27. //Comment these out to disable the corresponding effect.
  28. //#define VERTICAL //rotates shadow mask effect to fix vertical games on landsca
  29. pe monitors
  30. #define CURVATURE //Screen curvature effect.
  31. #define YUV //Tint and Saturation adjustments. You adjust the settings in Lotte
  32. s_CRT.vsh now...
  33. #define GAMMA_CONTRAST_BOOST //Expands contrast and makes image brighter but cau
  34. ses clipping.
  35. #define BLOOM //enables a bloom effect
  36. //#define MASK_APERTURE_GRILL //Only uncomment one of the MASK patterns at a tim
  37. e...
  38. #define MASK_TV
  39. //#define MASK_VGA
  40. //#define ORIGINAL_SCANLINES //Enable to use the original scanlines.
  41. //#define ORIGINAL_HARDPIX //Enable to use the original hardPix calculation.
  42.  
  43. //Normal MAME GLSL Uniforms
  44. uniform sampler2D color_texture;
  45. uniform vec2 color_texture_sz; // size of color_texture
  46.  
  47. uniform vec2 color_texture_pow2_sz; // size of color texture rounded
  48. up to power of 2
  49. uniform vec2 screen_texture_sz; // size of output resolution
  50. uniform vec2 screen_texture_pow2_sz; // size of output resolution rounded
  51. up to power of 2
  52.  
  53. //CRT Filter Variables
  54. const float hardScan=-20.0; //-8,-12,-16, etc to make scalines more prominent.
  55. const vec2 warp=vec2(1.0/64.0,1.0/48.0); //adjusts the warp filter (curvature).
  56.  
  57. const float maskDark=0.4; //Sets how dark a "dark subpixel" is in the aperture p
  58. attern.
  59. const float maskLight=1.5; //Sets how dark a "bright subpixel" is in the apertur
  60. e pattern.
  61. const float hardPix=-5.0; //-1,-2,-4, etc to make the upscaling sharper.
  62. const float hardBloomScan=-2.5;
  63. const float hardBloomPix=-1.75;
  64. const float bloomAmount=1.0/12.0; //Lower this if there is too much bloom!
  65. const float blackClip = 0.02;
  66. const float brightMult = 1.2;
  67. const float maskStrength = 0.6; //This sets the strength of the shadow mask effe
  68. ct
  69. const vec3 gammaBoost = vec3(1.0/1.15, 1.0/1.15, 1.0/1.15);
  70. varying vec3 YUVr;
  71. varying vec3 YUVg;
  72. varying vec3 YUVb;
  73.  
  74. //CRT Filter Functions
  75.  
  76. // sRGB to Linear.
  77. // Assuing using sRGB typed textures this should not be needed.
  78. float ToLinear1(float c){return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);}
  79. vec3 ToLinear(vec3 c){return vec3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b));
  80. }
  81.  
  82. // Linear to sRGB.
  83. // Assuing using sRGB typed textures this should not be needed.
  84. float ToSrgb1(float c){return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);}
  85. vec3 ToSrgb(vec3 c){return vec3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));}
  86.  
  87. // Nearest emulated sample given floating point position and texel offset.
  88. // Also zero's off screen.
  89. vec3 Fetch(vec2 pos,vec2 off){
  90. pos=(floor(pos*color_texture_pow2_sz+off)+0.5)/color_texture_pow2_sz;
  91. //if(max(abs(pos.x-0.5),abs(pos.y-0.5))>0.5)return vec3(0.0,0.0,0.0);
  92. return ToLinear(texture2D(color_texture,pos.xy).rgb);}
  93.  
  94. // Distance in emulated pixels to nearest texel.
  95. vec2 Dist(vec2 pos){pos=pos*color_texture_pow2_sz;return -((pos-floor(pos))-vec2
  96. (0.5));}
  97.  
  98. // 1D Gaussian.
  99. float Gaus(float pos,float scale){return exp2(scale*pos*pos);}
  100.  
  101. // 3-tap Gaussian filter along horz line.
  102. vec3 Horz3(vec2 pos,float off){
  103. vec3 b=Fetch(pos,vec2(-1.0,off));
  104. vec3 c=Fetch(pos,vec2( 0.0,off));
  105. vec3 d=Fetch(pos,vec2( 1.0,off));
  106. float dst=Dist(pos).x;
  107. // Convert distance to weight.
  108. #ifdef ORIGINAL_HARDPIX
  109. float scale=hardPix;
  110. #else
  111. float scale=hardPix * max(0.2, 1.5-color_texture_sz.x/512.0);
  112. #endif
  113. float wb=Gaus(dst-1.0,scale);
  114. float wc=Gaus(dst+0.0,scale);
  115. float wd=Gaus(dst+1.0,scale);
  116. // Return filtered sample.
  117. return (b*wb+c*wc+d*wd)/(wb+wc+wd);}
  118.  
  119. // 5-tap Gaussian filter along horz line.
  120. vec3 Horz5(vec2 pos,float off){
  121. vec3 a=Fetch(pos,vec2(-2.0,off));
  122. vec3 b=Fetch(pos,vec2(-1.0,off));
  123. vec3 c=Fetch(pos,vec2( 0.0,off));
  124. vec3 d=Fetch(pos,vec2( 1.0,off));
  125. vec3 e=Fetch(pos,vec2( 2.0,off));
  126. float dst=Dist(pos).x;
  127. // Convert distance to weight.
  128. #ifdef ORIGINAL_HARDPIX
  129. float scale=hardPix;
  130. #else
  131. float scale=hardPix * max(0.2, 1.5-color_texture_sz.x/512.0);
  132. #endif
  133. float wa=Gaus(dst-2.0,scale);
  134. float wb=Gaus(dst-1.0,scale);
  135. float wc=Gaus(dst+0.0,scale);
  136. float wd=Gaus(dst+1.0,scale);
  137. float we=Gaus(dst+2.0,scale);
  138. // Return filtered sample.
  139. return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}
  140.  
  141. vec3 Horz7(vec2 pos,float off){
  142. vec3 a=Fetch(pos,vec2(-3.0,off));
  143. vec3 b=Fetch(pos,vec2(-2.0,off));
  144. vec3 c=Fetch(pos,vec2(-1.0,off));
  145. vec3 d=Fetch(pos,vec2( 0.0,off));
  146. vec3 e=Fetch(pos,vec2( 1.0,off));
  147. vec3 f=Fetch(pos,vec2( 2.0,off));
  148. vec3 g=Fetch(pos,vec2( 3.0,off));
  149. float dst=Dist(pos).x;
  150. // Convert distance to weight.
  151. float scale=hardBloomPix* max(0.5, 1.5-color_texture_sz.x/512.0);
  152. float wa=Gaus(dst-3.0,scale);
  153. float wb=Gaus(dst-2.0,scale);
  154. float wc=Gaus(dst-1.0,scale);
  155. float wd=Gaus(dst+0.0,scale);
  156. float we=Gaus(dst+1.0,scale);
  157. float wf=Gaus(dst+2.0,scale);
  158. float wg=Gaus(dst+3.0,scale);
  159. // Return filtered sample.
  160. return (a*wa+b*wb+c*wc+d*wd+e*we+f*wf+g*wg)/(wa+wb+wc+wd+we+wf+wg);}
  161.  
  162. // Return scanline weight.
  163. float Scan(vec2 pos,float off){
  164. float dst=Dist(pos).y;
  165. #ifdef ORIGINAL_SCANLINES
  166. return Gaus(dst+off,hardScan);}
  167. #else
  168. vec3 col=Fetch(pos,vec2(0.0));
  169. return Gaus(dst+off,hardScan/(dot(col,col)*0.25+1.0));} //Modified to make sca
  170. nline respond to pixel brightness
  171. #endif
  172.  
  173. // Return scanline weight for bloom.
  174. float BloomScan(vec2 pos,float off){
  175. float dst=Dist(pos).y;
  176. return Gaus(dst+off,hardBloomScan);}
  177.  
  178. // Allow nearest three lines to effect pixel.
  179. vec3 Tri(vec2 pos){
  180. vec3 a=Horz3(pos,-1.0);
  181. vec3 b=Horz5(pos, 0.0);
  182. vec3 c=Horz3(pos, 1.0);
  183. float wa=Scan(pos,-1.0);
  184. float wb=Scan(pos, 0.0);
  185. float wc=Scan(pos, 1.0);
  186. return a*wa+b*wb+c*wc;}
  187.  
  188. // Small bloom.
  189. vec3 Bloom(vec2 pos){
  190. vec3 a=Horz5(pos,-2.0);
  191. vec3 b=Horz7(pos,-1.0);
  192. vec3 c=Horz7(pos, 0.0);
  193. vec3 d=Horz7(pos, 1.0);
  194. vec3 e=Horz5(pos, 2.0);
  195. float wa=BloomScan(pos,-2.0);
  196. float wb=BloomScan(pos,-1.0);
  197. float wc=BloomScan(pos, 0.0);
  198. float wd=BloomScan(pos, 1.0);
  199. float we=BloomScan(pos, 2.0);
  200. return a*wa+b*wb+c*wc+d*wd+e*we;}
  201.  
  202. // Distortion of scanlines, and end of screen alpha.
  203. vec2 Warp(vec2 pos){
  204. pos=pos*2.0-1.0;
  205. pos*=vec2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y);
  206. return pos*0.5+0.5;}
  207.  
  208. // Shadow mask.
  209.  
  210. vec3 Mask(vec2 pos){
  211. #ifdef VERTICAL
  212. pos.xy=pos.yx;
  213. #endif
  214. #ifdef MASK_VGA
  215. pos.x+=pos.y*3.0;
  216. vec3 mask=vec3(maskDark,maskDark,maskDark);
  217. pos.x=fract(pos.x/6.0);
  218. if(pos.x<0.333)mask.r=maskLight;
  219. else if(pos.x<0.666)mask.g=maskLight;
  220. else mask.b=maskLight;
  221. #endif
  222. #ifdef MASK_TV
  223. float line=maskLight;
  224. float odd=0.0;
  225. if(fract(pos.x/6.0)<0.5)odd=1.0;
  226. if(fract((pos.y+odd)/2.0)<0.5)line=maskDark;
  227. pos.x=fract(pos.x/3.0);
  228. vec3 mask=vec3(maskDark,maskDark,maskDark);
  229. if(pos.x<0.333)mask.r=maskLight;
  230. else if(pos.x<0.666)mask.g=maskLight;
  231. else mask.b=maskLight;
  232. mask*=line;
  233. #endif
  234. #ifdef MASK_APERTURE_GRILL
  235. pos.x=fract(pos.x/3.0);
  236. vec3 mask=vec3(maskDark,maskDark,maskDark);
  237. if(pos.x<0.333)mask.r=maskLight;
  238. else if(pos.x<0.666)mask.g=maskLight;
  239. else mask.b=maskLight;
  240. #endif
  241. return mask;}
  242.  
  243. void main(void){
  244. #ifdef CURVATURE
  245. vec2 pos=Warp(gl_TexCoord[0].xy);
  246. #else
  247. vec2 pos=gl_TexCoord[0].xy;
  248. #endif
  249. gl_FragColor.a=texture2D(color_texture,pos.xy).a;
  250. gl_FragColor.rgb=Tri(pos)*mix(vec3(1.0),Mask(gl_FragCoord.xy),maskStrength);
  251. #ifdef BLOOM
  252. gl_FragColor.rgb+=Bloom(pos)*bloomAmount;
  253. #endif
  254. #ifdef YUV
  255. gl_FragColor.rgb = vec3(dot(YUVr,gl_FragColor.rgb),dot(YUVg,gl_FragColor.rgb),
  256. dot(YUVb,gl_FragColor.rgb));
  257. gl_FragColor.rgb=clamp(gl_FragColor.rgb,0.0,1.0);
  258. #endif
  259. #ifdef GAMMA_CONTRAST_BOOST
  260. gl_FragColor.rgb=brightMult*pow(gl_FragColor.rgb,gammaBoost )-vec3(blackClip);
  261.  
  262. #endif
  263. gl_FragColor.rgb=clamp(ToSrgb(gl_FragColor.rgb),0.0,1.0);
  264. >
  265. failed to process shader_file: Lottes_CRT_rgb32_dir.fsh
  266. OpenGL: GLSL loading mame bitmap shader 0 failed (Lottes_CRT)
  267. Average speed: 100.00% (5 seconds)
  268. ../../../../../src/osd/modules/opengl/gl_shader_tool.c:331: GL Error: 1281 0x501
  269.  
  270.  
  271. C:\mame>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement