mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Compositor: Support implicit conversion across 2D vectors
This patch adds the necessary functions needed to support implicit conversion in GPU execution across 2D vectors in the compositor. Pull Request: https://projects.blender.org/blender/blender/pulls/147975
This commit is contained in:
parent
5af14bb572
commit
5517941a60
2 changed files with 32 additions and 2 deletions
|
|
@ -531,7 +531,7 @@ void ShaderOperation::generate_code(void *thunk,
|
|||
shader_create_info.local_group_size(16, 16);
|
||||
|
||||
/* Add implementation for implicit conversion operations inserted by the code generator. This
|
||||
* file should include the functions [float|vec3|vec4]_from_[float|vec3|vec4]. */
|
||||
* file should include the functions [float|vec2|vec3|vec4]_from_[float|vec2|vec3|vec4]. */
|
||||
shader_create_info.typedef_source("gpu_shader_compositor_type_conversion.glsl");
|
||||
|
||||
/* The source shader is a compute shader with a main function that calls the dynamically
|
||||
|
|
|
|||
|
|
@ -330,9 +330,34 @@ float float_from_vec3(float3 vector)
|
|||
return dot(vector, float3(1.0f)) / 3.0f;
|
||||
}
|
||||
|
||||
float float_from_vec2(float2 vector)
|
||||
{
|
||||
return dot(vector, float2(1.0f)) / 2.0f;
|
||||
}
|
||||
|
||||
float2 vec2_from_vec4(float4 vector)
|
||||
{
|
||||
return vector.xy;
|
||||
}
|
||||
|
||||
float2 vec2_from_vec3(float3 vector)
|
||||
{
|
||||
return vector.xy;
|
||||
}
|
||||
|
||||
float2 vec2_from_float(float value)
|
||||
{
|
||||
return float2(value);
|
||||
}
|
||||
|
||||
float3 vec3_from_vec4(float4 vector)
|
||||
{
|
||||
return vector.rgb;
|
||||
return vector.xyz;
|
||||
}
|
||||
|
||||
float3 vec3_from_vec2(float2 vector)
|
||||
{
|
||||
return float3(vector, 0.0f);
|
||||
}
|
||||
|
||||
float3 vec3_from_float(float value)
|
||||
|
|
@ -340,6 +365,11 @@ float3 vec3_from_float(float value)
|
|||
return float3(value);
|
||||
}
|
||||
|
||||
float4 vec4_from_vec2(float2 vector)
|
||||
{
|
||||
return float4(vector, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
float4 vec4_from_vec3(float3 vector)
|
||||
{
|
||||
return float4(vector, 1.0f);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue