-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom render passess & Implementing shadows #186
Comments
XML3D already has basic shadow support for spotlights, you can turn it on by giving the light a castShadow boolean: <light model="urn:xml3d:light:spot">
<bool name="castShadow">true</bool>
<float name="shadowBias">0.001</float>
</light> If you need soft shadows or ones that work for different light sources too then you'll need to write the necessary render passes for that. Since you have access to the WebGL context (gl) you can do pretty much anything there, including activating extensions like WEBGL_DEPTH_TEXTURE. Just be wary of any shadow rendering algorithm that requires rendering to floating point textures. The extensions governing that are a mess and the majority of devices out there probably don't support it. Every RenderPass gets the You can save the contents of the canvas by generating a dataURL for it and either downloading it or using it as the src for an img element: var url = document.querySelector("canvas").toDataURL();
var img = document.createElement("img");
img.src = url;
document.appendChild(img); |
What do you mean I can ignore Appending new textures to default pass Objects Sorting
Couldn't this be changed for: Whereas
|
The render pass has access to the active camera through Check out vertexattribute-pass.js, that's really the most bare bones way of rendering all the objects in the scene with a different shader program. It uses the SceneRenderPass as a "parent class", uses a custom shader and then calls the SceneRenderPass's scene.systemUniforms["depthTexture"] = [this.inputs.depthBuffer.colorTarget.handle];
this.renderObjectsToActiveBuffer(scene.ready, scene, target, scene.systemUniforms, [], {
transparent: false,
program: this._program
}); The only catch here is that SceneRenderPass is not exposed outside of xml3d.js, so if you want to create your own render pass using it as a XML3D.webgl = {};
XML3D.webgl.BaseRenderTree = require("./renderer/webgl/render-trees/base.js");
XML3D.webgl.BaseRenderPass = require("./renderer/webgl/render-passes/base.js");
XML3D.webgl.SceneRenderPass = require("./renderer/webgl/render-passes/scene-pass.js"); If you don't need sorting (for example for transparency) then you don't need to sort the objects, especially if you're rendering them all with a custom shader anyway. Just note that if you use the |
What is the simple way to implement shadows given tools we have withing XML3D?
What I need is two pasess.
One that renders whole scene geometry into depth map, then sends this as a texture to the next pass.
Second pass also renders whole geometry but with different shaders. Is that possible?
I mean somehow easier than manually giving whole geometry to the pass and setting shaders.
The whole difference would be replacement shaders within "normal" pass.
EDIT: if it would be too hard to do shadows I can somehow bake them.
How can I save current canvas into downloadable image?
EDIT2:
There is an extension to webgl that allows you to render depth into the same buffer.
The text was updated successfully, but these errors were encountered: