-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 36a1709
Showing
9 changed files
with
487 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# drastic_ds_shaders |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// lcd1x+nds_color shader | ||
============================================= | ||
<options> | ||
name=LCD1x + NDS Color | ||
textures=1 | ||
</options> | ||
|
||
<fheader> | ||
#if GL_ES | ||
#ifdef GL_FRAGMENT_PRECISION_HIGH | ||
precision highp float; | ||
#else | ||
precision mediump float; | ||
#endif | ||
#endif | ||
// Configuration | ||
#define BRIGHTEN_SCANLINES 16.0 // "Brighten Scanlines" - default: 16.0, min: 1.0, max: 32.0, step: 0.5 | ||
// (brightness of horizontal lines) | ||
#define BRIGHTEN_LCD 4.0 // "Brighten LCD" - default: 4.0, min: 1.0, max: 12.0, step: 0.1 | ||
// (brightness of vertical lines) | ||
</fheader> | ||
|
||
<texture:0> | ||
input=framebuffer | ||
min_filter=GL_NEAREST | ||
mag_filter=GL_NEAREST | ||
</texture> | ||
|
||
<pass> | ||
shader=lcd1x+nds_color.dsd | ||
sampler:u_texture=0 | ||
</pass> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// lcd1x+nds_color - Simple LCD 'scanline' shader, based on lcd3x | ||
// | ||
// - Original lcd3x code by Gigaherz, released into the public domain | ||
// | ||
// - Original 'nds_color' code written by hunterk, modified by Pokefan531 and | ||
// released into the public domain | ||
// | ||
// 'Ported' (i.e. copy/paste) to DraStic format by jdgleaver | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 2 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// lcd1x+nds_color differs from lcd3x in the following manner: | ||
// | ||
// > Omits LCD-style colour separation | ||
// | ||
// > Has 'correctly' aligned scanlines | ||
// | ||
// > Automatically supports 'high resolution 3d rendering' ON or OFF | ||
// | ||
// > Applies NDS colour correction | ||
============================================= | ||
|
||
<vertex> | ||
|
||
attribute vec2 a_vertex_coordinate; | ||
attribute vec2 a_texture_coordinate; | ||
uniform vec4 u_texture_size; | ||
|
||
varying vec2 v_texture_coordinate; | ||
|
||
void main() | ||
{ | ||
v_texture_coordinate = a_texture_coordinate; | ||
gl_Position = vec4(a_vertex_coordinate.xy, 0.0, 1.0); | ||
} | ||
|
||
</vertex> | ||
|
||
<fragment> | ||
|
||
#ifndef BRIGHTEN_SCANLINES | ||
#define BRIGHTEN_SCANLINES 16.0 | ||
#endif | ||
#ifndef BRIGHTEN_LCD | ||
#define BRIGHTEN_LCD 4.0 | ||
#endif | ||
|
||
#define PI 3.141592654 | ||
|
||
// Colour defines... | ||
#define target_gamma 2.2 | ||
#define display_gamma 2.2 | ||
#define r 0.83 | ||
#define g 0.65 | ||
#define b 0.765 | ||
#define rg 0.105 | ||
#define rb 0.105 | ||
#define gr 0.20 | ||
#define gb 0.13 | ||
#define br -0.03 | ||
#define bg 0.245 | ||
|
||
uniform sampler2D u_texture; | ||
uniform vec4 u_texture_size; | ||
|
||
varying vec2 v_texture_coordinate; | ||
|
||
const float NDS_SCREEN_HEIGHT = 192.0; | ||
const float INV_BRIGHTEN_SCANLINES_INC = 1.0 / (BRIGHTEN_SCANLINES + 1.0); | ||
const float INV_BRIGHTEN_LCD_INC = 1.0 / (BRIGHTEN_LCD + 1.0); | ||
|
||
void main() | ||
{ | ||
// Note to self: uniform vec4 u_texture_size(1.0/w, 1.0/h, w, h) | ||
|
||
// Generate LCD grid effect | ||
// > Note the 0.25 pixel offset -> required to ensure that | ||
// scanlines occur *between* pixels | ||
// > Divide pixel coordinate by current scale factor (texture_height / NDS_SCREEN_HEIGHT) | ||
vec2 angle = 2.0 * PI * (((v_texture_coordinate.xy * u_texture_size.zw) * NDS_SCREEN_HEIGHT * u_texture_size.y) - 0.25); | ||
|
||
float yfactor = (BRIGHTEN_SCANLINES + sin(angle.y)) * INV_BRIGHTEN_SCANLINES_INC; | ||
float xfactor = (BRIGHTEN_LCD + sin(angle.x)) * INV_BRIGHTEN_LCD_INC; | ||
|
||
// Get colour sample and apply colour correction | ||
vec3 colour = pow(texture2D(u_texture, v_texture_coordinate.xy).rgb, vec3(target_gamma)); | ||
colour = clamp(colour, 0.0, 1.0); | ||
colour = pow( | ||
mat3(r, rg, rb, | ||
gr, g, gb, | ||
br, bg, b) * colour, | ||
vec3(1.0 / display_gamma) | ||
); | ||
|
||
// Apply LCD grid effect | ||
colour.rgb = yfactor * xfactor * colour.rgb; | ||
|
||
gl_FragColor = vec4(colour.rgb, 1.0); | ||
} | ||
|
||
</fragment> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// lcd1x shader | ||
============================================= | ||
<options> | ||
name=LCD1x | ||
textures=1 | ||
</options> | ||
|
||
<fheader> | ||
#if GL_ES | ||
#ifdef GL_FRAGMENT_PRECISION_HIGH | ||
precision highp float; | ||
#else | ||
precision mediump float; | ||
#endif | ||
#endif | ||
// Configuration | ||
#define BRIGHTEN_SCANLINES 16.0 // "Brighten Scanlines" - default: 16.0, min: 1.0, max: 32.0, step: 0.5 | ||
// (brightness of horizontal lines) | ||
#define BRIGHTEN_LCD 4.0 // "Brighten LCD" - default: 4.0, min: 1.0, max: 12.0, step: 0.1 | ||
// (brightness of vertical lines) | ||
</fheader> | ||
|
||
<texture:0> | ||
input=framebuffer | ||
min_filter=GL_NEAREST | ||
mag_filter=GL_NEAREST | ||
</texture> | ||
|
||
<pass> | ||
shader=lcd1x.dsd | ||
sampler:u_texture=0 | ||
</pass> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// lcd1x - Simple LCD 'scanline' shader, based on lcd3x | ||
// | ||
// Original code by Gigaherz, released into the public domain | ||
// | ||
// 'Ported' (i.e. copy/paste) to DraStic format by jdgleaver | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 2 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// lcd1x differs from lcd3x in the following manner: | ||
// | ||
// > Omits LCD-style colour separation | ||
// | ||
// > Has 'correctly' aligned scanlines | ||
// | ||
// > Automatically supports 'high resolution 3d rendering' ON or OFF | ||
============================================= | ||
|
||
<vertex> | ||
|
||
attribute vec2 a_vertex_coordinate; | ||
attribute vec2 a_texture_coordinate; | ||
uniform vec4 u_texture_size; | ||
|
||
varying vec2 v_texture_coordinate; | ||
|
||
void main() | ||
{ | ||
v_texture_coordinate = a_texture_coordinate; | ||
gl_Position = vec4(a_vertex_coordinate.xy, 0.0, 1.0); | ||
} | ||
|
||
</vertex> | ||
|
||
<fragment> | ||
|
||
#ifndef BRIGHTEN_SCANLINES | ||
#define BRIGHTEN_SCANLINES 16.0 | ||
#endif | ||
#ifndef BRIGHTEN_LCD | ||
#define BRIGHTEN_LCD 4.0 | ||
#endif | ||
|
||
#define PI 3.141592654 | ||
|
||
uniform sampler2D u_texture; | ||
uniform vec4 u_texture_size; | ||
|
||
varying vec2 v_texture_coordinate; | ||
|
||
const float NDS_SCREEN_HEIGHT = 192.0; | ||
const float INV_BRIGHTEN_SCANLINES_INC = 1.0 / (BRIGHTEN_SCANLINES + 1.0); | ||
const float INV_BRIGHTEN_LCD_INC = 1.0 / (BRIGHTEN_LCD + 1.0); | ||
|
||
void main() | ||
{ | ||
// Note to self: uniform vec4 u_texture_size(1.0/w, 1.0/h, w, h) | ||
|
||
// Generate LCD grid effect | ||
// > Note the 0.25 pixel offset -> required to ensure that | ||
// scanlines occur *between* pixels | ||
// > Divide pixel coordinate by current scale factor (texture_height / NDS_SCREEN_HEIGHT) | ||
vec2 angle = 2.0 * PI * (((v_texture_coordinate.xy * u_texture_size.zw) * NDS_SCREEN_HEIGHT * u_texture_size.y) - 0.25); | ||
|
||
float yfactor = (BRIGHTEN_SCANLINES + sin(angle.y)) * INV_BRIGHTEN_SCANLINES_INC; | ||
float xfactor = (BRIGHTEN_LCD + sin(angle.x)) * INV_BRIGHTEN_LCD_INC; | ||
|
||
// Get colour sample | ||
vec3 colour = texture2D(u_texture, v_texture_coordinate.xy).rgb; | ||
|
||
// Apply LCD grid effect | ||
colour.rgb = yfactor * xfactor * colour.rgb; | ||
|
||
gl_FragColor = vec4(colour.rgb, 1.0); | ||
} | ||
|
||
</fragment> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// zfast_lcd+nds_color shader | ||
============================================= | ||
<options> | ||
name=zFast LCD + NDS Color | ||
textures=1 | ||
</options> | ||
|
||
<fheader> | ||
#if GL_ES | ||
#ifdef GL_FRAGMENT_PRECISION_HIGH | ||
precision highp float; | ||
#else | ||
precision mediump float; | ||
#endif | ||
#endif | ||
// Configuration: BORDERMULT "Border Multiplier" 14.0 -40.0 40.0 1.0 | ||
#define BORDERMULT 14.0 | ||
</fheader> | ||
|
||
<texture:0> | ||
input=framebuffer | ||
min_filter=GL_NEAREST | ||
mag_filter=GL_NEAREST | ||
</texture> | ||
|
||
<pass> | ||
shader=zfast_lcd+nds_color.dsd | ||
sampler:u_texture=0 | ||
</pass> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// zfast_lcd+nds_color - A very simple LCD shader meant to be used at 1080p | ||
// | ||
// - Original 'zfast_lcd' code copyright (C) 2017 Greg Hogan (SoltanGris42) | ||
// | ||
// - Original 'nds_color' code written by hunterk, modified by Pokefan531 and | ||
// released into the public domain | ||
// | ||
// 'Ported' (i.e. copy/paste) to DraStic format by jdgleaver | ||
// | ||
// This program is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU General Public License as published by the Free | ||
// Software Foundation; either version 2 of the License, or (at your option) | ||
// any later version. | ||
// | ||
// Notes: This shader applies colour correction to mimic the display characteristics | ||
// of an NDS Phat, then applies a simple grid effect, darkening the borders of | ||
// 'virtual' pixels at the native NDS resolution to imitate an LCD screen. | ||
// You can change the darkness/thickness of the borders. | ||
// The shader is compatible with both 'native' and 'high resolution' 3D | ||
// rendering modes. | ||
// | ||
// *** Integer screen scaling is recommended for best results | ||
============================================= | ||
|
||
<vertex> | ||
|
||
attribute vec2 a_vertex_coordinate; | ||
attribute vec2 a_texture_coordinate; | ||
uniform vec4 u_texture_size; | ||
|
||
varying vec2 v_texture_coordinate; | ||
|
||
void main() | ||
{ | ||
v_texture_coordinate = a_texture_coordinate; | ||
gl_Position = vec4(a_vertex_coordinate.xy, 0.0, 1.0); | ||
} | ||
|
||
</vertex> | ||
|
||
<fragment> | ||
|
||
#ifndef BORDERMULT | ||
#define BORDERMULT 14.0 | ||
#endif | ||
|
||
// Colour defines... | ||
#define target_gamma 2.2 | ||
#define display_gamma 2.2 | ||
#define r 0.83 | ||
#define g 0.65 | ||
#define b 0.765 | ||
#define rg 0.105 | ||
#define rb 0.105 | ||
#define gr 0.20 | ||
#define gb 0.13 | ||
#define br -0.03 | ||
#define bg 0.245 | ||
|
||
uniform sampler2D u_texture; | ||
uniform vec4 u_texture_size; | ||
|
||
varying vec2 v_texture_coordinate; | ||
|
||
const float NDS_SCREEN_HEIGHT = 192.0; | ||
|
||
void main() | ||
{ | ||
// Generate grid pattern (in native NDS coordinate space) | ||
// - Have to divide by the current scale factor... | ||
// There can only be two values here: | ||
// > 'High-Resolution 3D Rendering' OFF - scale factor == 1 | ||
// > 'High-Resolution 3D Rendering' ON - scale factor == 2 | ||
// But it's easiest to assume the general case... | ||
// scale_factor == texture_height / NDS_SCREEN_HEIGHT | ||
vec2 texcoordInPixels = v_texture_coordinate.xy * u_texture_size.zw * (NDS_SCREEN_HEIGHT * u_texture_size.y); | ||
vec2 centerCoord = floor(texcoordInPixels.xy) + vec2(0.5, 0.5); | ||
vec2 distFromCenter = abs(centerCoord - texcoordInPixels); | ||
|
||
float Y = max(distFromCenter.x, distFromCenter.y); | ||
|
||
Y = Y * Y; | ||
float YY = Y * Y; | ||
float YYY = YY * Y; | ||
|
||
float LineWeight = YY - 2.7 * YYY; | ||
LineWeight = 1.0 - BORDERMULT * LineWeight; | ||
|
||
// Apply colour correction | ||
vec3 screen = pow(texture2D(u_texture, v_texture_coordinate.xy).rgb, vec3(target_gamma)); | ||
screen = clamp(screen, 0.0, 1.0); | ||
screen = pow( | ||
mat3(r, rg, rb, | ||
gr, g, gb, | ||
br, bg, b) * screen, | ||
vec3(1.0 / display_gamma) | ||
); | ||
|
||
// Add grid lines | ||
gl_FragColor = vec4(screen * LineWeight, 1.0); | ||
} | ||
|
||
</fragment> |
Oops, something went wrong.