MCPcopy Create free account
hub / github.com/dfranx/ShaderDebugger / lib_hlsl_lit

Function lib_hlsl_lit

src/HLSLLibrary.cpp:432–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430 return Common::create_vec(prog, bv_type_float, 4);
431 }
432 bv_variable lib_hlsl_lit(bv_program* prog, u8 count, bv_variable* args)
433 {
434 float ambient = 1, diffuse = 0, specular = 0;
435
436 /* float4 lit(float, float, float) */
437 if (count >= 3) {
438 float n_dot_l = bv_variable_get_float(args[0]);
439 float n_dot_h = bv_variable_get_float(args[1]);
440 float m = bv_variable_get_float(args[2]);
441
442 ambient = 1;
443 diffuse = (n_dot_l < 0) ? 0 : n_dot_l;
444 specular = (n_dot_l < 0 || n_dot_h < 0) ? 0 : glm::pow(n_dot_h, m);
445 }
446
447 bv_variable ret = Common::create_vec(prog, bv_type_float, 4);
448 bv_object* vec = bv_variable_get_object(ret);
449 vec->prop[0] = bv_variable_create_float(ambient);
450 vec->prop[1] = bv_variable_create_float(diffuse);
451 vec->prop[2] = bv_variable_create_float(specular);
452 vec->prop[3] = bv_variable_create_float(1.0f);
453
454 return ret;
455 }
456
457 /* Texture1/2/3D */
458 bv_variable lib_hlsl_Texture_Sample(bv_program* prog, bv_object* me, u8 argc, bv_variable* args)

Callers

nothing calls this directly

Calls 1

create_vecFunction · 0.85

Tested by

no test coverage detected