Moving the highlights in this water material

Hi all. I’ve been digging into this water material that I converted from some HLSL code.

float3 reflected_eye_to_pixel_vector;
float specular_factor;
reflected_eye_to_pixel_vector = -pixel_to_eye_vector + 2*dot(pixel_to_eye_vector , microbump_normal) * microbump_normal;
specular_factor = fresnel_factor * pow(
    max( 0, dot( pixel_to_light_vector , reflected_eye_to_pixel_vector ) 
    ), SpecularPower);
return specular_factor;

The code is NOT important. The material works exactly the same once I converted it. It’s more for reference for those who understand it.

I converted it into a material function:

The goal of the function is to create the specular highlights and winks you get in real life water. This is created by blowing out the highlight temporarily in the emission channel to explode the bloom while also shading the water with proper specular reflections. It almost works exactly as intended. This is the result:

What I’m trying to do is take the beautiful winks of light from the bottom right of the frame to where you can see the wash of specular light on the water in the rest of the frame. For some reason the glitter highlights are offset from the rest of the specular highlights and I’m not sure why.

Anybody got a clue?

It could potentially be a scene depth or pixel depth. Since my knowledge of hlsl is negative at best, I couldn’t answer how the magic works yet, just that something is 90% working somewhere. On the vector multiply question, yes that’s correct. I’m reversing the camera vector to get the opposite. Why? No idea haha. I picked up the code from the forums probably about 5 or 6 years ago and dredged it up from the archives for a recent project.

I’d think it would call for a scene depth and/or pixel depth nodes to render to for the camera to get it across the whole surface. Why is the Input Camera Vector Multiply at -1? Is it basically drawing or getting a negative vector from the camera?

It may be the negative vector needs a scene depth, or scene capture, or something similar to project the glimmering effect across the water. Not sure if it would require a multiply, divide, lerp, or what node though. So far, I think it is probably attempting to draw the effect and is restrained by what’s missing in the material network, or perhaps what’s in the network is shuffling it off to the side of the view. In that corner of the screenshot (lower right), is it positive space, negative space, or a combination? as in, which of the 3 axes are in that direction, positive or negative for each axis? When multiplying a vector by a negative, it could be switching the render priority in XYZ space without a scene depth or some other node that defines where to render it. That’s what I’m saying, though I could be wrong.