![]() |
![]() |



Submitted by: falcon13efx
Date Submitted: 2005-03-29 07:32:58

Ok, you misbelievers, now at last you see proof that I have indeed integrated GPU shaders into the Cipher Core! I hope I didn't piss off the original developers or people in the forum :-) I'm just a nutter...
This program is from the Shader Designer by Typhoon labs.
This is the scripts the shader system uses. Don't like it? make a better parser... I might rewrite the tools in C# later anyways.
cipherfx
type GLSLVP
{
const {
{ "myLightPos" float 3 0 0 5 }
{ "GlassColor" float 4 0.1 0.5 0.6 0.15 }
{ "SpecularColor1" float 4 0.1 0.08 0.05 1 }
{ "SpecularColor2" float 4 0.1 0.1 0.05 1 }
{ "SpecularFactor1" float 1 2.0 }
{ "SpecularFactor2" float 1 2.0 }
}
inputs {
}
code { shaders/glass.vp }
}
type GLSLFP
{
code { shaders/glass.fp }
}
Here are the original programs:
//
// glass.vert: Vertex shader for doing a glass-like effect
//
// author: John Kessenich
//
// Copyright (c) 2002: 3Dlabs, Inc.
//
varying vec3 LightDir;
varying vec3 EyeDir;
varying vec3 Normal;
uniform vec3 myLightPos;
void main(void)
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
EyeDir = -1.0 * normalize(vec3(gl_ModelViewMatrix * gl_Vertex));
LightDir = normalize(myLightPos);
gl_TexCoord[0] = gl_MultiTexCoord0;
Normal = normalize(gl_NormalMatrix * gl_Normal);
}
//
// glass.frag: Fragment shader for doing a glass-like effect
//
// author: John Kessenich
//
// Copyright (c) 2002: 3Dlabs, Inc.
//
varying vec3 LightDir;
varying vec3 EyeDir;
varying vec3 Normal;
uniform vec4 GlassColor;
uniform vec4 SpecularColor1;
uniform vec4 SpecularColor2;
uniform float SpecularFactor1;
uniform float SpecularFactor2;
void main (void)
{
vec4 color;
vec3 reflectDir = -reflect(LightDir, Normal);
//
// Uncomment this line for a cool solid look.
// Comment it out for light shining off of flat glass.
//
reflectDir = -reflectDir;
float spec = max(dot(EyeDir, reflectDir), 0.0);
//
// Compute two rings of specular effect.
//
spec = spec * spec;
//
// Basic glass color + first specular effect
//
color = GlassColor + SpecularFactor1 * spec * SpecularColor1;
//
// Second specular effect
//
spec = pow(spec, 8.0) * SpecularFactor2;
color += spec * SpecularColor2;
gl_FragColor = min(color, vec4(1.0));
}
[Recent Contributions] [Recent Screenshots]
User Contributed Comments