How to "project" on only nearest face of DX11 geometry?

ConstantProjection (DX11.Effect) “projects” on both the front and back sides of an object. There is a DX9 version, ProjectedTexture (EX9.Effect) that has a front face-only input pin to toggle this behavior.

Seems like I figured this out in the dim past, but maybe I’m just thinking of the DX9 version. Is there a way to do this in DX11? I looked at the code in the DX9 shader, which is a very simple conditional:

    //show only if projection comes from the front
	if (FrontOnly)
    	if(input.angle.x < 0) 
			col = BorderColor;

but no idea how to do something similar in the DX11 ConstantProjection code. Athankew!

Not sure I get you right, maybe you’re looking for SV_IsFrontFace?

The issue is not the side of a face that it is projecting on, it’s that it puts the image on the side of an object opposite the “projector” as well as the side closest to it. If you run the help patch for ProjectedTexture (EX9.Effect) and toggle the “front project only” toggle you’'ll see what I mean (you’ll need to rotate the view to see it, such as on the back of the handle).

ConstantProjection (DX11.Effect) does not have this toggle, and always projects on the side opposite the projector. I just don’t know how to do the same thing in DX11 as in that DX9 code snippet above, such as how to get that angle to test.

I think there might be a test with z w components after the projection is applied.
I’m not sure but it is possible that if projected point’s z component less then 1 means that it’s oposite direction from camera, but i can be wrong… The second option also, on PointeditorCS i remeber i had this problem with selection, that you had vertices behind your camera selected also, maybe there is some fix in the selecting shader.

Hmmm I thought about this a bit more, and realized that angle test really just eliminates faces away from the projector, but does not do what one would really want which is to use only the first or closest face to the projector. In the attached modified DX9 help patch, you can see that the handle does not cast a shadow on the pot, and in fact the spout gets the image too though it is behind the pot from the projector’s perspective.

So to realy work like one would expect, seems like this should work like a shadow-casting point light with a gobo. I expect a depth map is used in there somewhere, dunno, never looked into shadow code.

I’m trying to visualize in DX11 what a multi-projector setup will look like in a complex environment, and all this back face and no shadow business is making it a total mess. Odd this hasn’t come up more; there is an old thread about the DX9 version along these lines, but surely other folks have tried to do similar visualizations since then…

ProjectedTexture noshadow.v4p (16.8 KB)

Back in the days there was a patch by Elliot to simulate physical projectors I think. I guess with some tinkering to find out your FOV you can also use Superphysical and a spotlight to project your texture. Volumetric lights in the superphysical engine will also make it look nice in simulations.

why not visualize multi-projectors under superphysical with spotlight texture ?

@mediadog have you considered doing this in vvvv gamma instead? VL.Stride comes with a node called ProjectorLight that should be very convenient to do exactly that. for an example see the “Project a texture” howto in the helpbrowser.

@ggml and @joreg thanks for the suggestions, and yes Superphysical can do it, but those are both pretty high-impact solutions, not something that can be easily slid into existing applications.

flashback friday! i have a fairly lightweight solution using vanilla DX11 that might fit your requirements: ProjectorCoverage (DX11).zip (10.2 KB)

1 Like

Poifect! And the projectors even add on common faces. Thanks a ton!