Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/shaders/gpu_shader_material.glsl
| Show First 20 Lines • Show All 421 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void vec_math_sub(vec3 v1, vec3 v2, out vec3 outvec, out float outval) | void vec_math_sub(vec3 v1, vec3 v2, out vec3 outvec, out float outval) | ||||
| { | { | ||||
| outvec = v1 - v2; | outvec = v1 - v2; | ||||
| outval = (abs(outvec[0]) + abs(outvec[1]) + abs(outvec[2])) * 0.333333; | outval = (abs(outvec[0]) + abs(outvec[1]) + abs(outvec[2])) * 0.333333; | ||||
| } | } | ||||
| void vec_math_multiply(vec3 v1, vec3 v2, out vec3 outvec, out float outval) | |||||
| { | |||||
| outvec = v1 * v2; | |||||
| outval = (abs(outvec[0]) + abs(outvec[1]) + abs(outvec[2])) * 0.333333; | |||||
| } | |||||
| void vec_math_average(vec3 v1, vec3 v2, out vec3 outvec, out float outval) | void vec_math_average(vec3 v1, vec3 v2, out vec3 outvec, out float outval) | ||||
| { | { | ||||
| outvec = v1 + v2; | outvec = v1 + v2; | ||||
| outval = length(outvec); | outval = length(outvec); | ||||
| outvec = normalize(outvec); | outvec = normalize(outvec); | ||||
| } | } | ||||
| void vec_math_mix(float strength, vec3 v1, vec3 v2, out vec3 outvec) | void vec_math_mix(float strength, vec3 v1, vec3 v2, out vec3 outvec) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 1,357 Lines • ▼ Show 20 Lines | #endif | ||||
| camera = vec3(co.xy, -co.z); | camera = vec3(co.xy, -co.z); | ||||
| window = (ProjectionMatrix[3][3] == 0.0) ? | window = (ProjectionMatrix[3][3] == 0.0) ? | ||||
| vec3(mtex_2d_mapping(I).xy * camerafac.xy + camerafac.zw, 0.0) : | vec3(mtex_2d_mapping(I).xy * camerafac.xy + camerafac.zw, 0.0) : | ||||
| vec3(vec2(0.5) * camerafac.xy + camerafac.zw, 0.0); | vec3(vec2(0.5) * camerafac.xy + camerafac.zw, 0.0); | ||||
| reflection = -coords; | reflection = -coords; | ||||
| } | } | ||||
| /* vector rotate */ | |||||
| /* XYZ order */ | |||||
| void eul_to_mat(inout mat4 mat, const vec3 eul) | |||||
| { | |||||
| float ci, cj, ch, si, sj, sh, cc, cs, sc, ss; | |||||
| ci = cos(eul[0]); | |||||
| cj = cos(eul[1]); | |||||
| ch = cos(eul[2]); | |||||
| si = sin(eul[0]); | |||||
| sj = sin(eul[1]); | |||||
| sh = sin(eul[2]); | |||||
| cc = ci * ch; | |||||
| cs = ci * sh; | |||||
| sc = si * ch; | |||||
| ss = si * sh; | |||||
| mat[0][0] = (cj * ch); | |||||
| mat[1][0] = (sj * sc - cs); | |||||
| mat[2][0] = (sj * cc + ss); | |||||
| mat[0][1] = (cj * sh); | |||||
| mat[1][1] = (sj * ss + cc); | |||||
| mat[2][1] = (sj * cs - sc); | |||||
| mat[0][2] = -sj; | |||||
| mat[1][2] = (cj * si); | |||||
| mat[2][2] = (cj * ci); | |||||
| mat[3][0] = mat[3][1] = mat[3][2] = mat[0][3] = mat[1][3] = mat[2][3] = 0.0; | |||||
| mat[3][3] = 1.0; | |||||
| } | |||||
| void node_vector_rotate(vec3 vector_in, vec3 origin, float x, float y, float z, out vec3 vec) | |||||
| { | |||||
| vec3 vin = vector_in; | |||||
| mat4 rmat; | |||||
| eul_to_mat(rmat, vec3(x,y,z)); | |||||
| vin = vin - origin; | |||||
| vin = transform_point(rmat, vin); | |||||
| vin = vin + origin; | |||||
| vec = vin; | |||||
| } | |||||
| #if defined(WORLD_BACKGROUND) || (defined(PROBE_CAPTURE) && !defined(MESH_SHADER)) | #if defined(WORLD_BACKGROUND) || (defined(PROBE_CAPTURE) && !defined(MESH_SHADER)) | ||||
| #define node_tex_coord node_tex_coord_background | #define node_tex_coord node_tex_coord_background | ||||
| #endif | #endif | ||||
| /* textures */ | /* textures */ | ||||
| float calc_gradient(vec3 p, int gradient_type) | float calc_gradient(vec3 p, int gradient_type) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 1,176 Lines • Show Last 20 Lines | |||||