(D3D) Cleanups of shaders

This commit is contained in:
twinaphex 2016-08-01 22:43:51 +02:00
parent 3787d9d691
commit c314077f1d
4 changed files with 122 additions and 94 deletions

View File

@ -1,30 +1,37 @@
static const char *font_hlsl_d3d9_program =
"struct VS_IN\n"
"{\n"
"float2 Pos : POSITION;\n"
"float2 Tex : TEXCOORD0;\n"
"};\n"
"struct VS_OUT\n"
"{\n"
"float4 Position : POSITION;\n"
"float2 TexCoord0 : TEXCOORD0;\n"
"};\n"
"uniform float4 Color : register(c1);\n"
"uniform float2 TexScale : register(c2);\n"
"sampler FontTexture : register(s0);\n"
"VS_OUT main_vertex( VS_IN In )\n"
"{\n"
"VS_OUT Out;\n"
"Out.Position.x = (In.Pos.x-0.5);\n"
"Out.Position.y = (In.Pos.y-0.5);\n"
"Out.Position.z = ( 0.0 );\n"
"Out.Position.w = ( 1.0 );\n"
"Out.TexCoord0.x = In.Tex.x * TexScale.x;\n"
"Out.TexCoord0.y = In.Tex.y * TexScale.y;\n"
"return Out;\n"
"}\n"
"float4 main_fragment( VS_OUT In ) : COLOR0\n"
"{\n"
"float4 FontTexel = tex2D( FontTexture, In.TexCoord0 );\n"
"return FontTexel;\n"
"}\n";
#include "shaders_common.h"
static const char *font_hlsl_d3d9_program = CG(
struct VS_IN
{
float2 Pos : POSITION;
float2 Tex : TEXCOORD0;
};
struct VS_OUT
{
float4 Position : POSITION;
float2 TexCoord0 : TEXCOORD0;
};
uniform float4 Color : register(c1);
uniform float2 TexScale : register(c2);
sampler FontTexture : register(s0);
VS_OUT main_vertex( VS_IN In )
{
VS_OUT Out;
Out.Position.x = (In.Pos.x-0.5);
Out.Position.y = (In.Pos.y-0.5);
Out.Position.z = ( 0.0 );
Out.Position.w = ( 1.0 );
Out.TexCoord0.x = In.Tex.x * TexScale.x;
Out.TexCoord0.y = In.Tex.y * TexScale.y;
return Out;
}
float4 main_fragment( VS_OUT In ) : COLOR0
{
float4 FontTexel = tex2D( FontTexture, In.TexCoord0 );
return FontTexel;
}
);

View File

@ -1,23 +1,26 @@
static const char *stock_cg_d3d9_program =
"void main_vertex"
"("
" float4 position : POSITION,"
" float2 texCoord : TEXCOORD0,"
" float4 color : COLOR,"
""
" uniform float4x4 modelViewProj,"
""
" out float4 oPosition : POSITION,"
" out float2 otexCoord : TEXCOORD0,"
" out float4 oColor : COLOR"
")"
"{"
" oPosition = mul(modelViewProj, position);"
" otexCoord = texCoord;"
" oColor = color;"
"}"
""
"float4 main_fragment(in float4 color : COLOR, float2 tex : TEXCOORD0, uniform sampler2D s0 : TEXUNIT0) : COLOR"
"{"
" return color * tex2D(s0, tex);"
"}";
#include "shaders_common.h"
static const char *stock_cg_d3d9_program = CG(
void main_vertex
(
float4 position : POSITION,
float2 texCoord : TEXCOORD0,
float4 color : COLOR,
uniform float4x4 modelViewProj,
out float4 oPosition : POSITION,
out float2 otexCoord : TEXCOORD0,
out float4 oColor : COLOR
)
{
oPosition = mul(modelViewProj, position);
otexCoord = texCoord;
oColor = color;
}
float4 main_fragment(in float4 color : COLOR, float2 tex : TEXCOORD0, uniform sampler2D s0 : TEXUNIT0) : COLOR
{
return color * tex2D(s0, tex);
}
);

View File

@ -1,41 +1,44 @@
static const char *stock_hlsl_program =
"void main_vertex\n"
"(\n"
" float4 position : POSITION,\n"
" float4 color : COLOR,\n"
"\n"
" uniform float4x4 modelViewProj,\n"
"\n"
" float4 texCoord : TEXCOORD0,\n"
" out float4 oPosition : POSITION,\n"
" out float4 oColor : COLOR,\n"
" out float2 otexCoord : TEXCOORD\n"
")\n"
"{\n"
" oPosition = mul(modelViewProj, position);\n"
" oColor = color;\n"
" otexCoord = texCoord;\n"
"}\n"
"\n"
"struct output\n"
"{\n"
" float4 color: COLOR;\n"
"};\n"
"\n"
"struct input\n"
"{\n"
" float2 video_size;\n"
" float2 texture_size;\n"
" float2 output_size;\n"
" float frame_count;\n"
" float frame_direction;\n"
" float frame_rotation;\n"
"};\n"
"\n"
"output main_fragment(float2 texCoord : TEXCOORD0,\n"
"uniform sampler2D decal : TEXUNIT0, uniform input IN)\n"
"{\n"
" output OUT;\n"
" OUT.color = tex2D(decal, texCoord);\n"
" return OUT;\n"
"}\n";
#include "shaders_common.h"
static const char *stock_hlsl_program = CG(
void main_vertex
(
float4 position : POSITION,
float4 color : COLOR,
uniform float4x4 modelViewProj,
float4 texCoord : TEXCOORD0,
out float4 oPosition : POSITION,
out float4 oColor : COLOR,
out float2 otexCoord : TEXCOORD
)
{
oPosition = mul(modelViewProj, position);
oColor = color;
otexCoord = texCoord;
}
struct outpu
{
float4 color: COLOR;
};
struct input
{
float2 video_size;
float2 texture_size;
float2 output_size;
float frame_count;
float frame_direction;
float frame_rotation;
};
output main_fragment(float2 texCoord : TEXCOORD0,
uniform sampler2D decal : TEXUNIT0, uniform input IN)
{
output OUT;
OUT.color = tex2D(decal, texCoord);
return OUT;
}
);

View File

@ -0,0 +1,15 @@
#ifndef _SHADERS_COMMON
#define _SHADERS_COMMON
#if defined(HAVE_OPENGLES)
#define CG(src) "" #src
#define GLSL(src) "precision mediump float;\n" #src
#define GLSL_330(src) "#version 330 es\nprecision mediump float;\n" #src
#else
#define CG(src) "" #src
#define GLSL(src) "" #src
#define GLSL_300(src) "#version 300 es\n" #src
#define GLSL_330(src) "#version 330 core\n" #src
#endif
#endif