Mirror Texture Distortion by Normal Map

Now I got the mirror texture working from this,
http://www.tutorialsforblender3d.com/Game_Engine/VideoTexture/VideoTexture_Mirror_1.html

And I added a Normal map that looks like water and all, but I have one problem.

The normal map distorts as it should, but not in a non reflective way like I want it to.

I want it reflect like this, how real water does by distorting what its reflecting with ripples and all.

But I get this,


I mean its good, but it doesn’t distort the image like it should! I’ve tried putting the Mirror texture mapping on reflective instead of UV, but that just makes it one solid color!

So any ideas? I attatched the .blend in question! As always, thanks in advance! :smiley:

Mirror reflection.blend (1.23 MB)

Actually, the normal map isn’t distorting the mirror texture in any way. I think you can distort it by using nodes (and get the effect you want). Add the normal map color to the UV vector, and use it as vector in the texture node.

EDIT:

For example:
Without distortion:


With distortion:


Use your mirror texture in the texture node from the top, and the normal map below. If you want to change the intensity of the distortion, change the “fac” value in the mix node.

Doesn’t work, :confused:

The Mirror Texture script requires that the texture it’s putting it’s mirror onto has to be in a specific Texture Channel.

Is there another way besides nodes? I mean, Unless you can make the script find the texture in a specific node, then that would do it!

This script below as you can see requires it be in a specific texture channel.

######################################################
#
#    Mirror.py        Blender 2.5
#
#    Tutorial for using Mirror.py can be found at
#
#    www.tutorialsforblender3d.com
#
#    Released under the Creative Commons Attribution 3.0 Unported License.    
#
#    If you use this code, please include this information header.
#
######################################################

# import bge module
import bge

# get the current controller
controller = bge.logic.getCurrentController()

# get object script is attached to
obj = controller.owner

# check to see variable Mirror has been created
if "Mirror" in obj:
                
    # update the mirror
    obj["Mirror"].refresh(True)

# if variable Mirror hasn't been created
else:

    # get current scene
    scene = bge.logic.getCurrentScene()

    # get the mirror material ID
    matID = bge.texture.materialID(obj, "MA" + obj['material'])

    # get the active camera
    cam = scene.active_camera 
            
    # texture channel
    if 'channel' in obj:
        
        # set texture channel
        texChannel = obj['channel']
    
    else:
        
        # use texture channel 1
        texChannel = 0

    # get the mirrortexture
    mirror = bge.texture.Texture(obj, matID, texChannel)
    
    # get the mirror source
    mirror.source = bge.texture.ImageMirror(scene, cam, obj, matID)

    # save mirror as an object variable
    obj["Mirror"] = mirror
    

In the node “Texture” add the texture that you would otherwise use for rendering the texture. Also make sure this is selected in the rendered object texture.

You could learn to use Du Dv maps, but I am not sure if it works for reflections.

I don’t think you understand, Carlo697’s node set up Works, I just need the mirror texture to be in a node!

Like I said above, the mirror image is assigned to any texture in a certain texture channel on the objects material. if I can get the script to assign the mirror image to a node instead of a place in the texture channel, it should work! So, my question now is how do you get python to get nodes? Or, assign images to nodes?

You can’t edit nodes in-game, the mirror script get the texture from one specific channel, for example, the channel 0, so the texture that is in that channel will be the texture that the script write to, so that’s the texture you have to put in the texture node.

See this example of the node setup working with a mirror (base is from tutorialsforblender3d.com):


File: Mirror.zip (132 KB)

Nice effect! I don’t know anything about nodes, but this makes me want to learn. Thanks for sharing carlo697!

GSL Nodes are very powerful, I wish there were some examples that came with blender,

Splendid! Exactly what I needed, thanks Carlo697! :smiley: