Sure is. You just have to constrain your render to only render the objects you want. In this example, the ground plane is rendered but the torus is not.
EDIT…
WAIT. I just re-read your post, let me try to wrap my head around what that would look like. base_only_shadows.tox (2.75 KB)
Using a custom GLSL shader, with TDHardShadow/TDSoftShadow you could get the shadow value for the pixel. Then you can output alpha based on that value. You can do this in a separate color buffer to avoid the need to do two passes.
So, I want to create an surreal effect for a theater-show where an projector is used to “project shadow” without the physical light situation being changed.
I created a scene with a body geometry, lights and a floor geometry, where the shadows should be casted onto. The rendered image will then be projected on the stage.
Now, I want to kind-of separate the shadow of the body, keeping the rest of the lighting situation constant.
So my idea was to create a GLSL material that has either a constant color (white) when there’s no shadow on it or it’s gonna be black when there’s a shadow…
I created a simple (erroneous) pixel shader with sth like that (here with red and green):
camSpaceVert refers to a position (vert as in vertex position) in the ‘camera space’, meaning that position and scale etc is based on the camera properties as opposed to the world space, which is how vertices will arrive in a vertex shader.
There are TD functions to convert a vertex position between different spaces - essentially converting from an absolute position to a position relative to the cameras.
// For example you'd transform the vertex in SOP space into camera space with this line of code
// vec4 camSpaceVert = uTDMats[TDCameraIndex()].worldCam * vec4(P, 1.0);
But in 099, it looks like a worldspace position would work:
float TDHardShadow(int lightIndex, vec3 worldSpacePos);<br>
// This one will apply soft shadows with both 25 search steps done, and 25 filter samples.
float TDSoftShadow(int lightIndex, vec3 worldSpacePos);<br>
// Allows for control of search steps and filter samples.
float TDSoftShadow(int lightIndex, vec3 worldSpacePos, int samples, int searchSteps);
OK, sounds reasonable.
So, the vertex in camera space also refers to the currently processed pixel, just in a different space?
So I would have to figure the current pixel and find the corresponding vertex in camera space?
I was also looking in these transformation function but was wondering that they all return vec4… I seem to be looking for some vec3
That actually was the right path and it was quite easy to solve:
Vertex shader:
[code]
out vec3 vertex;
void main()
{
vertex = P.xyz;
// P is the position of the current vertex
// TDDeform() will return the deformed P position, in world space.
// Transform it from world space to projection space so it can be rasterized
gl_Position = TDWorldToProj(TDDeform(P));
Nice work! Before you solved it, I was going to say that the pixel position in a fragment shader should already be in camera space, so it may just work. But yes, you need some sort of minimum code in vertex shader too.
What I would have replied to your previous question is that the vertex shader runs once per vertex in your model, but shadowing happens in the fragment shader, per pixel, so your answer probably laid there.
I always try to start a shader from the phong material, with as many elements I need all fleshed out, so there’s no custom TD stuff missed off in my custom shader.
out vec3 vertex;
void main()
{
vertex =TDDeform(P).xyz;
// P is the position of the current vertex
// TDDeform() will return the deformed P position, in world space.
// Transform it from world space to projection space so it can be rasterized
gl_Position = TDWorldToProj(TDDeform(P));
}