]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
small jump fix
authorPeter Schaefer <schaeferpm@gmail.com>
Wed, 24 Jun 2015 13:24:13 +0000 (15:24 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Wed, 24 Jun 2015 13:24:13 +0000 (15:24 +0200)
replaced Fragmentcolor with gl_FragColor (shader)

CGUE2015_Weave.sln
Weave/Scene/Level.cpp
Weave/Scene/SceneObject.cpp
shader/basicTexture_FS.hlsl
shader/basic_FS.hlsl
shader/blur_FS.hlsl [new file with mode: 0644]
shader/lightingTexture_FS.hlsl
shader/skyplane_FS.hlsl
shader/skyplane_color_FS.hlsl

index 7a36625ae432230213d3ed111730f87fe63e6e33..8d0b4d6a1ca95e2200750302ccef942d60e0e496 100644 (file)
@@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shader", "shader", "{75179E
                shader\basic_VS.hlsl = shader\basic_VS.hlsl
                shader\basicTexture_FS.hlsl = shader\basicTexture_FS.hlsl
                shader\basicTexture_VS.hlsl = shader\basicTexture_VS.hlsl
+               shader\blur_FS.hlsl = shader\blur_FS.hlsl
                shader\lightingTexture_FS.hlsl = shader\lightingTexture_FS.hlsl
                shader\perspective_VS.hlsl = shader\perspective_VS.hlsl
                shader\skybox_VS.hlsl = shader\skybox_VS.hlsl
index f565eec1ae0294523b0215d21d4a9c8bb94fdaf7..f9ae3bab23c19ae8fd4b0faec2f5b5a925eb6329 100644 (file)
@@ -52,13 +52,14 @@ void Level::collides(SceneObject* _other, btPersistentManifold* _contactManifold
 
 
                //Height
-               if (_other->yFloorDist < 0 && _other->ySpeed < 0)
-               {
-                       _other->move(-pdist * vec3(0.f, normal[1], 0.f)); 
-               }
 
-               if (normal[1] >= .3f && _other->ySpeed < 0)
+
+               if (normal[1] >= .3f && _other->ySpeed <= 0)
                {
+                       if (_other->yFloorDist < 0)
+                       {
+                               _other->move(-pdist * vec3(0.f, normal[1], 0.f));
+                       }
                        _other->ySpeed = 0;
                }
                        
index 2d3645128949a547c5af59b41fafee7b78e65668..453a4109cbae4d60be03a2f81171a14a34999d38 100644 (file)
@@ -156,10 +156,10 @@ void SceneObject::update(float deltaT)
                if (yFloorDist>0 || ySpeed!=0)
                {
                        if (ySpeed*deltaT < yFloorDist || ySpeed>0)
-                               modelMat = translate(vec3(0.f, ySpeed*deltaT, 0.f))*modelMat;
+                               move(vec3(0.f, ySpeed*deltaT, 0.f));
                        else
                        {
-                               modelMat = translate(vec3(0.f, yFloorDist, 0.f))*modelMat;
+                               move(vec3(0.f, yFloorDist, 0.f));
                                ySpeed = 0;     //set to FloorSpeed?
                        }
                        ySpeed -= deltaT*YFALL_SPEED;
index aae33bc438479a359485f853c0301f24028ea6d2..132e13f5160e478871687576188e88c2dbcd408f 100644 (file)
@@ -3,11 +3,9 @@
 //in worldNormal;
 in vec2 fUVs;
 
-out vec4 FragmentColor;
-
 uniform sampler2D uColorTexture;
  
 void main()
 {
-       FragmentColor = texture(uColorTexture, fUVs);
+       gl_FragColor = texture(uColorTexture, fUVs);
 }
\ No newline at end of file
index a041461493c0b546b11eefbe098c3a376cbb246d..c2b701afb832780df7a497aee3e83bd04d131439 100644 (file)
@@ -1,9 +1,7 @@
 //Fragment Shader
 #version 330
-out vec4 FragmentColor;
-
 uniform vec4 uFragmentColor = vec4(0.6, 0, 0, 0.6);
  
 void main(){
-       FragmentColor = uFragmentColor;
+       gl_FragColor = uFragmentColor;
 }
diff --git a/shader/blur_FS.hlsl b/shader/blur_FS.hlsl
new file mode 100644 (file)
index 0000000..fd99996
--- /dev/null
@@ -0,0 +1,47 @@
+//Fragment Shader
+#version 330
+//"in" attributes from our vertex shader
+varying vec4 vColor;
+varying vec2 fUVs;
+
+//declare uniforms
+uniform sampler2D u_texture;
+uniform float resolution;
+uniform float radius;
+uniform vec2 dir;
+
+void main() {
+       //this will be our RGBA sum
+       vec4 sum = vec4(0.0);
+
+       //our original texcoord for this fragment
+       vec2 tc = fUVs;
+
+       //the amount to blur, i.e. how far off center to sample from 
+       //1.0 -> blur by one pixel
+       //2.0 -> blur by two pixels, etc.
+       float blur = radius / resolution;
+
+       //the direction of our blur
+       //(1.0, 0.0) -> x-axis blur
+       //(0.0, 1.0) -> y-axis blur
+       float hstep = dir.x;
+       float vstep = dir.y;
+
+       //apply blurring, using a 9-tap filter with predefined gaussian weights
+
+       sum += texture2D(u_texture, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.0162162162;
+       sum += texture2D(u_texture, vec2(tc.x - 3.0*blur*hstep, tc.y - 3.0*blur*vstep)) * 0.0540540541;
+       sum += texture2D(u_texture, vec2(tc.x - 2.0*blur*hstep, tc.y - 2.0*blur*vstep)) * 0.1216216216;
+       sum += texture2D(u_texture, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.1945945946;
+
+       sum += texture2D(u_texture, vec2(tc.x, tc.y)) * 0.2270270270;
+
+       sum += texture2D(u_texture, vec2(tc.x + 1.0*blur*hstep, tc.y + 1.0*blur*vstep)) * 0.1945945946;
+       sum += texture2D(u_texture, vec2(tc.x + 2.0*blur*hstep, tc.y + 2.0*blur*vstep)) * 0.1216216216;
+       sum += texture2D(u_texture, vec2(tc.x + 3.0*blur*hstep, tc.y + 3.0*blur*vstep)) * 0.0540540541;
+       sum += texture2D(u_texture, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.0162162162;
+
+       //discard alpha for our simple demo, multiply by vertex color and return
+       gl_FragColor = vColor * vec4(sum.rgb, 1.0);
+}
\ No newline at end of file
index 74ce55c643692517e7b05767dfccc89d2e854395..501ee9221c309da1e3b90e680be88e32d86774e2 100644 (file)
@@ -5,8 +5,6 @@ in vec2 fUVs;
 
 in vec3 PointLightPosition1, DirectionalLightDirection1;
 
-out vec4 FragmentColor;
-
 uniform sampler2D uColorTexture;
 uniform vec4 material;                                 //vec4 in the form (ambient, point, directional, glossyness); so far it was (1, 1, 1, 3)
  
@@ -37,15 +35,15 @@ void main()
        float squaredist1 = worldPointLightDir1.x * worldPointLightDir1.x + worldPointLightDir1.y * worldPointLightDir1.y + worldPointLightDir1.z * worldPointLightDir1.z;
 
 
-       FragmentColor = vec4(uvColor.rgb * (AmbientLightColor * material[0]
+       gl_FragColor = vec4(uvColor.rgb * (AmbientLightColor * material[0]
                + PointLightColor1 * material[1] * (cosThetaPoint1 + pow(SpecularCosPoint1, specularConst)) / squaredist1
                + DirectionalLightColor1 * material[2] * (cosThetaDirection1 + pow(SpecularCosDirection1, specularConst))
                ), uvColor.a);
 
 
-       //FragmentColor = vec4((normalize(worldNormal)+1)/2, 1.0f);
-       //FragmentColor = vec4(length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, 1.0f);
+       //gl_FragColor = vec4((normalize(worldNormal)+1)/2, 1.0f);
+       //gl_FragColor = vec4(length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, 1.0f);
 
        //vec3 uvColor = texture(uColorTexture, fUVs).rgb;
-       //FragmentColor = vec4(uvColor, 1.0);
+       //gl_FragColor = vec4(uvColor, 1.0);
 }
index 1e1c0cc49b5cfd81f224da2f9950e7550603c225..1054192710c057212e4c9179958fca34205785ad 100644 (file)
@@ -3,8 +3,7 @@
 uniform samplerCube uColorTexture;
 
 smooth in vec3 eyeDirection;
-out vec4 FragmentColor;
  
 void main(){
-       FragmentColor = texture(uColorTexture, eyeDirection);
+       gl_FragColor = texture(uColorTexture, eyeDirection);
 }
index 1724745fdaad7473fa3d013e78d21e2ac7aa04c4..cf53dee240897b545a70e04f28361b3a74988e8c 100644 (file)
@@ -2,8 +2,7 @@
 #version 330
 
 smooth in vec3 eyeDirection;
-out vec4 FragmentColor;
  
 void main(){
-       FragmentColor = vec4((eyeDirection+vec3(2.f))/4, 0.5);
+       gl_FragColor = vec4((eyeDirection+vec3(2.f))/4, 0.5);
 }