本文整理汇总了C#中Texture2D.SetFilter方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.SetFilter方法的具体用法?C# Texture2D.SetFilter怎么用?C# Texture2D.SetFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture2D
的用法示例。
在下文中一共展示了Texture2D.SetFilter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: init
public static void init()
{
if (shaderUniversal == null){
shaderUniversal = new ShaderProgram("/Application/shaders/Universal.cgx");
shaderUniversal.SetAttributeBinding(0, "a_Position");
shaderUniversal.SetAttributeBinding(1, "a_VertexColor");
shaderUniversal.SetAttributeBinding(2, "a_TexCoord");
shaderUniversal.SetUniformBinding(0, "u_SceneMatrix");
shaderUniversal.SetUniformBinding(1, "u_ScreenMatrix");
shaderUniversal.SetUniformBinding(2, "u_Alpha");
texture = new Texture2D("/Application/assets/texturepack/rymdkapsel-hd.png", false);
texture.SetFilter(TextureFilterMode.Disabled);
texture.SetWrap(TextureWrapMode.ClampToEdge);
texture.SetMaxAnisotropy(0);
}
if (shaderColored == null){
shaderColored = new ShaderProgram("/Application/shaders/Colored.cgx");
shaderColored.SetAttributeBinding(0, "a_Position");
shaderColored.SetAttributeBinding(1, "a_VertexColor");
shaderColored.SetUniformBinding(0, "u_SceneMatrix");
shaderColored.SetUniformBinding(1, "u_ScreenMatrix");
shaderColored.SetUniformBinding(2, "u_Alpha");
}
}
示例2: RendererStartup
public RendererStartup(Sprite sprite)
: base(sprite)
{
float[] verts = new float[8];
float[] uvs = new float[8];
texture = new Texture2D("/Application/assets/bootscreen/Vita.png", false);
texture.SetFilter(TextureFilterMode.Disabled);
texture.SetWrap(TextureWrapMode.ClampToEdge);
texture.SetMaxAnisotropy(0);
int offsetX = (Settings.STAGE_W - texture.Width) / 2;
int offsetY = (Settings.STAGE_H - texture.Height) / 2;
verts[0] = (float) offsetX;
verts[1] = (float) offsetY;
verts[2] = (float) offsetX;
verts[3] = (float) offsetY + texture.Height;
verts[6] = (float) offsetX + texture.Width;
verts[7] = (float) offsetY;
verts[4] = (float) offsetX + texture.Width;
verts[5] = (float) offsetY + texture.Height;
uvs[0] = 0;
uvs[1] = 0;
uvs[2] = 0;
uvs[3] = 1;
uvs[6] = 1;
uvs[7] = 0;
uvs[4] = 1;
uvs[5] = 1;
vertexBuffer = new VertexBuffer(4, VertexFormat.Float2, VertexFormat.Float2);
vertexBuffer.SetVertices(0, verts);
vertexBuffer.SetVertices(1, uvs);
}
示例3: CreateTexture
//.........这里部分代码省略.........
0x04044830, 0x00304804, // 'C'
0x4848281c, 0x001c2848, // 'D'
0x3c04047c, 0x007c0404, // 'E'
0x3c04047c, 0x00040404, // 'F'
0x74044438, 0x00384444, // 'G'
0x7c444444, 0x00444444, // 'H'
0x10101038, 0x00381010, // 'I'
0x20202070, 0x00182420, // 'J'
0x0c142444, 0x00442414, // 'K'
0x04040404, 0x007c0404, // 'L'
0x54546c44, 0x00444444, // 'M'
0x544c4c44, 0x00446464, // 'N'
0x44444438, 0x00384444, // 'O'
0x3c44443c, 0x00040404, // 'P'
0x44444438, 0x00582454, // 'Q'
0x3c44443c, 0x00442414, // 'R'
0x38044438, 0x00384440, // 'S'
0x1010107c, 0x00101010, // 'T'
0x44444444, 0x00384444, // 'U'
0x44444444, 0x00102828, // 'V'
0x54444444, 0x00446c54, // 'W'
0x10284444, 0x00444428, // 'X'
0x38444444, 0x00101010, // 'Y'
0x1020407c, 0x007c0408, // 'Z'
0x10101070, 0x00701010, // '['
0x10080400, 0x00004020, // '\'
0x1010101c, 0x001c1010, // ']'
0x00442810, 0x00000000, // '^'
0x00000000, 0x007c0000, // '_'
0x00100804, 0x00000000, // '`'
0x40380000, 0x00784478, // 'a'
0x4c340404, 0x00344c44, // 'b'
0x44380000, 0x00384404, // 'c'
0x64584040, 0x00586444, // 'd'
0x44380000, 0x0038047c, // 'e'
0x7c105020, 0x00101010, // 'f'
0x64580000, 0x38405864, // 'g'
0x4c340404, 0x00444444, // 'h'
0x10180010, 0x00381010, // 'i'
0x10180010, 0x0c121010, // 'j'
0x14240404, 0x0024140c, // 'k'
0x10101018, 0x00381010, // 'l'
0x542c0000, 0x00545454, // 'm'
0x4c340000, 0x00444444, // 'n'
0x44380000, 0x00384444, // 'o'
0x4c340000, 0x0404344c, // 'p'
0x64580000, 0x40405864, // 'q'
0x4c340000, 0x00040404, // 'r'
0x04780000, 0x003c403c, // 's'
0x083c0808, 0x00304808, // 't'
0x24240000, 0x00582424, // 'u'
0x44440000, 0x00102844, // 'v'
0x54440000, 0x00285454, // 'w'
0x28440000, 0x00442810, // 'x'
0x44440000, 0x38405864, // 'y'
0x207c0000, 0x007c0810, // 'z'
0x04080830, 0x00300808, // '{'
0x10101010, 0x00101010, // '|'
0x2010100c, 0x000c1010, // '}'
0x0000007c, 0x00000000, // '~'
};
Vector2i font_size = new Vector2i (1024, 8);
byte[] data = new byte[font_size.X * font_size.Y];
for (int i=0; i < data.Length; ++i)
data [i] = 0x00;
for (int c = 0; c != NumChars; ++c)
{
for (int y = 0; y != CharSizei.Y; ++y)
{
for (int x = 0; x != CharSizei.X; ++x)
{
// get the pixel (x,y) for character c:
bool white = false;
uint a = SCE_PSP_FONT_DATA [c * 2 + 0];
uint b = SCE_PSP_FONT_DATA [c * 2 + 1];
uint index = (uint)(x + CharSizei.X * y);
if (index < (uint)32)
white = ((a & (1 << (int)index)) != 0);
else
white = ((b & (1 << (int)(index - 32))) != 0);
Int32 ddd = (c * CharSizei.X + x) + y * font_size.X;
data[ddd] = (byte)(white ? 0xff : 0x00);
}
}
}
texture = new Texture2D(font_size.X, font_size.Y, false, PixelFormat.Luminance);
texture.SetPixels (0, data, PixelFormat.Luminance);
texture.SetFilter (TextureFilterMode.Nearest, TextureFilterMode.Nearest, TextureFilterMode.Nearest);
return texture;
}
示例4: LoadTexture2D
public override Texture2D LoadTexture2D(LoadedAsset asset)
{
Bitmap bmp = null;
if (asset.FilePath.EndsWith(".tga"))
{
bmp = ApexEngine.Assets.Util.TargaImage.LoadTargaImage(asset.Data);
}
else
bmp = new Bitmap(asset.Data);
BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Texture2D tex = new Texture2D(Texture.GenTextureID());
tex.TexturePath = asset.FilePath;
tex.Use();
tex.SetWrap(Convert.ToInt32(TextureWrapMode.Repeat), Convert.ToInt32(TextureWrapMode.Repeat));
tex.SetFilter((int)TextureMinFilter.LinearMipmapLinear, (int)TextureMagFilter.Linear);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, bmp_data.Width, bmp_data.Height, 0,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
tex.GenerateMipmap();
tex.Width = bmp.Width;
tex.Height = bmp.Height;
bmp.UnlockBits(bmp_data);
Texture2D.Clear();
return tex;
}
示例5: TestOffscreen
public void TestOffscreen(string name, Texture2D texture)
{
const int Width = 32;
const int Height = 32;
ImageRect old_scissor = Director.Instance.GL.Context.GetScissor();
ImageRect old_viewport = Director.Instance.GL.Context.GetViewport();
FrameBuffer old_frame_buffer = Director.Instance.GL.Context.GetFrameBuffer();
ColorBuffer color_buffer = new ColorBuffer(Width, Height, PixelFormat.Rgba);
FrameBuffer frame_buffer = new FrameBuffer();
frame_buffer.SetColorTarget(color_buffer);
System.Console.WriteLine("SetFrameBuffer(): enter");
Director.Instance.GL.Context.SetFrameBuffer(frame_buffer);
System.Console.WriteLine("SetFrameBuffer(): exit");
ShaderProgram.SetAttributeBinding(0, "iPosition");
ShaderProgram.SetAttributeBinding(1, "iUV");
texture.SetWrap(TextureWrapMode.ClampToEdge);
texture.SetFilter(TextureFilterMode.Linear);
Director.Instance.GL.Context.SetTexture(0, texture);
Director.Instance.GL.Context.SetVertexBuffer(0, VertexBuffer);
Director.Instance.GL.Context.SetShaderProgram(ShaderProgram);
Director.Instance.GL.Context.SetScissor(0, 0, Width, Height);
Director.Instance.GL.Context.SetViewport(0, 0, Width, Height);
float uv_x0 = 0.0f;
float uv_x1 = 1.0f;
float uv_y0 = 0.0f;
float uv_y1 = 1.0f;
VertexDataArray[0] = new VertexData() { position = new Vector2(-1.0f, -1.0f), uv = new Vector2(uv_x0, uv_y1) };
VertexDataArray[1] = new VertexData() { position = new Vector2(-1.0f, +1.0f), uv = new Vector2(uv_x0, uv_y0) };
VertexDataArray[2] = new VertexData() { position = new Vector2(+1.0f, +1.0f), uv = new Vector2(uv_x1, uv_y0) };
VertexDataArray[3] = new VertexData() { position = new Vector2(+1.0f, -1.0f), uv = new Vector2(uv_x1, uv_y1) };
VertexBuffer.SetIndices(IndexDataArray, 0, 0, 4);
VertexBuffer.SetVertices(VertexDataArray, 0, 0, 4);
Director.Instance.GL.Context.SetVertexBuffer(0, VertexBuffer);
Director.Instance.GL.Context.DrawArrays(DrawMode.TriangleFan, 0, 4);
int count = Width * Height * 4;
byte[] data = new byte[count];
System.Console.WriteLine("ReadPixels(): enter");
Director.Instance.GL.Context.ReadPixels(data, PixelFormat.Rgba, 0, 0, Width, Height);
System.Console.WriteLine("ReadPixels(): exit");
int nonzero = 0;
int nonclear = 0;
for (int i = 0; i < count; ++i)
{
if (data[i] != 0)
nonzero++;
if (data[i] != 0xfe)
nonclear++;
System.Console.Write("{0} ", data[i]);
if (i % Width == 0)
System.Console.WriteLine("");
}
System.Console.WriteLine("");
System.Console.WriteLine("nonzero: {0}, nonclear: {1}", nonzero, nonclear);
Director.Instance.GL.Context.SetVertexBuffer(0, null);
Director.Instance.GL.Context.SetShaderProgram(null);
Director.Instance.GL.Context.SetFrameBuffer(old_frame_buffer);
Director.Instance.GL.Context.SetScissor(old_scissor);
Director.Instance.GL.Context.SetViewport(old_viewport);
System.Console.WriteLine("SwapBuffers(): enter");
Director.Instance.GL.Context.SwapBuffers();
System.Console.WriteLine("SwapBuffers(): exit");
Thread.Sleep(250);
}
示例6: Add
public void Add(string name, Texture2D texture, int tiles_x, int tiles_y)
{
int tile_width = (int)FMath.Round((float)texture.Width / (float)tiles_x);
int tile_height = (int)FMath.Round((float)texture.Height / (float)tiles_y);
tile_width /= ScaleDivisor;
tile_height /= ScaleDivisor;
tile_width = System.Math.Max(1, tile_width);
tile_height = System.Math.Max(1, tile_height);
ColorBuffer color_buffer = new ColorBuffer(tile_width, tile_height, PixelFormat.Rgba);
FrameBuffer frame_buffer = new FrameBuffer();
frame_buffer.SetColorTarget(color_buffer);
FrameBuffer old_frame_buffer = Director.Instance.GL.Context.GetFrameBuffer();
Director.Instance.GL.Context.SetFrameBuffer(frame_buffer);
ShaderProgram.SetAttributeBinding(0, "iPosition");
ShaderProgram.SetAttributeBinding(1, "iUV");
texture.SetWrap(TextureWrapMode.ClampToEdge);
texture.SetFilter(TextureFilterMode.Linear);
Director.Instance.GL.Context.SetTexture(0, texture);
Director.Instance.GL.Context.SetVertexBuffer(0, VertexBuffer);
Director.Instance.GL.Context.SetShaderProgram(ShaderProgram);
ImageRect old_scissor = Director.Instance.GL.Context.GetScissor();
ImageRect old_viewport = Director.Instance.GL.Context.GetViewport();
Director.Instance.GL.Context.SetScissor(0, 0, tile_width, tile_height);
Director.Instance.GL.Context.SetViewport(0, 0, tile_width, tile_height);
Entry entry = new Entry();
entry.TilesX = tiles_x;
entry.TilesY = tiles_y;
entry.TileWidth = tile_width;
entry.TileHeight = tile_height;
entry.Data = new List<List<byte>>();
for (int i = 0; i < tiles_y * tiles_x; ++i)
entry.Data.Add(new List<byte>());
Vector2 uv_step = new Vector2(1.0f, 1.0f) / new Vector2(tiles_x, tiles_y);
for (int y = 0; y < tiles_y; y++)
{
for (int x = 0; x < tiles_x; x++)
{
float uv_x0 = uv_step.X * (x + 0);
float uv_x1 = uv_step.X * (x + 1);
float uv_y0 = uv_step.Y * (tiles_y - 1 - y + 0);
float uv_y1 = uv_step.Y * (tiles_y - 1 - y + 1);
VertexDataArray[0] = new VertexData() { position = new Vector2(-1.0f, -1.0f), uv = new Vector2(uv_x0, uv_y1) };
VertexDataArray[1] = new VertexData() { position = new Vector2(-1.0f, +1.0f), uv = new Vector2(uv_x0, uv_y0) };
VertexDataArray[2] = new VertexData() { position = new Vector2(+1.0f, +1.0f), uv = new Vector2(uv_x1, uv_y0) };
VertexDataArray[3] = new VertexData() { position = new Vector2(+1.0f, -1.0f), uv = new Vector2(uv_x1, uv_y1) };
VertexBuffer.SetIndices(IndexDataArray, 0, 0, 4);
VertexBuffer.SetVertices(VertexDataArray, 0, 0, 4);
Director.Instance.GL.Context.SetVertexBuffer(0, VertexBuffer);
Director.Instance.GL.Context.DrawArrays(DrawMode.TriangleFan, 0, 4);
byte[] data = new byte[tile_width * tile_height * 4];
// DEBUG: fill with visible memory pattern
//for (int i = 0; i< tile_width * tile_height * 4; ++i)
//data[i] = (byte)(i % (tile_width / 4));
Director.Instance.GL.Context.ReadPixels(data, PixelFormat.Rgba, 0, 0, tile_width, tile_height);
List<byte> output = entry.Data[tiles_x * y + x];
for (int i = 0; i < tile_width * tile_height * 4; ++i)
output.Add(data[i]);
}
}
Director.Instance.GL.Context.SetVertexBuffer(0, null);
Director.Instance.GL.Context.SetShaderProgram(null);
Director.Instance.GL.Context.SetFrameBuffer(old_frame_buffer);
Director.Instance.GL.Context.SetScissor(old_scissor);
Director.Instance.GL.Context.SetViewport(old_viewport);
TileData[name] = entry;
}
示例7: validateBuffer
public override void validateBuffer()
{
if (texture != null){
texture.Dispose();
texture = null;
}
if (vertexBuffer != null){
vertexBuffer.Dispose();
vertexBuffer = null;
}
if (textfield.text == null || textfield.text.Length == 0){
dirtyBuffer = false;
return;
}
updateSize();
float[] verts = new float[8];
float[] uvs = new float[8];
int maxWidth = (int) textWidth;
if (textfield.defaultTextFormat.align == "right"){
maxWidth = textfield.width;
}
verts[0] = (float) OFFSET_X;
verts[1] = (float) OFFSET_Y;
verts[2] = (float) OFFSET_X;
verts[3] = (float) OFFSET_Y + textHeight;
verts[6] = (float) OFFSET_X + maxWidth;
verts[7] = (float) OFFSET_Y;
verts[4] = (float) OFFSET_X + maxWidth;
verts[5] = (float) OFFSET_Y + textHeight;
uvs[0] = 0;
uvs[1] = 0;
uvs[2] = 0;
uvs[3] = 1;
uvs[6] = 1;
uvs[7] = 0;
uvs[4] = 1;
uvs[5] = 1;
vertexBuffer = new VertexBuffer(4, VertexFormat.Float2, VertexFormat.Float2);
vertexBuffer.SetVertices(0, verts);
vertexBuffer.SetVertices(1, uvs);
int argb = textfield.defaultTextFormat.color;
var image = new Image( ImageMode.Rgba,
new ImageSize((int)maxWidth, (int)textHeight),
new ImageColor(0, 0, 0, 0));
ImagePosition pos = new ImagePosition(0, 0);
for (int i = 0; i < textLines.Length; i++){
pos.X = 0;
pos.Y = i * font.Metrics.Height;
if (textfield.defaultTextFormat.align == "right"){
pos.X = (int) maxWidth - font.GetTextWidth(textLines[i]);
}
image.DrawText(
textLines[i],
new ImageColor((int)((argb >> 16) & 0xff),
(int)((argb >> 8) & 0xff),
(int)((argb >> 0) & 0xff),
255),
font,
pos
);
}
texture = new Texture2D((int)maxWidth, (int)textHeight, false, PixelFormat.Rgba);
texture.SetPixels(0, image.ToBuffer());
texture.SetFilter(TextureFilterMode.Disabled);
texture.SetWrap(TextureWrapMode.ClampToEdge);
texture.SetMaxAnisotropy(0);
image.Dispose();
dirtyBuffer = false;
//Console.WriteLine("buffer validated: " + renderable.commands.length);
}
示例8: startup
protected void startup()
{
// Set up the graphics system
graphics = new GraphicsContext();
graphics.SetViewport(0, 0, graphics.Screen.Width, graphics.Screen.Height);
graphics.SetClearColor(0.0f, 0.0f, 0.0f, 0.0f);
graphics.Enable(EnableMode.Blend);
graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.SrcAlpha, BlendFuncFactor.OneMinusSrcAlpha);
program = new ShaderProgram("/Application/shaders/Simple.cgx");
program.SetUniformBinding(0, "WorldViewProj");
program.SetAttributeBinding(0, "a_Position");
program.SetAttributeBinding(1, "a_TexCoord");
program.SetAttributeBinding(2, "a_Color");
Matrix4 unitScreenMatrix = new Matrix4(
2.0f / graphics.Screen.Width, 0.0f, 0.0f, 0.0f,
0.0f, -2.0f / graphics.Screen.Height, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 1.0f
);
program.SetUniformValue(0, ref unitScreenMatrix);
videoBuffer = new byte[VIDEO_WIDTH * VIDEO_HEIGHT * 4];
texture = new Texture2D(512, 512, false, PixelFormat.Rgba);
texture.SetFilter(VIDEO_FILTER ? TextureFilterMode.Linear : TextureFilterMode.Nearest);
float tx = (float) VIDEO_WIDTH / (float) texture.Width;
float ty = (float) VIDEO_HEIGHT / (float) texture.Height;
screenTexcoords = new float[] {
0.0f, 0.0f, // 0 top left.
0.0f, ty, // 1 bottom left.
tx, 0.0f, // 2 top right.
tx, ty, // 3 bottom right.
};
defaultTexcoords = new float[] {
0.0f, 0.0f, // 0 top left.
0.0f, 1.0f, // 1 bottom left.
1.0f, 0.0f, // 2 top right.
1.0f, 1.0f, // 3 bottom right.
};
colors = new float[] {
1.0f, 1.0f, 1.0f, 1.0f, // 0 top left.
1.0f, 1.0f, 1.0f, 1.0f, // 1 bottom left.
1.0f, 1.0f, 1.0f, 1.0f, // 2 top right.
1.0f, 1.0f, 1.0f, 1.0f, // 3 bottom right.
};
vertexCount = vertices.Length / 3;
vertexBuffer = new VertexBuffer(vertexCount,
VertexFormat.Float3,
VertexFormat.Float2,
VertexFormat.Float4);
//vertexBuffer.SetVertices(0, vertices);
//vertexBuffer.SetVertices(1, texcoords);
//vertexBuffer.SetVertices(2, colors);
/////
int fontSize = 14;
normalFont = new Font(FontAlias.System, fontSize, FontStyle.Regular);
/////
emu = new EmulatorApplication(this);
emu.initialize();
statistics = new Statistics();
}
示例9: CreateFramebuffers
void CreateFramebuffers()
{
deferred_fb = device.CreateFrameBuffer(device.Width, device.Height);
lighting_fb = device.CreateFrameBuffer(device.Width, device.Height);
shadow_fb = device.CreateFrameBuffer(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE);
if (device.Extensions.NV_depth_buffer_float)
{
has_stencil = true;
depth_texture = device.CreateTexture2D(InternalFormat.DepthComponent32F_Stencil8_NV, device.Width, device.Height);
shadow_texture = device.CreateTexture2D(InternalFormat.DepthComponent32F_NV, SHADOW_MAP_SIZE, SHADOW_MAP_SIZE);
shadow_texture_cube = device.CreateTextureCubeMap(InternalFormat.DepthComponent32F_NV, SHADOW_MAP_SIZE);
}
else if (device.Extensions.ARB_depth_buffer_float)
{
// TODO: does not work on ATI
//has_stencil = true;
//depth_texture = device.CreateTexture2D(InternalFormat.Depth24Stencil8, device.Width, device.Height);
has_stencil = false;
depth_texture = device.CreateTexture2D(InternalFormat.DepthComponent32F, device.Width, device.Height);
shadow_texture = device.CreateTexture2D(InternalFormat.DepthComponent32F, SHADOW_MAP_SIZE, SHADOW_MAP_SIZE);
shadow_texture_cube = device.CreateTextureCubeMap(InternalFormat.DepthComponent32F, SHADOW_MAP_SIZE);
}
else
{
throw new System.ApplicationException("no hardware floating shadow maps available!");
}
depth_texture.SetFilter(TextureMagFilter.Nearest, TextureMinFilter.Nearest);
depth_texture.SetWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
depth_texture.SetCompareMode(TextureCompareMode.None);
shadow_texture.SetFilter(TextureMagFilter.Linear, TextureMinFilter.Linear);
shadow_texture.SetWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
shadow_texture.SetCompareMode(TextureCompareMode.CompareRToTexture);
shadow_texture.SetCompareFunc(TextureCompareFunc.LEqual);
shadow_texture_cube.SetFilter(TextureMagFilter.Linear, TextureMinFilter.Linear);
shadow_texture_cube.SetWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
//shadow_texture_cube.SetCompareMode(TextureCompareMode.CompareRToTexture);
//shadow_texture_cube.SetCompareFunc(TextureCompareFunc.LEqual);
//color_texture = device.CreateTexture2D(InternalFormat.RGBA8, device.Width, device.Height); // fallback
color_texture = device.CreateTexture2D(InternalFormat.RGBA16F, device.Width, device.Height);
color_texture.SetFilter(TextureMagFilter.Nearest, TextureMinFilter.Nearest);
color_texture.SetWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
//normal_texture = device.CreateTexture2D(InternalFormat.RGBA8, device.Width, device.Height); // fallback
normal_texture = device.CreateTexture2D(InternalFormat.RGBA16F, device.Width, device.Height);
normal_texture.SetFilter(TextureMagFilter.Nearest, TextureMinFilter.Nearest);
normal_texture.SetWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
lighting_output = device.CreateTexture2D(InternalFormat.RGBA8, device.Width, device.Height);
//lighting_output = device.CreateTexture2D(InternalFormat.RGB16F, device.Width, device.Height); // for HDR
lighting_output.SetFilter(TextureMagFilter.Nearest, TextureMinFilter.Nearest);
lighting_output.SetWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
GL.ReadBuffer(ReadBufferMode.None); // TODO
GL.DrawBuffer(DrawBufferMode.None); // TODO
shadow_fb.SetTexture2D(FramebufferAttachment.DepthAttachment, 0, shadow_texture);
System.Diagnostics.Debug.Assert(shadow_fb.Status == FramebufferStatus.Complete);
deferred_fb.SetTexture2D(FramebufferAttachment.DepthAttachment, 0, depth_texture);
if (has_stencil)
{
deferred_fb.SetTexture2D(FramebufferAttachment.StencilAttachment, 0, depth_texture);
}
deferred_fb.SetTexture2D(FramebufferAttachment.Color0, 0, color_texture);
deferred_fb.SetTexture2D(FramebufferAttachment.Color1, 0, normal_texture);
System.Diagnostics.Debug.Assert(deferred_fb.Status == FramebufferStatus.Complete);
lighting_fb.SetTexture2D(FramebufferAttachment.DepthAttachment, 0, depth_texture);
if (has_stencil)
{
lighting_fb.SetTexture2D(FramebufferAttachment.StencilAttachment, 0, depth_texture);
}
lighting_fb.SetTexture2D(FramebufferAttachment.Color0, 0, lighting_output);
System.Diagnostics.Debug.Assert(lighting_fb.Status == FramebufferStatus.Complete);
}