repo: janusweb action: commit revision: path_from: revision_from: 837eff35e568857600a78b7e3678f9971a3589b2: path_to: revision_to:
commit 837eff35e568857600a78b7e3678f9971a3589b2 Author: James BaicoianuDate: Sun Dec 2 01:44:46 2018 -0800 Respect texture alpha when casting shadows diff --git a/scripts/object.js b/scripts/object.js
--- a/scripts/object.js
+++ b/scripts/object.js
@@ -530,7 +530,23 @@ elation.require(['janusweb.janusbase', 'janusweb.websurface'], function() {
if (this.depth_test !== null) {
m.depthTest = this.depth_test;
}
-
+ // If our diffuse texture has an alpha channel, set up a customDepthMaterial / customDistanceMaterial to allow shadows to work
+ if (true) { //this.shadow && m.transparent && m.map) {
+ if (!n.customDepthMaterial) {
+ n.customDepthMaterial = new THREE.MeshDepthMaterial({
+ depthPacking: THREE.RGBADepthPacking,
+ map: m.map,
+ alphaTest: 0.5
+ });
+ }
+ if (!n.customDistanceMaterial) {
+ n.customDistanceMaterial = new THREE.MeshDistanceMaterial({
+ //depthPacking: THREE.RGBADepthPacking,
+ map: m.map,
+ alphaTest: 0.5
+ });
+ }
+ }
//m.needsUpdate = true;
m.skinning = useSkinning;
}
-----END OF PAGE-----