I’ve poked around, but can’t find a DX11 equivalent of the DX9 shader. Is there one? If not, any pointers to converting DX9 shaders to DX11? The vertex shader sections look different enough that it is not obvious to me what to do there. Thanks folks!
There is this guide on shader porting from DX9 to DX11
it’s called constantprojection, connect your view projection to transform pin i think
Close, but does not work like ProjectedTexture, see this comparison patch. Looks like it may be a bug, as the mapped texture is shifted from where it should be. Thanks for the pointer though, I’ll look in ConstantProjection and see if I can figure out what’s going on.
ProjectionComparison.v4p (29.4 KB)
Looks like the shift is in the pixel shader, psPROJ(). This line:
has that offset at the end unlike the DX9 version. When changed to this:
then it does a correct world projection and matches the DX9 shader.
Not sure why that bit was at the end, I suspect for the other modes. Probably needs separate pixel shaders. @vux any suggestions?
i’m pretty sure the ConstantProjection shader works perfectly correct. This looks more like a bug in dx9 version, so TextureSpace not gonna work with dx11 version, basically dx9 coords and dx11 coords are different i setted up a helper so you can see what’s happening…
Seems like PerspectiveLookAtRect outputting incorrect
ProjectionComparison-1.v4p (32.7 KB)
and just in case you missed it, there is a new ProjectedTexture (EX9.Effect) now shipping with b35. see its helppatch for instructions.
@antokhio, PerspectiveLookAtRect is fine, I use it in many places. And as can be seen with the DX9 version on the right, for a given light point, and a given image location, it projects it exactly correctly on the torus. (This is basically the girlpower\Graphics\DX9\Shader\slide projector example). Your addition is missing making the Box 2x bigger (look in PerspectiveLookAtRect or nodes like CameraCone EX9 that display a frustum) which is why the frustum looks too small.
And a transform matrix is a transform matrix is a transform matrix, it is a mathematical entity independent of rendering pipelines. What is apparently happening in this DX11 shader, is that it is trying to take the texture transform input, and handle it like a world space object transform, and doing the conversion internally. Which explains the “DoubleScale” pin which looks like a kludge (turn it on and the projected image gets the right size).
The newer DX9 version that @joreg points to seems to have taken a different approach, and takes separate input transforms to do the projection, leaving the texture transform alone. Other than having a seemingly needless inverse input pin (why can’t that just be done internally - what does it buy?) it seems like another useful form of doing a projection; the girlpower shader works great for where you want to project an arbitrarily positioned “slide”/shadow that is in the model, and the newer one is good for when you just want to define the projection frustum with a traditional view/projection.
But the DX11 version does not jive with either of these. And as I mentioned, I suspect that is because it is somewhat overloaded in trying to do the various space projections internally via the texture transform, and that just needs to be properly sorted out.
ProjectionComparison2.v4p (34.3 KB)
Oh, and I guess you can use the new DX9 version with the for the slide projector example as well, since that PerspectiveLookAtRect does have projection and view outputs. So the newer one does look like the better case…
ah ye forgot to mention there is double size bool
The only reason for this is performance: calculating the inverse once instead of for every vertex (inside the shader) should save some ticks.
Ah, makes sense. Something like that that will always need to be done should be wrapped in a patch then - fewer mouse-clicks for the users and fewer chances to screw up - defensive coding.
Is there any chance to achive the exact same effect as is in the 3d projection mapping tutorial (DX9) in DX11 with the constantprojection shader ?
there is few days now that I am trying without any success, whatever I do I get always a very distorted projection (in the virtual and on the physical object too)
hei nissidis, i’d recommend starting a new forum thread where you upload a patch that demonstrates your problem.
thx Joreg, I will
Well, while I’m reading this, here is a patch that works for me with the DX11 version. You specify where the projector is, what it is looking at, and the field of View.
UserProjector.v4p (15.0 KB)
I will check it right now, just for the history, I opened a new thread for it , as @joreg kindly recomended.
3D Projection Mapping on Geomtery (DX11)
nope :/ I still getting the image upside-down and distorted.
Ooops, the above UserProjector.v4p was using a ConstantProjection I had hacked around on not the stock DX11 one. For others reading here, the correct solution is in the new thread above.
It would still be nice to have a DX11 way of doing this that was pin-compatible with DX9, just to make patch porting easier as the differences are obviously confusing if you are not familiar with the internal concepts.