* More renames 4.x-dev

Mon, 10 Mar 2014 00:11:33 +0200

author
cemkalyoncu
date
Mon, 10 Mar 2014 00:11:33 +0200
branch
4.x-dev
changeset 405
b764e13f947f
parent 404
484856b2e883
child 406
1519f221de25

* More renames
* Ignore file

.hgignore file | annotate | diff | comparison | revisions
Resources/Shaders/shade3D.frag file | annotate | diff | comparison | revisions
Resources/Shaders/transform3D.vert file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Mon Mar 10 00:11:33 2014 +0200
@@ -0,0 +1,10 @@
+Build
+Debug
+
+syntax: glob
+
+*.obj
+ipch
+*.suo
+*.sdf
+*.opensdf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/Shaders/shade3D.frag	Mon Mar 10 00:11:33 2014 +0200
@@ -0,0 +1,44 @@
+#version 330
+
+uniform sampler2D diffuse_tex;
+uniform sampler2D normal_tex;
+uniform sampler2D depth_tex;
+
+uniform mat3 world_to_view; // for transforming normals
+
+struct PointLight {
+	vec3 intensity;
+	vec3 position;
+};
+
+uniform PointLight point_light;
+uniform vec3 ambient;
+
+smooth in vec3 position;
+smooth in vec2 texcoord;
+
+out vec4 output_color;
+
+vec3 ShadePointLight(PointLight point_light, vec3 position, vec3 normal, vec3 diffuse)
+{
+	float	dist		= distance(point_light.position, position);
+	vec3	light		= normalize(point_light.position - position);
+	float	NdotL		= clamp(dot(light, normal), 0.0f, 1.0f);
+	float	attenuation = 1.0f / (1.0f + dist * dist);
+
+	return point_light.intensity * diffuse * NdotL * attenuation;
+	//return vec3(position.z * 0.01);
+	//return diffuse;
+}
+
+void main()
+{
+    vec4 diffuse	= texture(diffuse_tex, texcoord);
+	vec3 normal		= texture(normal_tex, texcoord).xyz;
+	float depth		= texture(depth_tex, texcoord).x;
+	vec3 pos		= position; pos.z += depth;
+	vec3 norm		= world_to_view * normal;
+
+	output_color = vec4(ShadePointLight(point_light, pos, norm, diffuse.xyz) + ambient * diffuse.xyz, diffuse.a);
+	//output_color = vec4(0.0f, 1.0f, 0.0f, 0.5f);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/Shaders/transform3D.vert	Mon Mar 10 00:11:33 2014 +0200
@@ -0,0 +1,17 @@
+#version 330
+
+layout(location = 0) in int vertex_index;
+
+uniform mat4x3 vertex_coords;
+uniform mat4x3 vertex_coords_view_space;
+uniform mat4x2 tex_coords;
+
+smooth out vec3 position;
+smooth out vec2 texcoord;
+
+void main()
+{
+	gl_Position = vec4(vertex_coords[vertex_index], 1.0f);
+	position = vertex_coords_view_space[vertex_index];
+    texcoord = tex_coords[vertex_index];
+}

mercurial