- Provant el shader crt-pi
This commit is contained in:
27
crtpi.glsl
27
crtpi.glsl
@@ -41,7 +41,7 @@ MASK_TYPE defines what, if any, shadow mask to use. MASK_BRIGHTNESS defines how
|
|||||||
#define MULTISAMPLE
|
#define MULTISAMPLE
|
||||||
#define GAMMA
|
#define GAMMA
|
||||||
//#define FAKE_GAMMA
|
//#define FAKE_GAMMA
|
||||||
//#define CURVATURE
|
#define CURVATURE
|
||||||
//#define SHARPER
|
//#define SHARPER
|
||||||
// MASK_TYPE: 0 = none, 1 = green/magenta, 2 = trinitron(ish)
|
// MASK_TYPE: 0 = none, 1 = green/magenta, 2 = trinitron(ish)
|
||||||
#define MASK_TYPE 1
|
#define MASK_TYPE 1
|
||||||
@@ -64,8 +64,8 @@ uniform COMPAT_PRECISION float BLOOM_FACTOR;
|
|||||||
uniform COMPAT_PRECISION float INPUT_GAMMA;
|
uniform COMPAT_PRECISION float INPUT_GAMMA;
|
||||||
uniform COMPAT_PRECISION float OUTPUT_GAMMA;
|
uniform COMPAT_PRECISION float OUTPUT_GAMMA;
|
||||||
#else
|
#else
|
||||||
#define CURVATURE_X 0.10
|
#define CURVATURE_X 0.25
|
||||||
#define CURVATURE_Y 0.25
|
#define CURVATURE_Y 0.45
|
||||||
#define MASK_BRIGHTNESS 0.70
|
#define MASK_BRIGHTNESS 0.70
|
||||||
#define SCANLINE_WEIGHT 6.0
|
#define SCANLINE_WEIGHT 6.0
|
||||||
#define SCANLINE_GAP_BRIGHTNESS 0.12
|
#define SCANLINE_GAP_BRIGHTNESS 0.12
|
||||||
@@ -78,7 +78,7 @@ uniform COMPAT_PRECISION float OUTPUT_GAMMA;
|
|||||||
- GLSL compilers
|
- GLSL compilers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uniform vec2 TextureSize;
|
//uniform vec2 TextureSize;
|
||||||
#if defined(CURVATURE)
|
#if defined(CURVATURE)
|
||||||
varying vec2 screenScale;
|
varying vec2 screenScale;
|
||||||
#endif
|
#endif
|
||||||
@@ -86,20 +86,20 @@ varying vec2 TEX0;
|
|||||||
varying float filterWidth;
|
varying float filterWidth;
|
||||||
|
|
||||||
#if defined(VERTEX)
|
#if defined(VERTEX)
|
||||||
uniform mat4 MVPMatrix;
|
//uniform mat4 MVPMatrix;
|
||||||
attribute vec4 VertexCoord;
|
//attribute vec4 VertexCoord;
|
||||||
attribute vec2 TexCoord;
|
//attribute vec2 TexCoord;
|
||||||
uniform vec2 InputSize;
|
//uniform vec2 InputSize;
|
||||||
uniform vec2 OutputSize;
|
//uniform vec2 OutputSize;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
#if defined(CURVATURE)
|
#if defined(CURVATURE)
|
||||||
screenScale = TextureSize / InputSize;
|
screenScale = vec2(1.0, 1.0); //TextureSize / InputSize;
|
||||||
#endif
|
#endif
|
||||||
filterWidth = (InputSize.y / OutputSize.y) / 3.0;
|
filterWidth = (768.0 / 240.0) / 3.0;
|
||||||
TEX0 = TexCoord*1.0001;
|
TEX0 = vec2(gl_MultiTexCoord0.x, 1.0-gl_MultiTexCoord0.y)*1.0001;
|
||||||
gl_Position = MVPMatrix * VertexCoord;
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||||
}
|
}
|
||||||
#elif defined(FRAGMENT)
|
#elif defined(FRAGMENT)
|
||||||
|
|
||||||
@@ -146,6 +146,7 @@ float CalcScanLine(float dy)
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
vec2 TextureSize = vec2(320.0, 240.0);
|
||||||
#if defined(CURVATURE)
|
#if defined(CURVATURE)
|
||||||
vec2 texcoord = Distort(TEX0);
|
vec2 texcoord = Distort(TEX0);
|
||||||
if (texcoord.x < 0.0)
|
if (texcoord.x < 0.0)
|
||||||
|
|||||||
15
main.cpp
15
main.cpp
@@ -21,8 +21,8 @@
|
|||||||
#include <SDL2/SDL_opengl_glext.h>
|
#include <SDL2/SDL_opengl_glext.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const int WIN_WIDTH = 640;
|
const int WIN_WIDTH = 1024;
|
||||||
const int WIN_HEIGHT = 480;
|
const int WIN_HEIGHT = 768;
|
||||||
|
|
||||||
const int WORLD_WIDTH = 320;
|
const int WORLD_WIDTH = 320;
|
||||||
const int WORLD_HEIGHT = 240;
|
const int WORLD_HEIGHT = 240;
|
||||||
@@ -81,8 +81,11 @@ GLuint compileShader(const char* source, GLuint shaderType) {
|
|||||||
//std::cout << "Compilando shader:" << std::endl << source << std::endl;
|
//std::cout << "Compilando shader:" << std::endl << source << std::endl;
|
||||||
// Create ID for shader
|
// Create ID for shader
|
||||||
GLuint result = glCreateShader(shaderType);
|
GLuint result = glCreateShader(shaderType);
|
||||||
|
|
||||||
|
const char *sources[2] = { shaderType==GL_VERTEX_SHADER?"#define VERTEX\n":"#define FRAGMENT\n", source };
|
||||||
|
|
||||||
// Define shader text
|
// Define shader text
|
||||||
glShaderSource(result, 1, &source, NULL);
|
glShaderSource(result, 2, sources, NULL);
|
||||||
// Compile shader
|
// Compile shader
|
||||||
glCompileShader(result);
|
glCompileShader(result);
|
||||||
|
|
||||||
@@ -118,9 +121,6 @@ GLuint compileProgram(const char* vtxFile, const char* fragFile) {
|
|||||||
std::string source((std::istreambuf_iterator<char>(f)),
|
std::string source((std::istreambuf_iterator<char>(f)),
|
||||||
std::istreambuf_iterator<char>());
|
std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
/*const char *sources[2] = { "#define VERTEX\n", source.c_str() };
|
|
||||||
glShaderSourceARB(shader, 2, sources, NULL);*/
|
|
||||||
|
|
||||||
vtxShaderId = compileShader(source.c_str(), GL_VERTEX_SHADER);
|
vtxShaderId = compileShader(source.c_str(), GL_VERTEX_SHADER);
|
||||||
|
|
||||||
f=std::ifstream(fragFile);
|
f=std::ifstream(fragFile);
|
||||||
@@ -159,6 +159,8 @@ void presentBackBuffer(SDL_Renderer *renderer, SDL_Window* win, SDL_Texture* bac
|
|||||||
GLint oldProgramId;
|
GLint oldProgramId;
|
||||||
// Guarrada para obtener el textureid (en driverdata->texture)
|
// Guarrada para obtener el textureid (en driverdata->texture)
|
||||||
//Detach the texture
|
//Detach the texture
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
|
||||||
SDL_SetRenderTarget(renderer, NULL);
|
SDL_SetRenderTarget(renderer, NULL);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
@@ -291,6 +293,7 @@ int main(int argc, char **argv){
|
|||||||
|
|
||||||
while ( ! done ) {
|
while ( ! done ) {
|
||||||
//Render to the texture
|
//Render to the texture
|
||||||
|
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||||
SDL_SetRenderTarget(renderer, texTarget);
|
SDL_SetRenderTarget(renderer, texTarget);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user