In the bottom picture I’ve given the low poly model the Lighting material and added a spotlight and shadow.
What I’d like to do is draw the light and shadow colours with the background picture colours. (So the model is effectively transparent, but is used for creating a brightening light effect). So something like this
Render the low poly scene as normal.
Render the background as a quad but without writing or testing for depth (could even just do it in the guiNode but make sure the additional render state’s depth write is turned off for the material)
Use post process shadows.
Edit: actually, can’t be in gui node because post process won’t run on the gui… just put it in the scene in the Gui bucket.
I’m a bit lost though. Currently I’m doing renderManager.createPreView(“background”, cam); and then attaching a Picture to it, and that gave me the background. I intended to render multiple backgrounds for different resolutions (or just use black borders). Either way if I use a quad the image gets scaled since its not p.o.t and does not line up with my view.
Also though, I drew a quad with depth test and write turned off - nothing showed up through it? When you say render the low poly scene as normal, the low poly scene is supposed to be invisible bar its lighting and shadow casts, tbh I’m not really sure what you ment or how that would result in the shadows or lighting how I want.
Thanks for helping though. I have tried the first approach but the resolution was a problem again. I was thinking I might have to use a shader that recieves the background someway, so it can use that as diffuse and light that, but still use the low poly models positions or something?
You will have to explain the situation with the resolution… I’m not sure I understand.
As far as “nothing showed up through it”, that was kind of the point though. The idea was to only render the low poly stuff to fill the depth buffer so that shadows will work… but it occurs to me that you can do it in a more classic ordering by turning color write off.
So, do like you are, render the background however as a background.
Then render the rest of your scene, presumably made of the low poly ‘map’ as well as your moving characters or whatever. It’s just that for the low poly map, turn color write off. You only want to write depth for that since JME shadows are based on depth.
That’s even easier than anything I’ve said so far because you don’t even have to worry about rendering order (other than rendering the background first).
IMO the simplest way to do this is to create a 1,1 quad place it in the sky bucket and have a shader that projects it full screen, and display the background image as a texture.
Then set the lighting material of the scene in blend mode modulate (through the additional render state).
Note that it will only work if your camera doesn’t move.
here is the code of a material I used to project an image on the background in Adventure.
Not sure where the modulate thing comes in. He doesn’t want to actually render the low poly scene… just use it for shadows and occlusion. Rendering it would just be rendering a crappier version of what is already prerendered anyway.
The other part is helpful as it occurs to me that for shadows to work the background will have to be rendered as part of the main viewport and not the preview port as he’s doing now.
Yes… he wants to combine them in the engine… presumably with JME shadows so that his characters walking around, etc. are also in shadow. I could have been wrong about that.
My assumption was that he wants to render a low poly scene with shadows but use the high quality non-shadowed render to drape over the low poly stuff so that it looks nice. Perhaps clarification is in order but that’s what I got from his description.
First, sorry I was not clearer about this, I appreciate you trying to help me.
Using what you first suggested pspeed I did achieve what I wanted and hopefully this explains better what I want:
So made by projecting the uv onto the texture, I have the pre-rendered background visible on the model, the shadows, and the light “lights up” my texture. (Can’t seem to get the projection perfect in blender though, floor is constantly messed up)
What I wanted ideally to achieve though was the exact same but just drawing the background image, then use the low poly mesh for depth, light, and shadow.
With renderManager.createPreView for the background image, and doing what you said pspeed with regards to turning off color write I get the depth and shadow part perfectly:
It is only missing the lighting. Worst case I will go with the projected texture, but ideally I’d like to do it without; I have had nothing but trouble making that projected UV work. Again, thanks for your help.
When I clean up my code to post it I find an ambient light that’s hiding my specular. Oh how I wish I had found that before I posted. So it’s pretty much working perfectly now. I have a few unrelated issues but I will save them for another topic and another day since everything is working so beautifully now.
Glad you got it working. It’s a technique I’ve kind of always wanted to have a reason to try. A few people seem to have tried it on the forum before (or similar) but yours I think is the best looking/farthest along.
Thanks. The graininess is because I set the samples in the render really low to get it done, needs a few hours to get a half decent render. I’m going to be using Kerkythea for the final renders, probably going to take a day each or something horrible.