@@ -732,12 +732,12 @@ CatShaderData::CatShaderData(uint32_t vert_decl_flags, Shader* shader) | |||
//----------------------------------------------------------------------------- | |||
void CatShaderData::SetupDefaultData() | |||
{ | |||
AddUniform("in_model_view"); | |||
AddUniform("in_normal_mat"); | |||
AddUniform("in_proj"); | |||
AddUniform("in_texture"); | |||
AddUniform("in_sprite_orientation"); | |||
AddUniform("in_sprite_flip"); | |||
AddUniform("u_model_view"); | |||
AddUniform("u_normal_mat"); | |||
AddUniform("u_proj"); | |||
AddUniform("u_texture"); | |||
AddUniform("u_sprite_orientation"); | |||
AddUniform("u_sprite_flip"); | |||
} | |||
//----------------------------------------------------------------------------- | |||
@@ -750,12 +750,12 @@ void CatShaderData::SetupShaderDatas(mat4 const &model) | |||
mat4 modelview = view * model; | |||
mat3 normalmat = transpose(inverse(mat3(view))); | |||
m_shader->SetUniform(*GetUniform("in_model_view"), modelview); | |||
m_shader->SetUniform(*GetUniform("in_normal_mat"), normalmat); | |||
m_shader->SetUniform(*GetUniform("in_proj"), proj); | |||
m_shader->SetUniform(*GetUniform("in_texture"), m_tex_uniform, 0); | |||
m_shader->SetUniform(*GetUniform("in_sprite_orientation"), m_sprite_orientation); | |||
m_shader->SetUniform(*GetUniform("in_sprite_flip"), m_sprite_flip); | |||
m_shader->SetUniform(*GetUniform("u_model_view"), modelview); | |||
m_shader->SetUniform(*GetUniform("u_normal_mat"), normalmat); | |||
m_shader->SetUniform(*GetUniform("u_proj"), proj); | |||
m_shader->SetUniform(*GetUniform("u_texture"), m_tex_uniform, 0); | |||
m_shader->SetUniform(*GetUniform("u_sprite_orientation"), m_sprite_orientation); | |||
m_shader->SetUniform(*GetUniform("u_sprite_flip"), m_sprite_flip); | |||
} | |||
int main(int argc, char **argv) | |||
@@ -1,27 +1,27 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec4 in_Color; | |||
attribute vec4 in_TexCoord; | |||
in vec3 in_position; | |||
in vec4 in_color; | |||
in vec4 in_texcoord; | |||
uniform mat4 in_model_view; | |||
uniform mat3 in_normal_mat; | |||
uniform mat4 in_proj; | |||
uniform float in_sprite_orientation; | |||
uniform mat4 u_model_view; | |||
uniform mat3 u_normal_mat; | |||
uniform mat4 u_proj; | |||
uniform float u_sprite_orientation; | |||
varying vec4 pass_texcoord; | |||
varying vec4 pass_color; | |||
out vec4 pass_texcoord; | |||
out vec4 pass_color; | |||
void main(void) | |||
{ | |||
vec4 vertex = in_model_view * vec4(in_Position - vec3(0.0,0.5,0.0), 1.0); | |||
vec4 vertex = u_model_view * vec4(in_position - vec3(0.0,0.5,0.0), 1.0); | |||
vec3 v_offset = vec3(1.0 * in_TexCoord.z, -1.0 * in_TexCoord.w, 0.0); | |||
vec3 v_offset = vec3(1.0 * in_texcoord.z, -1.0 * in_texcoord.w, 0.0); | |||
float sinX = sin(in_sprite_orientation); | |||
float cosX = cos(in_sprite_orientation); | |||
float sinX = sin(u_sprite_orientation); | |||
float cosX = cos(u_sprite_orientation); | |||
float sinY = sinX; | |||
mat2 rotationMatrix = mat2(cosX, -sinX, sinY, cosX); | |||
@@ -31,24 +31,24 @@ void main(void) | |||
vertex.xyz += v_offset; | |||
//pass datas | |||
pass_texcoord = in_TexCoord; | |||
pass_color = in_Color; | |||
pass_texcoord = in_texcoord; | |||
pass_color = in_color; | |||
gl_Position = in_proj * vertex; | |||
gl_Position = u_proj * vertex; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform sampler2D in_texture; | |||
uniform float in_sprite_flip; | |||
in vec4 pass_texcoord; | |||
in vec4 pass_color; | |||
varying vec4 pass_texcoord; | |||
varying vec4 pass_color; | |||
uniform sampler2D u_texture; | |||
uniform float u_sprite_flip; | |||
const float cos_45 = 0.70710678118; | |||
const float PI = 3.14159265358979323846264; | |||
@@ -75,10 +75,10 @@ const int sample_nb = 2; | |||
void main(void) | |||
{ | |||
vec2 texcoord = pass_texcoord.xy - vec2(pass_texcoord.z * in_sprite_flip, 0.0); | |||
vec4 color = texture2D(in_texture, texcoord) * pass_color; | |||
vec2 texcoord = pass_texcoord.xy - vec2(pass_texcoord.z * u_sprite_flip, 0.0); | |||
vec4 color = texture2D(u_texture, texcoord) * pass_color; | |||
//need 130 : ivec2 tex_size = textureSize(in_texture, 0); | |||
//need 130 : ivec2 tex_size = textureSize(u_texture, 0); | |||
if (color.a < 0.9) | |||
{ | |||
bool break_loop = false; | |||
@@ -89,8 +89,8 @@ void main(void) | |||
if (x != 0 && y != 0) | |||
{ | |||
vec2 new_tc = clamp(texcoord + (vec2(x, y) / 1024.0), vec2(0.0), vec2(1.0)); | |||
vec4 new_col = texture2D(in_texture, new_tc); | |||
//need 130 : vec4 new_col = texelFetch(in_texture, ivec2(tex_size * texcoord) + ivec2(x, y), 0); | |||
vec4 new_col = texture2D(u_texture, new_tc); | |||
//need 130 : vec4 new_col = texelFetch(u_texture, ivec2(tex_size * texcoord) + ivec2(x, y), 0); | |||
if (new_col.a > 0.9) | |||
{ | |||
color = vec4(0.0, 0.0, 0.0, 1.0); | |||
@@ -1,56 +1,56 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
in vec3 in_position; | |||
in vec3 in_Normal; | |||
in vec4 in_color; | |||
uniform mat4 u_modelview; | |||
uniform mat4 u_view; | |||
uniform mat4 u_projection; | |||
uniform mat3 u_normalmat; | |||
uniform float in_Damage; | |||
uniform float u_damage; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
out vec4 pass_vertex; /* View space */ | |||
out vec3 pass_tnormal; | |||
out vec4 pass_color; | |||
void main(void) | |||
{ | |||
vec4 vertex = vec4(in_Position + (in_Normal * in_Damage), 1.0); | |||
float dam_perc = in_Damage / (0.1 * 40); | |||
vec4 vertex = vec4(in_position + (in_Normal * u_damage), 1.0); | |||
float dam_perc = u_damage / (0.1 * 40); | |||
vec3 vGravity = vec3(0.0, -0.981, 0.0) * 2.0; | |||
float k = pow(dam_perc, 3); | |||
vertex = u_modelview * vertex + u_view * vec4(vGravity * k, 1.0); | |||
vec3 tnorm = normalize(u_normalmat * in_Normal); | |||
pass_Vertex = vertex; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
pass_vertex = vertex; | |||
pass_tnormal = tnorm; | |||
pass_color = in_color; | |||
gl_Position = u_projection * vertex; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
in vec4 pass_vertex; /* View space */ | |||
in vec3 pass_tnormal; | |||
in vec4 pass_color; | |||
uniform mat4 u_view; | |||
uniform mat4 u_inv_view; | |||
uniform mat4 u_inv_modelview; | |||
uniform float in_Damage; | |||
uniform float u_damage; | |||
//Light list | |||
uniform vec4 u_lights[8 * 2]; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
void main(void) | |||
{ | |||
/* Material properties */ | |||
@@ -63,7 +63,7 @@ void main(void) | |||
vec3 diffuse = vec3(0.0, 0.0, 0.0); | |||
/* Light precalculations */ | |||
vec3 v = normalize(-pass_Vertex.xyz); | |||
vec3 v = normalize(-pass_vertex.xyz); | |||
/* Apply lighting */ | |||
for (int i = 0; i < 8; i++) | |||
@@ -75,17 +75,17 @@ void main(void) | |||
if (pos.w > 0.0) | |||
{ | |||
/* Point light -- no attenuation yet */ | |||
s = normalize((u_view * pos).xyz - pass_Vertex.xyz); | |||
r = reflect(-s, pass_TNormal); | |||
s = normalize((u_view * pos).xyz - pass_vertex.xyz); | |||
r = reflect(-s, pass_tnormal); | |||
} | |||
else | |||
{ | |||
/* Directional light */ | |||
s = normalize(-pos.xyz); | |||
r = reflect(s, pass_TNormal); | |||
r = reflect(s, pass_tnormal); | |||
} | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float sdotn = max(dot(s, pass_tnormal), 0.0); | |||
diffuse += color.xyz * sdotn; | |||
if (sdotn > 0.0) | |||
specular += color.xyz * specular_reflect | |||
@@ -94,10 +94,10 @@ void main(void) | |||
vec3 light = ambient + diffuse + specular; | |||
vec4 world_vertex = u_inv_modelview * pass_Vertex; | |||
vec4 world_normal = u_inv_modelview * vec4(pass_TNormal, 1.0); | |||
vec4 world_vertex = u_inv_modelview * pass_vertex; | |||
vec4 world_normal = u_inv_modelview * vec4(pass_tnormal, 1.0); | |||
float dam_perc = in_Damage / (0.1 * 40); | |||
float dam_perc = u_damage / (0.1 * 40); | |||
float PI = 3.14159265358979323846264; | |||
dam_perc = (sin(PI * (dam_perc - 0.5)) * 0.5 + 0.5); | |||
dam_perc *= dam_perc; | |||
@@ -110,73 +110,8 @@ void main(void) | |||
abs(sin(world_vertex.z * mod) * dam_perc * 0.5 + 0.5) | |||
*/ | |||
//vec4 real_color = mix(pass_Color, vec4(1.2, 1.2, 1.2, 1.0), in_Damage); | |||
// - in_Damage | |||
gl_FragColor = pass_Color * vec4(light, (in_Damage == 0)?(1.0):(transp)); | |||
} | |||
[vert.hlsl] | |||
void main(float3 in_Vertex : POSITION, | |||
float3 in_Normal : NORMAL, | |||
float4 in_Color : COLOR, | |||
uniform float4x4 u_modelview, | |||
uniform float4x4 u_projection, | |||
uniform float3x3 u_normalmat, | |||
out float4 pass_Vertex : TEXCOORD0, | |||
out float3 pass_TNormal : TEXCOORD1, | |||
out float4 pass_Color : COLOR, | |||
out float4 out_Position : POSITION) | |||
{ | |||
float4 eye = mul(u_modelview, float4(in_Vertex, 1.0)); | |||
float3 tnorm = normalize(mul(u_normalmat, in_Normal)); | |||
pass_Vertex = eye; | |||
pass_TNormal = tnorm; | |||
#ifdef _XBOX | |||
pass_Color = in_Color.abgr; | |||
#else | |||
pass_Color = in_Color; | |||
#endif | |||
out_Position = mul(u_projection, eye); | |||
} | |||
[frag.hlsl] | |||
void main(float4 pass_Vertex : TEXCOORD0, | |||
float3 pass_TNormal : TEXCOORD1, | |||
float4 pass_Color : COLOR, | |||
uniform float in_Damage, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float3 in_LightDir = float3(0.3, 0.3, 0.7); | |||
/* Material properties */ | |||
float3 specular_reflect = float3(0.8, 0.75, 0.4); | |||
float specular_power = 60.0; | |||
/* World properties */ | |||
float ambient_mul = 0.5; | |||
float3 ambient_color = float3(0.25, 0.2, 0.35); | |||
float3 diffuse_color = float3(1.0, 1.0, 0.6); | |||
float3 specular_color = float3(1.0, 1.0, 0.6); | |||
float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */ | |||
float3 v = normalize(-pass_Vertex.xyz); | |||
float3 r = reflect(-s, pass_TNormal); | |||
float3 ambient = ambient_color; | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float3 diffuse = diffuse_color * sdotn; | |||
float3 specular = float3(0.0, 0.0, 0.0); | |||
if (sdotn > 0.0) | |||
specular = specular_color * specular_reflect | |||
* pow(max(dot(r, v), 0.0), specular_power); | |||
float3 light = ambient + diffuse + specular; | |||
float4 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0) | |||
+ (1.0 - in_Damage) * pass_Color; | |||
out_FragColor = real_color * float4(light, 1.0); | |||
//vec4 real_color = mix(pass_color, vec4(1.2, 1.2, 1.2, 1.0), u_damage); | |||
// - u_damage | |||
gl_FragColor = pass_color * vec4(light, (u_damage == 0)?(1.0):(transp)); | |||
} | |||
@@ -1,42 +1,47 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
attribute vec2 in_TexCoord; | |||
in vec3 in_position; | |||
in vec3 in_Normal; | |||
in vec4 in_color; | |||
in vec2 in_texcoord; | |||
uniform mat4 u_modelview; | |||
uniform mat4 u_view; | |||
uniform mat4 u_projection; | |||
uniform mat3 u_normalmat; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
varying vec2 pass_TexCoord; | |||
out vec4 pass_vertex; /* View space */ | |||
out vec3 pass_tnormal; | |||
out vec4 pass_color; | |||
out vec2 pass_texcoord; | |||
void main(void) | |||
{ | |||
vec4 vertex = u_modelview * vec4(in_Position, 1.0); | |||
vec4 vertex = u_modelview * vec4(in_position, 1.0); | |||
vec3 tnorm = normalize(u_normalmat * in_Normal); | |||
pass_Vertex = vertex; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
pass_TexCoord = in_TexCoord; | |||
pass_vertex = vertex; | |||
pass_tnormal = tnorm; | |||
pass_color = in_color; | |||
pass_texcoord = in_texcoord; | |||
gl_Position = u_projection * vertex; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
in vec4 pass_vertex; /* View space */ | |||
in vec3 pass_tnormal; | |||
in vec4 pass_color; | |||
in vec2 pass_texcoord; | |||
uniform mat4 u_view; | |||
uniform mat4 u_inv_view; | |||
uniform mat4 u_inv_modelview; | |||
@@ -45,11 +50,6 @@ uniform sampler2D u_Texture; | |||
//Light list | |||
uniform vec4 u_lights[8 * 2]; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
varying vec2 pass_TexCoord; | |||
void main(void) | |||
{ | |||
/* Material properties */ | |||
@@ -62,7 +62,7 @@ void main(void) | |||
vec3 diffuse = vec3(0.0, 0.0, 0.0); | |||
/* Light precalculations */ | |||
vec3 v = normalize(-pass_Vertex.xyz); | |||
vec3 v = normalize(-pass_vertex.xyz); | |||
/* Apply lighting */ | |||
for (int i = 0; i < 8; i++) | |||
@@ -74,17 +74,17 @@ void main(void) | |||
if (pos.w > 0.0) | |||
{ | |||
/* Point light -- no attenuation yet */ | |||
s = normalize((u_view * pos).xyz - pass_Vertex.xyz); | |||
r = reflect(-s, pass_TNormal); | |||
s = normalize((u_view * pos).xyz - pass_vertex.xyz); | |||
r = reflect(-s, pass_tnormal); | |||
} | |||
else | |||
{ | |||
/* Directional light */ | |||
s = normalize(-pos.xyz); | |||
r = reflect(s, pass_TNormal); | |||
r = reflect(s, pass_tnormal); | |||
} | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float sdotn = max(dot(s, pass_tnormal), 0.0); | |||
diffuse += color.xyz * sdotn; | |||
if (sdotn > 0.0) | |||
specular += color.xyz * specular_reflect | |||
@@ -93,71 +93,6 @@ void main(void) | |||
vec3 light = ambient + diffuse + specular; | |||
gl_FragColor = texture2D(u_Texture, pass_TexCoord.xy) * pass_Color * vec4(light, 1.0f); | |||
} | |||
[vert.hlsl] | |||
void main(float3 in_Vertex : POSITION, | |||
float3 in_Normal : NORMAL, | |||
float4 in_Color : COLOR, | |||
uniform float4x4 u_modelview, | |||
uniform float4x4 u_projection, | |||
uniform float3x3 u_normalmat, | |||
out float4 pass_Vertex : TEXCOORD0, | |||
out float3 pass_TNormal : TEXCOORD1, | |||
out float4 pass_Color : COLOR, | |||
out float4 out_Position : POSITION) | |||
{ | |||
float4 eye = mul(u_modelview, float4(in_Vertex, 1.0)); | |||
float3 tnorm = normalize(mul(u_normalmat, in_Normal)); | |||
pass_Vertex = eye; | |||
pass_TNormal = tnorm; | |||
#ifdef _XBOX | |||
pass_Color = in_Color.abgr; | |||
#else | |||
pass_Color = in_Color; | |||
#endif | |||
out_Position = mul(u_projection, eye); | |||
} | |||
[frag.hlsl] | |||
void main(float4 pass_Vertex : TEXCOORD0, | |||
float3 pass_TNormal : TEXCOORD1, | |||
float4 pass_Color : COLOR, | |||
uniform float in_Damage, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float3 in_LightDir = float3(0.3, 0.3, 0.7); | |||
/* Material properties */ | |||
float3 specular_reflect = float3(0.8, 0.75, 0.4); | |||
float specular_power = 60.0; | |||
/* World properties */ | |||
float ambient_mul = 0.5; | |||
float3 ambient_color = float3(0.25, 0.2, 0.35); | |||
float3 diffuse_color = float3(1.0, 1.0, 0.6); | |||
float3 specular_color = float3(1.0, 1.0, 0.6); | |||
float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */ | |||
float3 v = normalize(-pass_Vertex.xyz); | |||
float3 r = reflect(-s, pass_TNormal); | |||
float3 ambient = ambient_color; | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float3 diffuse = diffuse_color * sdotn; | |||
float3 specular = float3(0.0, 0.0, 0.0); | |||
if (sdotn > 0.0) | |||
specular = specular_color * specular_reflect | |||
* pow(max(dot(r, v), 0.0), specular_power); | |||
float3 light = ambient + diffuse + specular; | |||
float4 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0) | |||
+ (1.0 - in_Damage) * pass_Color; | |||
out_FragColor = real_color * float4(light, 1.0); | |||
gl_FragColor = texture2D(u_Texture, pass_texcoord.xy) * pass_color * vec4(light, 1.0f); | |||
} | |||
@@ -12,17 +12,17 @@ technique FlatColor | |||
} | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec2 in_Position; | |||
in vec2 in_position; | |||
void main(void) | |||
{ | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
gl_Position = vec4(in_position, 0.0, 1.0); | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
@@ -33,16 +33,3 @@ 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); | |||
} | |||
@@ -68,7 +68,7 @@ public: | |||
{ | |||
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(02_cube)); | |||
m_mvp = m_shader->GetUniformLocation("in_Matrix"); | |||
m_mvp = m_shader->GetUniformLocation("u_matrix"); | |||
m_coord = m_shader->GetAttribLocation(VertexUsage::Position, 0); | |||
m_color = m_shader->GetAttribLocation(VertexUsage::Color, 0); | |||
@@ -1,50 +1,32 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Color; | |||
uniform mat4 in_Matrix; | |||
varying vec3 pass_Color; | |||
attribute vec3 in_position; | |||
attribute vec3 in_color; | |||
uniform mat4 u_matrix; | |||
out vec3 pass_color; | |||
void main(void) | |||
{ | |||
gl_Position = in_Matrix * vec4(in_Position, 1.0); | |||
pass_Color = in_Color; | |||
gl_Position = u_matrix * vec4(in_position, 1.0); | |||
pass_color = in_color; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
varying vec3 pass_Color; | |||
in vec3 pass_color; | |||
void main(void) | |||
{ | |||
gl_FragColor = vec4(pass_Color, 1.0); | |||
} | |||
[vert.hlsl] | |||
void main(float3 in_Vertex : POSITION, | |||
float3 in_Color : COLOR, | |||
uniform float4x4 in_Matrix, | |||
out float4 out_Position : POSITION, | |||
out float3 pass_Color : COLOR) | |||
{ | |||
pass_Color = in_Color; | |||
out_Position = mul(in_Matrix, float4(in_Vertex, 1.0)); | |||
} | |||
[frag.hlsl] | |||
void main(float3 pass_Color : COLOR, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
out_FragColor = float4(pass_Color, 1.0); | |||
gl_FragColor = vec4(pass_color, 1.0); | |||
} | |||
@@ -1,14 +1,14 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
uniform float u_time; | |||
in vec2 in_position; | |||
attribute vec2 in_Position; | |||
uniform float u_time; | |||
varying vec4 pass_Position; | |||
varying vec3 water[4]; | |||
varying vec3 fire[4]; | |||
out vec4 pass_position; | |||
out vec3 water[4]; | |||
out vec3 fire[4]; | |||
float mod289(float x) | |||
{ | |||
@@ -18,7 +18,7 @@ float mod289(float x) | |||
void main(void) | |||
{ | |||
mat3 r = mat3(0.36, 0.48, -0.8, -0.8, 0.60, 0.0, 0.48, 0.64, 0.60); | |||
vec3 p_pos = r * vec3(in_Position * vec2(16.0, 9.0), 0.0); | |||
vec3 p_pos = r * vec3(in_position * vec2(16.0, 9.0), 0.0); | |||
vec3 p_time = r * vec3(0.0, 0.0, u_time * 2.0); | |||
/* Noise sampling points for water */ | |||
@@ -35,26 +35,26 @@ void main(void) | |||
fire[3] = p_pos / 16.0 + p_time; | |||
/* Pass rotated screen coordinates */ | |||
pass_Position.xy = in_Position; | |||
pass_position.xy = in_position; | |||
mat2 rot = mat2(cos(u_time), sin(u_time), -sin(u_time), cos(u_time)); | |||
pass_Position.zw = rot * in_Position; | |||
pass_position.zw = rot * in_position; | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
gl_Position = vec4(in_position, 0.0, 1.0); | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform float u_time; | |||
in vec4 pass_position; | |||
in vec3 water[4]; | |||
in vec3 fire[4]; | |||
varying vec4 pass_Position; | |||
varying vec3 water[4]; | |||
varying vec3 fire[4]; | |||
uniform float u_time; | |||
vec4 mod289(vec4 x) | |||
{ | |||
@@ -92,8 +92,8 @@ float noise3d(vec3 p) | |||
void main(void) | |||
{ | |||
/* Dither the transition between water and fire */ | |||
float test = pass_Position.z * pass_Position.w + 1.5 * sin(u_time); | |||
vec2 d = vec2(16.0, 9.0) * pass_Position.xy; | |||
float test = pass_position.z * pass_position.w + 1.5 * sin(u_time); | |||
vec2 d = vec2(16.0, 9.0) * pass_position.xy; | |||
test += 0.5 * (length(fract(d) - 0.5) - length(fract(d + 0.5) - 0.5)); | |||
/* Compute 4 octaves of noise */ | |||
@@ -118,7 +118,7 @@ void main(void) | |||
float p = dot(n, vec4(0.125, 0.125, 0.25, 0.5)); | |||
/* Fade to black on top of screen */ | |||
p -= pass_Position.y * 0.8 + 0.25; | |||
p -= pass_position.y * 0.8 + 0.25; | |||
p = max(p, 0.0); | |||
p = min(p, 1.0); | |||
@@ -145,134 +145,3 @@ void main(void) | |||
gl_FragColor = color; | |||
} | |||
[vert.hlsl] | |||
float mod289(float x) | |||
{ | |||
return x - floor(x * (1.0 / 289.0)) * 289.0; | |||
} | |||
void main(float2 in_Position : POSITION, | |||
uniform float u_time, | |||
out float4 out_Position : POSITION, | |||
out float4 pass_Position : TEXCOORD0, | |||
out float3 water[4] : TEXCOORD1, | |||
out float3 fire[4] : TEXCOORD5) | |||
{ | |||
float3x3 r = float3x3(0.36, 0.48, -0.8, -0.8, 0.60, 0.0, 0.48, 0.64, 0.60); | |||
float3 p_pos = mul(r, float3(in_Position * float2(16.0, 9.0), 0.0)); | |||
float3 p_time = mul(r, float3(0.0, 0.0, u_time * 2.0)); | |||
/* Noise sampling points for water */ | |||
water[0] = p_pos / 2.0 + p_time; | |||
water[1] = p_pos / 4.0 + p_time; | |||
water[2] = p_pos / 8.0 + p_time; | |||
water[3] = p_pos / 16.0 + p_time; | |||
/* Noise sampling points for fire */ | |||
p_pos = 16.0 * p_pos - mul(r, float3(0.0, mod289(u_time) * 128.0, 0.0)); | |||
fire[0] = p_pos / 2.0 + p_time * 2.0; | |||
fire[1] = p_pos / 4.0 + p_time * 1.5; | |||
fire[2] = p_pos / 8.0 + p_time; | |||
fire[3] = p_pos / 16.0 + p_time; | |||
/* Pass rotated screen coordinates */ | |||
pass_Position.xy = in_Position; | |||
float2x2 rot = float2x2(cos(u_time), sin(u_time), -sin(u_time), cos(u_time)); | |||
pass_Position.zw = mul(rot, in_Position); | |||
out_Position = float4(in_Position, 0.0, 1.0); | |||
} | |||
[frag.hlsl] | |||
float4 mod289(float4 x) | |||
{ | |||
return x - floor(x * (1.0 / 289.0)) * 289.0; | |||
} | |||
float4 perm(float4 x) | |||
{ | |||
return mod289(((x * 34.0) + 1.0) * x); | |||
} | |||
float noise3d(float3 p) | |||
{ | |||
float3 a = floor(p); | |||
float3 d = p - a; | |||
d = d * d * (3.0 - 2.0 * d); | |||
float4 b = a.xxyy + float4(0.0, 1.0, 0.0, 1.0); | |||
float4 k1 = perm(b.xyxy); | |||
float4 k2 = perm(k1.xyxy + b.zzww); | |||
float4 c = k2 + a.zzzz; | |||
float4 k3 = perm(c); | |||
float4 k4 = perm(c + 1.0); | |||
float4 o1 = frac(k3 * (1.0 / 41.0)); | |||
float4 o2 = frac(k4 * (1.0 / 41.0)); | |||
float4 o3 = o2 * d.z + o1 * (1.0 - d.z); | |||
float2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x); | |||
return o4.y * d.y + o4.x * (1.0 - d.y); | |||
} | |||
void main(in float4 pass_Position : TEXCOORD0, | |||
in float3 water[4] : TEXCOORD1, | |||
in float3 fire[4] : TEXCOORD5, | |||
uniform float u_time, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
/* Dither the transition between water and fire */ | |||
float test = pass_Position.z * pass_Position.w + 1.5 * sin(u_time); | |||
float2 d = float2(16.0, 9.0) * pass_Position.xy; | |||
test += 0.5 * (length(frac(d) - 0.5) - length(frac(d + 0.5) - 0.5)); | |||
float3 points[4]; | |||
points[0] = (test > 0.0) ? fire[0] : water[0]; | |||
points[1] = (test > 0.0) ? fire[1] : water[1]; | |||
points[2] = (test > 0.0) ? fire[2] : water[2]; | |||
points[3] = (test > 0.0) ? fire[3] : water[3]; | |||
/* Compute 4 octaves of noise */ | |||
float4 n = float4(noise3d(points[0]), | |||
noise3d(points[1]), | |||
noise3d(points[2]), | |||
noise3d(points[3])); | |||
float4 color; | |||
if (test > 0.0) | |||
{ | |||
/* Use noise results for fire */ | |||
float p = dot(n, float4(0.125, 0.125, 0.25, 0.5)); | |||
/* Fade to black on top of screen */ | |||
p -= pass_Position.y * 0.8 + 0.25; | |||
p = max(p, 0.0); | |||
p = min(p, 1.0); | |||
float q = p * p * (3.0 - 2.0 * p); | |||
float r = q * q * (3.0 - 2.0 * q); | |||
color = float4(min(q * 2.0, 1.0), | |||
max(r * 1.5 - 0.5, 0.0), | |||
max(q * 8.0 - 7.3, 0.0), | |||
1.0); | |||
} | |||
else | |||
{ | |||
/* Use noise results for water */ | |||
float p = dot(abs(2.0 * n - 1.0), | |||
float4(0.5, 0.25, 0.125, 0.125)); | |||
float q = sqrt(p); | |||
color = float4(1.0 - q, | |||
1.0 - 0.5 * q, | |||
1.0, | |||
1.0); | |||
} | |||
out_FragColor = color; | |||
} |
@@ -71,7 +71,7 @@ public: | |||
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(04_texture)); | |||
m_coord = m_shader->GetAttribLocation(VertexUsage::Position, 0); | |||
m_texture_uni = m_shader->GetUniformLocation("u_Texture"); | |||
m_texture_uni = m_shader->GetUniformLocation("u_texture"); | |||
m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | |||
@@ -86,6 +86,7 @@ public: | |||
} | |||
/* Send new heightmap to GPU */ | |||
m_texture->Bind(); | |||
m_texture->SetData(m_heightmap.data()); | |||
m_shader->Bind(); | |||
@@ -1,28 +1,28 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec2 in_Position; | |||
in vec2 in_position; | |||
varying vec4 pass_Position; | |||
out vec4 pass_position; | |||
void main(void) | |||
{ | |||
pass_Position = vec4(0.5 * in_Position + 0.5, 0.0, 1.0); | |||
gl_Position = vec4(in_Position, 0.5, 1.0); | |||
pass_position = vec4(0.5 * in_position + 0.5, 0.0, 1.0); | |||
gl_Position = vec4(in_position, 0.5, 1.0); | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform sampler2D u_Texture; | |||
uniform sampler2D u_texture; | |||
varying vec4 pass_Position; | |||
in vec4 pass_position; | |||
float segdist(vec2 p1, vec2 p2, vec2 a) | |||
{ | |||
@@ -31,30 +31,6 @@ float segdist(vec2 p1, vec2 p2, vec2 a) | |||
return distance(a, mix(p1, p2, t)); | |||
} | |||
vec3 hsv2rgb(vec3 c) | |||
{ | |||
vec3 tmp = abs(fract(c[0] + vec3(3.0, 2.0, 1.0) / 3.0) * 6.0 - 3.0); | |||
return c[2] * mix(vec3(1.0), clamp((tmp - 1.0), 0.0, 1.0), c[1]); | |||
} | |||
vec3 rgb2hsv(vec3 c) | |||
{ | |||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); | |||
vec4 v1 = mix(vec4(c.bg, K.wz), | |||
vec4(c.gb, K.xy), | |||
step(c.b, c.g)); | |||
vec4 v3 = mix(vec4(v1.x, v1.yw, c.r), | |||
vec4(c.r, v1.yzx), | |||
step(v1.x, c.r)); | |||
float chroma = v3.r - min(v3.a, v3.g); | |||
float h = abs(v3.b + (v3.a - v3.g) / (6.0 * chroma + 1.0e-10)); | |||
float s = chroma / (v3.r + 1.0e-10); | |||
float v = v3.r; | |||
return vec3(h, s, v); | |||
} | |||
void main(void) | |||
{ | |||
float width = 800.0; | |||
@@ -65,14 +41,14 @@ void main(void) | |||
vec4 delta = vec4(1.0 / texture_width, 0.0, | |||
2.0 / texture_width, 0.0); | |||
vec2 p = pass_Position.xy; | |||
vec2 p = pass_position.xy; | |||
vec2 tc = vec2(floor(p.x * texture_width) / texture_width, p.y); | |||
float t = p.x * texture_width - floor(p.x * texture_width); | |||
vec4 c; | |||
c[0] = texture2D(u_Texture, tc - delta.xy).x; | |||
c[1] = texture2D(u_Texture, tc).x; | |||
c[2] = texture2D(u_Texture, tc + delta.xy).x; | |||
c[3] = texture2D(u_Texture, tc + delta.zw).x; | |||
c[0] = texture2D(u_texture, tc - delta.xy).x; | |||
c[1] = texture2D(u_texture, tc).x; | |||
c[2] = texture2D(u_texture, tc + delta.xy).x; | |||
c[3] = texture2D(u_texture, tc + delta.zw).x; | |||
/* Find the 4 closest points in screen space */ | |||
vec2 p0 = vec2((tc.x - delta.x) * width, c[0] * height); | |||
@@ -100,78 +76,6 @@ void main(void) | |||
/* Choose some funny colours */ | |||
vec4 col = vec4(mix(p.x, 1.0, lum), lum, lum, 1.0); | |||
col.rgb = hsv2rgb(rgb2hsv(col.rgb) * vec3(1.0, 1.0, 0.5) + vec3(p.x, 0.5, 0.0)); | |||
col.rgb = hsv2rgb(rgb2hsv(col.rgb)); | |||
col.rgb = hsv2rgb(rgb2hsv(col.rgb)); | |||
col.rgb = hsv2rgb(rgb2hsv(col.rgb)); | |||
gl_FragColor = col; | |||
} | |||
[vert.hlsl] | |||
void main(float2 in_Position : POSITION, | |||
out float4 out_Position : POSITION, | |||
out float4 pass_Position : TEXCOORD0) | |||
{ | |||
pass_Position = float4(0.5 * in_Position + 0.5, 0.0, 1.0); | |||
out_Position = float4(in_Position, 0.5, 1.0); | |||
} | |||
[frag.hlsl] | |||
float segdist(float2 p1, float2 p2, float2 a) | |||
{ | |||
float d = max(1e-10, dot(p2 - p1, p2 - p1)); | |||
float t = clamp(dot(a - p1, p2 - p1) / d, 0.0, 1.0); | |||
return distance(a, lerp(p1, p2, t)); | |||
} | |||
void main(in float4 pass_Position : TEXCOORD0, | |||
uniform sampler2D u_Texture, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float width = 800.0; | |||
float height = 600.0; | |||
float texture_width = 256.0; | |||
float line_width = 1.2; | |||
float dot_size = 1.0; | |||
float4 delta = float4(1.0 / texture_width, 0.0, | |||
2.0 / texture_width, 0.0); | |||
float2 p = pass_Position.xy; | |||
float2 tc = float2(floor(p.x * texture_width) / texture_width, p.y); | |||
float t = p.x * texture_width - floor(p.x * texture_width); | |||
float4 c; | |||
c[0] = tex2D(u_Texture, tc - delta.xy).x; | |||
c[1] = tex2D(u_Texture, tc).x; | |||
c[2] = tex2D(u_Texture, tc + delta.xy).x; | |||
c[3] = tex2D(u_Texture, tc + delta.zw).x; | |||
/* Find the 4 closest points in screen space */ | |||
float2 p0 = float2((tc.x - delta.x) * width, c[0] * height); | |||
float2 p1 = float2((tc.x ) * width, c[1] * height); | |||
float2 p2 = float2((tc.x + delta.x) * width, c[2] * height); | |||
float2 p3 = float2((tc.x + delta.z) * width, c[3] * height); | |||
float2 a = float2(p.x * width, p.y * height); | |||
/* Compute distance to segments */ | |||
float d = segdist(p0, p1, a); | |||
d = min(d, segdist(p1, p2, a)); | |||
d = min(d, segdist(p2, p3, a)); | |||
/* Compute distance to dots */ | |||
d = min(d, length(a - p0) - dot_size); | |||
d = min(d, length(a - p1) - dot_size); | |||
d = min(d, length(a - p2) - dot_size); | |||
d = min(d, length(a - p3) - dot_size); | |||
/* Add line width */ | |||
float lum = clamp(line_width - d, 0.0, 1.0); | |||
/* Compensate for sRGB */ | |||
lum = pow(1.0 - lum, 1.0 / 2.4); | |||
/* Choose some funny colours */ | |||
out_FragColor = float4(lerp(p.x, 1.0, lum), lum, lum, 1.0); | |||
} | |||
@@ -164,7 +164,7 @@ public: | |||
{ | |||
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(07_input)); | |||
m_mvp = m_shader->GetUniformLocation("in_Matrix"); | |||
m_mvp = m_shader->GetUniformLocation("u_matrix"); | |||
m_coord = m_shader->GetAttribLocation(VertexUsage::Position, 0); | |||
m_color = m_shader->GetAttribLocation(VertexUsage::Color, 0); | |||
@@ -1,50 +1,32 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Color; | |||
uniform mat4 in_Matrix; | |||
varying vec3 pass_Color; | |||
in vec3 in_position; | |||
in vec3 in_color; | |||
uniform mat4 u_matrix; | |||
out vec3 pass_color; | |||
void main(void) | |||
{ | |||
gl_Position = in_Matrix * vec4(in_Position, 1.0); | |||
pass_Color = in_Color; | |||
gl_Position = u_matrix * vec4(in_position, 1.0); | |||
pass_color = in_color; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
varying vec3 pass_Color; | |||
in vec3 pass_color; | |||
void main(void) | |||
{ | |||
gl_FragColor = vec4(pass_Color, 1.0); | |||
} | |||
[vert.hlsl] | |||
void main(float3 in_Vertex : POSITION, | |||
float3 in_Color : COLOR, | |||
uniform float4x4 in_Matrix, | |||
out float4 out_Position : POSITION, | |||
out float3 pass_Color : COLOR) | |||
{ | |||
pass_Color = in_Color; | |||
out_Position = mul(in_Matrix, float4(in_Vertex, 1.0)); | |||
} | |||
[frag.hlsl] | |||
void main(float3 pass_Color : COLOR, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
out_FragColor = float4(pass_Color, 1.0); | |||
gl_FragColor = vec4(pass_color, 1.0); | |||
} | |||
@@ -60,9 +60,9 @@ public: | |||
{ | |||
m_shader = Shader::Create(LOLFX_RESOURCE_NAME(08_fbo)); | |||
m_coord = m_shader->GetAttribLocation(VertexUsage::Position, 0); | |||
m_uni_flag = m_shader->GetUniformLocation("in_Flag"); | |||
m_uni_point = m_shader->GetUniformLocation("in_Point"); | |||
m_uni_color = m_shader->GetUniformLocation("in_Color"); | |||
m_uni_flag = m_shader->GetUniformLocation("u_flag"); | |||
m_uni_point = m_shader->GetUniformLocation("u_point"); | |||
m_uni_color = m_shader->GetUniformLocation("u_color"); | |||
m_uni_texture = m_shader->GetUniformLocation("u_texture"); | |||
m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | |||
@@ -93,6 +93,8 @@ public: | |||
RenderContext rc; | |||
rc.SetDepthFunc(DepthFunc::Disabled); | |||
/* FIXME: this no longer works because we don’t restore the | |||
* actually bound framebuffer. */ | |||
m_fbo->Bind(); | |||
m_shader->Bind(); | |||
@@ -1,94 +1,52 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec2 in_Position; | |||
in vec2 in_position; | |||
varying vec2 pass_Position; | |||
out vec2 pass_position; | |||
void main() | |||
{ | |||
pass_Position = in_Position; | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
pass_position = in_position; | |||
gl_Position = vec4(in_position, 0.0, 1.0); | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform sampler2D u_texture; | |||
uniform float in_Flag; | |||
uniform vec3 in_Point; | |||
uniform vec3 in_Color; | |||
in vec2 pass_position; | |||
varying vec2 pass_Position; | |||
uniform sampler2D u_texture; | |||
uniform float u_flag; | |||
uniform vec3 u_point; | |||
uniform vec3 u_color; | |||
void main(void) | |||
{ | |||
if (in_Flag == 0.0) | |||
if (u_flag == 0.0) | |||
{ | |||
float tc = 0.0, ta = 0.0; | |||
{ | |||
float s = 3.0 + 2.0 * in_Point.z; | |||
vec2 p = pass_Position - in_Point.xy * 0.9; | |||
float s = 3.0 + 2.0 * u_point.z; | |||
vec2 p = pass_position - u_point.xy * 0.9; | |||
float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0); | |||
float u = t * t * t * t; | |||
tc += 3.0 * t * t - 2.0 * t * t * t; | |||
ta += 3.0 * u * u - 2.0 * u * u * u; | |||
} | |||
gl_FragColor = vec4(tc * in_Color, ta + 0.1); | |||
gl_FragColor = vec4(tc * u_color, ta + 0.1); | |||
} | |||
else | |||
{ | |||
vec2 texcoords = pass_Position * 0.5 + vec2(0.5, 0.5); | |||
vec2 texcoords = pass_position * 0.5 + vec2(0.5, 0.5); | |||
gl_FragColor = vec4(texture2D(u_texture, texcoords).xyz, 1.0); | |||
} | |||
} | |||
[vert.hlsl] | |||
void main(float2 in_Position : POSITION, | |||
out float2 pass_Position : TEXCOORD0, | |||
out float4 out_Position : POSITION) | |||
{ | |||
pass_Position = in_Position; | |||
out_Position = float4(in_Position, 0.0, 1.0); | |||
} | |||
[frag.hlsl] | |||
void main(in float2 pass_Position : TEXCOORD0, | |||
uniform sampler2D u_texture, | |||
uniform float in_Flag, | |||
uniform float3 in_Point, | |||
uniform float3 in_Color, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
if (in_Flag == 0.0) | |||
{ | |||
float tc = 0.0, ta = 0.0; | |||
{ | |||
float s = 3.0 + 2.0 * in_Point.z; | |||
float2 p = pass_Position - in_Point.xy * 0.9; | |||
float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0); | |||
float u = t * t * t * t; | |||
tc += 3.0 * t * t - 2.0 * t * t * t; | |||
ta += 3.0 * u * u - 2.0 * u * u * u; | |||
} | |||
out_FragColor = float4(tc * in_Color, ta + 0.1); | |||
} | |||
else | |||
{ | |||
float2 texcoords = pass_Position * float2(0.5, -0.5) + float2(0.5, 0.5); | |||
/* FIXME: this should be passed as a uniform or something */ | |||
texcoords += float2(0.5 / 800.0, 0.5 / 600.0); | |||
out_FragColor = float4(tex2D(u_texture, texcoords).xyz, 1.0); | |||
} | |||
} | |||
@@ -1,94 +1,52 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec2 in_Position; | |||
in vec2 in_position; | |||
varying vec2 pass_Position; | |||
out vec2 pass_position; | |||
void main() | |||
{ | |||
pass_Position = in_Position; | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
pass_position = in_position; | |||
gl_Position = vec4(in_position, 0.0, 1.0); | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform sampler2D u_texture; | |||
uniform float in_Flag; | |||
uniform vec3 in_Point; | |||
uniform vec3 in_Color; | |||
in vec2 pass_position; | |||
varying vec2 pass_Position; | |||
uniform sampler2D u_texture; | |||
uniform float u_flag; | |||
uniform vec3 u_point; | |||
uniform vec3 u_color; | |||
void main(void) | |||
{ | |||
if (in_Flag == 0.0) | |||
if (u_flag == 0.0) | |||
{ | |||
float tc = 0.0, ta = 0.0; | |||
{ | |||
float s = 3.0 + 2.0 * in_Point.z; | |||
vec2 p = pass_Position - in_Point.xy * 0.9; | |||
float s = 3.0 + 2.0 * u_point.z; | |||
vec2 p = pass_position - u_point.xy * 0.9; | |||
float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0); | |||
float u = t * t * t * t; | |||
tc += 3.0 * t * t - 2.0 * t * t * t; | |||
ta += 3.0 * u * u - 2.0 * u * u * u; | |||
} | |||
gl_FragColor = vec4(tc * in_Color, ta + 0.1); | |||
gl_FragColor = vec4(tc * u_color, ta + 0.1); | |||
} | |||
else | |||
{ | |||
vec2 texcoords = pass_Position * 0.5 + vec2(0.5, 0.5); | |||
vec2 texcoords = pass_position * 0.5 + vec2(0.5, 0.5); | |||
gl_FragColor = vec4(texture2D(u_texture, texcoords).xyz, 1.0); | |||
} | |||
} | |||
[vert.hlsl] | |||
void main(float2 in_Position : POSITION, | |||
out float2 pass_Position : TEXCOORD0, | |||
out float4 out_Position : POSITION) | |||
{ | |||
pass_Position = in_Position; | |||
out_Position = float4(in_Position, 0.0, 1.0); | |||
} | |||
[frag.hlsl] | |||
void main(in float2 pass_Position : TEXCOORD0, | |||
uniform sampler2D u_texture, | |||
uniform float in_Flag, | |||
uniform float3 in_Point, | |||
uniform float3 in_Color, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
if (in_Flag == 0.0) | |||
{ | |||
float tc = 0.0, ta = 0.0; | |||
{ | |||
float s = 3.0 + 2.0 * in_Point.z; | |||
float2 p = pass_Position - in_Point.xy * 0.9; | |||
float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0); | |||
float u = t * t * t * t; | |||
tc += 3.0 * t * t - 2.0 * t * t * t; | |||
ta += 3.0 * u * u - 2.0 * u * u * u; | |||
} | |||
out_FragColor = float4(tc * in_Color, ta + 0.1); | |||
} | |||
else | |||
{ | |||
float2 texcoords = pass_Position * float2(0.5, -0.5) + float2(0.5, 0.5); | |||
/* FIXME: this should be passed as a uniform or something */ | |||
texcoords += float2(0.5 / 800.0, 0.5 / 600.0); | |||
out_FragColor = float4(tex2D(u_texture, texcoords).xyz, 1.0); | |||
} | |||
} | |||
@@ -1,27 +1,28 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec2 in_Position; | |||
in vec2 in_position; | |||
varying vec2 pass_position; | |||
out vec2 pass_position; | |||
void main() | |||
{ | |||
pass_position = in_Position; | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
pass_position = in_position; | |||
gl_Position = vec4(in_position, 0.0, 1.0); | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform sampler2D in_texture; | |||
varying vec2 pass_position; | |||
in vec2 pass_position; | |||
uniform sampler2D u_texture; | |||
vec3 rand_color(float t) | |||
{ | |||
@@ -33,7 +34,7 @@ vec3 rand_color(float t) | |||
void main(void) | |||
{ | |||
vec2 texcoords = pass_position * 0.5 + vec2(0.5, 0.5); | |||
vec4 src_color = texture2D(in_texture, texcoords); | |||
vec4 src_color = texture2D(u_texture, texcoords); | |||
float newg = src_color.z; | |||
float newb = 0.0; | |||
if (newg > 0.0) | |||
@@ -41,52 +42,3 @@ void main(void) | |||
gl_FragColor = vec4(rand_color(newg), 1.0); | |||
} | |||
[vert.hlsl] | |||
void main(float2 in_Position : POSITION, | |||
out float2 pass_Position : TEXCOORD0, | |||
out float4 out_Position : POSITION) | |||
{ | |||
pass_Position = in_Position; | |||
out_Position = float4(in_Position, 0.0, 1.0); | |||
} | |||
[frag.hlsl] | |||
float3 rand_color(float t) | |||
{ | |||
return float3(0.5 + 0.5 * sin(t * 9.0 + 3.0), | |||
0.5 + 0.5 * sin(t * 4.0 + 1.0), | |||
0.5 + 0.5 * sin(t * 7.0 + 2.0)); | |||
} | |||
void main(in float2 pass_Position : TEXCOORD0, | |||
uniform sampler2D u_texture, | |||
uniform float in_Flag, | |||
uniform float3 in_Point, | |||
uniform float3 in_Color, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
if (in_Flag == 0.0) | |||
{ | |||
float tc = 0.0, ta = 0.0; | |||
{ | |||
float s = 3.0 + 2.0 * in_Point.z; | |||
float2 p = pass_Position - in_Point.xy * 0.9; | |||
float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0); | |||
float u = t * t * t * t; | |||
tc += 3.0 * t * t - 2.0 * t * t * t; | |||
ta += 3.0 * u * u - 2.0 * u * u * u; | |||
} | |||
out_FragColor = float4(tc * in_Color, ta + 0.1); | |||
} | |||
else | |||
{ | |||
float2 texcoords = pass_Position * float2(0.5, -0.5) + float2(0.5, 0.5); | |||
/* FIXME: this should be passed as a uniform or something */ | |||
texcoords += float2(0.5 / 800.0, 0.5 / 600.0); | |||
out_FragColor = float4(tex2D(u_texture, texcoords).xyz, 1.0); | |||
} | |||
} | |||
@@ -110,7 +110,7 @@ public: | |||
m_screen_shader = Shader::Create(LOLFX_RESOURCE_NAME(12_texture_to_screen)); | |||
m_screen_coord = m_screen_shader->GetAttribLocation(VertexUsage::Position, 0); | |||
m_screen_texture = m_screen_shader->GetUniformLocation("in_texture"); | |||
m_screen_texture = m_screen_shader->GetUniformLocation("u_texture"); | |||
for (int i = 0; i < MaxFboType; ++i) | |||
{ | |||
@@ -119,17 +119,17 @@ public: | |||
if (i == SrcVoronoiFbo) | |||
{ | |||
m_fbos[i].m2 = Shader::Create(LOLFX_RESOURCE_NAME(12_voronoi_setup)); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("in_texture"); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("in_source_point"); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("in_screen_res"); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("u_texture"); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("u_source_point"); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("u_screen_res"); | |||
m_fbos[i].m4 << m_fbos[i].m2->GetAttribLocation(VertexUsage::Position, 0); | |||
} | |||
else if (i == VoronoiFbo) | |||
{ | |||
m_fbos[i].m2 = Shader::Create(LOLFX_RESOURCE_NAME(12_voronoi)); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("in_texture"); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("in_step"); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("in_screen_res"); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("u_texture"); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("u_step"); | |||
m_fbos[i].m3 << m_fbos[i].m2->GetUniformLocation("u_screen_res"); | |||
m_fbos[i].m4 << m_fbos[i].m2->GetAttribLocation(VertexUsage::Position, 0); | |||
} | |||
else if (i == DistanceVoronoiFbo) | |||
@@ -278,9 +278,9 @@ public: | |||
m_fbos[f].m2->Bind(); | |||
int i = 0; | |||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], src_buf->GetTextureUniform(), 0); //"in_texture" | |||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], voronoi_points[j].m1); //"in_source_point" | |||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], vec2(512.f, 512.f)); //"in_screen_res" | |||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], src_buf->GetTextureUniform(), 0); //"u_texture" | |||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], voronoi_points[j].m1); //"u_source_point" | |||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], vec2(512.f, 512.f)); //"u_screen_res" | |||
m_vdecl->SetStream(m_vbo, m_fbos[f].m4.last()); | |||
m_vdecl->Bind(); | |||
@@ -344,9 +344,9 @@ public: | |||
m_screen_shader->SetUniform(m_screen_texture, src_buf->GetTextureUniform(), 0); | |||
else if (m_cur_fbo == VoronoiFbo) | |||
{ | |||
shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], src_buf->GetTextureUniform(), 0); //"in_texture" | |||
shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], ((float)curres.x) / 512.f); //"in_step" | |||
shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], vec2(512.f, 512.f)); //"in_screen_res" | |||
shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], src_buf->GetTextureUniform(), 0); //"u_texture" | |||
shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], ((float)curres.x) / 512.f); //"u_step" | |||
shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], vec2(512.f, 512.f)); //"u_screen_res" | |||
} | |||
m_vdecl->SetStream(m_vbo, m_fbos[m_cur_fbo].m4.last()); | |||
@@ -1,24 +1,22 @@ | |||
//----------------------------------------------------------------------------- | |||
//GLSL | |||
//----------------------------------------------------------------------------- | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec2 in_Position; | |||
in vec2 in_position; | |||
uniform vec2 in_screen_res; | |||
uniform vec2 u_screen_res; | |||
uniform float u_step; | |||
uniform float in_step; | |||
varying vec2 pass_pos; | |||
varying vec2 pass_p[8]; | |||
out vec2 pass_pos; | |||
out vec2 pass_p[8]; | |||
void main() | |||
{ | |||
//JFA ALGO | |||
pass_pos = ((vec2(1.0) + in_Position) * 0.5); | |||
pass_pos = ((vec2(1.0) + in_position) * 0.5); | |||
float k = in_step; | |||
float k = u_step; | |||
vec2 p2 = pass_pos; | |||
pass_p[0] = p2 + vec2(-k, -k); | |||
@@ -30,30 +28,30 @@ void main() | |||
pass_p[6] = p2 + vec2( 0, k); | |||
pass_p[7] = p2 + vec2( k, k); | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
gl_Position = vec4(in_position, 0.0, 1.0); | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform sampler2D in_texture; | |||
in vec2 pass_pos; | |||
in vec2 pass_p[8]; | |||
varying vec2 pass_pos; | |||
varying vec2 pass_p[8]; | |||
uniform sampler2D u_texture; | |||
void main(void) | |||
{ | |||
vec4 src_color = texture2D(in_texture, pass_pos); | |||
vec4 src_color = texture2D(u_texture, pass_pos); | |||
vec4 neigh_color; | |||
for (int i = 0; i < 8; ++i) | |||
{ | |||
neigh_color = texture2D(in_texture, pass_p[i]); | |||
neigh_color = texture2D(u_texture, pass_p[i]); | |||
if (neigh_color.z > 0.0 && src_color.z == 0.0) | |||
src_color = neigh_color; | |||
@@ -66,27 +64,3 @@ void main(void) | |||
gl_FragColor = src_color; | |||
} | |||
//----------------------------------------------------------------------------- | |||
//HLSL | |||
//----------------------------------------------------------------------------- | |||
[vert.hlsl] | |||
void main(float2 in_Position : POSITION, | |||
out float2 pass_Position : TEXCOORD0, | |||
out float4 out_Position : POSITION) | |||
{ | |||
pass_Position = in_Position; | |||
out_Position = float4(in_Position, 0.0, 1.0); | |||
} | |||
[frag.hlsl] | |||
void main(in float2 pass_Position : TEXCOORD0, | |||
uniform float in_Flag, | |||
uniform float3 in_Point, | |||
uniform float3 in_Color, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
out_FragColor = float4(0.0); | |||
} | |||
@@ -1,94 +1,52 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec2 in_Position; | |||
in vec2 in_position; | |||
varying vec2 pass_Position; | |||
out vec2 pass_position; | |||
void main() | |||
{ | |||
pass_Position = in_Position; | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
pass_position = in_position; | |||
gl_Position = vec4(in_position, 0.0, 1.0); | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform sampler2D u_texture; | |||
uniform float in_Flag; | |||
uniform vec3 in_Point; | |||
uniform vec3 in_Color; | |||
in vec2 pass_position; | |||
varying vec2 pass_Position; | |||
uniform sampler2D u_texture; | |||
uniform float u_flag; | |||
uniform vec3 u_point; | |||
uniform vec3 u_color; | |||
void main(void) | |||
{ | |||
if (in_Flag == 0.0) | |||
if (u_flag == 0.0) | |||
{ | |||
float tc = 0.0, ta = 0.0; | |||
{ | |||
float s = 3.0 + 2.0 * in_Point.z; | |||
vec2 p = pass_Position - in_Point.xy * 0.9; | |||
float s = 3.0 + 2.0 * u_point.z; | |||
vec2 p = pass_position - u_point.xy * 0.9; | |||
float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0); | |||
float u = t * t * t * t; | |||
tc += 3.0 * t * t - 2.0 * t * t * t; | |||
ta += 3.0 * u * u - 2.0 * u * u * u; | |||
} | |||
gl_FragColor = vec4(tc * in_Color, ta + 0.1); | |||
gl_FragColor = vec4(tc * u_color, ta + 0.1); | |||
} | |||
else | |||
{ | |||
vec2 texcoords = pass_Position * 0.5 + vec2(0.5, 0.5); | |||
vec2 texcoords = pass_position * 0.5 + vec2(0.5, 0.5); | |||
gl_FragColor = vec4(texture2D(u_texture, texcoords).xyz, 1.0); | |||
} | |||
} | |||
[vert.hlsl] | |||
void main(float2 in_Position : POSITION, | |||
out float2 pass_Position : TEXCOORD0, | |||
out float4 out_Position : POSITION) | |||
{ | |||
pass_Position = in_Position; | |||
out_Position = float4(in_Position, 0.0, 1.0); | |||
} | |||
[frag.hlsl] | |||
void main(in float2 pass_Position : TEXCOORD0, | |||
uniform sampler2D u_texture, | |||
uniform float in_Flag, | |||
uniform float3 in_Point, | |||
uniform float3 in_Color, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
if (in_Flag == 0.0) | |||
{ | |||
float tc = 0.0, ta = 0.0; | |||
{ | |||
float s = 3.0 + 2.0 * in_Point.z; | |||
float2 p = pass_Position - in_Point.xy * 0.9; | |||
float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0); | |||
float u = t * t * t * t; | |||
tc += 3.0 * t * t - 2.0 * t * t * t; | |||
ta += 3.0 * u * u - 2.0 * u * u * u; | |||
} | |||
out_FragColor = float4(tc * in_Color, ta + 0.1); | |||
} | |||
else | |||
{ | |||
float2 texcoords = pass_Position * float2(0.5, -0.5) + float2(0.5, 0.5); | |||
/* FIXME: this should be passed as a uniform or something */ | |||
texcoords += float2(0.5 / 800.0, 0.5 / 600.0); | |||
out_FragColor = float4(tex2D(u_texture, texcoords).xyz, 1.0); | |||
} | |||
} | |||
@@ -1,69 +1,43 @@ | |||
//----------------------------------------------------------------------------- | |||
//GLSL | |||
//----------------------------------------------------------------------------- | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec2 in_Position; | |||
in vec2 in_position; | |||
uniform vec2 in_screen_res; | |||
uniform vec2 u_screen_res; | |||
varying vec2 pass_position; | |||
out vec2 pass_position; | |||
void main() | |||
{ | |||
pass_position = ((vec2(1.0) + in_Position) * 0.5 * in_screen_res); | |||
gl_Position = vec4(in_Position, 0.0, 1.0); | |||
pass_position = ((vec2(1.0) + in_position) * 0.5 * u_screen_res); | |||
gl_Position = vec4(in_position, 0.0, 1.0); | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform sampler2D in_texture; | |||
uniform vec3 in_source_point; | |||
uniform vec2 in_screen_res; | |||
in vec2 pass_position; | |||
varying vec2 pass_position; | |||
uniform sampler2D u_texture; | |||
uniform vec3 u_source_point; | |||
uniform vec2 u_screen_res; | |||
void main(void) | |||
{ | |||
if (floor(in_source_point.xy) == floor(pass_position)) | |||
gl_FragColor = vec4(in_source_point.xy / in_screen_res, in_source_point.z, 1.0); | |||
if (floor(u_source_point.xy) == floor(pass_position)) | |||
gl_FragColor = vec4(u_source_point.xy / u_screen_res, u_source_point.z, 1.0); | |||
else | |||
{ | |||
vec4 src_color = texture2D(in_texture, pass_position / in_screen_res); | |||
vec4 src_color = texture2D(u_texture, pass_position / u_screen_res); | |||
gl_FragColor = src_color;//vec4(0.0, 0.0, 0.0, 1.0); | |||
} | |||
//vec4(pass_position / in_screen_res, 0.0, 1.0); | |||
} | |||
//----------------------------------------------------------------------------- | |||
//HLSL | |||
//----------------------------------------------------------------------------- | |||
[vert.hlsl] | |||
void main(float2 in_Position : POSITION, | |||
out float2 pass_Position : TEXCOORD0, | |||
out float4 out_Position : POSITION) | |||
{ | |||
pass_Position = in_Position; | |||
out_Position = float4(in_Position, 0.0, 1.0); | |||
} | |||
[frag.hlsl] | |||
void main(in float2 pass_Position : TEXCOORD0, | |||
uniform float in_Flag, | |||
uniform float3 in_Point, | |||
uniform float3 in_Color, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
out_FragColor = float4(0.0); | |||
//vec4(pass_position / u_screen_res, 0.0, 1.0); | |||
} | |||
@@ -166,7 +166,7 @@ static const String DefaultUniforms[8] = | |||
String("u_inv_view"), | |||
String("u_proj"), | |||
String("u_normalmat"), | |||
String("in_Damage") | |||
String("u_damage") | |||
}; | |||
//----------------------------------------------------------------------------- | |||
void DefaultShaderData::StoreUniformNames() | |||
@@ -1,48 +1,49 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
in vec3 in_Position; | |||
in vec3 in_Normal; | |||
in vec4 in_Color; | |||
uniform mat4 u_modelview; | |||
uniform mat4 u_view; | |||
uniform mat4 u_projection; | |||
uniform mat3 u_normalmat; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
out vec4 pass_vertex; /* View space */ | |||
out vec3 pass_tnormal; | |||
out vec4 pass_color; | |||
void main(void) | |||
{ | |||
vec4 vertex = u_modelview * vec4(in_Position, 1.0); | |||
vec3 tnorm = normalize(u_normalmat * in_Normal); | |||
pass_Vertex = vertex; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
pass_vertex = vertex; | |||
pass_tnormal = tnorm; | |||
pass_color = in_Color; | |||
gl_Position = u_projection * vertex; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform float in_Damage; | |||
in vec4 pass_vertex; /* View space */ | |||
in vec3 pass_tnormal; | |||
in vec4 pass_color; | |||
uniform mat4 u_view; | |||
uniform mat4 u_inv_view; | |||
uniform vec4 u_lights[8 * 2]; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
uniform float u_damage; /* FIXME: remove this */ | |||
#if 0 | |||
//Cos(45) = 0.70710678118 | |||
@@ -60,7 +61,7 @@ vec3 in_Light3_diffuse = vec3(0.4, 1.0, 0.4); | |||
void main(void) | |||
{ | |||
vec3 TNormal = pass_TNormal; | |||
vec3 tnormal = pass_tnormal; | |||
/* Material properties */ | |||
vec3 specular_reflect = vec3(0.8, 0.75, 0.4); | |||
@@ -72,7 +73,7 @@ void main(void) | |||
vec3 diffuse = vec3(0.0, 0.0, 0.0); | |||
/* Light precalculations */ | |||
vec3 v = normalize(-pass_Vertex.xyz); | |||
vec3 v = normalize(-pass_vertex.xyz); | |||
/* Apply lighting */ | |||
for (int i = 0; i < 8; i++) | |||
@@ -85,16 +86,16 @@ void main(void) | |||
if (pos.w > 0.0) | |||
{ | |||
/* Point light -- no attenuation yet */ | |||
s = normalize(p - pass_Vertex.xyz); | |||
s = normalize(p - pass_vertex.xyz); | |||
} | |||
else | |||
{ | |||
/* Directional light */ | |||
s = normalize(-p); | |||
} | |||
r = reflect(-s, TNormal); | |||
r = reflect(-s, tnormal); | |||
float sdotn = max(dot(s, TNormal), 0.0); | |||
float sdotn = max(dot(s, tnormal), 0.0); | |||
diffuse += color.xyz * sdotn; | |||
if (sdotn > 0.0) | |||
specular += color.xyz * specular_reflect | |||
@@ -104,7 +105,7 @@ void main(void) | |||
#if 0 | |||
//Light calculation for cube light | |||
vec3 specular_color = vec3(1.0, 1.0, 0.6); | |||
vec3 Local_Vertex = (u_inv_view * pass_Vertex).xyz - (in_Light3_Pos).xyz; | |||
vec3 Local_Vertex = (u_inv_view * pass_vertex).xyz - (in_Light3_Pos).xyz; | |||
vec3 Proj_Vertex = clamp(Local_Vertex.xyz, -in_Light3_Size_Inner, in_Light3_Size_Inner); | |||
vec3 new_LightDir = Local_Vertex - Proj_Vertex; | |||
@@ -115,9 +116,9 @@ void main(void) | |||
sdotn = 1.0; | |||
else | |||
{ | |||
new_LightDir = normalize((u_view * vec4(Proj_Vertex + in_Light3_Pos.xyz,1.0)).xyz - pass_Vertex.xyz); | |||
sdotn = max(dot(new_LightDir, TNormal), 0.0); | |||
r = reflect(-new_LightDir, TNormal); | |||
new_LightDir = normalize((u_view * vec4(Proj_Vertex + in_Light3_Pos.xyz,1.0)).xyz - pass_vertex.xyz); | |||
sdotn = max(dot(new_LightDir, tnormal), 0.0); | |||
r = reflect(-new_LightDir, tnormal); | |||
if (sdotn > 0.0 && light_radius_mod > 0.0) | |||
specular += specular_color * min(specular_reflect, light_radius_mod) | |||
* pow(max(dot(r, v), 0.0), specular_power); | |||
@@ -128,68 +129,7 @@ void main(void) | |||
vec3 light = ambient + diffuse + specular; | |||
vec4 real_color = mix(pass_Color, vec4(1.2, 1.2, 1.2, 1.0), in_Damage); | |||
vec4 real_color = mix(pass_color, vec4(1.2, 1.2, 1.2, 1.0), u_damage); | |||
gl_FragColor = real_color * vec4(light, 1.0); | |||
} | |||
[vert.hlsl] | |||
void main(float3 in_Vertex : POSITION, | |||
float3 in_Normal : NORMAL, | |||
float4 in_Color : COLOR, | |||
uniform float4x4 u_modelview, | |||
uniform float4x4 u_projection, | |||
uniform float3x3 u_normalmat, | |||
out float4 pass_Vertex : TEXCOORD0, | |||
out float3 pass_TNormal : TEXCOORD1, | |||
out float4 pass_Color : COLOR, | |||
out float4 out_Position : POSITION) | |||
{ | |||
float4 eye = mul(u_modelview, float4(in_Vertex, 1.0)); | |||
float3 tnorm = normalize(mul(u_normalmat, in_Normal)); | |||
pass_Vertex = eye; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
out_Position = mul(u_projection, eye); | |||
} | |||
[frag.hlsl] | |||
void main(float4 pass_Vertex : TEXCOORD0, | |||
float3 pass_TNormal : TEXCOORD1, | |||
float4 pass_Color : COLOR, | |||
uniform float in_Damage, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float3 in_LightDir = float3(0.3, 0.3, 0.7); | |||
/* Material properties */ | |||
float3 specular_reflect = float3(0.8, 0.75, 0.4); | |||
float specular_power = 60.0; | |||
/* World properties */ | |||
float ambient_mul = 0.5; | |||
float3 ambient_color = float3(0.25, 0.2, 0.35); | |||
float3 diffuse_color = float3(1.0, 1.0, 0.6); | |||
float3 specular_color = float3(1.0, 1.0, 0.6); | |||
float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */ | |||
float3 v = normalize(-pass_Vertex.xyz); | |||
float3 r = reflect(-s, pass_TNormal); | |||
float3 ambient = ambient_color; | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float3 diffuse = diffuse_color * sdotn; | |||
float3 specular = float3(0.0, 0.0, 0.0); | |||
if (sdotn > 0.0) | |||
specular = specular_color * specular_reflect | |||
* pow(max(dot(r, v), 0.0), specular_power); | |||
float3 light = ambient + diffuse + specular; | |||
float4 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0) | |||
+ (1.0 - in_Damage) * pass_Color; | |||
out_FragColor = real_color * float4(light, 1.0); | |||
} | |||
@@ -1,53 +1,53 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
attribute vec2 in_Index; | |||
attribute vec2 in_Weight; | |||
in vec3 in_position; | |||
in vec3 in_Normal; | |||
in vec4 in_color; | |||
in vec2 in_Index; | |||
in vec2 in_Weight; | |||
uniform mat4 u_modelview; | |||
uniform mat4 u_view; | |||
uniform mat4 u_projection; | |||
uniform mat3 u_normalmat; | |||
//10is not a fix idea, should be more. | |||
uniform mat4 in_BoneList[10]; | |||
uniform mat4 u_bone_list[10]; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
out vec4 pass_vertex; /* View space */ | |||
out vec3 pass_tnormal; | |||
out vec4 pass_color; | |||
void main(void) | |||
{ | |||
vec4 vertex = u_modelview * vec4(in_Position, 1.0); | |||
vec4 vertex = u_modelview * vec4(in_position, 1.0); | |||
vec3 tnorm = normalize(u_normalmat * in_Normal); | |||
pass_Vertex = vertex; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
pass_vertex = vertex; | |||
pass_tnormal = tnorm; | |||
pass_color = in_color; | |||
gl_Position = u_projection * vertex; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform float in_Damage; | |||
in vec4 pass_vertex; /* View space */ | |||
in vec3 pass_tnormal; | |||
in vec4 pass_color; | |||
uniform float u_damage; | |||
uniform mat4 u_view; | |||
uniform mat4 u_inv_view; | |||
uniform vec4 u_lights[8 * 2]; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
#if 0 | |||
//Cube Light | |||
//Cos(45) = 0.70710678118 | |||
@@ -74,7 +74,7 @@ void main(void) | |||
vec3 diffuse = vec3(0.0, 0.0, 0.0); | |||
/* Light precalculations */ | |||
vec3 v = normalize(-pass_Vertex.xyz); | |||
vec3 v = normalize(-pass_vertex.xyz); | |||
/* Apply lighting */ | |||
for (int i = 0; i < 8; i++) | |||
@@ -86,17 +86,17 @@ void main(void) | |||
if (pos.w > 0.0) | |||
{ | |||
/* Point light -- no attenuation yet */ | |||
s = normalize((u_view * pos).xyz - pass_Vertex.xyz); | |||
r = reflect(-s, pass_TNormal); | |||
s = normalize((u_view * pos).xyz - pass_vertex.xyz); | |||
r = reflect(-s, pass_tnormal); | |||
} | |||
else | |||
{ | |||
/* Directional light */ | |||
s = normalize(-pos.xyz); | |||
r = reflect(s, pass_TNormal); | |||
r = reflect(s, pass_tnormal); | |||
} | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float sdotn = max(dot(s, pass_tnormal), 0.0); | |||
diffuse += color.xyz * sdotn; | |||
if (sdotn > 0.0) | |||
specular += color.xyz * specular_reflect | |||
@@ -107,7 +107,7 @@ void main(void) | |||
//Light calculation for cube light | |||
//const float cos_45 = 0.70710678118; | |||
//const float inv_cos_45 = 0.29289321881; | |||
vec3 local_vertex = (u_inv_view * pass_Vertex).xyz - (in_Light3_Pos).xyz; | |||
vec3 local_vertex = (u_inv_view * pass_vertex).xyz - (in_Light3_Pos).xyz; | |||
vec3 proj_vertex = clamp(local_vertex.xyz, -in_Light3_Size_Inner, in_Light3_Size_Inner); | |||
vec3 proj_local_dir = local_vertex - proj_vertex; | |||
vec3 inner_dir = proj_vertex / in_Light3_Size_Inner; | |||
@@ -138,9 +138,9 @@ void main(void) | |||
// //vec3 proj_local_light = max(vec3(0.0,0.0,0.0), vec3(1.0,1.0,1.0) - abs(proj_local_dir / in_Light3_Size_Outer)); | |||
//} | |||
/* | |||
proj_local_dir = normalize((u_view * vec4(proj_vertex + in_Light3_Pos.xyz,1.0)).xyz - pass_Vertex.xyz); | |||
sdotn = max(dot(proj_local_dir, pass_TNormal), 0.0); | |||
r = reflect(-proj_local_dir, pass_TNormal); | |||
proj_local_dir = normalize((u_view * vec4(proj_vertex + in_Light3_Pos.xyz,1.0)).xyz - pass_vertex.xyz); | |||
sdotn = max(dot(proj_local_dir, pass_tnormal), 0.0); | |||
r = reflect(-proj_local_dir, pass_tnormal); | |||
if (sdotn > 0.0 && light_radius_mod > 0.0) | |||
specular += specular_color * min(specular_reflect, light_radius_mod) | |||
* pow(max(dot(r, v), 0.0), specular_power); | |||
@@ -153,68 +153,7 @@ void main(void) | |||
vec3 light = ambient + diffuse + specular; | |||
vec4 real_color = mix(pass_Color, vec4(1.2, 1.2, 1.2, 1.0), in_Damage); | |||
vec4 real_color = mix(pass_color, vec4(1.2, 1.2, 1.2, 1.0), u_damage); | |||
gl_FragColor = real_color * vec4(light, 1.0); | |||
} | |||
[vert.hlsl] | |||
void main(float3 in_Vertex : POSITION, | |||
float3 in_Normal : NORMAL, | |||
float4 in_Color : COLOR, | |||
uniform float4x4 u_modelview, | |||
uniform float4x4 u_projection, | |||
uniform float3x3 u_normalmat, | |||
out float4 pass_Vertex : TEXCOORD0, | |||
out float3 pass_TNormal : TEXCOORD1, | |||
out float4 pass_Color : COLOR, | |||
out float4 out_Position : POSITION) | |||
{ | |||
float4 eye = mul(u_modelview, float4(in_Vertex, 1.0)); | |||
float3 tnorm = normalize(mul(u_normalmat, in_Normal)); | |||
pass_Vertex = eye; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
out_Position = mul(u_projection, eye); | |||
} | |||
[frag.hlsl] | |||
void main(float4 pass_Vertex : TEXCOORD0, | |||
float3 pass_TNormal : TEXCOORD1, | |||
float4 pass_Color : COLOR, | |||
uniform float in_Damage, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float3 in_LightDir = float3(0.3, 0.3, 0.7); | |||
/* Material properties */ | |||
float3 specular_reflect = float3(0.8, 0.75, 0.4); | |||
float specular_power = 60.0; | |||
/* World properties */ | |||
float ambient_mul = 0.5; | |||
float3 ambient_color = float3(0.25, 0.2, 0.35); | |||
float3 diffuse_color = float3(1.0, 1.0, 0.6); | |||
float3 specular_color = float3(1.0, 1.0, 0.6); | |||
float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */ | |||
float3 v = normalize(-pass_Vertex.xyz); | |||
float3 r = reflect(-s, pass_TNormal); | |||
float3 ambient = ambient_color; | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float3 diffuse = diffuse_color * sdotn; | |||
float3 specular = float3(0.0, 0.0, 0.0); | |||
if (sdotn > 0.0) | |||
specular = specular_color * specular_reflect | |||
* pow(max(dot(r, v), 0.0), specular_power); | |||
float3 light = ambient + diffuse + specular; | |||
float4 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0) | |||
+ (1.0 - in_Damage) * pass_Color; | |||
out_FragColor = real_color * float4(light, 1.0); | |||
} | |||
@@ -1,65 +1,65 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
attribute vec2 in_TexCoord; | |||
in vec3 in_position; | |||
in vec3 in_Normal; | |||
in vec4 in_color; | |||
in vec2 in_texcoord; | |||
uniform mat4 u_modelview; | |||
uniform mat4 u_view; | |||
uniform mat4 u_projection; | |||
uniform mat3 u_normalmat; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
varying vec2 pass_TexCoord; | |||
out vec4 pass_vertex; /* View space */ | |||
out vec3 pass_tnormal; | |||
out vec4 pass_color; | |||
out vec2 pass_texcoord; | |||
void main(void) | |||
{ | |||
vec4 vertex = u_modelview * vec4(in_Position, 1.0); | |||
vec4 vertex = u_modelview * vec4(in_position, 1.0); | |||
vec3 tnorm = normalize(u_normalmat * in_Normal); | |||
pass_Vertex = vertex; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
pass_TexCoord = in_TexCoord; | |||
pass_vertex = vertex; | |||
pass_tnormal = tnorm; | |||
pass_color = in_color; | |||
pass_texcoord = in_texcoord; | |||
gl_Position = u_projection * vertex; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform float in_Damage; | |||
in vec4 pass_vertex; /* View space */ | |||
in vec3 pass_tnormal; | |||
in vec4 pass_color; | |||
in vec2 pass_texcoord; | |||
uniform float u_damage; | |||
uniform mat4 u_view; | |||
uniform mat4 u_inv_view; | |||
uniform vec4 u_lights[8 * 2]; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
varying vec2 pass_TexCoord; | |||
void main(void) | |||
{ | |||
float mode = 0.0; | |||
if (mode == 0.0) | |||
{ | |||
gl_FragColor = vec4(mod(pass_TexCoord.x, 1.0), | |||
gl_FragColor = vec4(mod(pass_texcoord.x, 1.0), | |||
0.1, | |||
mod(pass_TexCoord.y, 1.0), 1.0); | |||
mod(pass_texcoord.y, 1.0), 1.0); | |||
} | |||
else | |||
{ | |||
float col = ((mod(mode, 2.0) == 1.0)?(mod(pass_TexCoord.x, 1.0)):(mod(pass_TexCoord.y, 1.0))); | |||
float col = ((mod(mode, 2.0) == 1.0)?(mod(pass_texcoord.x, 1.0)):(mod(pass_texcoord.y, 1.0))); | |||
if (mode == 1.0 || mode == 2.0) | |||
{ | |||
if (col > 1.0/3.0) gl_FragColor.r = 0.0; | |||
@@ -85,70 +85,9 @@ void main(void) | |||
gl_FragColor.a = 1.0; | |||
gl_FragColor *= | |||
//= pass_Color * | |||
length(normalize(pass_TexCoord)) * | |||
length(normalize(pass_Color.xyz)) * | |||
length(normalize(pass_TNormal)); | |||
} | |||
[vert.hlsl] | |||
void main(float3 in_Vertex : POSITION, | |||
float3 in_Normal : NORMAL, | |||
float4 in_Color : COLOR, | |||
uniform float4x4 u_modelview, | |||
uniform float4x4 u_projection, | |||
uniform float3x3 u_normalmat, | |||
out float4 pass_Vertex : TEXCOORD0, | |||
out float3 pass_TNormal : TEXCOORD1, | |||
out float4 pass_Color : COLOR, | |||
out float4 out_Position : POSITION) | |||
{ | |||
float4 eye = mul(u_modelview, float4(in_Vertex, 1.0)); | |||
float3 tnorm = normalize(mul(u_normalmat, in_Normal)); | |||
pass_Vertex = eye; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
out_Position = mul(u_projection, eye); | |||
} | |||
[frag.hlsl] | |||
void main(float4 pass_Vertex : TEXCOORD0, | |||
float3 pass_TNormal : TEXCOORD1, | |||
float4 pass_Color : COLOR, | |||
uniform float in_Damage, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float3 in_LightDir = float3(0.3, 0.3, 0.7); | |||
/* Material properties */ | |||
float3 specular_reflect = float3(0.8, 0.75, 0.4); | |||
float specular_power = 60.0; | |||
/* World properties */ | |||
float ambient_mul = 0.5; | |||
float3 ambient_color = float3(0.25, 0.2, 0.35); | |||
float3 diffuse_color = float3(1.0, 1.0, 0.6); | |||
float3 specular_color = float3(1.0, 1.0, 0.6); | |||
float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */ | |||
float3 v = normalize(-pass_Vertex.xyz); | |||
float3 r = reflect(-s, pass_TNormal); | |||
float3 ambient = ambient_color; | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float3 diffuse = diffuse_color * sdotn; | |||
float3 specular = float3(0.0, 0.0, 0.0); | |||
if (sdotn > 0.0) | |||
specular = specular_color * specular_reflect | |||
* pow(max(dot(r, v), 0.0), specular_power); | |||
float3 light = ambient + diffuse + specular; | |||
float4 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0) | |||
+ (1.0 - in_Damage) * pass_Color; | |||
out_FragColor = real_color * float4(light, 1.0); | |||
//= pass_color * | |||
length(normalize(pass_texcoord)) * | |||
length(normalize(pass_color.xyz)) * | |||
length(normalize(pass_tnormal)); | |||
} | |||
@@ -1,49 +1,49 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
in vec3 in_position; | |||
in vec3 in_Normal; | |||
in vec4 in_color; | |||
uniform mat4 u_modelview; | |||
uniform mat4 u_view; | |||
uniform mat4 u_projection; | |||
uniform mat3 u_normalmat; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
out vec4 pass_vertex; /* View space */ | |||
out vec3 pass_tnormal; | |||
out vec4 pass_color; | |||
void main(void) | |||
{ | |||
vec4 vertex = u_modelview * vec4(in_Position, 1.0); | |||
vec4 vertex = u_modelview * vec4(in_position, 1.0); | |||
vec3 tnorm = normalize(u_normalmat * in_Normal); | |||
pass_Vertex = vertex; | |||
pass_TNormal = tnorm; | |||
pass_Color = vec4(1.0, 1.0, 1.0, in_Color.w);//; | |||
pass_vertex = vertex; | |||
pass_tnormal = tnorm; | |||
pass_color = vec4(1.0, 1.0, 1.0, in_color.w);//; | |||
gl_Position = u_projection * vertex; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform float in_Damage; | |||
in vec4 pass_vertex; /* View space */ | |||
in vec3 pass_tnormal; | |||
in vec4 pass_color; | |||
uniform float u_damage; | |||
uniform mat4 u_view; | |||
uniform mat4 u_inv_view; | |||
uniform vec4 u_lights[8 * 2]; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
void main(void) | |||
{ | |||
/* Material properties */ | |||
@@ -56,7 +56,7 @@ void main(void) | |||
vec3 diffuse = vec3(0.0, 0.0, 0.0); | |||
/* Light precalculations */ | |||
vec3 v = normalize(-pass_Vertex.xyz); | |||
vec3 v = normalize(-pass_vertex.xyz); | |||
/* Apply lighting */ | |||
for (int i = 0; i < 8; i++) | |||
@@ -68,17 +68,17 @@ void main(void) | |||
if (pos.w > 0.0) | |||
{ | |||
/* Point light -- no attenuation yet */ | |||
s = normalize((u_view * pos).xyz - pass_Vertex.xyz); | |||
r = reflect(-s, pass_TNormal); | |||
s = normalize((u_view * pos).xyz - pass_vertex.xyz); | |||
r = reflect(-s, pass_tnormal); | |||
} | |||
else | |||
{ | |||
/* Directional light */ | |||
s = normalize(-pos.xyz); | |||
r = reflect(s, pass_TNormal); | |||
r = reflect(s, pass_tnormal); | |||
} | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float sdotn = max(dot(s, pass_tnormal), 0.0); | |||
diffuse += color.xyz * sdotn; | |||
if (sdotn > 0.0) | |||
specular += color.xyz * specular_reflect | |||
@@ -87,68 +87,7 @@ void main(void) | |||
vec3 light = ambient + diffuse + specular; | |||
//vec4 real_color = mix(pass_Color, vec4(1.0, 1.0, 1.0, 1.0), 1.0); | |||
gl_FragColor = pass_Color * vec4(light, 1.0); | |||
} | |||
[vert.hlsl] | |||
void main(float3 in_Vertex : POSITION, | |||
float3 in_Normal : NORMAL, | |||
float4 in_Color : COLOR, | |||
uniform float4x4 u_modelview, | |||
uniform float4x4 u_projection, | |||
uniform float3x3 u_normalmat, | |||
out float4 pass_Vertex : TEXCOORD0, | |||
out float3 pass_TNormal : TEXCOORD1, | |||
out float4 pass_Color : COLOR, | |||
out float4 out_Position : POSITION) | |||
{ | |||
float4 eye = mul(u_modelview, float4(in_Vertex, 1.0)); | |||
float3 tnorm = normalize(mul(u_normalmat, in_Normal)); | |||
pass_Vertex = eye; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
out_Position = mul(u_projection, eye); | |||
} | |||
[frag.hlsl] | |||
void main(float4 pass_Vertex : TEXCOORD0, | |||
float3 pass_TNormal : TEXCOORD1, | |||
float4 pass_Color : COLOR, | |||
uniform float in_Damage, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float3 in_LightDir = float3(0.3, 0.3, 0.7); | |||
/* Material properties */ | |||
float3 specular_reflect = float3(0.8, 0.75, 0.4); | |||
float specular_power = 60.0; | |||
/* World properties */ | |||
float ambient_mul = 0.5; | |||
float3 ambient_color = float3(0.25, 0.2, 0.35); | |||
float3 diffuse_color = float3(1.0, 1.0, 0.6); | |||
float3 specular_color = float3(1.0, 1.0, 0.6); | |||
float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */ | |||
float3 v = normalize(-pass_Vertex.xyz); | |||
float3 r = reflect(-s, pass_TNormal); | |||
float3 ambient = ambient_color; | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float3 diffuse = diffuse_color * sdotn; | |||
float3 specular = float3(0.0, 0.0, 0.0); | |||
if (sdotn > 0.0) | |||
specular = specular_color * specular_reflect | |||
* pow(max(dot(r, v), 0.0), specular_power); | |||
float3 light = ambient + diffuse + specular; | |||
float4 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0) | |||
+ (1.0 - in_Damage) * pass_Color; | |||
out_FragColor = real_color * float4(light, 1.0); | |||
//vec4 real_color = mix(pass_color, vec4(1.0, 1.0, 1.0, 1.0), 1.0); | |||
gl_FragColor = pass_color * vec4(light, 1.0); | |||
} | |||
@@ -1,116 +1,55 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
in vec3 in_position; | |||
in vec3 in_Normal; | |||
in vec4 in_color; | |||
uniform mat4 u_modelview; | |||
uniform mat4 u_view; | |||
uniform mat4 u_projection; | |||
uniform mat3 u_normalmat; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
out vec4 pass_vertex; /* View space */ | |||
out vec3 pass_tnormal; | |||
out vec4 pass_color; | |||
void main(void) | |||
{ | |||
vec4 vertex = u_modelview * vec4(in_Position, 1.0); | |||
vec4 vertex = u_modelview * vec4(in_position, 1.0); | |||
vec3 tnorm = normalize(in_Normal); | |||
pass_Vertex = vertex; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
pass_vertex = vertex; | |||
pass_tnormal = tnorm; | |||
pass_color = in_color; | |||
gl_Position = u_projection * vertex; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform float in_Damage; | |||
in vec4 pass_vertex; /* View space */ | |||
in vec3 pass_tnormal; | |||
in vec4 pass_color; | |||
uniform float u_damage; | |||
uniform mat4 u_view; | |||
uniform mat4 u_inv_view; | |||
uniform vec4 u_lights[8 * 2]; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
void main(void) | |||
{ | |||
vec3 real_color = vec3(0.0, 0.0, 0.0); | |||
real_color += abs(pass_TNormal.x) * ((pass_TNormal.x < 0.0)?(vec3(0.0, 1.0, 1.0)):(vec3(1.0, 0.0, 0.0))); | |||
real_color += abs(pass_TNormal.y) * ((pass_TNormal.y < 0.0)?(vec3(1.0, 0.0, 1.0)):(vec3(0.0, 1.0, 0.0))); | |||
real_color += abs(pass_TNormal.z) * ((pass_TNormal.z < 0.0)?(vec3(1.0, 1.0, 0.0)):(vec3(0.0, 0.0, 1.0))); | |||
gl_FragColor = vec4(real_color, pass_Color.w); | |||
} | |||
[vert.hlsl] | |||
void main(float3 in_Vertex : POSITION, | |||
float3 in_Normal : NORMAL, | |||
float4 in_Color : COLOR, | |||
uniform float4x4 u_modelview, | |||
uniform float4x4 u_projection, | |||
uniform float3x3 u_normalmat, | |||
out float4 pass_Vertex : TEXCOORD0, | |||
out float3 pass_TNormal : TEXCOORD1, | |||
out float4 pass_Color : COLOR, | |||
out float4 out_Position : POSITION) | |||
{ | |||
float4 eye = mul(u_modelview, float4(in_Vertex, 1.0)); | |||
float3 tnorm = normalize(mul(u_normalmat, in_Normal)); | |||
pass_Vertex = eye; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
out_Position = mul(u_projection, eye); | |||
} | |||
[frag.hlsl] | |||
void main(float4 pass_Vertex : TEXCOORD0, | |||
float3 pass_TNormal : TEXCOORD1, | |||
float4 pass_Color : COLOR, | |||
uniform float in_Damage, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float3 in_LightDir = float3(0.3, 0.3, 0.7); | |||
/* Material properties */ | |||
float3 specular_reflect = float3(0.8, 0.75, 0.4); | |||
float specular_power = 60.0; | |||
/* World properties */ | |||
float ambient_mul = 0.5; | |||
float3 ambient_color = float3(0.25, 0.2, 0.35); | |||
float3 diffuse_color = float3(1.0, 1.0, 0.6); | |||
float3 specular_color = float3(1.0, 1.0, 0.6); | |||
float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */ | |||
float3 v = normalize(-pass_Vertex.xyz); | |||
float3 r = reflect(-s, pass_TNormal); | |||
float3 ambient = ambient_color; | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float3 diffuse = diffuse_color * sdotn; | |||
float3 specular = float3(0.0, 0.0, 0.0); | |||
if (sdotn > 0.0) | |||
specular = specular_color * specular_reflect | |||
* pow(max(dot(r, v), 0.0), specular_power); | |||
float3 light = ambient + diffuse + specular; | |||
float4 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0) | |||
+ (1.0 - in_Damage) * pass_Color; | |||
out_FragColor = real_color * float4(light, 1.0); | |||
real_color += abs(pass_tnormal.x) * ((pass_tnormal.x < 0.0)?(vec3(0.0, 1.0, 1.0)):(vec3(1.0, 0.0, 0.0))); | |||
real_color += abs(pass_tnormal.y) * ((pass_tnormal.y < 0.0)?(vec3(1.0, 0.0, 1.0)):(vec3(0.0, 1.0, 0.0))); | |||
real_color += abs(pass_tnormal.z) * ((pass_tnormal.z < 0.0)?(vec3(1.0, 1.0, 0.0)):(vec3(0.0, 0.0, 1.0))); | |||
gl_FragColor = vec4(real_color, pass_color.w); | |||
} | |||
@@ -1,112 +1,51 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
in vec3 in_position; | |||
in vec3 in_Normal; | |||
in vec4 in_color; | |||
uniform mat4 u_modelview; | |||
uniform mat4 u_view; | |||
uniform mat4 u_projection; | |||
uniform mat3 u_normalmat; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
out vec4 pass_vertex; /* View space */ | |||
out vec3 pass_tnormal; | |||
out vec4 pass_color; | |||
void main(void) | |||
{ | |||
vec4 vertex = u_modelview * vec4(in_Position, 1.0); | |||
vec4 vertex = u_modelview * vec4(in_position, 1.0); | |||
vec3 tnorm = normalize(u_normalmat * in_Normal); | |||
pass_Vertex = vertex; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
pass_vertex = vertex; | |||
pass_tnormal = tnorm; | |||
pass_color = in_color; | |||
gl_Position = u_projection * vertex; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform float in_Damage; | |||
in vec4 pass_vertex; /* View space */ | |||
in vec3 pass_tnormal; | |||
in vec4 pass_color; | |||
uniform float u_damage; | |||
uniform mat4 u_view; | |||
uniform mat4 u_inv_view; | |||
uniform vec4 u_lights[8 * 2]; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
void main(void) | |||
{ | |||
gl_FragColor = pass_Color * length(normalize(pass_TNormal)); | |||
} | |||
[vert.hlsl] | |||
void main(float3 in_Vertex : POSITION, | |||
float3 in_Normal : NORMAL, | |||
float4 in_Color : COLOR, | |||
uniform float4x4 u_modelview, | |||
uniform float4x4 u_projection, | |||
uniform float3x3 u_normalmat, | |||
out float4 pass_Vertex : TEXCOORD0, | |||
out float3 pass_TNormal : TEXCOORD1, | |||
out float4 pass_Color : COLOR, | |||
out float4 out_Position : POSITION) | |||
{ | |||
float4 eye = mul(u_modelview, float4(in_Vertex, 1.0)); | |||
float3 tnorm = normalize(mul(u_normalmat, in_Normal)); | |||
pass_Vertex = eye; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
out_Position = mul(u_projection, eye); | |||
} | |||
[frag.hlsl] | |||
void main(float4 pass_Vertex : TEXCOORD0, | |||
float3 pass_TNormal : TEXCOORD1, | |||
float4 pass_Color : COLOR, | |||
uniform float in_Damage, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float3 in_LightDir = float3(0.3, 0.3, 0.7); | |||
/* Material properties */ | |||
float3 specular_reflect = float3(0.8, 0.75, 0.4); | |||
float specular_power = 60.0; | |||
/* World properties */ | |||
float ambient_mul = 0.5; | |||
float3 ambient_color = float3(0.25, 0.2, 0.35); | |||
float3 diffuse_color = float3(1.0, 1.0, 0.6); | |||
float3 specular_color = float3(1.0, 1.0, 0.6); | |||
float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */ | |||
float3 v = normalize(-pass_Vertex.xyz); | |||
float3 r = reflect(-s, pass_TNormal); | |||
float3 ambient = ambient_color; | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float3 diffuse = diffuse_color * sdotn; | |||
float3 specular = float3(0.0, 0.0, 0.0); | |||
if (sdotn > 0.0) | |||
specular = specular_color * specular_reflect | |||
* pow(max(dot(r, v), 0.0), specular_power); | |||
float3 light = ambient + diffuse + specular; | |||
float4 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0) | |||
+ (1.0 - in_Damage) * pass_Color; | |||
out_FragColor = real_color * float4(light, 1.0); | |||
gl_FragColor = pass_color * length(normalize(pass_tnormal)); | |||
} | |||
@@ -1,49 +1,49 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec3 in_Normal; | |||
attribute vec4 in_Color; | |||
in vec3 in_position; | |||
in vec3 in_Normal; | |||
in vec4 in_color; | |||
uniform mat4 u_modelview; | |||
uniform mat4 u_view; | |||
uniform mat4 u_projection; | |||
uniform mat3 u_normalmat; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
out vec4 pass_vertex; /* View space */ | |||
out vec3 pass_tnormal; | |||
out vec4 pass_color; | |||
void main(void) | |||
{ | |||
vec4 vertex = u_modelview * vec4(in_Position, 1.0); | |||
vec4 vertex = u_modelview * vec4(in_position, 1.0); | |||
vec3 tnorm = normalize(u_normalmat * in_Normal); | |||
pass_Vertex = vertex; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
pass_vertex = vertex; | |||
pass_tnormal = tnorm; | |||
pass_color = in_color; | |||
gl_Position = u_projection * vertex; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision highp float; | |||
#endif | |||
uniform float in_Damage; | |||
in vec4 pass_vertex; /* View space */ | |||
in vec3 pass_tnormal; | |||
in vec4 pass_color; | |||
uniform float u_damage; | |||
uniform mat4 u_view; | |||
uniform mat4 u_inv_view; | |||
uniform vec4 u_lights[8 * 2]; | |||
varying vec4 pass_Vertex; /* View space */ | |||
varying vec3 pass_TNormal; | |||
varying vec4 pass_Color; | |||
#if 0 | |||
//Cos(45) = 0.70710678118 | |||
//1.0 - Cos(45) = 0.29289321881 | |||
@@ -60,10 +60,10 @@ vec3 in_Light3_diffuse = vec3(0.4, 1.0, 0.4); | |||
void main(void) | |||
{ | |||
vec3 TNormal = pass_TNormal; | |||
vec3 X = dFdx(pass_Vertex.xyz); | |||
vec3 Y = dFdy(pass_Vertex.xyz); | |||
TNormal = normalize(cross(Y, X)) * length(normalize(pass_TNormal)); | |||
vec3 TNormal = pass_tnormal; | |||
vec3 X = dFdx(pass_vertex.xyz); | |||
vec3 Y = dFdy(pass_vertex.xyz); | |||
TNormal = normalize(cross(Y, X)) * length(normalize(pass_tnormal)); | |||
/* Material properties */ | |||
vec3 specular_reflect = vec3(0.8, 0.75, 0.4); | |||
@@ -75,7 +75,7 @@ void main(void) | |||
vec3 diffuse = vec3(0.0, 0.0, 0.0); | |||
/* Light precalculations */ | |||
vec3 v = normalize(-pass_Vertex.xyz); | |||
vec3 v = normalize(-pass_vertex.xyz); | |||
/* Apply lighting */ | |||
for (int i = 0; i < 8; i++) | |||
@@ -88,7 +88,7 @@ void main(void) | |||
if (pos.w > 0.0) | |||
{ | |||
/* Point light -- no attenuation yet */ | |||
s = normalize(p - pass_Vertex.xyz); | |||
s = normalize(p - pass_vertex.xyz); | |||
} | |||
else | |||
{ | |||
@@ -107,7 +107,7 @@ void main(void) | |||
#if 0 | |||
//Light calculation for cube light | |||
vec3 specular_color = vec3(1.0, 1.0, 0.6); | |||
vec3 Local_Vertex = (u_inv_view * pass_Vertex).xyz - (in_Light3_Pos).xyz; | |||
vec3 Local_Vertex = (u_inv_view * pass_vertex).xyz - (in_Light3_Pos).xyz; | |||
vec3 Proj_Vertex = clamp(Local_Vertex.xyz, -in_Light3_Size_Inner, in_Light3_Size_Inner); | |||
vec3 new_LightDir = Local_Vertex - Proj_Vertex; | |||
@@ -118,7 +118,7 @@ void main(void) | |||
sdotn = 1.0; | |||
else | |||
{ | |||
new_LightDir = normalize((u_view * vec4(Proj_Vertex + in_Light3_Pos.xyz,1.0)).xyz - pass_Vertex.xyz); | |||
new_LightDir = normalize((u_view * vec4(Proj_Vertex + in_Light3_Pos.xyz,1.0)).xyz - pass_vertex.xyz); | |||
sdotn = max(dot(new_LightDir, TNormal), 0.0); | |||
r = reflect(-new_LightDir, TNormal); | |||
if (sdotn > 0.0 && light_radius_mod > 0.0) | |||
@@ -131,68 +131,7 @@ void main(void) | |||
vec3 light = ambient + diffuse + specular; | |||
vec4 real_color = mix(pass_Color, vec4(1.2, 1.2, 1.2, 1.0), in_Damage); | |||
vec4 real_color = mix(pass_color, vec4(1.2, 1.2, 1.2, 1.0), u_damage); | |||
gl_FragColor = real_color * vec4(light, 1.0); | |||
} | |||
[vert.hlsl] | |||
void main(float3 in_Vertex : POSITION, | |||
float3 in_Normal : NORMAL, | |||
float4 in_Color : COLOR, | |||
uniform float4x4 u_modelview, | |||
uniform float4x4 u_projection, | |||
uniform float3x3 u_normalmat, | |||
out float4 pass_Vertex : TEXCOORD0, | |||
out float3 pass_TNormal : TEXCOORD1, | |||
out float4 pass_Color : COLOR, | |||
out float4 out_Position : POSITION) | |||
{ | |||
float4 eye = mul(u_modelview, float4(in_Vertex, 1.0)); | |||
float3 tnorm = normalize(mul(u_normalmat, in_Normal)); | |||
pass_Vertex = eye; | |||
pass_TNormal = tnorm; | |||
pass_Color = in_Color; | |||
out_Position = mul(u_projection, eye); | |||
} | |||
[frag.hlsl] | |||
void main(float4 pass_Vertex : TEXCOORD0, | |||
float3 pass_TNormal : TEXCOORD1, | |||
float4 pass_Color : COLOR, | |||
uniform float in_Damage, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float3 in_LightDir = float3(0.3, 0.3, 0.7); | |||
/* Material properties */ | |||
float3 specular_reflect = float3(0.8, 0.75, 0.4); | |||
float specular_power = 60.0; | |||
/* World properties */ | |||
float ambient_mul = 0.5; | |||
float3 ambient_color = float3(0.25, 0.2, 0.35); | |||
float3 diffuse_color = float3(1.0, 1.0, 0.6); | |||
float3 specular_color = float3(1.0, 1.0, 0.6); | |||
float3 s = normalize(in_LightDir); /* normalize(pass_Vertex - lightpos); */ | |||
float3 v = normalize(-pass_Vertex.xyz); | |||
float3 r = reflect(-s, pass_TNormal); | |||
float3 ambient = ambient_color; | |||
float sdotn = max(dot(s, pass_TNormal), 0.0); | |||
float3 diffuse = diffuse_color * sdotn; | |||
float3 specular = float3(0.0, 0.0, 0.0); | |||
if (sdotn > 0.0) | |||
specular = specular_color * specular_reflect | |||
* pow(max(dot(r, v), 0.0), specular_power); | |||
float3 light = ambient + diffuse + specular; | |||
float4 real_color = in_Damage * float4(1.2, 1.2, 1.2, 1.0) | |||
+ (1.0 - in_Damage) * pass_Color; | |||
out_FragColor = real_color * float4(light, 1.0); | |||
} | |||
@@ -1,67 +1,43 @@ | |||
[vert.glsl] | |||
#version 120 | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec2 in_TexCoord; | |||
varying vec2 pass_TexCoord; | |||
in vec3 in_position; | |||
in vec2 in_texcoord; | |||
uniform mat4 u_projection; | |||
uniform mat4 u_view; | |||
uniform mat4 u_model; | |||
out vec2 pass_texcoord; | |||
void main() | |||
{ | |||
gl_Position = u_projection * u_view * u_model | |||
* vec4(in_Position, 1.0); | |||
pass_TexCoord = in_TexCoord; | |||
* vec4(in_position, 1.0); | |||
pass_texcoord = in_texcoord; | |||
} | |||
[frag.glsl] | |||
#version 120 | |||
#version 130 | |||
#if defined GL_ES | |||
precision mediump float; | |||
#endif | |||
in vec2 pass_texcoord; | |||
uniform sampler2D u_texture; | |||
uniform sampler2D u_palette; | |||
uniform vec2 u_texsize; | |||
varying vec2 pass_TexCoord; | |||
void main() | |||
{ | |||
vec4 pal = texture2D(u_texture, pass_TexCoord); | |||
vec4 pal = texture2D(u_texture, pass_texcoord); | |||
vec4 col = texture2D(u_palette, vec2(pal.x, 0.0)); | |||
if (pal.x == 0.0) | |||
discard; | |||
gl_FragColor = col; | |||
} | |||
[vert.hlsl] | |||
void main(float4 in_Position : POSITION, | |||
float2 in_TexCoord : TEXCOORD0, | |||
uniform float4x4 u_projection, | |||
uniform float4x4 u_view, | |||
uniform float4x4 u_model, | |||
uniform float2 u_texsize, | |||
out float2 out_TexCoord : TEXCOORD0, | |||
out float4 out_Position : POSITION) | |||
{ | |||
float2 delta = float2(0.0, 0.0); | |||
out_Position = mul(u_projection, mul(u_view, mul(u_model, in_Position))); | |||
out_TexCoord = in_TexCoord + delta; | |||
} | |||
[frag.hlsl] | |||
void main(float2 in_TexCoord : TEXCOORD0, | |||
uniform sampler2D u_texture, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float4 col = tex2D(u_texture, in_TexCoord); | |||
out_FragColor = col; | |||
} | |||
@@ -92,10 +92,3 @@ void main(void) | |||
/* Defines HLSL vertex shader "Prout" */ | |||
[prout.hlsl] | |||
void main(void) | |||
{ | |||
/* Blah */ | |||
} | |||
@@ -2,19 +2,20 @@ | |||
#version 130 | |||
attribute vec3 in_Position; | |||
attribute vec4 in_Color; | |||
varying vec4 pass_Color; | |||
in vec3 in_position; | |||
in vec4 in_color; | |||
uniform mat4 u_projection; | |||
uniform mat4 u_view; | |||
uniform mat4 u_model; | |||
out vec4 pass_color; | |||
void main() | |||
{ | |||
gl_Position = u_projection * u_view * u_model | |||
* vec4(in_Position, 1.0); | |||
pass_Color = in_Color; | |||
* vec4(in_position, 1.0); | |||
pass_color = in_color; | |||
} | |||
[frag.glsl] | |||
@@ -25,7 +26,7 @@ void main() | |||
precision highp float; | |||
#endif | |||
varying vec4 pass_Color; | |||
in vec4 pass_color; | |||
mat4 bayer = mat4( 0.0, 12.0, 3.0, 15.0, | |||
8.0, 4.0, 11.0, 7.0, | |||
@@ -44,7 +45,7 @@ float rand(vec2 p) | |||
void main() | |||
{ | |||
vec4 col = pass_Color; | |||
vec4 col = pass_color; | |||
#if defined GL_ES | |||
int dx = int(mod(gl_FragCoord.x, 4.0)); | |||
int dy = int(mod(gl_FragCoord.y, 4.0)); | |||
@@ -77,52 +78,3 @@ void main() | |||
gl_FragColor = col; | |||
} | |||
[vert.hlsl] | |||
void main(float4 in_Vertex : POSITION, | |||
float4 in_Color : COLOR, | |||
uniform float4x4 u_projection, | |||
uniform float4x4 u_view, | |||
uniform float4x4 u_model, | |||
out float4 out_Color : COLOR, | |||
out float4 out_Position : POSITION) | |||
{ | |||
out_Position = mul(u_projection, mul(u_view, mul(u_model, in_Vertex))); | |||
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, | |||
2.0, 14.0, 1.0, 13.0, | |||
10.0, 6.0, 9.0, 5.0); | |||
#if 1 | |||
float4x4 cluster = float4x4(12.0, 5.0, 6.0, 13.0, | |||
4.0, 0.0, 1.0, 7.0, | |||
11.0, 3.0, 2.0, 8.0, | |||
15.0, 10.0, 9.0, 14.0); | |||
#endif | |||
void main(float4 in_Color : COLOR, | |||
float4 in_FragCoord : WPOS, | |||
out float4 out_FragColor : COLOR) | |||
{ | |||
float4 col = in_Color; | |||
#if 1 | |||
int x = (int)in_FragCoord.x; | |||
int y = (int)in_FragCoord.y; | |||
// FIXME: we cannot address this matrix directly on the PS3 | |||
float t = bayer[int(frac(x * 0.25) * 4.0)] | |||
[int(frac(y * 0.25) * 4.0)]; | |||
t = (t + 0.5) / 17.0; | |||
col.x += frac(t - col.x) - t; | |||
col.y += frac(t - col.y) - t; | |||
col.z += frac(t - col.z) - t; | |||
#endif | |||
out_FragColor = col; | |||
} | |||