Differential D16990 Diff 60050 source/blender/compositor/realtime_compositor/shaders/compositor_realize_on_domain.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/realtime_compositor/shaders/compositor_realize_on_domain.glsl
| Show All 13 Lines | void main() | ||||
| /* Since an input image with an identity transformation is supposed to be centered in the domain, | /* Since an input image with an identity transformation is supposed to be centered in the domain, | ||||
| * we subtract the offset between the lower left corners of the input image and the domain, which | * we subtract the offset between the lower left corners of the input image and the domain, which | ||||
| * is half the difference between their sizes, because the difference in size is on both sides of | * is half the difference between their sizes, because the difference in size is on both sides of | ||||
| * the centered image. Additionally, we floor the offset to retain the 0.5 offset added above in | * the centered image. Additionally, we floor the offset to retain the 0.5 offset added above in | ||||
| * case the difference in sizes was odd. */ | * case the difference in sizes was odd. */ | ||||
| ivec2 domain_size = imageSize(domain_img); | ivec2 domain_size = imageSize(domain_img); | ||||
| ivec2 input_size = texture_size(input_tx); | ivec2 input_size = texture_size(input_tx); | ||||
| vec2 offset = floor((domain_size - input_size) / 2.0); | vec2 offset = floor(vec2(domain_size - input_size) / 2.0); | ||||
| /* Subtract the offset and divide by the input image size to get the relevant coordinates into | /* Subtract the offset and divide by the input image size to get the relevant coordinates into | ||||
| * the sampler's expected [0, 1] range. */ | * the sampler's expected [0, 1] range. */ | ||||
| vec2 normalized_coordinates = (coordinates - offset) / input_size; | vec2 normalized_coordinates = (coordinates - offset) / vec2(input_size); | ||||
| imageStore(domain_img, texel, texture(input_tx, normalized_coordinates)); | imageStore(domain_img, texel, texture(input_tx, normalized_coordinates)); | ||||
| } | } | ||||