Parcourir la source

Added Shiny flat lolfx

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> il y a 11 ans
Parent
révision
34688578ae
6 fichiers modifiés avec 217 ajouts et 6 suppressions
  1. +2
    -1
      src/Makefile.am
  2. +1
    -0
      src/easymesh/easymesh.cpp
  3. +7
    -5
      src/easymesh/shiny.lolfx
  4. +203
    -0
      src/easymesh/shinyflat.lolfx
  5. +1
    -0
      src/lolcore.vcxproj
  6. +3
    -0
      src/lolcore.vcxproj.filters

+ 2
- 1
src/Makefile.am Voir le fichier

@@ -66,7 +66,8 @@ liblolcore_sources = \
\
easymesh/easymesh.cpp easymesh/easymesh.h \
easymesh/csgbsp.cpp easymesh/csgbsp.h \
easymesh/shiny.lolfx easymesh/shinydebugwireframe.lolfx \
easymesh/shiny.lolfx easymesh/shinyflat.lolfx \
easymesh/shinydebugwireframe.lolfx \
easymesh/shinydebuglighting.lolfx easymesh/shinydebugnormal.lolfx \
easymesh/shinydebugUV.lolfx easymesh/shiny_SK.lolfx \
easymesh/easymesh-compiler.cpp easymesh/easymesh-compiler.h \


+ 1
- 0
src/easymesh/easymesh.cpp Voir le fichier

@@ -23,6 +23,7 @@
#include "easymesh/easymesh-compiler.h"

LOLFX_RESOURCE_DECLARE(shiny);
LOLFX_RESOURCE_DECLARE(shinyflat);
LOLFX_RESOURCE_DECLARE(shinydebugwireframe);
LOLFX_RESOURCE_DECLARE(shinydebuglighting);
LOLFX_RESOURCE_DECLARE(shinydebugnormal);


+ 7
- 5
src/easymesh/shiny.lolfx Voir le fichier

@@ -60,6 +60,8 @@ vec3 in_Light3_diffuse = vec3(0.4, 1.0, 0.4);

void main(void)
{
vec3 TNormal = pass_TNormal;

/* Material properties */
vec3 specular_reflect = vec3(0.8, 0.75, 0.4);
float specular_power = 60.0;
@@ -83,16 +85,16 @@ void main(void)
{
/* Point light -- no attenuation yet */
s = normalize((in_View * pos).xyz - pass_Vertex.xyz);
r = reflect(-s, pass_TNormal);
r = reflect(-s, TNormal);
}
else
{
/* Directional light */
s = normalize(-pos.xyz);
r = reflect(s, pass_TNormal);
r = reflect(s, TNormal);
}

float sdotn = max(dot(s, pass_TNormal), 0.0);
float sdotn = max(dot(s, TNormal), 0.0);
diffuse += color.xyz * sdotn;
if (sdotn > 0.0)
specular += color.xyz * specular_reflect
@@ -114,8 +116,8 @@ void main(void)
else
{
new_LightDir = normalize((in_View * vec4(Proj_Vertex + in_Light3_Pos.xyz,1.0)).xyz - pass_Vertex.xyz);
sdotn = max(dot(new_LightDir, pass_TNormal), 0.0);
r = reflect(-new_LightDir, pass_TNormal);
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);


+ 203
- 0
src/easymesh/shinyflat.lolfx Voir le fichier

@@ -0,0 +1,203 @@

[vert.glsl]
#version 120

attribute vec3 in_Position;
attribute vec3 in_Normal;
attribute vec4 in_Color;

uniform mat4 in_ModelView;
uniform mat4 in_View;
uniform mat4 in_Proj;
uniform mat3 in_NormalMat;

varying vec4 pass_Vertex; /* View space */
varying vec3 pass_TNormal;
varying vec4 pass_Color;

void main(void)
{
vec4 vertex = in_ModelView * vec4(in_Position, 1.0);
vec3 tnorm = normalize(in_NormalMat * in_Normal);

pass_Vertex = vertex;
pass_TNormal = tnorm;
pass_Color = in_Color;

gl_Position = in_Proj * vertex;
}

[frag.glsl]
#version 120

#if defined GL_ES
precision highp float;
#endif

uniform float in_Damage;
uniform mat4 in_View;
uniform mat4 in_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

const float cos_45 = 0.70710678118;
const float inv_cos_45 = 0.29289321881;

//Cube Light
vec4 in_Light3_Pos = vec4(-10.0, 10.0, 5.0, 1.0);
vec3 in_Light3_Size_Inner = vec3(3.0, 1.0, 3.0);
vec3 in_Light3_Size_Outer = vec3(15.0, 15.0, 15.0);
vec3 in_Light3_diffuse = vec3(0.4, 1.0, 0.4);
#endif

void main(void)
{
vec3 TNormal = pass_TNormal;
vec3 X = dFdx(pass_Vertex.xyz);
vec3 Y = dFdy(pass_Vertex.xyz);
TNormal = normalize(cross(X, Y) ) * length(normalize(pass_TNormal));

/* Material properties */
vec3 specular_reflect = vec3(0.8, 0.75, 0.4);
float specular_power = 60.0;

/* World properties */
vec3 ambient = vec3(0.1, 0.1, 0.1);
vec3 specular = vec3(0.0, 0.0, 0.0);
vec3 diffuse = vec3(0.0, 0.0, 0.0);

/* Light precalculations */
vec3 v = normalize(-pass_Vertex.xyz);

/* Apply lighting */
for (int i = 0; i < 8; i++)
{
vec4 pos = u_Lights[i * 2];
vec4 color = u_Lights[i * 2 + 1];
vec3 s, r;

if (pos.w > 0.0)
{
/* Point light -- no attenuation yet */
s = normalize((in_View * pos).xyz - pass_Vertex.xyz);
r = reflect(-s, TNormal);
}
else
{
/* Directional light */
s = normalize(-pos.xyz);
r = reflect(s, TNormal);
}

float sdotn = max(dot(s, TNormal), 0.0);
diffuse += color.xyz * sdotn;
if (sdotn > 0.0)
specular += color.xyz * specular_reflect
* pow(max(dot(r, v), 0.0), specular_power);
}

#if 0
//Light calculation for cube light
vec3 specular_color = vec3(1.0, 1.0, 0.6);
vec3 Local_Vertex = (in_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;

vec3 light_radius = max(vec3(0.0,0.0,0.0), vec3(1.0,1.0,1.0) - abs(new_LightDir / in_Light3_Size_Outer));
float light_radius_mod = min(light_radius.x, min(light_radius.y, light_radius.z));

if (length(new_LightDir) == 0.0)
sdotn = 1.0;
else
{
new_LightDir = normalize((in_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);
}
diffuse += in_Light3_diffuse * min(sdotn, light_radius_mod);
//----------
#endif

vec3 light = ambient + diffuse + specular;

vec4 real_color = mix(pass_Color, vec4(1.2, 1.2, 1.2, 1.0), in_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 in_ModelView,
uniform float4x4 in_Model,
uniform float4x4 in_Proj,
uniform float3x3 in_NormalMat,
out float4 pass_Vertex : TEXCOORD0,
out float3 pass_TNormal : TEXCOORD1,
out float4 pass_Color : COLOR,
out float4 out_Position : POSITION)
{
float4 eye = mul(in_ModelView, float4(in_Vertex, 1.0));
float3 tnorm = normalize(mul(in_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(in_Proj, 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
- 0
src/lolcore.vcxproj Voir le fichier

@@ -312,6 +312,7 @@
<LolFxCompile Include="easymesh\shinydebugnormal.lolfx" />
<LolFxCompile Include="easymesh\shinydebugUV.lolfx" />
<LolFxCompile Include="easymesh\shinydebugwireframe.lolfx" />
<LolFxCompile Include="easymesh\shinyflat.lolfx" />
<LolFxCompile Include="easymesh\shiny_SK.lolfx" />
<LolFxCompile Include="gpu\defaultmaterial.lolfx" />
<LolFxCompile Include="gpu\emptymaterial.lolfx" />


+ 3
- 0
src/lolcore.vcxproj.filters Voir le fichier

@@ -683,6 +683,9 @@
<LolFxCompile Include="easymesh\shinydebugwireframe.lolfx">
<Filter>easymesh</Filter>
</LolFxCompile>
<LolFxCompile Include="easymesh\shinyflat.lolfx">
<Filter>easymesh</Filter>
</LolFxCompile>
</ItemGroup>
<ItemGroup>
<None Include="easymesh\easymesh-parser.y">


Chargement…
Annuler
Enregistrer