Refraction script idea

 From:  Fubax
10709.5 In reply to 10709.4 
Hello, I can try the nodeeditor, thank you for suggesting that.

This is the equation I came up with for producing refracted line



And here's the GLSL code that could do just that, I need to look into MoI scripting.

GLSL code:
vec3 refract(float n_trans, vec3 incident, vec3 normal)
{
	// Scale normal (assuming normal is an unit vector)
	normal *= dot(incident, normal);
	// Preserve incident vector length as squared value
	float sq_length = dot(incident, incident);
	// Scale incident vector tangentially to normal,
	// by transition refraction index (eg. air/glass=1/1.52)
	incident = n_trans*(incident-normal)+normal;
	// Normalize length of refracted incident, to scale along sine
	return -incident*rsqrt(dot(incident, incident)/sq_length);
}


Maybe someone could implement that.

EDITED: 1 Jun 2022 by FUBAX