Convert other shaders

This commit is contained in:
twinaphex 2016-05-28 18:43:00 +02:00
parent 653359911a
commit 3d5cc14030
6 changed files with 161 additions and 143 deletions

View File

@ -1,43 +1,50 @@
static const char *stock_vertex_xmb_modern =
"in vec3 VertexCoord;\n"
"uniform float time;\n"
"out vec3 fragVertexEc;\n"
"float iqhash( float n )\n"
"{\n"
" return fract(sin(n)*43758.5453);\n"
"}\n"
"float noise( vec3 x )\n"
"{\n"
" vec3 p = floor(x);\n"
" vec3 f = fract(x);\n"
" f = f*f*(3.0-2.0*f);\n"
" float n = p.x + p.y*57.0 + 113.0*p.z;\n"
" return mix(mix(mix( iqhash(n+0.0 ), iqhash(n+1.0 ),f.x),\n"
" mix( iqhash(n+57.0 ), iqhash(n+58.0 ),f.x),f.y),\n"
" mix(mix( iqhash(n+113.0), iqhash(n+114.0),f.x),\n"
" mix( iqhash(n+170.0), iqhash(n+171.0),f.x),f.y),f.z);\n"
"}\n"
"float xmb_noise2( vec3 x )\n"
"{\n"
" return cos((x.z*1.0)*2.0);"
"}\n"
"void main()\n"
"{\n"
" vec3 v = vec3(VertexCoord.x, 0.0, VertexCoord.y);\n"
" vec3 v2 = v;\n"
" vec3 v3 = v;\n"
#include "shaders_common.h"
" v.y = xmb_noise2(v2)/6.0;\n"
static const char *stock_vertex_xmb_modern = GLSL(
in vec3 VertexCoord;
uniform float time;
out vec3 fragVertexEc;
" v3.x = v3.x + time/5.0;\n"
" v3.x = v3.x / 2.0;\n"
float iqhash( float n )
{
return fract(sin(n)*43758.5453);
}
" v3.z = v3.z + time/10.0;\n"
" v3.y = v3.y + time/100.0;\n"
float noise( vec3 x )
{
vec3 p = floor(x);
vec3 f = fract(x);
f = f*f*(3.0-2.0*f);
float n = p.x + p.y*57.0 + 113.0*p.z;
return mix(mix(mix( iqhash(n+0.0 ), iqhash(n+1.0 ),f.x),
mix( iqhash(n+57.0 ), iqhash(n+58.0 ),f.x),f.y),
mix(mix( iqhash(n+113.0), iqhash(n+114.0),f.x),
mix( iqhash(n+170.0), iqhash(n+171.0),f.x),f.y),f.z);
}
" v.z = v.z + noise(v3*7.0)/15.0;\n"
" v.y = v.y + noise(v3*7.0)/15.0 + cos(v.x*2.0-time/5.0)/5.0 - 0.3;\n"
float xmb_noise2( vec3 x )
{
return cos((x.z*1.0)*2.0);
}
" gl_Position = vec4(v, 1.0);\n"
" fragVertexEc = gl_Position.xyz;\n"
"}\n";
void main()
{
vec3 v = vec3(VertexCoord.x, 0.0, VertexCoord.y);
vec3 v2 = v;
vec3 v3 = v;
v.y = xmb_noise2(v2)/6.0;
v3.x = v3.x + time/5.0;
v3.x = v3.x / 2.0;
v3.z = v3.z + time/10.0;
v3.y = v3.y + time/100.0;
v.z = v.z + noise(v3*7.0)/15.0;
v.y = v.y + noise(v3*7.0)/15.0 + cos(v.x*2.0-time/5.0)/5.0 - 0.3;
gl_Position = vec4(v, 1.0);
fragVertexEc = gl_Position.xyz;
}
);

View File

@ -1,37 +1,38 @@
static const char *nuklear_shader =
"struct input\n"
"{\n"
" float time;\n"
"};\n"
#include "shaders_common.h"
"void main_vertex\n"
"(\n"
" float4 position : POSITION,\n"
" float4 color : COLOR,\n"
" float2 texCoord : TEXCOORD0,\n"
static const char *nuklear_shader = GLSL(
struct input
{
float time;
};
" uniform float4x4 modelViewProj,\n"
void main_vertex
(
float4 position : POSITION,
float4 color : COLOR,
float2 texCoord : TEXCOORD0,
" 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"
uniform float4x4 modelViewProj,
"struct output \n"
"{\n"
" float4 color : COLOR;\n"
"};\n"
out float4 oPosition : POSITION,
out float4 oColor : COLOR,
out float2 otexCoord : TEXCOORD
)
{
oPosition = mul(modelViewProj, position);
oColor = color;
otexCoord = texCoord;
}
struct output
{
float4 color : COLOR;
};
"output main_fragment(float2 texCoord : TEXCOORD0, uniform sampler2D Texture : TEXUNIT0, uniform input IN)\n"
"{\n"
" output OUT;\n"
" OUT.color = tex2D(Texture, texCoord);\n"
" return OUT;\n"
"}\n"
;
output main_fragment(float2 texCoord : TEXCOORD0, uniform sampler2D Texture : TEXUNIT0, uniform input IN)\
{
output OUT;
OUT.color = tex2D(Texture, texCoord);
return OUT;
}
);

View File

@ -1,10 +1,13 @@
static const char *nuklear_fragment_shader =
"#version 300 es\n"
"precision mediump float;\n"
"uniform sampler2D Texture;\n"
"in vec2 Frag_UV;\n"
"in vec4 Frag_Color;\n"
"out vec4 Out_Color;\n"
"void main(){\n"
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
"}\n";
#include "shaders_common.h"
static const char *nuklear_fragment_shader = GLSL_330_ES(
precision mediump float;
uniform sampler2D Texture;
in vec2 Frag_UV;
in vec4 Frag_Color;
out vec4 Out_Color;
void main(){
Out_Color = Frag_Color * texture(Texture, Frag_UV.st);
}
);

View File

@ -1,13 +1,17 @@
static const char *nuklear_vertex_shader =
"#version 300 es\n"
"uniform mat4 ProjMtx;\n"
"in vec2 Position;\n"
"in vec2 TexCoord;\n"
"in vec4 Color;\n"
"out vec2 Frag_UV;\n"
"out vec4 Frag_Color;\n"
"void main() {\n"
" Frag_UV = TexCoord;\n"
" Frag_Color = Color;\n"
" gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
"}\n";
#include "shaders_common.h"
static const char *nuklear_vertex_shader = GLSL_330_ES(
uniform mat4 ProjMtx;
in vec2 Position;
in vec2 TexCoord;
in vec4 Color;
out vec2 Frag_UV;
out vec4 Frag_Color;
void main()
{
Frag_UV = TexCoord;
Frag_Color = Color;
gl_Position = ProjMtx * vec4(Position.xy, 0, 1);
}
);

View File

@ -1,58 +1,60 @@
static const char *stock_xmb_simple =
"struct input\n"
"{\n"
" float time;\n"
"};\n"
#include "shaders_common.h"
"float iqhash(float n)\n"
"{\n"
"return frac(sin(n)*43758.5453);\n"
"}\n"
static const char *stock_xmb_simple = GLSL(
struct input
{
float time;
};
"float noise(float3 x)\n"
"{\n"
"float3 p = floor(x);\n"
"float3 f = frac(x);\n"
"f = f * f * (3.0 - 2.0 * f);\n"
"float n = p.x + p.y * 57.0 + 113.0 * p.z;\n"
"return lerp(lerp(lerp(iqhash(n+0.0), iqhash(n+1.0), f.x),\n"
"lerp(iqhash(n+57.0), iqhash(n+58.0), f.x), f.y),\n"
"lerp(lerp(iqhash(n+113.0), iqhash(n+114.0), f.x),\n"
"lerp(iqhash(n+170.0), iqhash(n+171.0), f.x), f.y), f.z);\n"
"}\n"
float iqhash(float n)
{
return frac(sin(n)*43758.5453);
}
"void main_vertex\n"
"(\n"
" float2 position : POSITION,\n"
" float4 color : COLOR,\n"
" float2 texCoord : TEXCOORD0,\n"
float noise(float3 x)
{
float3 p = floor(x);
float3 f = frac(x);
f = f * f * (3.0 - 2.0 * f);
float n = p.x + p.y * 57.0 + 113.0 * p.z;
return lerp(lerp(lerp(iqhash(n+0.0), iqhash(n+1.0), f.x),
lerp(iqhash(n+57.0), iqhash(n+58.0), f.x), f.y),
lerp(lerp(iqhash(n+113.0), iqhash(n+114.0), f.x),
lerp(iqhash(n+170.0), iqhash(n+171.0), f.x), f.y), f.z);
}
" uniform input IN,\n"
void main_vertex
(
float2 position : POSITION,
float4 color : COLOR,
float2 texCoord : TEXCOORD0,
" out float4 oPosition : POSITION,\n"
" out float4 oColor : COLOR,\n"
" out float2 otexCoord : TEXCOORD\n"
")\n"
"{\n"
"float3 v = float3(position.x, 0.0, position.y);\n"
"float3 v2 = v;\n"
"v2.x = v2.x + IN.time / 2.0;\n"
"v2.z = v.z * 3.0;\n"
"v.y = -cos((v.x + v.z / 3.0 + IN.time) * 2.0) / 10.0 - noise(v2.xyz) / 3.0;\n"
" oPosition = float4(v, 1.0);\n"
" oColor = color;\n"
" otexCoord = texCoord;\n"
"}\n"
uniform input IN,
"struct output\n"
"{\n"
" float4 color : COLOR;\n"
"};\n"
out float4 oPosition : POSITION,
out float4 oColor : COLOR,
out float2 otexCoord : TEXCOORD
)
{
float3 v = float3(position.x, 0.0, position.y);
float3 v2 = v;
v2.x = v2.x + IN.time / 2.0;
v2.z = v.z * 3.0;
v.y = -cos((v.x + v.z / 3.0 + IN.time) * 2.0) / 10.0 - noise(v2.xyz) / 3.0;
oPosition = float4(v, 1.0);
oColor = color;
otexCoord = texCoord;
}
"output main_fragment(uniform input IN) \n"
"{\n"
" output OUT;\n"
" OUT.color = float4(1.0, 1.0, 1.0, 0.05);\n"
" return OUT;\n"
"}\n"
;
struct output
{
float4 color : COLOR;
};
output main_fragment(uniform input IN)
{
output OUT;
OUT.color = float4(1.0, 1.0, 1.0, 0.05);
return OUT;
}
);

View File

@ -3,6 +3,7 @@
#define GLSL(src) "" #src
#define GLSL_330_ES(src) "#version 330 es\n" #src
#define GLSL_330_CORE(src) "#version 330 core\n" #src
#endif