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

Function lib_glsl_mod

src/GLSLLibrary.cpp:239–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237 return bv_variable_create_float(0.0f);
238 }
239 bv_variable lib_glsl_mod(bv_program* prog, u8 count, bv_variable* args)
240 {
241 /* mod(genType, genType), mod(genType, float), also for genDType */
242 if (count == 2) {
243 if (args[0].type == bv_type_object) {
244 bv_object* vec = bv_variable_get_object(args[0]);
245
246 // using: genType, float, genDType, double
247 glm::vec4 x = sd::AsVector<4, float>(args[0]);
248 glm::vec4 y(0.0f);
249
250 // get y
251 if (args[1].type == bv_type_object)
252 y = sd::AsVector<4, float>(args[1]);
253 else
254 y = glm::vec4(bv_variable_get_float(bv_variable_cast(bv_type_float, args[1])));
255
256 glm::vec4 vecData = glm::mod(x, y);
257
258 bv_variable ret = Common::create_vec(prog, bv_type_float, vec->type->props.name_count);
259 bv_object* retObj = bv_variable_get_object(ret);
260
261 for (u16 i = 0; i < retObj->type->props.name_count; i++)
262 retObj->prop[i] = bv_variable_create_float(vecData[i]);
263
264 return ret;
265 }
266
267 // mod(float, float)
268 else if (args[0].type == bv_type_float) {
269 float x = bv_variable_get_float(bv_variable_cast(bv_type_float, args[0]));
270 float y = bv_variable_get_float(bv_variable_cast(bv_type_float, args[1]));
271
272 return bv_variable_create_float(glm::mod(x, y));
273 }
274 }
275
276 return bv_variable_create_float(0.0f);
277 }
278 bv_variable lib_glsl_noise1(bv_program* prog, u8 count, bv_variable* args)
279 {
280 /* noise1(genType) */

Callers

nothing calls this directly

Calls 1

create_vecFunction · 0.85

Tested by

no test coverage detected