]> git.tdb.fi Git - libs/gl.git/commitdiff
Use PBR with IBL for the sphere in desert pillars
authorMikko Rasa <tdb@tdb.fi>
Sat, 8 May 2021 11:45:28 +0000 (14:45 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 8 May 2021 11:45:28 +0000 (14:45 +0300)
demos/desertpillars/data/exported/Iron.tech
demos/desertpillars/data/sphere.glsl
demos/desertpillars/data/sphere.shader
demos/desertpillars/data/sphere_morph.glsl [new file with mode: 0644]
demos/desertpillars/data/sphere_phong.object [deleted file]
demos/desertpillars/data/sphere_phong.tech [deleted file]
demos/desertpillars/data/sphere_shadow.glsl [new file with mode: 0644]
demos/desertpillars/scene.blend
demos/desertpillars/source/desertpillars.cpp

index 57d0f12d868ff0cc9c2612e218fc17f6a1ce2808..d3852af90c277c319e7785000bf5e68358da2bdb 100644 (file)
@@ -5,12 +5,12 @@ pass ""
                type pbr;
                base_color 0.550000 0.570000 0.570000 1.00000;
                metalness 1.00000;
-               roughness 0.0500000;
+               roughness 0.200000;
                emission 0.00000 0.00000 0.00000;
        };
-       receive_shadows true;
+       shader "sphere.shader";
 };
 pass "shadow"
 {
-       shader "_occluder.glsl.shader";
+       shader "sphere_shadow.glsl.shader";
 };
index 6144acaadab85db545c2568dbc1214e6afb31c12..0dd872bd71e4dc800b728e69abdeb46dd6cdcdf2 100644 (file)
@@ -1,38 +1,2 @@
-import phong;
-
-uniform Morph
-{
-       float morph;
-};
-
-const float PI = 3.1415926535;
-const float OFFSET = 0.001;
-
-#pragma MSP stage(vertex)
-vec3 deform(vec3 p)
-{
-       vec3 d = cos(p*(2.0*PI)+morph)*0.05;
-       return p*(1.0+(d.x+d.y+d.z)*sin(morph*0.2));
-}
-
-vec4 get_vertex_position() override
-{
-       return vec4(deform(vertex.xyz), 1.0);
-}
-
-vec3 get_vertex_normal() override
-{
-       vec3 tangent;
-       if(abs(normal.x)>abs(normal.y))
-               tangent = normalize(vec3(-normal.z, 0.0, normal.x));
-       else
-               tangent = normalize(vec3(0.0, -normal.z, normal.y));
-       vec3 binormal = cross(normal, tangent);
-
-       vec3 xn = deform(vertex.xyz-tangent*OFFSET);
-       vec3 xp = deform(vertex.xyz+tangent*OFFSET);
-       vec3 yn = deform(vertex.xyz-binormal*OFFSET);
-       vec3 yp = deform(vertex.xyz+binormal*OFFSET);
-
-       return normalize(cross(xp-xn, yp-yn));
-}
+import cooktorrance;
+import sphere_morph;
index ba938ff37d541b7da724c4bbe5be543e79081e65..d203cd1b35dd2e2a83bdb207340e4260032e4597 100644 (file)
@@ -1,5 +1,4 @@
 module "sphere.glsl"
 {
-       specialize "use_specular" true;
-       specialize "use_reflectivity" true;
+       specialize "use_image_based_lighting" true;
 };
diff --git a/demos/desertpillars/data/sphere_morph.glsl b/demos/desertpillars/data/sphere_morph.glsl
new file mode 100644 (file)
index 0000000..e020ed6
--- /dev/null
@@ -0,0 +1,36 @@
+uniform Morph
+{
+       float morph;
+};
+
+const float PI = 3.1415926535;
+const float OFFSET = 0.001;
+
+#pragma MSP stage(vertex)
+vec3 deform(vec3 p)
+{
+       vec3 d = cos(p*(2.0*PI)+morph)*0.05;
+       return p*(1.0+(d.x+d.y+d.z)*sin(morph*0.2));
+}
+
+vec4 get_vertex_position() override
+{
+       return vec4(deform(vertex.xyz), 1.0);
+}
+
+vec3 get_vertex_normal() override
+{
+       vec3 tangent;
+       if(abs(normal.x)>abs(normal.y))
+               tangent = normalize(vec3(-normal.z, 0.0, normal.x));
+       else
+               tangent = normalize(vec3(0.0, -normal.z, normal.y));
+       vec3 binormal = cross(normal, tangent);
+
+       vec3 xn = deform(vertex.xyz-tangent*OFFSET);
+       vec3 xp = deform(vertex.xyz+tangent*OFFSET);
+       vec3 yn = deform(vertex.xyz-binormal*OFFSET);
+       vec3 yp = deform(vertex.xyz+binormal*OFFSET);
+
+       return normalize(cross(xp-xn, yp-yn));
+}
diff --git a/demos/desertpillars/data/sphere_phong.object b/demos/desertpillars/data/sphere_phong.object
deleted file mode 100644 (file)
index b8f75dc..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-mesh "Sphere.mesh";
-technique "sphere_phong.tech";
diff --git a/demos/desertpillars/data/sphere_phong.tech b/demos/desertpillars/data/sphere_phong.tech
deleted file mode 100644 (file)
index 638d243..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-pass ""
-{
-       material
-       {
-               type basic;
-               diffuse 0.0 0.0 0.0;
-               specular 0.77 0.78 0.78;
-               reflectivity 0.77;
-       };
-       shader "sphere.shader";
-};
-pass "shadow"
-{
-       //shader "_occluder.glsl.shader";
-       shader "sphere.shader";
-};
diff --git a/demos/desertpillars/data/sphere_shadow.glsl b/demos/desertpillars/data/sphere_shadow.glsl
new file mode 100644 (file)
index 0000000..1064389
--- /dev/null
@@ -0,0 +1,8 @@
+import common;
+import sphere_morph;
+
+#pragma MSP stage(fragment)
+void main()
+{
+       frag_color = vec4(1.0);
+}
index e519cfb54f6359cb09b4784eb9889f896728293d..847ef1a43441f34a1481270a4b075f55b89f3241 100644 (file)
Binary files a/demos/desertpillars/scene.blend and b/demos/desertpillars/scene.blend differ
index bdbc069e3e153d31bc69747c5a4f4a203c0dce2d..6cde69b008e00ab47431dda0d939fde7489498fe 100644 (file)
@@ -24,7 +24,7 @@ DesertPillars::DesertPillars(int, char **):
        keyboard(window),
        view(window, gl_ctx),
        camera(resources.get<GL::Camera>("Camera.camera")),
-       sphere(resources.get<GL::Object>("sphere_phong.object")),
+       sphere(resources.get<GL::Object>("Sphere.object")),
        sphere_morph(0.0f),
        sphere_frozen(false),
        sphere_stopped(false),
@@ -55,7 +55,7 @@ DesertPillars::DesertPillars(int, char **):
        step->set_lighting(&resources.get<GL::Lighting>("Desert.lightn"));
        step->set_depth_test(&GL::DepthTest::lequal());
 
-       env_map = make_unique<GL::EnvironmentMap>(256, GL::RGB16F, sphere, *env_seq);
+       env_map = make_unique<GL::EnvironmentMap>(256, GL::RGB16F, 7, sphere, *env_seq);
        sphere.set_matrix(GL::Matrix::translation(GL::Vector3(0.0f, 0.0f, 3.3f)));
 
        content.add(resources.get<GL::Scene>("Background.scene"));