Browse Source

neercs: if shaders don't support integer attributes, pass them as vectors

of ubytes; foreground colour already works.
master
Sam Hocevar 12 years ago
parent
commit
5e0461ffc5
2 changed files with 12 additions and 8 deletions
  1. +3
    -3
      neercs/video/text-render.cpp
  2. +9
    -5
      neercs/video/text.lolfx

+ 3
- 3
neercs/video/text-render.cpp View File

@@ -52,8 +52,8 @@ void TextRender::Init()
m_transform = m_shader->GetUniformLocation("u_Transform"); m_transform = m_shader->GetUniformLocation("u_Transform");
m_datasize = m_shader->GetUniformLocation("u_DataSize"); m_datasize = m_shader->GetUniformLocation("u_DataSize");
m_vdecl m_vdecl
= new VertexDeclaration(VertexStream<uint32_t>(VertexUsage::Color),
VertexStream<uint32_t>(VertexUsage::Color));
= new VertexDeclaration(VertexStream<u8vec4>(VertexUsage::Color),
VertexStream<u8vec4>(VertexUsage::Color));


CreateBuffers(); CreateBuffers();
} }
@@ -61,7 +61,7 @@ void TextRender::Init()
void TextRender::CreateBuffers() void TextRender::CreateBuffers()
{ {
m_vbo2 = new VertexBuffer(m_cells * sizeof(int32_t)); m_vbo2 = new VertexBuffer(m_cells * sizeof(int32_t));
m_vbo3 = new VertexBuffer(m_cells * sizeof(int32_t));
m_vbo3 = new VertexBuffer(m_cells * sizeof(u8vec4));


m_fbo = new FrameBuffer(m_fbo_size); m_fbo = new FrameBuffer(m_fbo_size);
} }


+ 9
- 5
neercs/video/text.lolfx View File

@@ -23,8 +23,10 @@ void main()
float u = float(in_Char & 0xfu) / 32.0 + 0.0; float u = float(in_Char & 0xfu) / 32.0 + 0.0;
float v = float((in_Char >> 4u) & 0xfu) / 32.0 + 0.5; float v = float((in_Char >> 4u) & 0xfu) / 32.0 + 0.5;
#else #else
float u = mod(in_Char.x, 16.0) / 32.0 + 0.0;
float v = floor(in_Char.x / 16.0) / 32.0 + 0.5;
vec4 tmp_Char = in_Char * 255.0;

float u = mod(tmp_Char.x, 16.0) / 32.0 + 0.0;
float v = floor(tmp_Char.x / 16.0) / 32.0 + 0.5;
#endif #endif
pass_UV = vec2(u, v); pass_UV = vec2(u, v);


@@ -39,15 +41,17 @@ void main()
float G = float((in_Attr >> 7u) & 0xfu) / 15.0; float G = float((in_Attr >> 7u) & 0xfu) / 15.0;
float H = float((in_Attr >> 4u) & 0x7u) / 7.0; float H = float((in_Attr >> 4u) & 0x7u) / 7.0;
#else #else
vec4 tmp_Attr = in_Attr * 255.0;

float A = 0.0; float A = 0.0;
float B = 0.0; float B = 0.0;
float C = 0.0; float C = 0.0;
float D = 0.0; float D = 0.0;


float E = 0.0; float E = 0.0;
float F = mod(floor(in_Attr.y / 8.0), 16.0) / 15.0;
float G = (mod(in_Attr.y, 8.0) * 2.0 + floor(in_Attr.x / 128.0)) / 15.0;
float H = mod(floor(in_Attr.x / 16.0), 8.0) / 7.0;
float F = mod(floor(tmp_Attr.y / 8.0), 16.0) / 15.0;
float G = (mod(tmp_Attr.y, 8.0) * 2.0 + floor(tmp_Attr.x / 128.0)) / 15.0;
float H = mod(floor(tmp_Attr.x / 16.0), 8.0) / 7.0;
#endif #endif


pass_Background = vec4(B + 0.0625, C + 0.125, D + 0.125, 1.0 - A); pass_Background = vec4(B + 0.0625, C + 0.125, D + 0.125, 1.0 - A);


Loading…
Cancel
Save