move shaders into .glsl files and add #include feature
This commit is contained in:
29
data/shaders/equirect.glsl
Normal file
29
data/shaders/equirect.glsl
Normal file
@@ -0,0 +1,29 @@
|
||||
[[vertex]]
|
||||
#define PI 3.1415926535897932384626433832795
|
||||
#define TWO_PI 6.283185307179586476925286766559
|
||||
uniform mat4 mvp;
|
||||
in vec4 pos;
|
||||
in vec2 uvs;
|
||||
out vec2 uv;
|
||||
void main()
|
||||
{
|
||||
uv = (vec2(1.0) - uvs + vec2(0.25,0.0)) * vec2(TWO_PI, PI);
|
||||
gl_Position = mvp * vec4(pos.xyz, 1.0);
|
||||
}
|
||||
|
||||
[[fragment]]
|
||||
uniform samplerCube tex;
|
||||
in highp vec2 uv;
|
||||
out mediump vec4 frag;
|
||||
void main()
|
||||
{
|
||||
highp float anglex = uv.x;
|
||||
highp float angley = uv.y;
|
||||
highp float sx = sin(anglex);
|
||||
highp float cx = cos(anglex);
|
||||
highp vec3 dir = vec3(0.0, 0.0, 0.0);
|
||||
dir.x = sin(angley) * cx;
|
||||
dir.y = cos(angley);
|
||||
dir.z = sin(angley) * sx;
|
||||
frag = texture(tex, dir);
|
||||
}
|
||||
Reference in New Issue
Block a user