Skip to content

Commit

Permalink
added a sun, bigger terrain, normal map, better street
Browse files Browse the repository at this point in the history
Aidandos committed Jun 13, 2016
1 parent a979d63 commit 53cd1e8
Showing 25 changed files with 21,171 additions and 5,698 deletions.
80 changes: 64 additions & 16 deletions bRenderer_ios.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file added project/data/Moon_floor_jaqx_tilable_1024_NRM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added project/data/TexturesCom_Asphalt_heightmap_S.tif
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions project/data/plane.frag
Original file line number Diff line number Diff line change
@@ -42,8 +42,8 @@ void main()
highp vec3 l = normalize(LightPos - pos).xyz;

highp float intensity = dot(n, l);
highp vec3 diffuse = clamp(intensity, 0.0, 1.0) * Id;
highp vec4 diffuseResult = vec4(clamp(diffuse, 0.0, 1.0), 1.0);
highp vec3 diffuse = /*Kd */ clamp(intensity, 0.0, 1.0) * Id;
highp vec4 diffuseResult = vec4(diffuse, 1.0);

// If vertex is lit, calculate specular term in view space using the Blinn-Phong model
highp vec4 specularResult = vec4(0.0);
@@ -52,9 +52,9 @@ void main()
highp vec3 eyeVec = normalize(EyePos.xyz - pos.xyz);
highp vec3 h = normalize(l + eyeVec);

highp float specIntensity = pow(1.0, Ns);
highp vec3 specular = Ks * clamp(0.5, 0.0, 1.0) * Is;
specularResult = vec4(clamp(specular, 0.0, 1.0), 1.0);
highp float specIntensity = pow(max(dot(h,n), 0.0), Ns);
highp vec3 specular = Ks * clamp(specIntensity, 0.0, 1.0) * Is;
specularResult = vec4(specular, 1.0);
}

highp vec4 color = texture2D(DiffuseMap, texCoordVarying.st);
@@ -66,5 +66,5 @@ void main()
diffuseResult = vec4(0.6, 0.2, 0.0, 1.0);
}
}
gl_FragColor = (ambientResult + diffuseResult + specularResult) * color;
gl_FragColor = (ambientResult + diffuseResult+ specularResult) * color;
}
8 changes: 4 additions & 4 deletions project/data/plane.mtl
Original file line number Diff line number Diff line change
@@ -3,10 +3,10 @@

newmtl plane
Ns 94.117647
Ka 0.000000 0.000000 0.000000
Kd 0.000000 0.000000 0.000000
Ks 0.100111 0.100111 0.100111
Ke 0.000000 0.000000 0.000000
Ka 0.200000 0.200000 0.200000
Kd 0.200000 0.200000 0.200000
Ks 1.000000 1.000000 1.000000
Ke 0.100000 0.100000 0.100000
Ni 1.000000
d 1.000000
illum 2
Binary file added project/data/preview_sun.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 28 additions & 18 deletions project/data/road.frag
Original file line number Diff line number Diff line change
@@ -38,23 +38,23 @@ void main()
highp vec3 n = normalize(normalVarying);

// TODO: calculate tbn matrix, ensure it's orthonormal
highp vec3 t = normalize(tangentVarying);
t = normalize(t-n*dot(n,t));
highp vec3 b = normalize(cross(t, n));

highp mat3 tbn = mat3(t, b, n);

// TODO: read and correctly transform normals from normal map, then use them for lighting
highp vec3 bump = texture2D(NormalMap, texCoordVarying.st).xyz;
bump -= vec3(.5);
bump *= 2.;
n = normalize(tbn * bump);
// highp vec3 t = normalize(tangentVarying);
// t = normalize(t-n*dot(n,t));
// highp vec3 b = normalize(cross(t, n));
//
// highp mat3 tbn = mat3(t, b, n);
//
// // TODO: read and correctly transform normals from normal map, then use them for lighting
// highp vec3 bump = texture2D(NormalMap, texCoordVarying.st).xyz;
// bump -= vec3(.5);
// bump *= 2.;
n = normalize(texture2D(NormalMap, texCoordVarying.st).xyz*100.0);

highp vec3 l = normalize(LightPos - pos).xyz;

highp float intensity = dot(n, l);
highp vec3 diffuse = Kd * clamp(intensity, 0.0, 1.0) * Id;
highp vec4 diffuseResult = vec4(clamp(diffuse, 0.0, 1.0), 1.0);
highp vec4 diffuseResult = vec4(diffuse, 1.0);

// If vertex is lit, calculate specular term in view space using the Blinn-Phong model
highp vec4 specularResult = vec4(0.0);
@@ -63,11 +63,21 @@ void main()
highp vec3 eyeVec = normalize(EyePos.xyz - pos.xyz);
highp vec3 h = normalize(l + eyeVec);

highp float specIntensity = pow(max(dot(h,n), 0.0), Ns);
highp vec3 specular = Ks * clamp(specIntensity, 0.0, 1.0) * Is;
specularResult = vec4(clamp(specular, 0.0, 1.0), 1.0)*texture2DProj(SpecularMap, texCoordVarying);
highp float specIntensity = pow(max(dot(h,n), 0.0), 4.0*Ns);
highp vec3 specular = Ks * clamp(specIntensity, 0.0, 1.0) * (Is*100.0);
specularResult = vec4(specular, 1.0);
}

highp vec4 color = texture2DProj(DiffuseMap, texCoordVarying);
gl_FragColor = /*vec4(0.0, 0.0, 1.0, 1.0);*/ /* (ambientResult + diffuseResult) */ color /*+ specularResult*/;
}
highp vec4 color = texture2D(DiffuseMap, texCoordVarying.st);

// if(color.x > 0.4 && color.z < 0.4){
// ambientResult = vec4(0.5, 0.25, 0.0, 1.0);
// diffuseResult = vec4(0.5, 0.25, 0.0, 1.0);
// if(braking){
// ambientResult = vec4(0.6, 0.2, 0.0, 1.0);
// diffuseResult = vec4(0.6, 0.2, 0.0, 1.0);
// }
// }
gl_FragColor = /*(ambientResult + specularResult) */ color* ( diffuseResult+ambientResult+specularResult);
}

13 changes: 7 additions & 6 deletions project/data/road.mtl
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Blender MTL File: 'road.blend'
# Blender MTL File: 'road_success.blend'
# Material Count: 1

newmtl road
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ns 200.078431
Ka 0.200000 0.200000 0.200000
Kd 0.200000 0.200000 0.200000
Ks 1.000000 1.000000 1.000000
Ke 0.100000 0.100000 0.100000
Ni 1.000000
d 1.000000
illum 2
map_Kd road.png
map_Bump TexturesCom_Asphalt_heightmap_S.tif
Loading

0 comments on commit 53cd1e8

Please sign in to comment.