I’d like to know if it’s possible to do camera projection in UE4. (Like in 3ds Max…camera mapping…for example)
So let’s say I have a room modeled, no textures. I have a static camera set up in UE4.
I’d like to assign one shader to all walls and objects.
This shader would project an image from the camera view onto the walls - objects. Basically the objects ‘disappear’, no edges are visible, only the image as if you’d open it a painting program.
The objects still receive shadows from set up lights and characters walking in the room, but the lights would have no brightening effect on this shader. Only shadow receive.
I’ve been trying to get camera projection working for a while in UE4. It’s certainly possible, but the maths is pretty complicated, and it’s been slow going.
I’m doing the projection as a decal - the other way to apply it would be as a layer in each material in your scene. Hope to get it working better this weekend.
Projecting the matte painting into the emissive channel of a material almost gives the effect you are after - but it doesn’t receive shadows. I’ve been experimenting with putting an ‘ambiently lit’ projection into the ‘emissive’ channel, and a ‘lit’ version into the ‘base colour’ channel. That way, the lighting is still pre-baked, but characters can also cast shadows.
I think it could be a very powerful tool - I just haven’t quite got it working yet.
Yours projects even if the camera is moving, right?
I’ve managed to do what I wanted using ‘screen positon’ fed into the sample texture UV, that goes into diffuse and also into emissive (0.5 multiply)
Now I’d like to figure out how to resize the texture according to the screen resolution.
For example: now the game starts in 1680x1050, the texture file has the same resolution. If I change the play resolution to 1024X768, I’d like the texture to match this and be resized to 1024X768 on the fly. So I need some math in the shader that grabs the screen resolution and if it’s different than the original texture size, it scales the texture to match the new screen res.
Any ideas?
I’m a bit sleepy so I might have misunderstood you, but from what I understand why don’t you just do the projection inside of max instead? then render that out using Render-to-Texture into regular UV sheet (I’ve never tried, just assuming).
Well… that’s assuming that the entire level exists arranged in 3ds Max, which might not be the case, perhaps you’ve arranged this room in UE4.
If I get it all working as intended, the idea is to be able to do many projections from many different cameras - it’s not connected to the player view at all.
Screen position UVs will only work if you want to ‘look through’ the camera you are projecting from - from your description of what you are trying to do, this seems a bit limiting.
Limiting only if you are looking for something else.
This is exactly what I’m looking for so I don’t mind. The only thing left is to solve the scalability of the projection, according to the screen resoluition the game was started in.
@
I thought about that too but I think render to texture is not going to be precise because of different camera properties in ue4 and Max. I’ll do a quick test though…
Update: You can export the camera from ue4 and import into Max. Looks promising!