Jump to content

Cool Ice Effect


havenphillip

3,283 views

 Share

Here's a cool effect I don't know why I didn't think of this sooner. This shader uses parallax occlusion and a trick similar to that in the weeper (22a_weeper). The idea is that you can get a cheap refraction effect by multiplying the texture coordinates of the diffuse texture with the normals (naturally you'd have to establish the diffuse "outcolor" after you establish the normals). It looks something like this:

float amplitude = 0.1;
vec4 outcolor = texture(texture0,ex_texcoords0 + normal.xy * amplitude);

That's pretty much the gist of it. What this does is it warps the diffuse texture coordinates by the normals. But adding the normals to the texture coordinates pushes the effect to one side so I took it a step further by subtracting the ex_normal from that and the difference creates a nice centered refraction effect against the diffuse texture.

vec2 n1 = normal.xy * amplitude;
vec2 n2 = ex_normal.xy * amplitude;
vec4 outcolor = texture(texture0,ex_texcoords0 + n1 - n2);

In the weeper shader I added time to the normal texcoords and that makes an effect like water dripping down a wall. Here I didn't need that because this is ice. It's stuck in place.

Once I got that established I added parallax to the diffuse texture. I used texture4 in this shader for my "outcolor" because I reserved texture0 for the little scratch marks on the surface of the ice.

vec4 refractcol = texture(texture4, parallaxed_texcoords.xy + n1 - n2);

After this I finished the color by mixing the outcolor and the refractcol by a "lighten" blend mode I found on Github.

If you look at the normals and the outcolor in the shader you'll notice I didn't use the parallaxed texcoords because I wanted the surface to remain where its at and give the impression that there is something sort of encasing the "ice" i.e., the surface of the object - what the light bounces off of. The whole "ice" effect happens under some surface, right?

I also z-sorted the object, which gets rid of the shaded sides (like ice doesn't really have a shadowed side does it?) and because of that I lost the specular so I added a blinn-phong to replace it. Also I added a cubemap to simulate reflection.

I think this would work great as a frozen lake or an iceberg. Maybe even as ice cubes. It doesn't take the screen into consideration like the creek refraction does so you still technically have an opaque object. It's also parallax which notoriously has trouble with curves. I've added a few tricks so that the parallax can work on gentle slopes. You can adjust the texture sizes, the light, the cubemap fresnel, the parallax depth, the refraction amount, and the ice "contrast." If you put it on your own model you'll have to adjust the texture sizes and stuff but it's set up to work on a Leadwerks box brush so you can just slap it on one of those to quickly see it in action. The picture doesn't do it justice you have to move it around to see the effect. Anyway it's something fun. 

232855603_icything.thumb.jpg.1c3d5a0f097b3ff302766cd6cc7b1b12.jpg

 

27a_ice.zip

  • Like 8
 Share

9 Comments


Recommended Comments

Wow! It really looks like there are solid pieces of ice inside the object when I view this in the material editor.

  • Like 1
Link to comment

@havenphillip Thanks to this Shader, you have given me a cool idea that I am going to use inside one of the maps of "Thanks to the people of this forum" within FotoMuseo 3D:

I know it's not the same as modeling a frozen body, but from the optimization work I love this. Being able to take your idea and add something inside the ice with Photoshop.

I have use this image...

  • Like 4
Link to comment

The ice rock was created using a rock model inside Leadwerks and changing the texture with yours...

Love this Shader, seriously!!!

  • Like 1
Link to comment
On 3/15/2023 at 8:48 PM, havenphillip said:

That ice rock looks pretty cool. What other shaders should I attempt?

Hi havenphilip,

Would it be possible to make a shader that generates water little circle-waves around the position, where for exampl someone would have thrown a stone in water?

Would you have a start idea for this or is that a way impossible?

Link to comment
On 4/21/2023 at 7:24 AM, Marcousik said:

Would it be possible to make a shader that generates water little circle-waves around the position, where for exampl someone would have thrown a stone in water?

 

Best I can come up with is to find a simple ripple shader on Shadertoy and then get normals from that noise and plug it into a decal shader, then just use it like you would in your tire tread decal system. I made one and tried it on the FPS gun bullet decal material. It works ok. I left the diffuse output at 0 so only the normals show up. You can adjust the speed, zoom, frequency and centering on the ripple. I found one where the ripples fade out on the edges. Also that's how the decal material is set up I don't know how much that matters to the effect:

974020529_decalripple.thumb.jpg.c4349ff291e38ea963bfd7720da70c83.jpg

 

decal ripple.zip


 

  • Like 5
Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...