Implemented GLSL shader techniques

This commit is contained in:
SND\AstrorEnales_cp 2012-01-16 13:48:21 +00:00
parent 060b732d1b
commit b6bd56bab6
20 changed files with 1129 additions and 603 deletions

View File

@ -60,42 +60,46 @@ using Microsoft.Xna.Framework.Content.Pipeline.Processors;
using TInput = Microsoft.Xna.Framework.Content.Pipeline.Graphics.EffectContent;
using TOutput = Microsoft.Xna.Framework.Content.Pipeline.Processors.CompiledEffectContent;
using ANX.Framework.Windows.GL3;
using System.Text;
namespace ANX.Framework.ContentPipeline
{
[ContentProcessor(DisplayName = "OpenGL3 Effect - ANX Framework")]
public class GL3_EffectProcessor : ContentProcessor<TInput, TOutput>
{
public override TOutput Process(TInput input, ContentProcessorContext context)
{
byte[] effectByteCode = EffectGL3.CompileShader(input.EffectCode);
[ContentProcessor(DisplayName = "OpenGL3 Effect - ANX Framework")]
public class GL3_EffectProcessor : ContentProcessor<TInput, TOutput>
{
public override TOutput Process(TInput input, ContentProcessorContext context)
{
byte[] effectByteCode = ShaderHelper.SaveShaderCode(input.EffectCode);
Byte[] byteCode = new Byte[3 + 2 + 1 + 4 + effectByteCode.Length];
Byte[] byteCode = new Byte[3 + 2 + 1 + 4 + effectByteCode.Length];
StringToByteArray("ANX").CopyTo(byteCode, 0); // Magic Number to recognize format
byteCode[3] = 0; // Major Version
byteCode[4] = 2; // Minor Version
byteCode[5] = (byte)EffectProcessorOutputFormat.OPEN_GL3_GLSL; // Format of byte array
// Magic Number to recognize format
StringToByteArray("ANX").CopyTo(byteCode, 0);
// Major Version
byteCode[3] = 0;
// Minor Version
byteCode[4] = 2;
// Format of byte array
byteCode[5] = (byte)EffectProcessorOutputFormat.OPEN_GL3_GLSL;
int dataStart = 6;
int dataStart = 6;
BitConverter.GetBytes(effectByteCode.Length).CopyTo(byteCode, dataStart); // length of vertexShaderByteCode
Array.Copy(effectByteCode, 0, byteCode, dataStart + 4, effectByteCode.Length);
// length of vertexShaderByteCode
BitConverter.GetBytes(effectByteCode.Length).CopyTo(byteCode, dataStart);
Array.Copy(effectByteCode, 0, byteCode, dataStart + 4, effectByteCode.Length);
return new TOutput(byteCode);
}
return new TOutput(byteCode);
}
private byte[] StringToByteArray(string str)
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
return enc.GetBytes(str);
}
private byte[] StringToByteArray(string str)
{
return Encoding.ASCII.GetBytes(str);
}
private string ByteArrayToString(byte[] arr)
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
return enc.GetString(arr);
}
private string ByteArrayToString(byte[] arr)
{
return Encoding.ASCII.GetString(arr);
}
}
}
}
}

View File

@ -79,8 +79,8 @@ namespace ANX.Framework.Graphics
this.byteCode = new byte[byteCode.Length];
Array.Copy(byteCode, this.byteCode, byteCode.Length);
base.GraphicsDevice.ResourceCreated += new EventHandler<ResourceCreatedEventArgs>(GraphicsDevice_ResourceCreated);
base.GraphicsDevice.ResourceDestroyed += new EventHandler<ResourceDestroyedEventArgs>(GraphicsDevice_ResourceDestroyed);
base.GraphicsDevice.ResourceCreated += GraphicsDevice_ResourceCreated;
base.GraphicsDevice.ResourceDestroyed += GraphicsDevice_ResourceDestroyed;
CreateNativeEffect();

View File

@ -61,7 +61,7 @@ namespace ANX.Framework.Input
#endregion // Private Members
public KeyboardState(Keys[] keys)
public KeyboardState(params Keys[] keys)
{
pressedKeys = new List<Keys>();
pressedKeys.AddRange(keys);

View File

@ -66,6 +66,8 @@
<Compile Include="RenderTarget2DGL3.cs" />
<Compile Include="SamplerStateGL3.cs" />
<Compile Include="ShaderByteCode.cs" />
<Compile Include="ShaderData.cs" />
<Compile Include="ShaderHelper.cs" />
<Compile Include="Texture2DGL3.cs" />
<Compile Include="VertexBufferGL3.cs" />
<Compile Include="WindowsGameHost.cs" />

View File

@ -112,7 +112,8 @@ namespace ANX.Framework.Windows.GL3
#endregion
#region CreateEffect
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream byteCode)
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect,
Stream byteCode)
{
AddInSystemFactory.Instance.PreventRenderSystemChange();

View File

@ -4,8 +4,6 @@ using System.IO;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
using OpenTK.Graphics.OpenGL;
using System.Text;
using System.Security.Cryptography;
#region License
@ -63,47 +61,51 @@ namespace ANX.Framework.Windows.GL3
/// </summary>
public class EffectGL3 : INativeEffect
{
#region ShaderAttribute (Helper struct)
public struct ShaderAttribute
{
public string Name;
public uint Location;
public int Size;
public ActiveAttribType Type;
}
#endregion
#region Constants
private const string FragmentSeparator = "##!fragment!##";
#endregion
#region Private
/// <summary>
/// The native shader handle.
/// The managed effect instance of this shader.
/// </summary>
internal int programHandle;
private Effect managedEffect;
private Effect managedEffect;
/// <summary>
/// The loaded shader data from the shader file.
/// </summary>
private ShaderData shaderData;
internal Dictionary<string, ShaderAttribute> ActiveAttributes
/// <summary>
/// The available techniques of this shader.
/// </summary>
private List<EffectTechnique> techniques;
/// <summary>
/// The current native technique.
/// </summary>
internal EffectTechniqueGL3 CurrentTechnique
{
get;
private set;
get
{
return managedEffect.CurrentTechnique.NativeTechnique as EffectTechniqueGL3;
}
}
/// <summary>
/// The active uniforms of this technique.
/// </summary>
internal List<EffectParameter> parameters;
#endregion
#region Public
#region Techniques (TODO)
#region Techniques
public IEnumerable<EffectTechnique> Techniques
{
get
{
List<EffectTechnique> techniques = new List<EffectTechnique>();
if (techniques.Count == 0)
{
CompileTechniques();
}
// TODO: dummy, fill with actual data.
techniques.Add(new EffectTechnique(this.managedEffect, new EffectTechniqueGL3()));
return techniques;
return techniques;
}
}
#endregion
@ -113,33 +115,6 @@ namespace ANX.Framework.Windows.GL3
{
get
{
List<EffectParameter> parameters = new List<EffectParameter>();
int uniformCount;
GL.GetProgram(programHandle, ProgramParameter.ActiveUniforms,
out uniformCount);
ErrorHelper.Check("GetProgram ActiveUniforms");
List<string> names = new List<string>();
for (int index = 0; index < uniformCount; index++)
{
string name = GL.GetActiveUniformName(programHandle, index);
ErrorHelper.Check("GetActiveUniformName name=" + name);
if (names.Contains(name) == false)
{
names.Add(name);
int uniformIndex = GL.GetUniformLocation(programHandle, name);
ErrorHelper.Check("GetUniformLocation name=" + name +
" uniformIndex=" + uniformIndex);
parameters.Add(new EffectParameter()
{
NativeParameter =
new EffectParameterGL3(this, name, uniformIndex),
});
}
}
return parameters;
}
}
@ -147,70 +122,141 @@ namespace ANX.Framework.Windows.GL3
#endregion
#region Constructor
/// <summary>
/// Private helper constructor for the basic initialization.
/// </summary>
/// <param name="setManagedEffect"></param>
private EffectGL3(Effect setManagedEffect)
{
parameters = new List<EffectParameter>();
techniques = new List<EffectTechnique>();
managedEffect = setManagedEffect;
}
/// <summary>
/// Create a new effect instance of separate streams.
/// </summary>
/// <param name="vertexShaderByteCode">The vertex shader code.</param>
/// <param name="pixelShaderByteCode">The fragment shader code.</param>
public EffectGL3(Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode)
public EffectGL3(Effect setManagedEffect, Stream vertexShaderByteCode,
Stream pixelShaderByteCode)
: this(setManagedEffect)
{
this.managedEffect = managedEffect;
CreateShader(LoadShaderCode(vertexShaderByteCode), LoadShaderCode(pixelShaderByteCode));
// TODO: this is probably not right!
throw new NotImplementedException("TODO: implement effect constructor with vertex and fragment streams, check HOWTO...");
//CreateShader(ShaderHelper.LoadShaderCode(vertexShaderByteCode),
// ShaderHelper.LoadShaderCode(pixelShaderByteCode));
}
/// <summary>
/// Create a new effect instance of one streams.
/// </summary>
/// <param name="byteCode">The byte code of the shader.</param>
public EffectGL3(Effect managedEffect, Stream byteCode)
public EffectGL3(Effect setManagedEffect, Stream byteCode)
: this(setManagedEffect)
{
this.managedEffect = managedEffect;
string source = LoadShaderCode(byteCode);
string[] parts = source.Split(new string[] { FragmentSeparator },
StringSplitOptions.RemoveEmptyEntries);
CreateShader(parts[0], parts[1]);
string source = ShaderHelper.LoadShaderCode(byteCode);
shaderData = ShaderHelper.ParseShaderCode(source);
}
#endregion
#region CreateShader
private void CreateShader(string vertexSource, string fragmentSource)
#region CompileTechniques
private void CompileTechniques()
{
int vertexShader = GL.CreateShader(ShaderType.VertexShader);
string vertexError = CompileShader(vertexShader, vertexSource);
if (String.IsNullOrEmpty(vertexError) == false)
parameters.Clear();
techniques.Clear();
Dictionary<string, int> vertexShaders = new Dictionary<string, int>();
Dictionary<string, int> fragmentShaders = new Dictionary<string, int>();
List<string> parameterNames = new List<string>();
#region Compile vertex shaders
foreach (string vertexName in shaderData.VertexShaderCodes.Keys)
{
throw new InvalidDataException("Failed to compile the vertex " +
"shader because of: " + vertexError);
}
string vertexSource = shaderData.VertexGlobalCode +
shaderData.VertexShaderCodes[vertexName];
int fragmentShader = GL.CreateShader(ShaderType.FragmentShader);
string fragmentError = CompileShader(fragmentShader, fragmentSource);
if (String.IsNullOrEmpty(fragmentError) == false)
int vertexShader = GL.CreateShader(ShaderType.VertexShader);
string vertexError = CompileShader(vertexShader, vertexSource);
if (String.IsNullOrEmpty(vertexError) == false)
{
throw new InvalidDataException("Failed to compile the vertex " +
"shader '" + vertexName + "' because of: " + vertexError);
}
vertexShaders.Add(vertexName, vertexShader);
}
#endregion
#region Compile fragment shaders
foreach (string fragmentName in shaderData.FragmentShaderCodes.Keys)
{
throw new InvalidDataException("Failed to compile the fragment " +
"shader because of: " + fragmentError);
string fragmentSource = shaderData.FragmentGlobalCode +
shaderData.FragmentShaderCodes[fragmentName];
int fragmentShader = GL.CreateShader(ShaderType.FragmentShader);
string vertexError = CompileShader(fragmentShader, fragmentSource);
if (String.IsNullOrEmpty(vertexError) == false)
{
throw new InvalidDataException("Failed to compile the fragment " +
"shader '" + fragmentName + "' because of: " + vertexError);
}
fragmentShaders.Add(fragmentName, fragmentShader);
}
#endregion
programHandle = GL.CreateProgram();
ErrorHelper.Check("CreateProgram");
GL.AttachShader(programHandle, vertexShader);
ErrorHelper.Check("AttachShader vertexShader");
GL.AttachShader(programHandle, fragmentShader);
ErrorHelper.Check("AttachShader fragmentShader");
GL.LinkProgram(programHandle);
int result;
GL.GetProgram(programHandle, ProgramParameter.LinkStatus, out result);
if (result == 0)
#region Compile programs
foreach (string programName in shaderData.Techniques.Keys)
{
string programError;
GL.GetProgramInfoLog(programHandle, out programError);
throw new InvalidDataException("Failed to link the shader program " +
"because of: " + programError);
}
string vertexName = shaderData.Techniques[programName].Key;
string fragmentName = shaderData.Techniques[programName].Value;
GetAttributes();
int programHandle = GL.CreateProgram();
ErrorHelper.Check("CreateProgram");
GL.AttachShader(programHandle, vertexShaders[vertexName]);
ErrorHelper.Check("AttachShader vertexShader");
GL.AttachShader(programHandle, fragmentShaders[fragmentName]);
ErrorHelper.Check("AttachShader fragmentShader");
GL.LinkProgram(programHandle);
int result;
GL.GetProgram(programHandle, ProgramParameter.LinkStatus, out result);
if (result == 0)
{
string programError;
GL.GetProgramInfoLog(programHandle, out programError);
throw new InvalidDataException("Failed to link the shader program '" +
programName + "' because of: " + programError);
}
EffectTechniqueGL3 technique = new EffectTechniqueGL3(programName, programHandle);
techniques.Add(new EffectTechnique(managedEffect, technique));
int uniformCount;
GL.GetProgram(programHandle, ProgramParameter.ActiveUniforms,
out uniformCount);
ErrorHelper.Check("GetProgram ActiveUniforms");
for (int index = 0; index < uniformCount; index++)
{
string name = GL.GetActiveUniformName(programHandle, index);
ErrorHelper.Check("GetActiveUniformName name=" + name);
if (parameterNames.Contains(name) == false)
{
parameterNames.Add(name);
int uniformIndex = GL.GetUniformLocation(programHandle, name);
ErrorHelper.Check("GetUniformLocation name=" + name +
" uniformIndex=" + uniformIndex);
parameters.Add(new EffectParameter()
{
NativeParameter =
new EffectParameterGL3(technique, name, uniformIndex),
});
}
}
}
#endregion
}
#endregion
@ -236,128 +282,13 @@ namespace ANX.Framework.Windows.GL3
}
#endregion
#region CompileShader (for external)
public static byte[] CompileShader(string effectCode)
{
#region Source Cleanup
// We wanna clean up the shader a little bit, so we remove
// empty lines, spaces and tabs at beginning and end and also
// remove comments.
List<string> lines = new List<string>(effectCode.Split('\n'));
for (int index = lines.Count - 1; index >= 0; index--)
{
lines[index] = lines[index].Trim();
if (String.IsNullOrEmpty(lines[index]) ||
lines[index].StartsWith("//"))
{
lines.RemoveAt(index);
continue;
}
// TODO: add /**/ comment checking and removing.
}
effectCode = "";
foreach (string line in lines)
{
effectCode += line + "\n";
}
// Now to some additional cleanup
string[] minimizables =
{
" * ", " = ", " + ", " / ", " - ", ", ",
};
foreach (string mizable in minimizables)
{
effectCode = effectCode.Replace(mizable, mizable.Trim());
}
effectCode = effectCode.Replace("\n{\n", "{\n");
effectCode = effectCode.Replace("\n}\n", "}\n");
#endregion
MemoryStream stream = new MemoryStream();
BinaryWriter writer = new BinaryWriter(stream);
// First of all writer the shader code (which is already preceeded
// by a length identifier, making it harder to manipulate the code)
writer.Write(effectCode);
// And now we additionally generate a sha hash so it nearly becomes
// impossible to manipulate the shader.
SHA512Managed sha = new SHA512Managed();
byte[] data = stream.ToArray();
byte[] hash = sha.ComputeHash(data);
// The hash is added to the end of the stream.
writer.Write(hash);
writer.Flush();
sha.Dispose();
return stream.ToArray();
}
#endregion
#region LoadShaderCode
private static string LoadShaderCode(Stream stream)
{
BinaryReader reader = new BinaryReader(stream);
// First load the source.
string source = reader.ReadString();
// And now check if it was manipulated.
SHA512Managed sha = new SHA512Managed();
int lengthRead = (int)stream.Position;
stream.Position = 0;
byte[] data = reader.ReadBytes(lengthRead);
byte[] hash = sha.ComputeHash(data);
sha.Dispose();
byte[] loadedHash = reader.ReadBytes(64);
for (int index = 0; index < hash.Length; index++)
{
if (hash[index] != loadedHash[index])
{
throw new InvalidDataException("Failed to load the shader " +
"because the data got manipulated!");
}
}
return source;
}
#endregion
#region GetAttributes
private void GetAttributes()
{
ActiveAttributes = new Dictionary<string, ShaderAttribute>();
int attributeCount;
GL.GetProgram(programHandle, ProgramParameter.ActiveAttributes,
out attributeCount);
for (int index = 0; index < attributeCount; index++)
{
int attributeSize;
ActiveAttribType attributeType;
string name = GL.GetActiveAttrib(programHandle, index,
out attributeSize, out attributeType);
uint attributeIndex = (uint)GL.GetAttribLocation(programHandle, name);
ActiveAttributes.Add(name, new ShaderAttribute
{
Name = name,
Location = attributeIndex,
Size = attributeSize,
Type = attributeType,
});
}
}
#endregion
#region Apply (TODO)
public void Apply(GraphicsDevice graphicsDevice)
{
if (GraphicsDeviceWindowsGL3.activeEffect != this)
{
GL.Enable(EnableCap.Blend);
GL.UseProgram(programHandle);
GL.UseProgram(CurrentTechnique.programHandle);
GraphicsDeviceWindowsGL3.activeEffect = this;
ErrorHelper.Check("UseProgram");
}
@ -370,18 +301,25 @@ namespace ANX.Framework.Windows.GL3
/// </summary>
public void Dispose()
{
GL.DeleteProgram(programHandle);
ErrorHelper.Check("DeleteProgram");
int result;
GL.GetProgram(programHandle, ProgramParameter.DeleteStatus, out result);
if (result == 0)
foreach (EffectTechnique technique in techniques)
{
string deleteError;
GL.GetProgramInfoLog(programHandle, out deleteError);
throw new Exception("Failed to delete the shader program because of: " +
deleteError);
int programHandle = (technique.NativeTechnique as EffectTechniqueGL3).programHandle;
GL.DeleteProgram(programHandle);
ErrorHelper.Check("DeleteProgram");
int result;
GL.GetProgram(programHandle, ProgramParameter.DeleteStatus, out result);
if (result == 0)
{
string deleteError;
GL.GetProgramInfoLog(programHandle, out deleteError);
throw new Exception("Failed to delete the shader program '" + technique.Name +
"' because of: " + deleteError);
}
}
techniques.Clear();
}
#endregion
}

View File

@ -58,7 +58,7 @@ namespace ANX.Framework.Windows.GL3
public class EffectParameterGL3 : INativeEffectParameter
{
#region Private
private EffectGL3 parentEffect;
private EffectTechniqueGL3 parentTechnique;
#endregion
#region Public
@ -85,10 +85,10 @@ namespace ANX.Framework.Windows.GL3
/// <summary>
/// Create a ne effect parameter object.
/// </summary>
internal EffectParameterGL3(EffectGL3 setParentEffect,
internal EffectParameterGL3(EffectTechniqueGL3 setParentTechnique,
string setName, int setUniformIndex)
{
parentEffect = setParentEffect;
parentTechnique = setParentTechnique;
Name = setName;
UniformIndex = setUniformIndex;
}
@ -101,7 +101,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(Matrix value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
OpenTK.Matrix4 matrix = new OpenTK.Matrix4(
@ -122,7 +122,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(Matrix[] value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
float[] array = new float[value.Length * 16];
for (int index = 0; index < value.Length; index++)
@ -179,7 +179,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(Texture value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
if (textureCache == null ||
textureCache != value)
@ -227,7 +227,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(int value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform1(UniformIndex, value);
ErrorHelper.Check("Uniform1i");
@ -241,7 +241,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(int[] value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform1(UniformIndex, value.Length, value);
ErrorHelper.Check("Uniform1iv");
@ -255,7 +255,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(float value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform1(UniformIndex, value);
ErrorHelper.Check("Uniform1f");
@ -269,7 +269,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(float[] value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform1(UniformIndex, value.Length, value);
ErrorHelper.Check("Uniform1fv");
@ -283,7 +283,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector2 value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform2(UniformIndex, value.X, value.Y);
ErrorHelper.Check("Uniform2f");
@ -297,7 +297,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector2[] value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
float[] array = new float[value.Length * 2];
for(int index = 0; index < value.Length; index++)
@ -317,7 +317,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector3 value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform3(UniformIndex, value.X, value.Y, value.Z);
ErrorHelper.Check("Uniform3f");
@ -331,7 +331,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector3[] value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
float[] array = new float[value.Length * 3];
for (int index = 0; index < value.Length; index++)
@ -352,7 +352,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector4 value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform4(UniformIndex, value.X, value.Y, value.Z, value.W);
ErrorHelper.Check("Uniform4f");
@ -366,7 +366,7 @@ namespace ANX.Framework.Windows.GL3
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector4[] value)
{
GL.UseProgram(parentEffect.programHandle);
GL.UseProgram(parentTechnique.programHandle);
ErrorHelper.Check("UseProgram");
float[] array = new float[value.Length * 4];
for (int index = 0; index < value.Length; index++)

View File

@ -1,7 +1,8 @@
using System;
using ANX.Framework.NonXNA;
using System.Collections.Generic;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
using OpenTK.Graphics.OpenGL;
#region License
@ -57,6 +58,28 @@ namespace ANX.Framework.Windows.GL3
/// </summary>
public class EffectTechniqueGL3 : INativeEffectTechnique
{
#region ShaderAttribute (Helper struct)
public struct ShaderAttribute
{
public string Name;
public uint Location;
public int Size;
public ActiveAttribType Type;
}
#endregion
#region Private
/// <summary>
/// The native shader handle.
/// </summary>
internal int programHandle;
/// <summary>
/// The active attributes of this technique.
/// </summary>
internal Dictionary<string, ShaderAttribute> activeAttributes;
#endregion
#region Public
/// <summary>
/// The name of the effect technique.
@ -84,8 +107,37 @@ namespace ANX.Framework.Windows.GL3
/// <summary>
/// Create a ne effect technique object.
/// </summary>
internal EffectTechniqueGL3()
internal EffectTechniqueGL3(string setName, int setProgramHandle)
{
Name = setName;
programHandle = setProgramHandle;
GetAttributes();
}
#endregion
#region GetAttributes
private void GetAttributes()
{
activeAttributes = new Dictionary<string, ShaderAttribute>();
int attributeCount;
GL.GetProgram(programHandle, ProgramParameter.ActiveAttributes,
out attributeCount);
for (int index = 0; index < attributeCount; index++)
{
int attributeSize;
ActiveAttribType attributeType;
string name = GL.GetActiveAttrib(programHandle, index,
out attributeSize, out attributeType);
uint attributeIndex = (uint)GL.GetAttribLocation(programHandle, name);
activeAttributes.Add(name, new ShaderAttribute
{
Name = name,
Location = attributeIndex,
Size = attributeSize,
Type = attributeType,
});
}
}
#endregion
}

View File

@ -54,193 +54,234 @@ namespace ANX.Framework.Windows.GL3
#region SpriteBatchShader
internal static byte[] SpriteBatchByteCode = new byte[]
{
180,
003, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114, 105, 120,
084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118,
101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 010, 118, 097,
114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101,
120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032, 041,
123, 010, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116, 114, 105, 120,
084, 114, 097, 110, 115, 102, 111, 114, 109, 042, 112, 111, 115, 059, 010, 100, 105, 102, 102, 117,
115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 010, 100, 105, 102, 102,
117, 115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 010, 035, 035, 033, 102, 114,
097, 103, 109, 101, 110, 116, 033, 035, 035, 010, 112, 114, 101, 099, 105, 115, 115, 105, 111, 110,
032, 109, 101, 100, 105, 117, 109, 112, 032, 102, 108, 111, 097, 116, 059, 010, 117, 110, 105, 102,
111, 114, 109, 032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114,
101, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102,
117, 115, 101, 067, 111, 108, 111, 114, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101,
099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 010,
118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032, 041, 123, 010, 103, 108, 095, 070, 114, 097,
103, 067, 111, 108, 111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120,
116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100,
041, 042, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 010, 086, 087, 131,
182, 038, 179, 193, 226, 251, 193, 042, 232, 050, 136, 064, 087, 245, 166, 178, 106, 045, 070, 101,
038, 108, 096, 128, 039, 041, 206, 046, 082, 012, 201, 196, 054, 107, 012, 036, 042, 201, 075, 019,
238, 148, 026, 221, 157, 011, 092, 071, 242, 175, 166, 135, 135, 045, 079, 158, 203, 065, 100, 242,
030
187,
004, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115, 123, 115, 104, 097, 100, 101,
114, 032, 034, 083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101,
114, 034, 123, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114,
105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 097, 116, 116, 114, 105, 098, 117, 116,
101, 032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032,
118, 101, 099, 050, 032, 116, 101, 120, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099,
052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105,
110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111,
111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095,
080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115,
102, 111, 114, 109, 042, 112, 111, 115, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067,
111, 111, 114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111,
114, 061, 099, 111, 108, 059, 125, 125, 125, 102, 114, 097, 103, 109, 101, 110, 116, 115, 104, 097,
100, 101, 114, 115, 123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101, 070,
114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 123, 117, 110, 105, 102, 111,
114, 109, 032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101,
059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115,
101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 118, 111, 105, 100,
032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108, 111,
114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120, 116, 117, 114, 101, 044,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102,
102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110, 105, 113,
117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032, 034, 083, 112, 114, 105, 116,
101, 084, 101, 099, 104, 110, 105, 113, 117, 101, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034,
083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034, 102,
114, 097, 103, 109, 101, 110, 116, 032, 034, 083, 112, 114, 105, 116, 101, 070, 114, 097, 103, 109,
101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 125, 125, 085, 005, 093, 183, 066, 090, 070, 104,
093, 184, 253, 199, 246, 081, 152, 083, 013, 048, 171, 074, 063, 021, 247, 182, 129, 011, 094, 003,
189, 026, 178, 121, 230, 157, 193, 056, 001, 064, 136, 044, 054, 172, 146, 241, 173, 160, 182, 034,
092, 221, 158, 045, 049, 229, 144, 171, 015, 022, 089, 025, 248, 163, 175, 081
};
#endregion //SpriteBatchShader
#region AlphaTestEffectShader
internal static byte[] AlphaTestEffectByteCode = new byte[]
{
160,
003, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114, 105, 120,
084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118,
101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 010, 118, 097,
114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101,
120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 118, 111,
105, 100, 041, 123, 010, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116,
114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 042, 112, 111, 115, 059, 010, 100, 105,
102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 010, 100,
105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 010, 035, 035,
033, 102, 114, 097, 103, 109, 101, 110, 116, 033, 035, 035, 010, 117, 110, 105, 102, 111, 114, 109,
032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059, 010,
118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101,
067, 111, 108, 111, 114, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105,
100, 032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 123, 010, 103, 108, 095, 070, 114, 097,
103, 067, 111, 108, 111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120,
116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100,
041, 042, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 010, 095, 046, 094,
078, 240, 054, 006, 106, 005, 190, 104, 250, 201, 129, 166, 050, 199, 249, 189, 159, 008, 207, 084,
062, 171, 010, 076, 101, 119, 047, 079, 245, 134, 024, 149, 110, 166, 213, 153, 023, 179, 120, 191,
146, 106, 047, 180, 084, 037, 088, 036, 132, 126, 030, 027, 054, 044, 236, 120, 086, 102, 211, 178,
125
187,
004, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115, 123, 115, 104, 097, 100, 101,
114, 032, 034, 083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101,
114, 034, 123, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114,
105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 097, 116, 116, 114, 105, 098, 117, 116,
101, 032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032,
118, 101, 099, 050, 032, 116, 101, 120, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099,
052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105,
110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111,
111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095,
080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115,
102, 111, 114, 109, 042, 112, 111, 115, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067,
111, 111, 114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111,
114, 061, 099, 111, 108, 059, 125, 125, 125, 102, 114, 097, 103, 109, 101, 110, 116, 115, 104, 097,
100, 101, 114, 115, 123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101, 070,
114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 123, 117, 110, 105, 102, 111,
114, 109, 032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101,
059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115,
101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 118, 111, 105, 100,
032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108, 111,
114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120, 116, 117, 114, 101, 044,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102,
102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110, 105, 113,
117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032, 034, 083, 112, 114, 105, 116,
101, 084, 101, 099, 104, 110, 105, 113, 117, 101, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034,
083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034, 102,
114, 097, 103, 109, 101, 110, 116, 032, 034, 083, 112, 114, 105, 116, 101, 070, 114, 097, 103, 109,
101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 125, 125, 085, 005, 093, 183, 066, 090, 070, 104,
093, 184, 253, 199, 246, 081, 152, 083, 013, 048, 171, 074, 063, 021, 247, 182, 129, 011, 094, 003,
189, 026, 178, 121, 230, 157, 193, 056, 001, 064, 136, 044, 054, 172, 146, 241, 173, 160, 182, 034,
092, 221, 158, 045, 049, 229, 144, 171, 015, 022, 089, 025, 248, 163, 175, 081
};
#endregion //AlphaTestEffectShader
#region BasicEffectShader
internal static byte[] BasicEffectByteCode = new byte[]
{
160,
003, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114, 105, 120,
084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118,
101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 010, 118, 097,
114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101,
120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 118, 111,
105, 100, 041, 123, 010, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116,
114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 042, 112, 111, 115, 059, 010, 100, 105,
102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 010, 100,
105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 010, 035, 035,
033, 102, 114, 097, 103, 109, 101, 110, 116, 033, 035, 035, 010, 117, 110, 105, 102, 111, 114, 109,
032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059, 010,
118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101,
067, 111, 108, 111, 114, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105,
100, 032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 123, 010, 103, 108, 095, 070, 114, 097,
103, 067, 111, 108, 111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120,
116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100,
041, 042, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 010, 095, 046, 094,
078, 240, 054, 006, 106, 005, 190, 104, 250, 201, 129, 166, 050, 199, 249, 189, 159, 008, 207, 084,
062, 171, 010, 076, 101, 119, 047, 079, 245, 134, 024, 149, 110, 166, 213, 153, 023, 179, 120, 191,
146, 106, 047, 180, 084, 037, 088, 036, 132, 126, 030, 027, 054, 044, 236, 120, 086, 102, 211, 178,
125
187,
004, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115, 123, 115, 104, 097, 100, 101,
114, 032, 034, 083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101,
114, 034, 123, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114,
105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 097, 116, 116, 114, 105, 098, 117, 116,
101, 032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032,
118, 101, 099, 050, 032, 116, 101, 120, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099,
052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105,
110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111,
111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095,
080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115,
102, 111, 114, 109, 042, 112, 111, 115, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067,
111, 111, 114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111,
114, 061, 099, 111, 108, 059, 125, 125, 125, 102, 114, 097, 103, 109, 101, 110, 116, 115, 104, 097,
100, 101, 114, 115, 123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101, 070,
114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 123, 117, 110, 105, 102, 111,
114, 109, 032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101,
059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115,
101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 118, 111, 105, 100,
032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108, 111,
114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120, 116, 117, 114, 101, 044,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102,
102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110, 105, 113,
117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032, 034, 083, 112, 114, 105, 116,
101, 084, 101, 099, 104, 110, 105, 113, 117, 101, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034,
083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034, 102,
114, 097, 103, 109, 101, 110, 116, 032, 034, 083, 112, 114, 105, 116, 101, 070, 114, 097, 103, 109,
101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 125, 125, 085, 005, 093, 183, 066, 090, 070, 104,
093, 184, 253, 199, 246, 081, 152, 083, 013, 048, 171, 074, 063, 021, 247, 182, 129, 011, 094, 003,
189, 026, 178, 121, 230, 157, 193, 056, 001, 064, 136, 044, 054, 172, 146, 241, 173, 160, 182, 034,
092, 221, 158, 045, 049, 229, 144, 171, 015, 022, 089, 025, 248, 163, 175, 081
};
#endregion //BasicEffectShader
#region DualTextureEffectShader
internal static byte[] DualTextureEffectByteCode = new byte[]
{
160,
003, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114, 105, 120,
084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118,
101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 010, 118, 097,
114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101,
120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 118, 111,
105, 100, 041, 123, 010, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116,
114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 042, 112, 111, 115, 059, 010, 100, 105,
102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 010, 100,
105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 010, 035, 035,
033, 102, 114, 097, 103, 109, 101, 110, 116, 033, 035, 035, 010, 117, 110, 105, 102, 111, 114, 109,
032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059, 010,
118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101,
067, 111, 108, 111, 114, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105,
100, 032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 123, 010, 103, 108, 095, 070, 114, 097,
103, 067, 111, 108, 111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120,
116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100,
041, 042, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 010, 095, 046, 094,
078, 240, 054, 006, 106, 005, 190, 104, 250, 201, 129, 166, 050, 199, 249, 189, 159, 008, 207, 084,
062, 171, 010, 076, 101, 119, 047, 079, 245, 134, 024, 149, 110, 166, 213, 153, 023, 179, 120, 191,
146, 106, 047, 180, 084, 037, 088, 036, 132, 126, 030, 027, 054, 044, 236, 120, 086, 102, 211, 178,
125
187,
004, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115, 123, 115, 104, 097, 100, 101,
114, 032, 034, 083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101,
114, 034, 123, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114,
105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 097, 116, 116, 114, 105, 098, 117, 116,
101, 032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032,
118, 101, 099, 050, 032, 116, 101, 120, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099,
052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105,
110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111,
111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095,
080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115,
102, 111, 114, 109, 042, 112, 111, 115, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067,
111, 111, 114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111,
114, 061, 099, 111, 108, 059, 125, 125, 125, 102, 114, 097, 103, 109, 101, 110, 116, 115, 104, 097,
100, 101, 114, 115, 123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101, 070,
114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 123, 117, 110, 105, 102, 111,
114, 109, 032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101,
059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115,
101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 118, 111, 105, 100,
032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108, 111,
114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120, 116, 117, 114, 101, 044,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102,
102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110, 105, 113,
117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032, 034, 083, 112, 114, 105, 116,
101, 084, 101, 099, 104, 110, 105, 113, 117, 101, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034,
083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034, 102,
114, 097, 103, 109, 101, 110, 116, 032, 034, 083, 112, 114, 105, 116, 101, 070, 114, 097, 103, 109,
101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 125, 125, 085, 005, 093, 183, 066, 090, 070, 104,
093, 184, 253, 199, 246, 081, 152, 083, 013, 048, 171, 074, 063, 021, 247, 182, 129, 011, 094, 003,
189, 026, 178, 121, 230, 157, 193, 056, 001, 064, 136, 044, 054, 172, 146, 241, 173, 160, 182, 034,
092, 221, 158, 045, 049, 229, 144, 171, 015, 022, 089, 025, 248, 163, 175, 081
};
#endregion //DualTextureEffectShader
#region EnvironmentMapEffectShader
internal static byte[] EnvironmentMapEffectByteCode = new byte[]
{
160,
003, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114, 105, 120,
084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118,
101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 010, 118, 097,
114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101,
120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 118, 111,
105, 100, 041, 123, 010, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116,
114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 042, 112, 111, 115, 059, 010, 100, 105,
102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 010, 100,
105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 010, 035, 035,
033, 102, 114, 097, 103, 109, 101, 110, 116, 033, 035, 035, 010, 117, 110, 105, 102, 111, 114, 109,
032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059, 010,
118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101,
067, 111, 108, 111, 114, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105,
100, 032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 123, 010, 103, 108, 095, 070, 114, 097,
103, 067, 111, 108, 111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120,
116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100,
041, 042, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 010, 095, 046, 094,
078, 240, 054, 006, 106, 005, 190, 104, 250, 201, 129, 166, 050, 199, 249, 189, 159, 008, 207, 084,
062, 171, 010, 076, 101, 119, 047, 079, 245, 134, 024, 149, 110, 166, 213, 153, 023, 179, 120, 191,
146, 106, 047, 180, 084, 037, 088, 036, 132, 126, 030, 027, 054, 044, 236, 120, 086, 102, 211, 178,
125
187,
004, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115, 123, 115, 104, 097, 100, 101,
114, 032, 034, 083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101,
114, 034, 123, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114,
105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 097, 116, 116, 114, 105, 098, 117, 116,
101, 032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032,
118, 101, 099, 050, 032, 116, 101, 120, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099,
052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105,
110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111,
111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095,
080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115,
102, 111, 114, 109, 042, 112, 111, 115, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067,
111, 111, 114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111,
114, 061, 099, 111, 108, 059, 125, 125, 125, 102, 114, 097, 103, 109, 101, 110, 116, 115, 104, 097,
100, 101, 114, 115, 123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101, 070,
114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 123, 117, 110, 105, 102, 111,
114, 109, 032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101,
059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115,
101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 118, 111, 105, 100,
032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108, 111,
114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120, 116, 117, 114, 101, 044,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102,
102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110, 105, 113,
117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032, 034, 083, 112, 114, 105, 116,
101, 084, 101, 099, 104, 110, 105, 113, 117, 101, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034,
083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034, 102,
114, 097, 103, 109, 101, 110, 116, 032, 034, 083, 112, 114, 105, 116, 101, 070, 114, 097, 103, 109,
101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 125, 125, 085, 005, 093, 183, 066, 090, 070, 104,
093, 184, 253, 199, 246, 081, 152, 083, 013, 048, 171, 074, 063, 021, 247, 182, 129, 011, 094, 003,
189, 026, 178, 121, 230, 157, 193, 056, 001, 064, 136, 044, 054, 172, 146, 241, 173, 160, 182, 034,
092, 221, 158, 045, 049, 229, 144, 171, 015, 022, 089, 025, 248, 163, 175, 081
};
#endregion //EnvironmentMapEffectShader
#region SkinnedEffectShader
internal static byte[] SkinnedEffectByteCode = new byte[]
{
160,
003, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114, 105, 120,
084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 010, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118,
101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 010, 118, 097,
114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101,
120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 118, 111,
105, 100, 041, 123, 010, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116,
114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 042, 112, 111, 115, 059, 010, 100, 105,
102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 010, 100,
105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 010, 035, 035,
033, 102, 114, 097, 103, 109, 101, 110, 116, 033, 035, 035, 010, 117, 110, 105, 102, 111, 114, 109,
032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059, 010,
118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101,
067, 111, 108, 111, 114, 059, 010, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 010, 118, 111, 105,
100, 032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 123, 010, 103, 108, 095, 070, 114, 097,
103, 067, 111, 108, 111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120,
116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100,
041, 042, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 010, 095, 046, 094,
078, 240, 054, 006, 106, 005, 190, 104, 250, 201, 129, 166, 050, 199, 249, 189, 159, 008, 207, 084,
062, 171, 010, 076, 101, 119, 047, 079, 245, 134, 024, 149, 110, 166, 213, 153, 023, 179, 120, 191,
146, 106, 047, 180, 084, 037, 088, 036, 132, 126, 030, 027, 054, 044, 236, 120, 086, 102, 211, 178,
125
187,
004, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115, 123, 115, 104, 097, 100, 101,
114, 032, 034, 083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101,
114, 034, 123, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114,
105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 097, 116, 116, 114, 105, 098, 117, 116,
101, 032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101,
032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032,
118, 101, 099, 050, 032, 116, 101, 120, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099,
052, 032, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105,
110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111,
111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095,
080, 111, 115, 105, 116, 105, 111, 110, 061, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115,
102, 111, 114, 109, 042, 112, 111, 115, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067,
111, 111, 114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111,
114, 061, 099, 111, 108, 059, 125, 125, 125, 102, 114, 097, 103, 109, 101, 110, 116, 115, 104, 097,
100, 101, 114, 115, 123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101, 070,
114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 123, 117, 110, 105, 102, 111,
114, 109, 032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101,
059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115,
101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 118, 111, 105, 100,
032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108, 111,
114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120, 116, 117, 114, 101, 044,
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102,
102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110, 105, 113,
117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032, 034, 083, 112, 114, 105, 116,
101, 084, 101, 099, 104, 110, 105, 113, 117, 101, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034,
083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034, 102,
114, 097, 103, 109, 101, 110, 116, 032, 034, 083, 112, 114, 105, 116, 101, 070, 114, 097, 103, 109,
101, 110, 116, 083, 104, 097, 100, 101, 114, 034, 125, 125, 085, 005, 093, 183, 066, 090, 070, 104,
093, 184, 253, 199, 246, 081, 152, 083, 013, 048, 171, 074, 063, 021, 247, 182, 129, 011, 094, 003,
189, 026, 178, 121, 230, 157, 193, 056, 001, 064, 136, 044, 054, 172, 146, 241, 173, 160, 182, 034,
092, 221, 158, 045, 049, 229, 144, 171, 015, 022, 089, 025, 248, 163, 175, 081
};
#endregion //SkinnedEffectShader

View File

@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using StringPair = System.Collections.Generic.KeyValuePair<string, string>;
#region License
//
// This file is part of the ANX.Framework created by the "ANX.Framework developer group".
//
// This file is released under the Ms-PL license.
//
//
//
// Microsoft Public License (Ms-PL)
//
// This license governs use of the accompanying software. If you use the software, you accept this license.
// If you do not accept the license, do not use the software.
//
// 1.Definitions
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning
// here as under U.S. copyright law.
// A "contribution" is the original software, or any additions or changes to the software.
// A "contributor" is any person that distributes its contribution under this license.
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
//
// 2.Grant of Rights
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations
// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to
// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution
// or any derivative works that you create.
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in
// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed
// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution
// in the software or derivative works of the contribution in the software.
//
// 3.Conditions and Limitations
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your
// patent license from such contributor to the software ends automatically.
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
// notices that are present in the software.
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or
// object code form, you may only do so under a license that complies with this license.
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees,
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the
// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
// particular purpose and non-infringement.
#endregion // License
namespace ANX.Framework.Windows.GL3
{
public class ShaderData
{
public string VertexGlobalCode;
public Dictionary<string, string> VertexShaderCodes;
public string FragmentGlobalCode;
public Dictionary<string, string> FragmentShaderCodes;
public Dictionary<string, StringPair> Techniques;
public ShaderData()
{
VertexShaderCodes = new Dictionary<string, string>();
FragmentShaderCodes = new Dictionary<string, string>();
Techniques = new Dictionary<string, StringPair>();
}
}
}

View File

@ -0,0 +1,346 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using StringPair = System.Collections.Generic.KeyValuePair<string, string>;
#region License
//
// This file is part of the ANX.Framework created by the "ANX.Framework developer group".
//
// This file is released under the Ms-PL license.
//
//
//
// Microsoft Public License (Ms-PL)
//
// This license governs use of the accompanying software. If you use the software, you accept this license.
// If you do not accept the license, do not use the software.
//
// 1.Definitions
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning
// here as under U.S. copyright law.
// A "contribution" is the original software, or any additions or changes to the software.
// A "contributor" is any person that distributes its contribution under this license.
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
//
// 2.Grant of Rights
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations
// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to
// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution
// or any derivative works that you create.
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in
// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed
// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution
// in the software or derivative works of the contribution in the software.
//
// 3.Conditions and Limitations
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your
// patent license from such contributor to the software ends automatically.
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
// notices that are present in the software.
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or
// object code form, you may only do so under a license that complies with this license.
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees,
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the
// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
// particular purpose and non-infringement.
#endregion // License
namespace ANX.Framework.Windows.GL3
{
public static class ShaderHelper
{
#region SaveShaderCode (for external)
public static byte[] SaveShaderCode(string effectCode)
{
effectCode = CleanCode(effectCode);
MemoryStream stream = new MemoryStream();
BinaryWriter writer = new BinaryWriter(stream);
// First of all writer the shader code (which is already preceeded
// by a length identifier, making it harder to manipulate the code)
writer.Write(effectCode);
// And now we additionally generate a sha hash so it nearly becomes
// impossible to manipulate the shader.
SHA512Managed sha = new SHA512Managed();
byte[] data = stream.ToArray();
byte[] hash = sha.ComputeHash(data);
// The hash is added to the end of the stream.
writer.Write(hash);
writer.Flush();
sha.Dispose();
return stream.ToArray();
}
#endregion
#region LoadShaderCode
public static string LoadShaderCode(Stream stream)
{
BinaryReader reader = new BinaryReader(stream);
// First load the source.
string source = reader.ReadString();
// And now check if it was manipulated.
SHA512Managed sha = new SHA512Managed();
int lengthRead = (int)stream.Position;
stream.Position = 0;
byte[] data = reader.ReadBytes(lengthRead);
byte[] hash = sha.ComputeHash(data);
sha.Dispose();
byte[] loadedHash = reader.ReadBytes(64);
for (int index = 0; index < hash.Length; index++)
{
if (hash[index] != loadedHash[index])
{
throw new InvalidDataException("Failed to load the shader " +
"because the data got manipulated!");
}
}
return source;
}
#endregion
#region CleanCode
private static string CleanCode(string input)
{
// We wanna clean up the shader a little bit, so we remove
// empty lines, spaces and tabs at beginning and end and also
// remove comments.
List<string> lines = new List<string>(input.Split('\n'));
for (int index = lines.Count - 1; index >= 0; index--)
{
lines[index] = lines[index].Trim();
if (String.IsNullOrEmpty(lines[index]) ||
lines[index].StartsWith("//"))
{
lines.RemoveAt(index);
continue;
}
// TODO: add /**/ comment checking and removing.
}
input = "";
foreach (string line in lines)
{
input += line + "\n";
}
// Now to some additional cleanup
string[] minimizables =
{
" * ", " = ", " + ", " / ", " - ", ", ",
};
foreach (string mizable in minimizables)
{
input = input.Replace(mizable, mizable.Trim());
}
input = input.Replace("\n", "");
return input;
}
#endregion
#region ParseShaderCode
public static ShaderData ParseShaderCode(string source)
{
ShaderData result = new ShaderData();
string[] partIdentifiers =
{
"vertexglobal",
"vertexshaders",
"fragmentglobal",
"fragmentshaders",
"techniques",
};
int index = 0;
while (index < source.Length)
{
for (int partIdsIndex = 0; partIdsIndex < partIdentifiers.Length; partIdsIndex++)
{
string partId = partIdentifiers[partIdsIndex];
bool isValid = true;
for (int partIndex = 0; partIndex < partId.Length; partIndex++)
{
if (source[index + partIndex] != partId[partIndex])
{
isValid = false;
break;
}
}
if (isValid)
{
int startIndex = index + partId.Length;
startIndex = source.IndexOf('{', startIndex) + 1;
string area = ExtractArea(source, startIndex);
index = startIndex + area.Length - 1;
switch (partIdsIndex)
{
case 0:
result.VertexGlobalCode = area;
break;
case 2:
result.FragmentGlobalCode = area;
break;
case 1:
ExtractNamedAreas(area, "shader", 0, result);
break;
case 3:
ExtractNamedAreas(area, "shader", 1, result);
break;
case 4:
ExtractNamedAreas(area, "technique", 2, result);
break;
}
}
}
index++;
}
return result;
}
#endregion
#region ExtractNamedAreas
private static void ExtractNamedAreas(string areaSource, string identifier,
int addToId, ShaderData result)
{
int index = 0;
while (index < areaSource.Length)
{
bool isValid = true;
for (int partIndex = 0; partIndex < identifier.Length; partIndex++)
{
if (areaSource[index + partIndex] != identifier[partIndex])
{
isValid = false;
break;
}
}
if (isValid)
{
int startIndex = index + identifier.Length;
startIndex = areaSource.IndexOf('"', startIndex) + 1;
string name = areaSource.Substring(startIndex,
areaSource.IndexOf('"', startIndex) - startIndex);
startIndex = areaSource.IndexOf('{', startIndex) + 1;
string area = ExtractArea(areaSource, startIndex);
switch (addToId)
{
case 0:
result.VertexShaderCodes.Add(name, area);
break;
case 1:
result.FragmentShaderCodes.Add(name, area);
break;
case 2:
int vertexIndex = area.IndexOf("vertex");
vertexIndex = area.IndexOf('"', vertexIndex) + 1;
string vertexName = area.Substring(vertexIndex,
area.IndexOf('"', vertexIndex) - vertexIndex);
int fragmentIndex = area.IndexOf("fragment");
fragmentIndex = area.IndexOf('"', fragmentIndex) + 1;
string fragmentName = area.Substring(fragmentIndex,
area.IndexOf('"', fragmentIndex) - fragmentIndex);
result.Techniques.Add(name, new StringPair(vertexName, fragmentName));
break;
}
}
index++;
}
}
#endregion
#region ExtractArea
private static string ExtractArea(string source, int startIndex)
{
int endIndex = startIndex;
int openBraceCount = 0;
for (int index = startIndex; index < source.Length; index++)
{
if (source[index] == '{')
{
openBraceCount++;
}
if (source[index] == '}')
{
openBraceCount--;
}
if (openBraceCount == -1)
{
endIndex = index;
break;
}
}
return source.Substring(startIndex, endIndex - startIndex);
}
#endregion
private class Tests
{
#region TestCleanCode
public static void TestCleanCode()
{
string input = File.ReadAllText(@"..\..\shader\GL3\SpriteBatch_GLSL.fx");
Console.WriteLine(CleanCode(input));
}
#endregion
#region TestParseShaderCode
public static void TestParseShaderCode()
{
string input = CleanCode(File.ReadAllText(
@"..\..\shader\GL3\SpriteBatch_GLSL.fx"));
ShaderData data = ParseShaderCode(input);
Console.WriteLine("Vertex globals:");
Console.WriteLine(data.VertexGlobalCode);
Console.WriteLine("-------------------------");
Console.WriteLine("Fragment globals:");
Console.WriteLine(data.FragmentGlobalCode);
Console.WriteLine("-------------------------");
foreach (StringPair pair in data.VertexShaderCodes)
{
Console.WriteLine("vertex shader: " + pair.Key);
Console.WriteLine(pair.Value);
Console.WriteLine("-------------------------");
}
foreach (StringPair pair in data.FragmentShaderCodes)
{
Console.WriteLine("fragment shader: " + pair.Key);
Console.WriteLine(pair.Value);
Console.WriteLine("-------------------------");
}
foreach (KeyValuePair<string, StringPair> pair in data.Techniques)
{
Console.WriteLine("technique: " + pair.Key);
Console.WriteLine("vertex shader: " + pair.Value.Key);
Console.WriteLine("fragment shader: " + pair.Value.Value);
Console.WriteLine("-------------------------");
}
}
#endregion
}
}
}

View File

@ -180,20 +180,23 @@ namespace ANX.Framework.Windows.GL3
#region MapVertexDeclaration
internal void MapVertexDeclaration(EffectGL3 effect)
{
{
EffectTechniqueGL3 currentTechnique = effect.CurrentTechnique;
VertexElement[] elements = vertexDeclaration.GetVertexElements();
if (elements.Length != effect.ActiveAttributes.Count)
if (elements.Length != currentTechnique.activeAttributes.Count)
{
throw new InvalidOperationException("Mapping the VertexDeclaration " +
"onto the glsl attributes failed because we have " +
effect.ActiveAttributes.Count + " Shader Attributes and " +
currentTechnique.activeAttributes.Count + " Shader Attributes and " +
elements.Length + " elements in the vertex declaration which " +
"doesn't fit!");
}
foreach (string key in effect.ActiveAttributes.Keys)
foreach (string key in currentTechnique.activeAttributes.Keys)
{
EffectGL3.ShaderAttribute attribute = effect.ActiveAttributes[key];
EffectTechniqueGL3.ShaderAttribute attribute =
currentTechnique.activeAttributes[key];
GL.EnableVertexAttribArray(attribute.Location);
VertexElement element = elements[(int)attribute.Location];

View File

@ -11,7 +11,7 @@ namespace WindowsGame1
/// </summary>
static void Main(string[] args)
{
//AddInSystemFactory.Instance.PreferredRenderSystem = "OpenGL3";
//AddInSystemFactory.Instance.PreferredRenderSystem = "OpenGL3";
//AddInSystemFactory.Instance.PreferredRenderSystem = "DirectX11";
using (Game1 game = new Game1())

View File

@ -108,7 +108,7 @@ namespace StockShaderCodeGenerator
byteCode = Effect_DX11.CompileFXShader(sourceCode);
break;
case "ANX.Framework.Windows.GL3":
byteCode = EffectGL3.CompileShader(sourceCode);
byteCode = ShaderHelper.SaveShaderCode(sourceCode);
break;
default:
throw new NotImplementedException("compiling shaders for " + RenderSystem + " not yet implemented...");

View File

@ -41,38 +41,49 @@
// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
// particular purpose and non-infringement.
//
// Vertex Shader
//
//TODO: dummy implementation / placeholder
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main(void)
vertexshaders
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
shader "SpriteVertexShader"
{
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
}
}
}
##!fragment!##
//
// Fragment Shader
//
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main(void)
fragmentshaders
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
shader "SpriteFragmentShader"
{
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
}
}
}
techniques
{
technique "SpriteTechnique"
{
vertex "SpriteVertexShader"
fragment "SpriteFragmentShader"
}
}

View File

@ -43,36 +43,47 @@
//TODO: dummy implementation / placeholder
//
// Vertex Shader
//
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main(void)
vertexshaders
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
shader "SpriteVertexShader"
{
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
}
}
}
##!fragment!##
//
// Fragment Shader
//
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main(void)
fragmentshaders
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
shader "SpriteFragmentShader"
{
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
}
}
}
techniques
{
technique "SpriteTechnique"
{
vertex "SpriteVertexShader"
fragment "SpriteFragmentShader"
}
}

View File

@ -43,36 +43,47 @@
//TODO: dummy implementation / placeholder
//
// Vertex Shader
//
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main(void)
vertexshaders
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
shader "SpriteVertexShader"
{
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
}
}
}
##!fragment!##
//
// Fragment Shader
//
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main(void)
fragmentshaders
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
shader "SpriteFragmentShader"
{
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
}
}
}
techniques
{
technique "SpriteTechnique"
{
vertex "SpriteVertexShader"
fragment "SpriteFragmentShader"
}
}

View File

@ -43,36 +43,47 @@
//TODO: dummy implementation / placeholder
//
// Vertex Shader
//
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main(void)
vertexshaders
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
shader "SpriteVertexShader"
{
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
}
}
}
##!fragment!##
//
// Fragment Shader
//
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main(void)
fragmentshaders
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
shader "SpriteFragmentShader"
{
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
}
}
}
techniques
{
technique "SpriteTechnique"
{
vertex "SpriteVertexShader"
fragment "SpriteFragmentShader"
}
}

View File

@ -43,36 +43,47 @@
//TODO: dummy implementation / placeholder
//
// Vertex Shader
//
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main(void)
vertexshaders
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
shader "SpriteVertexShader"
{
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
}
}
}
##!fragment!##
//
// Fragment Shader
//
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main(void)
fragmentshaders
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
shader "SpriteFragmentShader"
{
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
}
}
}
techniques
{
technique "SpriteTechnique"
{
vertex "SpriteVertexShader"
fragment "SpriteFragmentShader"
}
}

View File

@ -41,36 +41,47 @@
// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
// particular purpose and non-infringement.
//
// Vertex Shader
//
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
vertexshaders
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
shader "SpriteVertexShader"
{
uniform mat4 MatrixTransform;
attribute vec4 pos;
attribute vec4 col;
attribute vec2 tex;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_Position = MatrixTransform * pos;
diffuseTexCoord = tex;
diffuseColor = col;
}
}
}
##!fragment!##
//
// Fragment Shader
//
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
fragmentshaders
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
shader "SpriteFragmentShader"
{
uniform sampler2D Texture;
varying vec4 diffuseColor;
varying vec2 diffuseTexCoord;
void main( )
{
gl_FragColor = texture2D(Texture, diffuseTexCoord) * diffuseColor;
}
}
}
techniques
{
technique "SpriteTechnique"
{
vertex "SpriteVertexShader"
fragment "SpriteFragmentShader"
}
}