| @@ -1,5 +1,5 @@ | |||
| [vert.glsl] | |||
| #version 120 | |||
| attribute vec3 in_Vertex; | |||
| @@ -26,7 +26,7 @@ void main(void) | |||
| gl_Position = in_Proj * eye; | |||
| } | |||
| [frag.glsl] | |||
| #version 120 | |||
| #if defined GL_ES | |||
| @@ -72,7 +72,7 @@ void main(void) | |||
| gl_FragColor = real_color * vec4(light, 1.0); | |||
| } | |||
| [vert.hlsl] | |||
| void main(float3 in_Vertex : POSITION, | |||
| float3 in_Normal : NORMAL, | |||
| @@ -99,7 +99,7 @@ void main(float3 in_Vertex : POSITION, | |||
| out_Position = mul(in_Proj, eye); | |||
| } | |||
| [frag.hlsl] | |||
| void main(float4 pass_Eye : TEXCOORD0, | |||
| float3 pass_TNormal : TEXCOORD1, | |||
| @@ -93,13 +93,13 @@ Shader *Shader::Create(char const *lolfx) | |||
| for (char *parser = src; *parser; ) | |||
| { | |||
| if (key == NULL && (parser[0] == '\n' || parser[0] == '\r') | |||
| && parser[1] == '-' && parser[2] == '-' && parser[3] == ' ') | |||
| && parser[1] == '[') | |||
| { | |||
| *parser = '\0'; | |||
| parser += 4; | |||
| parser += 2; | |||
| key = parser; | |||
| } | |||
| else if (key && parser[0] == ' ') | |||
| else if (key && parser[0] == ']') | |||
| { | |||
| *parser++ = '\0'; | |||
| } | |||
| @@ -119,18 +119,24 @@ Shader *Shader::Create(char const *lolfx) | |||
| for (int i = 0; i < sections.Count(); i++) | |||
| { | |||
| #if !defined __CELLOS_LV2__ && !defined _XBOX && !defined USE_D3D9 | |||
| if (!strcmp(sections[i].m1, "GLSL.Vert")) | |||
| if (!strcmp(sections[i].m1, "vert.glsl")) | |||
| vert = sections[i].m2; | |||
| if (!strcmp(sections[i].m1, "GLSL.Frag")) | |||
| if (!strcmp(sections[i].m1, "frag.glsl")) | |||
| frag = sections[i].m2; | |||
| #else | |||
| if (!strcmp(sections[i].m1, "HLSL.Vert")) | |||
| if (!strcmp(sections[i].m1, "vert.hlsl")) | |||
| vert = sections[i].m2; | |||
| if (!strcmp(sections[i].m1, "HLSL.Frag")) | |||
| if (!strcmp(sections[i].m1, "frag.hlsl")) | |||
| frag = sections[i].m2; | |||
| #endif | |||
| } | |||
| /* FIXME: we don’t know how to handle these yet. */ | |||
| if (!vert) | |||
| Log::Error("no vertex shader found… sorry, I’m gonna crash now.\n"); | |||
| if (!frag) | |||
| Log::Error("no fragment shader found… sorry, I’m gonna crash now.\n"); | |||
| uint32_t new_vert_crc = Hash::Crc32(vert); | |||
| uint32_t new_frag_crc = Hash::Crc32(frag); | |||
| @@ -495,7 +501,7 @@ void Shader::SetUniform(ShaderUniform const &uni, mat3 const &m) | |||
| { | |||
| #if defined USE_D3D9 || defined _XBOX | |||
| /* Padding matrix columns is necessary on DirectX. We need to create | |||
| * a new data structure; a 4×4 matrix will do. */ | |||
| * a new data structure; a 4×4 matrix will do. */ | |||
| mat4 tmp(m, 1.0f); | |||
| if (uni.flags & 1) | |||
| g_d3ddevice->SetPixelShaderConstantF((UINT)uni.frag, &tmp[0][0], 3); | |||
| @@ -66,8 +66,7 @@ technique Foo | |||
| /* Defines GLSL shader "Prout" */ | |||
| #pragma lolfx vertexshader(lang=GLSL 1.20, name=prout) | |||
| [prout.glsl] | |||
| #version 120 | |||
| /* Valid with my GLSL compiler */ | |||
| @@ -84,7 +83,7 @@ void main(void) | |||
| } | |||
| /* Defines GLSL shader "Zob" */ | |||
| #pragma lolfx vertexshader(lang=GLSL 1.20, name=zob) | |||
| [zob.glsl] | |||
| void main(void) | |||
| { | |||
| @@ -93,7 +92,7 @@ void main(void) | |||
| /* Defines HLSL vertex shader "Prout" */ | |||
| #pragma lolfx vertexshader(lang=HLSL, name=prout) | |||
| [prout.hlsl] | |||
| void main(void) | |||
| { | |||
| @@ -1,4 +1,4 @@ | |||
| [vert.glsl] | |||
| #version 130 | |||
| @@ -17,7 +17,7 @@ void main() | |||
| pass_TexCoord = in_TexCoord; | |||
| } | |||
| [frag.glsl] | |||
| #version 130 | |||
| @@ -68,7 +68,7 @@ void main() | |||
| gl_FragColor = col; | |||
| } | |||
| [vert.hlsl] | |||
| void main(float4 in_Position : POSITION, | |||
| float2 in_TexCoord : TEXCOORD0, | |||
| @@ -82,7 +82,7 @@ void main(float4 in_Position : POSITION, | |||
| out_TexCoord = in_TexCoord; | |||
| } | |||
| [frag.hlsl] | |||
| void main(float2 in_TexCoord : TEXCOORD0, | |||
| #if 0 | |||
| @@ -1,4 +1,4 @@ | |||
| [vert.glsl] | |||
| #version 130 | |||
| @@ -17,7 +17,7 @@ void main() | |||
| pass_Color = in_Color; | |||
| } | |||
| [frag.glsl] | |||
| #version 130 | |||
| @@ -49,7 +49,7 @@ void main() | |||
| gl_FragColor = col; | |||
| } | |||
| [vert.hlsl] | |||
| void main(float4 in_Vertex : POSITION, | |||
| float4 in_Color : COLOR, | |||
| @@ -63,7 +63,7 @@ void main(float4 in_Vertex : POSITION, | |||
| out_Color = in_Color; | |||
| } | |||
| [frag.hlsl] | |||
| float4x4 bayer = float4x4( 0.0, 12.0, 3.0, 15.0, | |||
| 8.0, 4.0, 11.0, 7.0, | |||
| @@ -1,5 +1,17 @@ | |||
| /* | |||
| * Awesome triangle shader | |||
| */ | |||
| technique Triangle | |||
| { | |||
| pass FirstPass | |||
| { | |||
| vertexshader = vert; | |||
| pixelshader = frag; | |||
| } | |||
| } | |||
| [vert.glsl] | |||
| #version 120 | |||
| attribute vec2 in_Position; | |||
| @@ -9,8 +21,7 @@ void main(void) | |||
| gl_Position = vec4(in_Position, 0.0, 1.0); | |||
| } | |||
| [frag.glsl] | |||
| #version 120 | |||
| void main(void) | |||
| @@ -18,16 +29,14 @@ void main(void) | |||
| gl_FragColor = vec4(0.7, 0.2, 0.5, 1.0); | |||
| } | |||
| [vert.hlsl] | |||
| void main(float2 in_Position : POSITION, | |||
| out float4 out_Position : POSITION) | |||
| { | |||
| out_Position = float4(in_Position, 0.0, 1.0); | |||
| } | |||
| [frag.hlsl] | |||
| void main(out float4 out_FragColor : COLOR) | |||
| { | |||
| out_FragColor = float4(0.7, 0.2, 0.5, 1.0); | |||
| @@ -1,4 +1,4 @@ | |||
| [vert.glsl] | |||
| #version 120 | |||
| @@ -13,7 +13,7 @@ void main(void) | |||
| pass_Color = in_Color; | |||
| } | |||
| [frag.glsl] | |||
| #version 120 | |||
| @@ -24,7 +24,7 @@ void main(void) | |||
| gl_FragColor = vec4(pass_Color, 1.0); | |||
| } | |||
| [vert.hlsl] | |||
| void main(float3 in_Vertex : POSITION, | |||
| float3 in_Color : COLOR, | |||
| @@ -36,7 +36,7 @@ void main(float3 in_Vertex : POSITION, | |||
| out_Position = mul(in_Matrix, float4(in_Vertex, 1.0)); | |||
| } | |||
| [frag.hlsl] | |||
| void main(float3 pass_Color : COLOR, | |||
| out float4 out_FragColor : COLOR) | |||
| @@ -1,4 +1,4 @@ | |||
| [vert.glsl] | |||
| #version 120 | |||
| @@ -42,7 +42,7 @@ void main(void) | |||
| gl_Position = vec4(in_Position, 0.0, 1.0); | |||
| } | |||
| [frag.glsl] | |||
| #version 120 | |||
| @@ -134,7 +134,7 @@ void main(void) | |||
| gl_FragColor = color; | |||
| } | |||
| [vert.hlsl] | |||
| float mod289(float x) | |||
| { | |||
| @@ -173,7 +173,7 @@ void main(float2 in_Position : POSITION, | |||
| out_Position = float4(in_Position, 0.0, 1.0); | |||
| } | |||
| [frag.hlsl] | |||
| float4 mod289(float4 x) | |||
| { | |||
| @@ -1,4 +1,4 @@ | |||
| [vert.glsl] | |||
| #version 120 | |||
| @@ -12,7 +12,7 @@ void main() | |||
| gl_Position = vec4(in_Position, 0.0, 1.0); | |||
| } | |||
| [frag.glsl] | |||
| #version 120 | |||
| @@ -50,7 +50,7 @@ void main(void) | |||
| } | |||
| } | |||
| [vert.hlsl] | |||
| void main(float2 in_Position : POSITION, | |||
| out float2 pass_Position : TEXCOORD0, | |||
| @@ -60,7 +60,7 @@ void main(float2 in_Position : POSITION, | |||
| out_Position = float4(in_Position, 0.0, 1.0); | |||
| } | |||
| [frag.hlsl] | |||
| void main(in float2 pass_Position : TEXCOORD0, | |||
| uniform sampler2D in_Texture, | |||
| @@ -1,4 +1,4 @@ | |||
| [vert.glsl] | |||
| #version 120 | |||
| @@ -49,7 +49,7 @@ void main(void) | |||
| v_IndexY = v_CenterY * u_ScreenSize.w - offsets.zwwz; | |||
| } | |||
| [frag.glsl] | |||
| #version 120 | |||
| @@ -131,7 +131,7 @@ void main(void) | |||
| #endif | |||
| } | |||
| [vert.hlsl] | |||
| void main(float2 a_Vertex : POSITION, | |||
| float2 a_TexCoord : TEXCOORD0, | |||
| @@ -166,7 +166,7 @@ void main(float2 a_Vertex : POSITION, | |||
| v_IndexY = v_CenterY * u_ScreenSize.w - offsets.zwwz; | |||
| } | |||
| [frag.hlsl] | |||
| void main(in float4 v_CenterX : TEXCOORD0, | |||
| in float4 v_CenterY : TEXCOORD1, | |||