Cleanup: Use const char * for layer names in collada exporter #104585
|
@ -647,21 +647,6 @@ char *GPU_material_split_sub_function(GPUMaterial *material,
|
|||
SNPRINTF(func_link->name, "ntree_fn%d", material->generated_function_len++);
|
||||
BLI_addtail(&material->graph.material_functions, func_link);
|
||||
|
||||
/* Set value to break the link with the main graph. */
|
||||
switch (return_type) {
|
||||
case GPU_FLOAT:
|
||||
GPU_link(material, "set_value_one", link);
|
||||
break;
|
||||
case GPU_VEC3:
|
||||
GPU_link(material, "set_rgb_one", link);
|
||||
break;
|
||||
case GPU_VEC4:
|
||||
GPU_link(material, "set_rgba_one", link);
|
||||
break;
|
||||
default:
|
||||
BLI_assert(0);
|
||||
break;
|
||||
}
|
||||
return func_link->name;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,11 @@ template<> uint convert_type<uint>(float val)
|
|||
return uint(val * float(0xFFFFFFFFu));
|
||||
}
|
||||
|
||||
template<typename D, typename S> uint pack_depth_stencil(D depth, S stencil)
|
||||
{
|
||||
return (((uint(depth)) << 8) & (~(0xFFu - 1))) | (uint(stencil) & (0xFFu - 1));
|
||||
}
|
||||
|
||||
struct TextureReadParams {
|
||||
int mip_index;
|
||||
int extent[3];
|
||||
|
@ -118,8 +123,14 @@ kernel void compute_texture_read(constant TextureReadParams ¶ms [[buffer(0)]
|
|||
|
||||
/* Read data */
|
||||
# if IS_DEPTH_FORMAT == 1
|
||||
output_data[index] = denormalize<OUTPUT_DATA_TYPE>(
|
||||
OUTPUT_DATA_TYPE value = denormalize<OUTPUT_DATA_TYPE>(
|
||||
read_tex.sample(pixelSampler, float2(params.offset[0], params.offset[1]) + float2(xx, yy)));
|
||||
# if IS_DEPTHSTENCIL_24_8 == 1
|
||||
/* Shift depth value into 24 bit region and mask out 8 bit stencil.
|
||||
* NOTE: Stencil currently not read as no use cases exist for this. */
|
||||
value = pack_depth_stencil(value, 0);
|
||||
# endif
|
||||
output_data[index] = value;
|
||||
# else
|
||||
read_colour = read_tex.read(uint2(params.offset[0], params.offset[1]) + uint2(xx, yy));
|
||||
# endif
|
||||
|
@ -156,10 +167,16 @@ kernel void compute_texture_read(constant TextureReadParams ¶ms [[buffer(0)]
|
|||
|
||||
/* Read data */
|
||||
# if IS_DEPTH_FORMAT == 1
|
||||
output_data[index] = denormalize<OUTPUT_DATA_TYPE>(
|
||||
OUTPUT_DATA_TYPE value = denormalize<OUTPUT_DATA_TYPE>(
|
||||
read_tex.sample(pixelSampler,
|
||||
float2(params.offset[0], params.offset[1]) + float2(xx, yy),
|
||||
uint(params.offset[2] + layer)));
|
||||
# if IS_DEPTHSTENCIL_24_8 == 1
|
||||
/* Shift depth value into 24 bit region and mask out 8 bit stencil.
|
||||
* NOTE: Stencil currently not read as no use cases exist for this. */
|
||||
value = pack_depth_stencil(value, 0);
|
||||
# endif
|
||||
output_data[index] = value;
|
||||
# else
|
||||
read_colour = read_tex.read(uint2(params.offset[0], params.offset[1]) + uint2(xx, yy),
|
||||
uint(params.offset[2] + layer));
|
||||
|
|
|
@ -647,7 +647,9 @@ id<MTLComputePipelineState> gpu::MTLTexture::mtl_texture_read_impl(
|
|||
@"IS_DEPTH_FORMAT" :
|
||||
[NSNumber numberWithInt:((specialization_params.depth_format_mode > 0) ? 1 : 0)],
|
||||
@"DEPTH_SCALE_FACTOR" : [NSNumber numberWithLongLong:depth_scale_factor],
|
||||
@"TEX_TYPE" : [NSNumber numberWithInt:((int)(texture_type))]
|
||||
@"TEX_TYPE" : [NSNumber numberWithInt:((int)(texture_type))],
|
||||
@"IS_DEPTHSTENCIL_24_8" :
|
||||
[NSNumber numberWithInt:(specialization_params.depth_format_mode == 2) ? 1 : 0]
|
||||
};
|
||||
|
||||
/* Prepare shader library for conversion routine. */
|
||||
|
|
|
@ -263,9 +263,7 @@ vec3 dF_impl(vec3 v)
|
|||
g_derivative_flag = -1; \
|
||||
result.y = (fn); \
|
||||
g_derivative_flag = 0; \
|
||||
result -= vec2((fn)); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* TODO(fclem): Remove. */
|
||||
|
|
|
@ -12,8 +12,13 @@ void differentiate_texco(vec4 v, out vec3 df)
|
|||
df = v.xyz + dF_impl(v.xyz);
|
||||
}
|
||||
|
||||
void node_bump(
|
||||
float strength, float dist, float height, vec3 N, vec2 dHd, float invert, out vec3 result)
|
||||
void node_bump(float strength,
|
||||
float dist,
|
||||
float height,
|
||||
vec3 N,
|
||||
vec2 height_xy,
|
||||
float invert,
|
||||
out vec3 result)
|
||||
{
|
||||
N = normalize(N);
|
||||
dist *= FrontFacing ? invert : -invert;
|
||||
|
@ -29,6 +34,7 @@ void node_bump(
|
|||
/* Compute surface gradient and determinant. */
|
||||
float det = dot(dPdx, Rx);
|
||||
|
||||
vec2 dHd = height_xy - vec2(height);
|
||||
vec3 surfgrad = dHd.x * Rx + dHd.y * Ry;
|
||||
|
||||
strength = max(strength, 0.0);
|
||||
|
|
|
@ -59,6 +59,14 @@ static int gpu_shader_bump(GPUMaterial *mat,
|
|||
|
||||
const char *height_function = GPU_material_split_sub_function(mat, GPU_FLOAT, &in[2].link);
|
||||
|
||||
/* TODO (Miguel Pozo):
|
||||
* Currently, this doesn't compute the actual differentials, just the height at dX and dY
|
||||
* offsets. The actual differentials are computed inside the GLSL node_bump function by
|
||||
* substracting the height input. This avoids redundant computations when the height input is
|
||||
* also needed by regular nodes as part in the main function (See #103903 for context).
|
||||
* A better option would be to add a "value" input socket (in this case the height) to the
|
||||
* differentiate node, but currently this kind of intermediate nodes are pruned in the codegen
|
||||
* process (see #104265), so we need to fix that first. */
|
||||
GPUNodeLink *dheight = GPU_differentiate_float_function(height_function);
|
||||
|
||||
float invert = (node->custom1) ? -1.0 : 1.0;
|
||||
|
|
|
@ -39,7 +39,6 @@ def get_gpu_device(args: None) -> List:
|
|||
if device.type == device_type:
|
||||
result.append({'type': device.type, 'name': device.name, 'index': index})
|
||||
index += 1
|
||||
break
|
||||
|
||||
return result
|
||||
|
||||
|
|
Loading…
Reference in New Issue