Add va_shader_example.txt
This commit is contained in:
		
							parent
							
								
									32ec76562b
								
							
						
					
					
						commit
						857b14450d
					
				
					 1 changed files with 42 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -0,0 +1,42 @@
 | 
			
		|||
 | 
			
		||||
uniform sampler2D offset_map;
 | 
			
		||||
uniform sampler2D normal_map;
 | 
			
		||||
 | 
			
		||||
uniform float start_frame = 0;
 | 
			
		||||
uniform float end_frame = 70.0;
 | 
			
		||||
uniform float time_scale = 0.5;
 | 
			
		||||
 | 
			
		||||
void vertex(){
 | 
			
		||||
	
 | 
			
		||||
	float time_int = 1.0;
 | 
			
		||||
	float time = modf(TIME * time_scale, time_int);
 | 
			
		||||
	float num_frames = end_frame - start_frame;
 | 
			
		||||
	float frame_offset = num_frames * INSTANCE_CUSTOM.a;
 | 
			
		||||
	float current_frame = start_frame + mod((time * num_frames) + frame_offset, num_frames);
 | 
			
		||||
	
 | 
			
		||||
	ivec2 tex_size = textureSize(offset_map, 0);
 | 
			
		||||
	float pixel_size = 1.0 / float(tex_size.y);
 | 
			
		||||
	float frame_floor = clamp(floor(current_frame), start_frame, end_frame);
 | 
			
		||||
	float frame_ceil = clamp(ceil(current_frame), start_frame, end_frame);
 | 
			
		||||
	
 | 
			
		||||
	vec2 frame_floor_uv_offset = vec2(0.0, -((frame_floor + 0.5) * pixel_size));
 | 
			
		||||
	vec2 frame_ceil_uv_offset = vec2(0.0, -((frame_ceil + 0.5) * pixel_size));
 | 
			
		||||
	
 | 
			
		||||
	float lerp_factor = current_frame - frame_floor;
 | 
			
		||||
	
 | 
			
		||||
	vec3 offset_floor = texture(offset_map, UV2 + frame_floor_uv_offset).xyz;
 | 
			
		||||
	vec3 offset_ceil = texture(offset_map, UV2 + frame_ceil_uv_offset).xyz;
 | 
			
		||||
	vec3 offset_lerp = mix(offset_floor, offset_ceil, lerp_factor);
 | 
			
		||||
	vec3 new_offset = vec3(offset_lerp.x, offset_lerp.z, offset_lerp.y);
 | 
			
		||||
	
 | 
			
		||||
	VERTEX += new_offset;
 | 
			
		||||
	
 | 
			
		||||
	vec3 normal_floor = texture(normal_map, UV2 + frame_floor_uv_offset).xyz;
 | 
			
		||||
	vec3 normal_ceil = texture(normal_map, UV2 + frame_ceil_uv_offset).xyz;
 | 
			
		||||
	vec3 normal_lerp = mix(normal_floor, normal_ceil, lerp_factor);
 | 
			
		||||
	vec3 new_normal = vec3((normal_lerp.x * 2.0) - 1.0, (normal_lerp.z * 2.0) - 1.0, (normal_lerp.y * 2.0) - 1.0);
 | 
			
		||||
	
 | 
			
		||||
	NORMAL = new_normal;
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		
		Reference in a new issue