59 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
shader_type spatial;
 | 
						|
render_mode cull_disabled;
 | 
						|
 | 
						|
uniform sampler2D npcTexture : filter_nearest;
 | 
						|
uniform int frame;
 | 
						|
uniform int direction;
 | 
						|
 | 
						|
const int FRAMES = 3;
 | 
						|
const int DIRECTIONS = 4;
 | 
						|
//const bool BILLBOARD_ROTATION_LOCK = false;
 | 
						|
 | 
						|
void vertex() {
 | 
						|
	//if(BILLBOARD_ROTATION_LOCK) {
 | 
						|
	    //mat4 modified_model_view = VIEW_MATRIX * mat4(
 | 
						|
	        //INV_VIEW_MATRIX[0],
 | 
						|
	        //INV_VIEW_MATRIX[1],
 | 
						|
	        //INV_VIEW_MATRIX[2],
 | 
						|
	        //MODEL_MATRIX[3]
 | 
						|
	    //);
 | 
						|
	    //MODELVIEW_MATRIX = modified_model_view;
 | 
						|
	//} else {
 | 
						|
	    //mat4 modified_model_view = VIEW_MATRIX * mat4(
 | 
						|
	        //INV_VIEW_MATRIX[0],
 | 
						|
	        //MODEL_MATRIX[1],
 | 
						|
	        //MODEL_MATRIX[2],
 | 
						|
	        //MODEL_MATRIX[3]
 | 
						|
	    //);
 | 
						|
	    //MODELVIEW_MATRIX = modified_model_view;
 | 
						|
	//}
 | 
						|
 | 
						|
	vec2 tileSize = vec2(1.0 / float(FRAMES), 1.0 / float(DIRECTIONS));
 | 
						|
	vec2 topLeft = tileSize * vec2(float(frame % FRAMES), float(direction % DIRECTIONS));
 | 
						|
	vec2 bottomRight = topLeft + tileSize;
 | 
						|
 | 
						|
	if(VERTEX_ID == 3) {
 | 
						|
		UV = topLeft;
 | 
						|
	} else if(VERTEX_ID == 2) {
 | 
						|
		UV = vec2(bottomRight.x, topLeft.y);
 | 
						|
	} else if(VERTEX_ID == 1) {
 | 
						|
		UV = vec2(topLeft.x, bottomRight.y);
 | 
						|
	} else if(VERTEX_ID == 0) {
 | 
						|
		UV = bottomRight;
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
void fragment() {
 | 
						|
	vec4 npcColor = texture(npcTexture, UV);
 | 
						|
 | 
						|
	// Remove PINK background
 | 
						|
	if(npcColor.r == 1.0 && npcColor.g == 0.0 && npcColor.b == 1.0)
 | 
						|
		discard;
 | 
						|
 | 
						|
	// Remove GREEN borders
 | 
						|
	if(npcColor.r == 0.00392156862745 && npcColor.g == 1.0 && npcColor.b == 0.0)
 | 
						|
		discard;
 | 
						|
 | 
						|
	ALBEDO.rgb = npcColor.rgb;
 | 
						|
}
 |