|
249 | 249 | "// uniform mediump vec4 UserVec4;\n",
|
250 | 250 | "uniform mediump float ColorFringe;\n",
|
251 | 251 | "// uniform highp float ClientTime;\n",
|
252 |
| -"// uniform sampler2D Texture_LUT;\n", |
| 252 | +"uniform sampler2D Texture_LUT;\n", |
253 | 253 | "uniform mediump vec2 PixelSize;\n",
|
254 | 254 | "\n",
|
255 | 255 | "#ifdef USEFXAA\n",
|
|
299 | 299 | "}\n",
|
300 | 300 | "#endif\n",
|
301 | 301 | "\n",
|
| 302 | +"#ifdef USEPOSTPROCESSING\n", |
| 303 | +"// https://github.com/mattdesl/glsl-lut\n", |
| 304 | +"vec4 sampleLUT(sampler2D lookupTable, vec3 textureColor) {\n", |
| 305 | +" mediump float blueColor = textureColor.b * 63.0;\n", |
| 306 | +"\n", |
| 307 | +" mediump vec2 quad1;\n", |
| 308 | +" quad1.y = floor(floor(blueColor) / 8.0);\n", |
| 309 | +" quad1.x = floor(blueColor) - (quad1.y * 8.0);\n", |
| 310 | +"\n", |
| 311 | +" mediump vec2 quad2;\n", |
| 312 | +" quad2.y = floor(ceil(blueColor) / 8.0);\n", |
| 313 | +" quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n", |
| 314 | +"\n", |
| 315 | +" highp vec2 texPos1;\n", |
| 316 | +" texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);\n", |
| 317 | +" texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);\n", |
| 318 | +"\n", |
| 319 | +" highp vec2 texPos2;\n", |
| 320 | +" texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);\n", |
| 321 | +" texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);\n", |
| 322 | +"\n", |
| 323 | +" lowp vec4 newColor1 = texture2D(lookupTable, texPos1);\n", |
| 324 | +" lowp vec4 newColor2 = texture2D(lookupTable, texPos2);\n", |
| 325 | +"\n", |
| 326 | +" lowp vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n", |
| 327 | +" return newColor;\n", |
| 328 | +"}\n", |
| 329 | +"#endif\n", |
| 330 | +"\n", |
302 | 331 | "void main(void)\n",
|
303 | 332 | "{\n",
|
304 | 333 | " float fringe = ColorFringe;//.0033f;\n",
|
|
312 | 341 | "#endif\n",
|
313 | 342 | "\n",
|
314 | 343 | "#ifdef USEPOSTPROCESSING\n",
|
| 344 | +" // color grading using LUTs\n", |
| 345 | +" vec4 oldColor = dp_texture2D(Texture_First, TexCoord1);\n", |
| 346 | +" dp_FragColor.rgb = sampleLUT(Texture_LUT, oldColor.rgb).rgb;\n", |
| 347 | +" dp_FragColor.a = oldColor.a;\n", |
| 348 | +"#endif\n", |
| 349 | +"\n", |
| 350 | +"#ifdef USEPOSTPROCESSING\n", |
315 | 351 | "// do r_glsl_dumpshader, edit glsl/default.glsl, and replace this by your own postprocessing if you want\n",
|
316 | 352 | "// this code does a blur with the radius specified in the first component of r_glsl_postprocess_uservec1 and blends it using the second component\n",
|
317 | 353 | "#if defined(USERVEC1) || defined(USERVEC2)\n",
|
|
0 commit comments