I have a simple scene where I’m trying to render a mesh with an alpha blended inside of an unlit sky sphere (PBR renderer). It’s very close to the PBR material example, except the material is set to alpha blending like below:
// Geometry var water = new h3d.prim.Sphere(1, 128, 128); water.addNormals(); water.addUVs(); var waterMesh = new h3d.scene.Mesh(water, root3d); waterMesh.material.blendMode = Alpha; waterMesh.material.mainPass.setPassName("alpha") waterMesh.material.color = new h3d.Vector(0, 1, 1, 0.5);
The way the example manages to render the sky sphere unlit without additional lighting side effects is by setting the main pass to overlay on the sky sphere’s material, similar to below.
// Sky sphere var sky = new h3d.prim.Sphere(1, 128, 128); sky.addNormals(); sky.addUVs(); skyMesh = new h3d.scene.Mesh(sky, root3d); skyMesh.scale(10); skyMesh.material.mainPass.culling = Front; skyMesh.material.mainPass.setPassName("overlay");
Rendering the skysphere during the overlay pass would be fine if all of the materials in the scene have their BlendMode set to None, because unfortunately blended materials render behind the overlay.
If I try to move the sky sphere material to “default”, then it renders with lighting, even if I set enableLighting to false on the mainPass:
// Sky sphere var sky = new h3d.prim.Sphere(1, 128, 128); sky.addNormals(); sky.addUVs(); skyMesh = new h3d.scene.Mesh(sky, root3d); skyMesh.scale(10); skyMesh.material.mainPass.culling = Front; skyMesh.material.blendMode = None; skyMesh.material.mainPass.setPassName("default"); skyMesh.material.mainPass.enableLights = false;
So from here, I tried setting the emissive property to 1 on the skysphere, expecting that it would at least render the sky sphere as if it’s fully lit regardless of lighting. It does, but (understandably) this has the additional affect of almost fully lighting the translucent geometry in the scene.
(Will attempt to post screenshot of this in second post… Discourse limited me to 1 image per post due to me being a new user)
So my question is: Is there a simple way to setup a material shader such that it’s unlit and doesn’t have lighting side effects (other than the environment map, which I believe is working as intended)?
I’m sure I’ll eventually figure it out by fumbling around with the shader classes under h3d and constructing a new shader list, but it feels like there’s going to be a trivial way to do this with the existing material stack that I missed.