cube to equirect conversion using shader, save latlong to file

This commit is contained in:
2017-04-30 02:20:54 +01:00
parent 78a87f9cd3
commit f64e9e746c
9 changed files with 94 additions and 10 deletions

View File

@@ -262,6 +262,35 @@ void App::initShaders()
" frag = mix(c1, c2, alpha);\n"
"}";
static const char* shader_equirect_v =
SHADER_VERSION
"#define PI 3.1415926535897932384626433832795\n"
"#define TWO_PI 6.283185307179586476925286766559\n"
"uniform mat4 mvp;\n"
"in vec4 pos;\n"
"in vec2 uvs;\n"
"out vec2 uv;\n"
"void main(){\n"
" uv = (vec2(1.0) - uvs + vec2(0.25,0.0)) * vec2(TWO_PI, PI);\n"
" gl_Position = mvp * vec4(pos.xyz, 1.0);\n"
"}";
static const char* shader_equirect_f =
SHADER_VERSION
"uniform samplerCube tex;\n"
"in mediump vec2 uv;\n"
"out mediump vec4 frag;\n"
"void main(){\n"
" float anglex = uv.x;\n"
" float angley = uv.y;\n"
" float sx = sin(anglex);\n"
" float cx = cos(anglex);\n"
" vec3 dir = vec3(0.0, 0.0, 0.0);\n"
" dir.x = sin(angley) * cx;\n"
" dir.y = cos(angley);\n"
" dir.z = sin(angley) * sx;\n"
" frag = texture(tex, dir);\n"
"}";
LOG("initializing shaders");
if (!ShaderManager::create(kShader::Texture, shader_v, shader_f))
LOG("Failed to create shader Texture");
@@ -287,6 +316,8 @@ void App::initShaders()
LOG("Failed to create shader StrokeLayer");
if (!ShaderManager::create(kShader::Checkerboard, shader_checkerboard_v, shader_checkerboard_f))
LOG("Failed to create shader Checkerboard");
if (!ShaderManager::create(kShader::Equirect, shader_equirect_v, shader_equirect_f))
LOG("Failed to create shader Equirect");
LOG("shaders initialized");
}
@@ -444,7 +475,7 @@ void App::initLayout()
//button->m_text->set_text(canvas->m_canvas->m_use_instanced ? "INST" : "NORM");
}
};
button->m_text->set_text("NORM");
//button->m_text->set_text("NORM");
}
if (auto* button = layout[main_id]->find<NodeButton>("btn-undo"))
{