Skip to content

Instantly share code, notes, and snippets.

@dellis1972
Created July 13, 2015 07:44
Show Gist options
  • Save dellis1972/4294aade0f4c2182bbf9 to your computer and use it in GitHub Desktop.
Save dellis1972/4294aade0f4c2182bbf9 to your computer and use it in GitHub Desktop.
Sample MonGame GLSL .fx Shader
attribute vec4 vertex;
attribute vec2 texCoord;
void vs_main()
{
}
varying vec3 LightDirection;
varying vec3 LightColor;
varying vec3 AmbientColor;
varying vec4 color;
varying vec2 texCoord;
uniform sampler2D TextureSampler;
uniform sampler2D NormalSampler;
void ps_main()
{
//Look up the texture value
vec4 tex = texture2D(TextureSampler, texCoord);
//Look up the normalmap value
vec4 normal = (texture2D(NormalSampler, texCoord) - 1.0) * 2;
// Compute lighting.
float lightAmount = max(dot(normal.xyz, LightDirection), 0.0);
vec3 color = AmbientColor + (lightAmount * LightColor);
gl_FragColor = tex * color;
}
technique Normalmap
{
pass Pass1
{
VertexShader = compile vs_main();
PixelShader = compile ps_main();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment