GPU: Cleanups: Remove GPUMatType, Vectorize / MADD some operations
This commit is contained in:
@@ -117,11 +117,6 @@ typedef enum GPUBuiltin {
|
||||
GPU_BARYCENTRIC_DIST = (1 << 20),
|
||||
} GPUBuiltin;
|
||||
|
||||
typedef enum GPUMatType {
|
||||
GPU_MATERIAL_TYPE_MESH = 1,
|
||||
GPU_MATERIAL_TYPE_WORLD = 2,
|
||||
} GPUMatType;
|
||||
|
||||
typedef enum GPUMatFlag {
|
||||
GPU_MATFLAG_DIFFUSE = (1 << 0),
|
||||
GPU_MATFLAG_GLOSSY = (1 << 1),
|
||||
@@ -187,7 +182,6 @@ void GPU_material_free(struct ListBase *gpumaterial);
|
||||
void GPU_materials_free(struct Main *bmain);
|
||||
|
||||
struct Scene *GPU_material_scene(GPUMaterial *material);
|
||||
GPUMatType GPU_Material_get_type(GPUMaterial *material);
|
||||
struct GPUPass *GPU_material_get_pass(GPUMaterial *material);
|
||||
struct ListBase *GPU_material_get_inputs(GPUMaterial *material);
|
||||
GPUMaterialStatus GPU_material_status(GPUMaterial *mat);
|
||||
|
||||
@@ -70,9 +70,6 @@ struct GPUMaterial {
|
||||
Scene *scene; /* DEPRECATED was only useful for lamps */
|
||||
Material *ma;
|
||||
|
||||
/* material for mesh surface, worlds or something else.
|
||||
* some code generation is done differently depending on the use case */
|
||||
int type; /* DEPRECATED */
|
||||
GPUMaterialStatus status;
|
||||
|
||||
const void *engine_type; /* attached engine type */
|
||||
@@ -228,11 +225,6 @@ Scene *GPU_material_scene(GPUMaterial *material)
|
||||
return material->scene;
|
||||
}
|
||||
|
||||
GPUMatType GPU_Material_get_type(GPUMaterial *material)
|
||||
{
|
||||
return material->type;
|
||||
}
|
||||
|
||||
GPUPass *GPU_material_get_pass(GPUMaterial *material)
|
||||
{
|
||||
return material->pass;
|
||||
|
||||
@@ -204,7 +204,7 @@ void point_transform_m4v3(vec3 vin, mat4 mat, out vec3 vout)
|
||||
|
||||
void point_texco_remap_square(vec3 vin, out vec3 vout)
|
||||
{
|
||||
vout = vec3(vin - vec3(0.5, 0.5, 0.5)) * 2.0;
|
||||
vout = vin * 2.0 - 1.0;
|
||||
}
|
||||
|
||||
void point_texco_clamp(vec3 vin, sampler2D ima, out vec3 vout)
|
||||
@@ -1462,16 +1462,20 @@ void node_wireframe_screenspace(float size, vec2 barycentric, out float fac)
|
||||
|
||||
/* background */
|
||||
|
||||
void background_transform_to_world(vec3 viewvec, out vec3 worldvec)
|
||||
void node_tex_environment_texco(vec3 viewvec, out vec3 worldvec)
|
||||
{
|
||||
#ifdef MESH_SHADER
|
||||
worldvec = worldPosition;
|
||||
#else
|
||||
vec4 v = (ProjectionMatrix[3][3] == 0.0) ? vec4(viewvec, 1.0) : vec4(0.0, 0.0, 1.0, 1.0);
|
||||
vec4 co_homogenous = (ProjectionMatrixInverse * v);
|
||||
|
||||
vec4 co = vec4(co_homogenous.xyz / co_homogenous.w, 0.0);
|
||||
#if defined(WORLD_BACKGROUND) || defined(PROBE_CAPTURE)
|
||||
# if defined(WORLD_BACKGROUND) || defined(PROBE_CAPTURE)
|
||||
worldvec = (ViewMatrixInverse * co).xyz;
|
||||
#else
|
||||
# else
|
||||
worldvec = (ModelViewMatrixInverse * co).xyz;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2229,9 +2233,7 @@ void node_tex_image_box(vec3 texco,
|
||||
float limit = 0.5 + 0.5 * blend;
|
||||
|
||||
vec3 weight;
|
||||
weight.x = N.x / (N.x + N.y);
|
||||
weight.y = N.y / (N.y + N.z);
|
||||
weight.z = N.z / (N.x + N.z);
|
||||
weight = N.xyz / (N.xyx + N.yzz);
|
||||
weight = clamp((weight - 0.5 * (1.0 - blend)) / max(1e-8, blend), 0.0, 1.0);
|
||||
|
||||
/* test for mixes between two textures */
|
||||
|
||||
@@ -103,8 +103,7 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat, bNode *node, bNodeE
|
||||
sss_scale = in[2].link;
|
||||
}
|
||||
else {
|
||||
float one[3] = {1.0f, 1.0f, 1.0f};
|
||||
GPU_link(mat, "set_rgb", GPU_constant((float *)one), &sss_scale);
|
||||
GPU_link(mat, "set_rgb_one", &sss_scale);
|
||||
}
|
||||
|
||||
bool use_diffuse = socket_not_one(4) && socket_not_one(15);
|
||||
|
||||
@@ -46,22 +46,13 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *node, bNodeExecDat
|
||||
{
|
||||
GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
|
||||
GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, "");
|
||||
GPUMatType type = GPU_Material_get_type(mat);
|
||||
|
||||
GPU_link(mat, "generated_from_orco", orco, &orco);
|
||||
|
||||
if (type == GPU_MATERIAL_TYPE_WORLD) {
|
||||
return GPU_stack_link(mat, node, "node_tex_coord_background", in, out,
|
||||
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
|
||||
GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
|
||||
GPU_builtin(GPU_CAMERA_TEXCO_FACTORS), orco, mtface);
|
||||
}
|
||||
else {
|
||||
return GPU_stack_link(mat, node, "node_tex_coord", in, out,
|
||||
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
|
||||
GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
|
||||
GPU_builtin(GPU_CAMERA_TEXCO_FACTORS), orco, mtface);
|
||||
}
|
||||
return GPU_stack_link(mat, node, "node_tex_coord", in, out,
|
||||
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
|
||||
GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
|
||||
GPU_builtin(GPU_CAMERA_TEXCO_FACTORS), orco, mtface);
|
||||
}
|
||||
|
||||
/* node type definition */
|
||||
|
||||
Reference in New Issue
Block a user