I’m trying to create a simple fresnel effect in the emissive channel of the material, using a shader chunk. It seems like something like this should work for a very basic effect:
Not sure why you get such a message, the code seems mostly right. I’d say if you aren’t using the texture_emissiveMap sampley uniform then remove that from your code.
If you keep getting that error try sharing a sample project url to take a look.
Ah so, the error I am getting is a dimension mismatch, and it makes sense. Since the result of your max/dot operation results in a float which can’t be assigned to a vec3.
However, that doesn’t seem to actually produce any result. I’ve deleted the light in the scene so I can see the emissive easily, and there’s no emissive.
Simply putting something like:
return vec3(1.0, 0.0, 0.0);
Works fine, so the shader chunk is working. Am I using the wrong variables to get the dot between normal and view direction?
I think it does, it just depends from what angle you see it. Disabling all lights though I think it makes the material shader revert to a simpler pipeline that doesn’t use this chunk.
Try lowering your light intensity to 0.01 and you will get something like this:
as you can see, i hardcoded the values for the typical bias, power and scale, but that’s ok for the moment.
What really stole some time was the fact that i was using vec3(0,0,0) as emissive1 because i thought that would be black and NO emission at all. But somehow it turned out, that it had the opposite effect. The middle was white and the blueish emission was really hard to see, like this:
When i use vec3(1.0) as the “middle” color, i get the results as expected. Just the normal material on the middle and a blueish emission on the “edges”: