Переглянути джерело

Revert "Cleanup imgui shaders (#2476)"

This reverts commit 01b7fc01050e0523effb6741e0a58c41b11194b0.
Бранимир Караџић 4 роки тому
батько
коміт
c3b8ec0dd0

+ 13 - 0
examples/common/imgui/fs_imgui_color.sc

@@ -0,0 +1,13 @@
+$input v_color0
+
+/*
+ * Copyright 2011-2021 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include <bgfx_shader.sh>
+
+void main()
+{
+	gl_FragColor = v_color0;
+}

+ 21 - 0
examples/common/imgui/fs_imgui_cubemap.sc

@@ -0,0 +1,21 @@
+$input v_normal
+
+/*
+ * Copyright 2011-2021 Branimir Karadzic. All rights reserved.
+ * 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
+
+void main()
+{
+	vec3 color = textureCubeLod(s_texColor, v_normal, u_imageLod).xyz;
+	float alpha = 0.2 + 0.8*u_imageEnabled;
+	gl_FragColor = vec4(color, alpha);
+}

+ 22 - 0
examples/common/imgui/fs_imgui_image_swizz.sc

@@ -0,0 +1,22 @@
+$input v_texcoord0
+
+/*
+ * Copyright 2014 Dario Manesku. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include <bgfx_shader.sh>
+
+uniform vec4 u_imageLodEnabled;
+uniform vec4 u_swizzle;
+SAMPLER2D(s_texColor, 0);
+
+#define u_imageLod     u_imageLodEnabled.x
+#define u_imageEnabled u_imageLodEnabled.y
+
+void main()
+{
+	float color = dot(texture2DLod(s_texColor, v_texcoord0, u_imageLod), u_swizzle);
+	float alpha = 0.2 + 0.8*u_imageEnabled;
+	gl_FragColor = vec4(vec3_splat(color), alpha);
+}

+ 38 - 0
examples/common/imgui/fs_imgui_latlong.sc

@@ -0,0 +1,38 @@
+$input v_texcoord0
+
+/*
+ * Copyright 2014-2015 Dario Manesku. All rights reserved.
+ * 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;
+	float theta = _uv.y * pi;
+
+	vec3 result;
+	result.x = -sin(theta)*sin(phi);
+	result.y = cos(theta);
+	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);
+}

+ 16 - 0
examples/common/imgui/fs_imgui_texture.sc

@@ -0,0 +1,16 @@
+$input v_texcoord0, v_color0
+
+/*
+ * Copyright 2011-2021 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include <bgfx_shader.sh>
+
+SAMPLER2D(s_texColor, 0);
+
+void main()
+{
+	float alpha = texture2D(s_texColor, v_texcoord0).x;
+	gl_FragColor = vec4(v_color0.xyz, v_color0.w * alpha);
+}

+ 1 - 1
examples/common/imgui/varying.def.sc

@@ -2,7 +2,7 @@ vec4 v_color0    : COLOR0    = vec4(1.0, 0.0, 0.0, 1.0);
 vec3 v_normal    : NORMAL    = vec3(0.0, 0.0, 1.0);
 vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
 
-vec2 a_position  : POSITION;
+vec3 a_position  : POSITION;
 vec4 a_normal    : NORMAL;
 vec4 a_color0    : COLOR0;
 vec2 a_texcoord0 : TEXCOORD0;

+ 15 - 0
examples/common/imgui/vs_imgui_color.sc

@@ -0,0 +1,15 @@
+$input a_position, a_color0
+$output v_color0
+
+/*
+ * Copyright 2011-2021 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include <bgfx_shader.sh>
+
+void main()
+{
+	gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0) );
+	v_color0 = a_color0;
+}

+ 15 - 0
examples/common/imgui/vs_imgui_cubemap.sc

@@ -0,0 +1,15 @@
+$input a_position, a_normal
+$output v_normal
+
+/*
+ * Copyright 2011-2021 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include <bgfx_shader.sh>
+
+void main()
+{
+	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
+	v_normal = a_normal.xyz;
+}

+ 15 - 0
examples/common/imgui/vs_imgui_latlong.sc

@@ -0,0 +1,15 @@
+$input a_position, a_texcoord0
+$output v_texcoord0
+
+/*
+ * Copyright 2015 Dario Manesku. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include <bgfx_shader.sh>
+
+void main()
+{
+	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
+	v_texcoord0 = a_texcoord0;
+}

+ 16 - 0
examples/common/imgui/vs_imgui_texture.sc

@@ -0,0 +1,16 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_color0
+
+/*
+ * Copyright 2011-2021 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ */
+
+#include <bgfx_shader.sh>
+
+void main()
+{
+	gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0) );
+	v_texcoord0 = a_texcoord0;
+	v_color0 = a_color0;
+}