Refraction script idea
All  1-3  4-6

Previous
Next
 From:  Michael Gibson
10709.4 In reply to 10709.1 
Hi Fubax, the node editor might be an easier place to start if you haven't done any script programming before at all:
https://moi3d.com/wiki/nodeeditor

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 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


  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Mik (MIKULAS)
10709.6 In reply to 10709.5 
It would be useful also if the node respected law of reflection. It means to have point/flat light source (solid) with rays (curves) as an input and curved surface - reflector (rotate conic curve) with Rho as a variable. Rays impacted of surface would be reflected to the detector (plane) in specific distance. This would be very nice educative tool. 2D would be enough :-)

Mik
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages: All  1-3  4-6