Announcement

Collapse
No announcement yet.

Can Refraction operate on colour channels separately?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    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?
    Last edited by TheJamsh; 06-01-2014, 07:12 AM.

    #2
    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 :P

    Comment


      #3
      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.

      Comment


        #4
        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

        Comment


          #5
          I've figured this out! Woo!
          It's a but buggy because of this issue:
          https://answers.unrealengine.com/que...lor-black.html

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

          Here's a VERY basic implementation


          And, here's the result:


          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.

          Comment


            #6
            Originally posted by DanielW View Post
            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.
            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.

            Comment


              #7
              That's pretty awesome! Thanks for sharing the blueprint nodes!
              Trevor Lee

              Comment


                #8
                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.

                Comment


                  #9
                  Nice work Tom! 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...

                  Comment


                    #10
                    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.

                    Comment


                      #11
                      Originally posted by JonHanna View Post
                      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

                      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.

                      Comment


                        #12
                        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

                        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
                        Last edited by Daedalus51; 07-26-2015, 12:33 PM.
                        Check out UNREAL 4 Lighting Academy
                        https://forums.unrealengine.com/show...ng-like-that-)

                        Comment


                          #13
                          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.

                          Comment


                            #14
                            For those coming here in the future, this is what he is talking about: Click image for larger version

Name:	u3ZjBKp.png
Views:	1
Size:	398.2 KB
ID:	1091143

                            Comment


                              #15
                              Kory, Tom Shannon, thanks.

                              Comment

                              Working...
                              X