bgfx/examples/common/imgui/fs_imgui_latlong.sc

39 lines
793 B
Python
Raw Normal View History

$input v_texcoord0
/*
* Copyright 2014-2015 Dario Manesku. All rights reserved.
2016-01-01 11:11:04 +03:00
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include <bgfx_shader.sh>
uniform vec4 u_imageLodEnabled;
SAMPLERCUBE(s_texColor, 0);
#define u_imageLod u_imageLodEnabled.x
#define u_imageEnabled u_imageLodEnabled.y
vec3 vecFromLatLong(vec2 _uv)
{
float pi = 3.14159265;
float twoPi = 2.0*pi;
float phi = _uv.x * twoPi;
2015-02-14 02:29:20 +03:00
float theta = _uv.y * pi;
vec3 result;
2015-02-23 22:52:30 +03:00
result.x = -sin(theta)*sin(phi);
result.y = cos(theta);
2015-02-23 22:52:30 +03:00
result.z = -sin(theta)*cos(phi);
return result;
}
void main()
{
vec3 dir = vecFromLatLong(v_texcoord0);
vec3 color = textureCubeLod(s_texColor, dir, u_imageLod).xyz;
float alpha = 0.2 + 0.8*u_imageEnabled;
gl_FragColor = vec4(color, alpha);
}