Hello guys!
After some days of struggling I finally get this to work.
This video illustrate the technique.
[ame="
http://www.youtube.com/watch?v=Bvar6X0dUGs"]Local Image-based Lighting With Parallax-corrected Cubemap - YouTube[/ame]
Technique comes from
here.
Credit for the node base approach:
http://oliverm-h.blogspot.fr/2013/10/wip-parallax-corrected-cubmaps-in-udkue3.html
This is my implementation and it's far from perfect.
Benefits:
- It uses custom actors to speedup the creation process (instead of manual input of coordinates).
- It uses
OOBB.
Drawback:
-
It only updates when starting the game not in the editor.
- It does not support BSP volume correction .
- It not optimized for production.
- It uses Pawn's location for weighting and may not work with cinematic Cameras.
First of all download the
PACKAGE.
As usual please Backup before you overwrite. To install you need to put the .uc script files here:
CustomPawn.uc -> $UDKInstallFolder$\Development\Src\CustomGame\Classes
Object.uc -> $UDKInstallFolder$\Development\Src\Core\Classes
others .uc -> $UDKInstallFolder$\Development\Src\Engine\Classes
Start Unreal and compile the scripts.
Then import the .upk and open the .udk file.
Notice: This is a test scene showing one of the worst case you can have.
You can look at the Material setup and reuse the MaterialFunction as you want.
Quick setup
1. First create a
ParallaxCorrectedCubemapActor from the Actor Class tab and use it like a typical SceneCaptureCubemapActor.
2. Create a
textureRenderTargetCube and plug it to the two inputs :
-
ParallaxCorrectedCubemapActor Properties (F4) ->
Scene Capture Actor ->
Texture Target
-
ParallaxCorrectedCubemapActor Properties (F4) ->
Parallax Corrected Cubemap Actor ->
Cubemap Texture
3. Create a
ParallaxCorrectionVolume and make it match the bound of your room.
4. Plug the
ParallaxCorrectionVolume to the
ParallaxCorrectedCubemapActor.
5. Create a material with the same
parameters' names as the reflection material in the upk to the
ParallaxCorrectedCubemapActor.
6. Plug the the material in the
static Linked Materials list of the
ParallaxCorrectedCubemapActor
At this point if you launch the game (in PIE) it will update the values of the materials attached to it and the reflections will appear corrected! WIN!
If you want to make the texture
offline (not updated during gameplay):
1. Make a static texture out of the
renderTarget
2. Unplug the
renderTarget from the
CubemapActor
3. Plug the Offline Texture in
Parallax Corrected Cubemap Actor ->
Cubemap Texture
Weighting volumes
1. Create a
CubemapInfluenceBoxVolume or a
CubemapInfluenceSphereVolume (Note: For the sphere use the
Sphere Radius of the Shape in the Actor properties).
2. Plug the
ParallaxCorrectedCubemapActor to the
CubemapInfluenceVolume.
Now if you walk in the influence zone all the dynamic Linked Materials of the CubemapActor will be updated with blending and cubemap to use. Be careful not to leave gaps between volumes otherwise you will have poping issue.
A picture worth a thousand words. Here is a recap:
And here is the result on a more "typical" scene :
Without Parallax Correction :
With Parallax Correction :
We could do better with BSP Volumes but I think it requires access to shader code which is not available in UDK.
I hope it will be useful to someone.
If you have any suggestion or critique do not hesitate to post. I'm willing to learn.
It was my first time coding with UnrealScript.
The last issues are :
- Use camera position to calculate Weighting.
- Global list of dynamic linked materials instead of per CubemapActor list.
- BSP Volume Correction.
Replies