Skip to content

Commit ea36c73

Browse files
committed
Añadir memoria, licencia y escena demo02
1 parent 83aabb4 commit ea36c73

File tree

4 files changed

+161
-1
lines changed

4 files changed

+161
-1
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Eritz Yerga Gutierrez
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@ Carmen Hernández Gómez
1919
En la carpeta _pbr_ se encuentran los ficheros de la aplicación, para abrir la aplicación abriremos el fichero _pbr.html_. Dentro de la carpeta _pbr_, en la carpeta _code_ se encuentra todo el código JavaScript principal de la aplicación, en la carpeta _libs_ se encuentran las librerías JavaScript utilizadas en el proyecto, en las carpetas _materials_ y _scenes_ se encuentran los materiales y escenas respectivamente, y finalmente, en la carpeta _shaders_ se encuentra el fichero _shaders.js_ que contiene todos los shaders en variables JavaScript. Por otro lado, en la carpeta _src/shaders_ se encuentran los ficheros fuente (.vert y .frag) de los shaders GLSL.
2020

2121
## Documentación:
22-
Este fichero se actualizará para añadir un enlace a la memoria del proyecto.
22+
La memoria del proyecto puede descargarse mediante [este enlace](https://github.com/eritzyg/TFG-PBR/releases).
23+
24+
## Licencia:
25+
La licencia para el código puede encontrarse en el fichero *LICENSE*.
26+
27+
Las licencias para las librerías pueden encontrarse en:
28+
* *pbr/libs/threejs-license*: Para las librerías Three.js, OrbitControls y BufferGeometryUtils.
29+
* *pbr/libs/dat-gui-license*: Para la librería dat.gui.
30+
* *pbr/libs/stats-license*: Para la librería stats.

pbr/materials/materials.js

+20
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,26 @@ principled:
178178
lights: true,
179179
vertexShader: shaders.principled_BRDF.vert,
180180
fragmentShader: shaders.principled_BRDF.frag
181+
}),
182+
183+
cloth_floor: new THREE.ShaderMaterial({
184+
uniforms: THREE.UniformsUtils.merge([THREE.UniformsLib['lights'],
185+
{
186+
baseColor: new THREE.Uniform(new THREE.Vector3(0.2588, 0.2588, 0.2588)),
187+
subsurface: new THREE.Uniform(new Number(0.0)),
188+
metallic: new THREE.Uniform(new Number(0.0)),
189+
specular: new THREE.Uniform(new Number(0.0)),
190+
specularTint: new THREE.Uniform(new Number(0.0)),
191+
roughness: new THREE.Uniform(new Number(0.74)),
192+
anisotropic: new THREE.Uniform(new Number(0.0)),
193+
sheen: new THREE.Uniform(new Number(1.0)),
194+
sheenTint: new THREE.Uniform(new Number(0.6)),
195+
clearcoat: new THREE.Uniform(new Number(0.0)),
196+
clearcoatGloss: new THREE.Uniform(new Number(0.0)),
197+
}]),
198+
lights: true,
199+
vertexShader: shaders.principled_BRDF.vert,
200+
fragmentShader: shaders.principled_BRDF.frag
181201
})
182202
}
183203
};

pbr/scenes/demo02.js

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/* DEMO 02
2+
* A demo scene with lights and objects using the Principled BRDF.
3+
* --------------------
4+
* Una escena demo con luces y objetos usando el BRDF Principled.
5+
*/
6+
7+
document.title = "BRDF - Scene: Demo 2 [Principled BRDF]";
8+
9+
// Scene
10+
scene.background = new THREE.Color(0x639ec7);
11+
bgcolor.Background = "#639EC7"
12+
13+
// Camera position
14+
camera.position.z = 5;
15+
16+
// Lights
17+
var ambientlight = new THREE.AmbientLight(0x4e5155);
18+
var directionalLight1 = new THREE.DirectionalLight(0xffe1d1, 1.0);
19+
var pointLight = new THREE.PointLight(0xffffff, 1, 100);
20+
var spotLight = new THREE.SpotLight(0xff0000, 1.0, 6);
21+
var spotLight2 = new THREE.SpotLight(0x00ff00, 1.0, 6);
22+
var spotLight3 = new THREE.SpotLight(0x0000ff, 1.0, 6);
23+
24+
// Default light values
25+
directionalLight1.position.set(3, 4, 0);
26+
directionalLight1.target.position.set(2, 3, 0);
27+
pointLight.position.set(0, 0, 2);
28+
spotLight.position.set(5, 1.5, 0);
29+
spotLight.angle = THREE.Math.degToRad(25);
30+
spotLight.distance = 2;
31+
spotLight.target.position.set(3, 0, 0);
32+
spotLight2.position.set(-5, 1.5, 0);
33+
spotLight2.angle = THREE.Math.degToRad(25);
34+
spotLight2.distance = 2;
35+
spotLight2.target.position.set(-3, 0, 0);
36+
spotLight3.position.set(0, 1.5, -5);
37+
spotLight3.angle = THREE.Math.degToRad(25);
38+
spotLight3.distance = 2;
39+
spotLight3.target.position.set(0, 0, -3);
40+
41+
// Helpers
42+
var helper1 = new THREE.DirectionalLightHelper(directionalLight1, 1);
43+
44+
var pointLightHelper = new THREE.PointLightHelper(pointLight, 1);
45+
46+
var spotLightHelper = new THREE.SpotLightHelper(spotLight);
47+
var spotLightHelper2 = new THREE.SpotLightHelper(spotLight2);
48+
var spotLightHelper3 = new THREE.SpotLightHelper(spotLight3);
49+
50+
var lights =
51+
{
52+
ambient: ambientlight,
53+
directional:
54+
{
55+
names: ["Directional Light"],
56+
lights: [directionalLight1],
57+
helpers: [helper1]
58+
},
59+
point:
60+
{
61+
names: ["Point Light"],
62+
lights: [pointLight],
63+
helpers: [pointLightHelper]
64+
},
65+
spot:
66+
{
67+
names: ["Spot Light R", "Spot Light G", "Spot Light B"],
68+
lights: [spotLight, spotLight2, spotLight3],
69+
helpers: [spotLightHelper, spotLightHelper2, spotLightHelper3]
70+
}
71+
}
72+
73+
addLightsToScene(lights);
74+
75+
// Geometry
76+
var plane = new THREE.Mesh(new THREE.PlaneBufferGeometry( 10, 10 ), materials.principled.cloth_floor.clone() );
77+
plane.rotation.x = THREE.Math.degToRad(-90);
78+
plane.position.y = -1.5;
79+
var plane2 = new THREE.Mesh(new THREE.PlaneBufferGeometry( 10, 5 ), materials.principled.cloth_floor.clone() );
80+
plane2.position.y = 1;
81+
plane2.position.z = -5;
82+
var cube = new THREE.Mesh( new THREE.BoxBufferGeometry( 1, 1, 1 ), materials.principled.gold.clone() );
83+
var sphere = new THREE.Mesh(new THREE.SphereBufferGeometry( 0.5, 32, 32 ), materials.principled.lowplastic.clone() );
84+
sphere.position.x += 2.0;
85+
var cone = new THREE.Mesh(new THREE.ConeBufferGeometry( 0.5, 1, 32 ), materials.principled.aluminium.clone() );
86+
cone.position.x -= 2.0;
87+
88+
var objects =
89+
{
90+
names: ["Floor", "Wall", "Cube", "Sphere", "Cone"],
91+
objs: [plane, plane2, cube, sphere, cone],
92+
shaders: ["principled", "principled", "principled", "principled", "principled"]
93+
};
94+
95+
addObjsToScene(objects);
96+
computeAllTangents(objects);
97+
generateGUIforScene(lights, objects);
98+
99+
var animate = function () {
100+
resDisp.Resolution = parseInt(renderprops.Resolution_Scale*window.innerWidth)+"x"+parseInt(renderprops.Resolution_Scale*window.innerHeight); res.updateDisplay();
101+
resDisp.Vertices = ""+parseInt(renderer.info.render.vertices); verts.updateDisplay();
102+
resDisp.Faces = ""+renderer.info.render.faces; faces.updateDisplay();
103+
fpsstats.begin();
104+
msstats.begin();
105+
render(scene);
106+
msstats.end();
107+
fpsstats.end();
108+
requestAnimationFrame(animate);
109+
};
110+
111+
animate();

0 commit comments

Comments
 (0)