Can Refraction operate on colour channels separately?

I’m trying to re-create Chromatic Aberration Refraction on a translucent material, later to be use in water or something like a glass lens, but before I waste my time working out how to do it, is it even possible? And is it even possible to do accurately?

At the moment is seems as if refraction just displaces the pixels it refracts, without any control over the resulting colour. So, does anybody know if it’s possible?

I too tried this, but to no avail. You simply cannot access the rendered scene in a translucent material. I was thinking of making a post process blendable that would use custom depth to split the channels, but never got further than that particular shower thought :stuck_out_tongue:

The built in refraction does not support this, but you can do it yourself with a SceneTexture lookup. Post process materials and translucency can lookup the scene texture with offset UVs.

Thanks Dan, how roughly would I go about it then?

You say Translucency can refer to the SceneTexture? All I would need to do then is mask each channel and offset each by ‘x’ amount, then pass that information back into the diffuse, or probably emissive?

EDIT: The Scene Texture entry in the unreal engine documents is blank, there’s no documentation at all :frowning:

I’ve figured this out! Woo!
It’s a but buggy because of this issue:

But, if you make a Material instance, you can at least tweak the values while in Simulate mode.

Here’s a VERY basic implementation
http://i.imgur.com/M9UX7dh.png

And, here’s the result:
http://i.imgur.com/YetxzHR.png

There’s still a lot of work to do to make it “production ready” like Fresnel terms, etc. But it should get you going in the right direction. Just remember that you can only see the effect when you either Play or Simulate.

Just to clarify, the SceneTexture lookup won’t work in this case as it only allows the SceneColor to be accessed from a PostProcess shader. I had to use the SceneColor node, specifically.

Also, as ANOTHER side note, I used the BreakOutFloat3 function as the Component mask looked strange when I merged the colors back together.

That’s pretty awesome! Thanks for sharing the blueprint nodes!

Sorry, I forgot there was a SceneTexture and a SceneColor node.

The bug with SceneTexture / SceneColor where it requires going into Play mode should be fixed in one of the next few updates. You can work around it by changing any property on the mesh (and then change it back) after recompiling the material. Or save and re-open the level.

Nice work ! That’s way more than I was expecting, and I didn’t realise we could break and make floats/vectors in the material editor now, that’s going to be helpful as!

Now to work on a very physically accurate implementation…

This method seems like it will work good enough for my use but I’m having trouble duplicating this setup. How do you get a negative value in the vector parameters?
Sorry, I’m new.

Welcome :slight_smile:

You can just type directly in the text edit box to get a negative number, no different to other edit boxes. They don’t necessarily have to be colours.

Just out of curiosity…how can you cast from a float3 to a float2 without getting a compiler error? The parameters are float3 and you plug them into UVs from SceneColor. I get errors with that and when I manually append (or composite mask) only R and G it still looks super weird on a watershader and flickers :frowning:

EDIT: Now that I think about it…the flickering etc could be related to the fact that I am using the new forward rendered translucency. Will try with default TLM_Surface as soon as I have time in the evening :wink:

You can’t do that directly, you have to append a Constant 0 to the Float 2 to make it a Float 3.

Also you need to click on the node and change the setting to the other one (I know, descriptive :P) - I can’t remember the options atm… but you want the one that ‘offsets’ them.

For those coming here in the future, this is what he is talking about:

1 Like

Kory, , thanks.