Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[p5.strands] Significant refactor for p5.strands#8009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
davepagurek merged 75 commits intoprocessing:dev-2.0fromlukeplowden:strands-refactor
Sep 18, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
75 commits
Select commitHold shift + click to select a range
23ff7e6
syntax/ remove unneccessary
lukeplowdenJun 24, 2025
1511ffb
blocking out new modular strands structure
lukeplowdenJun 27, 2025
604c2dd
chipping away at DOD approach.
lukeplowdenJul 1, 2025
8950817
nested ifs
lukeplowdenJul 5, 2025
f6369e7
if/else semi working
lukeplowdenJul 7, 2025
a355416
change if/elseif/else api to be chainable and functional (return assi…
lukeplowdenJul 9, 2025
3e1e149
binary ops and contructors prototyped
lukeplowdenJul 16, 2025
f718717
simplify type system
lukeplowdenJul 16, 2025
24f0c46
SSA
lukeplowdenJul 16, 2025
0851285
Return type checking for hooks with native types reimplemented (i.e. …
lukeplowdenJul 23, 2025
9b84f6f
declarations moved to backend, hook arguments fixed
lukeplowdenJul 23, 2025
8509231
rename file
lukeplowdenJul 24, 2025
47eda1a
update api imports for new filename
lukeplowdenJul 24, 2025
1088b4d
move extractTypeInfo and rename to extractNodeTypeInfo
lukeplowdenJul 24, 2025
87e8a99
rename files for clarity
lukeplowdenJul 24, 2025
e32fd47
builtin function overloads type checking
lukeplowdenJul 24, 2025
11a1610
function calls partially reimplemented. Still needs more error checking.
lukeplowdenJul 24, 2025
e8f03d6
update function calls to conform parameters when raw numbers are handed
lukeplowdenJul 25, 2025
1ddd9a2
adding struct types
lukeplowdenJul 25, 2025
f3155e6
adding struct types
lukeplowdenJul 25, 2025
babedfd
Merge branch 'strands-refactor' of github.com:lukeplowden/p5.js into …
lukeplowdenJul 25, 2025
afff707
struct types working
lukeplowdenJul 26, 2025
2e70e0e
comment old line. Should revisit structs if needs optimisation.
lukeplowdenJul 26, 2025
6d5913a
fix wrong ID in binary op node
lukeplowdenJul 26, 2025
2745bda
fix bug with binary op, and make strandsNode return node if arg is al…
lukeplowdenJul 26, 2025
4133fae
fix function call bugs
lukeplowdenJul 29, 2025
b3ce3ec
remove dag sort, use basic block instructions instead. Also start wor…
lukeplowdenJul 30, 2025
9ebf77e
syntax/ remove unneccessary
lukeplowdenJun 24, 2025
faae3aa
blocking out new modular strands structure
lukeplowdenJun 27, 2025
f6783d2
chipping away at DOD approach.
lukeplowdenJul 1, 2025
06faa2c
nested ifs
lukeplowdenJul 5, 2025
5d32089
if/else semi working
lukeplowdenJul 7, 2025
95fa410
change if/elseif/else api to be chainable and functional (return assi…
lukeplowdenJul 9, 2025
627b7a3
binary ops and contructors prototyped
lukeplowdenJul 16, 2025
7899f0d
simplify type system
lukeplowdenJul 16, 2025
b731c15
SSA
lukeplowdenJul 16, 2025
7166f35
Return type checking for hooks with native types reimplemented (i.e. …
lukeplowdenJul 23, 2025
e4e54ac
declarations moved to backend, hook arguments fixed
lukeplowdenJul 23, 2025
51e8ddd
rename file
lukeplowdenJul 24, 2025
79c2f8d
update api imports for new filename
lukeplowdenJul 24, 2025
18dc1d3
move extractTypeInfo and rename to extractNodeTypeInfo
lukeplowdenJul 24, 2025
eb5f1bf
rename files for clarity
lukeplowdenJul 24, 2025
446d3ec
builtin function overloads type checking
lukeplowdenJul 24, 2025
83b4cf4
function calls partially reimplemented. Still needs more error checking.
lukeplowdenJul 24, 2025
a743c68
update function calls to conform parameters when raw numbers are handed
lukeplowdenJul 25, 2025
295c140
adding struct types
lukeplowdenJul 25, 2025
7cd3d42
adding struct types
lukeplowdenJul 25, 2025
f7b1339
struct types working
lukeplowdenJul 26, 2025
ba4be8b
comment old line. Should revisit structs if needs optimisation.
lukeplowdenJul 26, 2025
4fe4aaf
fix wrong ID in binary op node
lukeplowdenJul 26, 2025
0908e43
fix bug with binary op, and make strandsNode return node if arg is al…
lukeplowdenJul 26, 2025
5ce9451
fix function call bugs
lukeplowdenJul 29, 2025
54851ba
remove dag sort, use basic block instructions instead. Also start wor…
lukeplowdenJul 30, 2025
2b681b8
Merge branch 'strands-refactor' of github.com:lukeplowden/p5.js into …
lukeplowdenJul 30, 2025
ebaaa08
change example
lukeplowdenJul 30, 2025
3d11637
Update src/strands/ir_builders.js
lukeplowdenAug 5, 2025
347900f
remove CFG sorting, make merge block use default behaviour, change ty…
lukeplowdenAug 5, 2025
1ddd5f8
remove old file and imports
lukeplowdenAug 5, 2025
085d1b8
Merge branch 'strands-refactor' of github.com:lukeplowden/p5.js into …
lukeplowdenAug 5, 2025
f806006
bug fixes, swizzle reads working, swizzle writes WIP
lukeplowdenSep 11, 2025
d2c17af
fix textures, struct bugs, and add swizzle assign.
lukeplowdenSep 15, 2025
d5c7fe8
remove old shadergenerator file
lukeplowdenSep 15, 2025
100304f
remove dev console.log
lukeplowdenSep 15, 2025
2b863e6
add instance mode changes, fix bug where struct properties returned i…
lukeplowdenSep 16, 2025
6462345
mark atan as p5 function, prevent bug where using atan outside strand…
lukeplowdenSep 16, 2025
37abf7f
add back documentation
lukeplowdenSep 16, 2025
f3afffc
add todo for internal parser options
lukeplowdenSep 16, 2025
d4d968a
Merge branch 'dev-2.0' into strands-refactor
davepagurekSep 17, 2025
bf92d1c
Fix issue with strands being immediately active
davepagurekSep 17, 2025
a269bd7
Add back alias for previous uniformVector2 syntax
davepagurekSep 17, 2025
18eb43c
add comments for clarity on swizzling and onrebind
lukeplowdenSep 18, 2025
bae0545
Merge branch 'strands-refactor' of github.com:lukeplowden/p5.js into …
lukeplowdenSep 18, 2025
e81920f
Parse hookTypes into a strands codegen type
davepagurekSep 18, 2025
f43770c
Merge branch 'dev-2.0' into strands-refactor
davepagurekSep 18, 2025
ecc8061
Merge atan test file into trigonometry tests and get it working
davepagurekSep 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
builtin function overloads type checking
  • Loading branch information
@lukeplowden
lukeplowden committedJul 24, 2025
commite32fd47267cc3beea72788c17ba85947c059c3d0
2 changes: 1 addition & 1 deletionpreview/global/sketch.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ function callback() {
getFinalColor((col) => {
let y = col.sub(-1,1,0,0);

returny//mix(0, col.add(y),1);
return mix(float(0), col.add(y),float(1));
});
}

Expand Down
84 changes: 77 additions & 7 deletionssrc/strands/ir_builders.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
import * as DAG from './ir_dag'
import * as CFG from './ir_cfg'
import * as FES from './strands_FES'
import { NodeType, OpCode, BaseType } from './ir_types';
import { NodeType, OpCode, BaseType, typeEquals, GenType } from './ir_types';
import { StrandsNode } from './strands_api';
import { strandsBuiltinFunctions } from './strands_builtins';
import { ar } from 'vitest/dist/chunks/reporters.D7Jzd9GS.js';

//////////////////////////////////////////////
// Builders for node graphs
Expand DownExpand Up@@ -167,18 +169,86 @@ export function createTypeConstructorNode(strandsContext, typeInfo, dependsOn) {
return id;
}

export function createFunctionCallNode(strandsContext,identifier, overrides, dependsOn) {
export function createFunctionCallNode(strandsContext,functionName, userArgs) {
const { cfg, dag } = strandsContext;
let typeInfo = { baseType: null, dimension: null };
console.log("HELLOOOOOOOO")
const overloads = strandsBuiltinFunctions[functionName];
const matchingArgsCounts = overloads.filter(overload => overload.params.length === userArgs.length);
if (matchingArgsCounts.length === 0) {
const argsLengthSet = new Set();
const argsLengthArr = [];
overloads.forEach((overload) => argsLengthSet.add(overload.params.length));
argsLengthSet.forEach((len) => argsLengthArr.push(`${len}`));
const argsLengthStr = argsLengthArr.join(' or ');
FES.userError("parameter validation error",`Function '${functionName}' has ${overloads.length} variants which expect ${argsLengthStr} arguments, but ${userArgs.length} arguments were provided.`);
}

let bestOverload = null;
let bestScore = 0;
let inferredReturnType = null;
for (const overload of matchingArgsCounts) {
let isValid = true;
let overloadParamTypes = [];
let inferredDimension = null;
let similarity = 0;

for (let i = 0; i < userArgs.length; i++) {
const argType = DAG.extractNodeTypeInfo(userArgs[i]);
const expectedType = overload.params[i];
let dimension = expectedType.dimension;

const isGeneric = (T) => T.dimension === null;
if (isGeneric(expectedType)) {
if (inferredDimension === null || inferredDimension === 1) {
inferredDimension = argType.dimension;
}
if (inferredDimension !== argType.dimension) {
isValid = false;
}
dimension = inferredDimension;
}
else {
if (argType.dimension > dimension) {
isValid = false;
}
}

if (argType.baseType === expectedType.baseType) {
similarity += 2;
}
else if(expectedType.priority > argType.priority) {
similarity += 1;
}

overloadParamTypes.push({ baseType: expectedType.baseType, dimension });
}

if (isValid && (!bestOverload || similarity > bestScore)) {
bestOverload = overloadParamTypes;
bestScore = similarity;
inferredReturnType = overload.returnType;
if (isGeneric(inferredReturnType)) {
inferredReturnType.dimension = inferredDimension;
}
}
}

if (bestOverload === null) {
const paramsString = (params) => `(${params.map((param) => param).join(', ')})`;
const expectedArgsString = overloads.map(overload => paramsString(overload.params)).join(' or ');
const providedArgsString = paramsString(userArgs.map((arg)=>arg.baseType+arg.dimension));
throw new Error(`Function '${functionName}' was called with wrong arguments. Most likely, you provided mixed lengths vectors as arguments.\nExpected argument types: ${expectedArgsString}\nProvided argument types: ${providedArgsString}\nAll of the arguments with expected type 'genType' should have a matching type. If one of those is different, try to find where it was created.
`);
}

const nodeData = DAG.createNodeData({
nodeType: NodeType.OPERATION,
opCode: OpCode.Nary.FUNCTION_CALL,
identifier,
overrides,
dependsOn,
identifier: functionName,
dependsOn: userArgs,
// no type info yet
...typeInfo,
baseType: inferredReturnType.baseType,
dimension: inferredReturnType.dimension
})
const id = DAG.getOrCreateNode(dag, nodeData);
CFG.recordInBasicBlock(cfg, cfg.currentBlock, id);
Expand Down
10 changes: 8 additions & 2 deletionssrc/strands/ir_types.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ export const BasePriority = {
[BaseType.DEFER]: -1,
};

export constTypeInfo = {
export constDataType = {
float1: { fnName: "float", baseType: BaseType.FLOAT, dimension:1, priority: 3, },
float2: { fnName: "vec2", baseType: BaseType.FLOAT, dimension:2, priority: 3, },
float3: { fnName: "vec3", baseType: BaseType.FLOAT, dimension:3, priority: 3, },
Expand All@@ -56,12 +56,18 @@ export const TypeInfo = {
defer: { fnName: null, baseType: BaseType.DEFER, dimension: null, priority: -1 },
}

export const GenType = {
FLOAT: { baseType: BaseType.FLOAT, dimension: null, priority: 3 },
INT: { baseType: BaseType.INT, dimension: null, priority: 2 },
BOOL: { baseType: BaseType.BOOL, dimension: null, priority: 1 },
}

export function typeEquals(nodeA, nodeB) {
return (nodeA.dimension === nodeB.dimension) && (nodeA.baseType === nodeB.baseType);
}

export const TypeInfoFromGLSLName = Object.fromEntries(
Object.values(TypeInfo)
Object.values(DataType)
.filter(info => info.fnName !== null)
.map(info => [info.fnName, info])
);
Expand Down
1 change: 0 additions & 1 deletionsrc/strands/p5.strands.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,6 @@
* @for p5
* @requires core
*/
import { WEBGL, /*WEBGPU*/ } from '../core/constants'
import { glslBackend } from './strands_glslBackend';

import { transpileStrandsToJS } from './strands_transpiler';
Expand Down
22 changes: 11 additions & 11 deletionssrc/strands/strands_api.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,8 +6,8 @@ import {
createTypeConstructorNode,
createUnaryOpNode,
} from './ir_builders'
import { OperatorTable, BlockType,TypeInfo, BaseType, TypeInfoFromGLSLName } from './ir_types'
import {strandsShaderFunctions } from './strands_builtins'
import { OperatorTable, BlockType,DataType, BaseType, TypeInfoFromGLSLName } from './ir_types'
import {strandsBuiltinFunctions } from './strands_builtins'
import { StrandsConditional } from './strands_conditionals'
import * as CFG from './ir_cfg'
import * as FES from './strands_FES'
Expand DownExpand Up@@ -66,37 +66,37 @@ export function initGlobalStrandsAPI(p5, fn, strandsContext) {
//////////////////////////////////////////////
// Builtins, uniforms, variable constructors
//////////////////////////////////////////////
for (const [fnName, overrides] of Object.entries(strandsShaderFunctions)) {
for (const [functionName, overrides] of Object.entries(strandsBuiltinFunctions)) {
const isp5Function = overrides[0].isp5Function;

if (isp5Function) {
const originalFn = fn[fnName];
fn[fnName] = function(...args) {
const originalFn = fn[functionName];
fn[functionName] = function(...args) {
if (strandsContext.active) {
return createFunctionCallNode(strandsContext,fnName, overrides, args);
return createFunctionCallNode(strandsContext,functionName, args);
} else {
return originalFn.apply(this, args);
}
}
} else {
fn[fnName] = function (...args) {
fn[functionName] = function (...args) {
if (strandsContext.active) {
return createFunctionCallNode(strandsContext,fnName, overrides, args);
return createFunctionCallNode(strandsContext,functionName, args);
} else {
p5._friendlyError(
`It looks like you've called ${fnName} outside of a shader's modify() function.`
`It looks like you've called ${functionName} outside of a shader's modify() function.`
)
}
}
}
}

// Next is type constructors and uniform functions
for (const type inTypeInfo) {
for (const type inDataType) {
if (type === BaseType.DEFER) {
continue;
}
const typeInfo =TypeInfo[type];
const typeInfo =DataType[type];

let pascalTypeName;
if (/^[ib]vec/.test(typeInfo.fnName)) {
Expand Down
160 changes: 95 additions & 65 deletionssrc/strands/strands_builtins.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,113 @@
import { GenType, DataType } from "./ir_types"

// GLSL Built in functions
// https://docs.gl/el3/abs
const builtInGLSLFunctions = {
//////////// Trigonometry //////////
'acos': [{args: ['genType'], returnType:'genType', isp5Function: true}],
'acosh': [{args: ['genType'], returnType:'genType', isp5Function: false}],
'asin': [{args: ['genType'], returnType:'genType', isp5Function: true}],
'asinh': [{args: ['genType'], returnType:'genType', isp5Function: false}],
'atan': [
{args: ['genType'], returnType:'genType', isp5Function: false},
{args: ['genType', 'genType'], returnType:'genType', isp5Function: false},
acos: [{params: [GenType.FLOAT], returnType:GenType.FLOAT, isp5Function: true}],
acosh: [{params: [GenType.FLOAT], returnType:GenType.FLOAT, isp5Function: false}],
asin: [{params: [GenType.FLOAT], returnType:GenType.FLOAT, isp5Function: true}],
asinh: [{params: [GenType.FLOAT], returnType:GenType.FLOAT, isp5Function: false}],
atan: [
{params: [GenType.FLOAT], returnType:GenType.FLOAT, isp5Function: false},
{params: [GenType.FLOAT, GenType.FLOAT], returnType:GenType.FLOAT, isp5Function: false},
],
'atanh': [{ args: ['genType'], returnType: 'genType', isp5Function: false}],
'cos': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'cosh': [{ args: ['genType'], returnType: 'genType', isp5Function: false}],
'degrees': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'radians': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'sin': [{ args: ['genType'], returnType: 'genType' , isp5Function: true}],
'sinh': [{ args: ['genType'], returnType: 'genType', isp5Function: false}],
'tan': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'tanh': [{ args: ['genType'], returnType: 'genType', isp5Function: false}],
atanh: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
cos: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
cosh: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
degrees: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
radians: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
sin: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT , isp5Function: true}],
sinh: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
tan: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
tanh: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],

////////// Mathematics //////////
'abs': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'ceil': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'clamp': [{ args: ['genType', 'genType', 'genType'], returnType: 'genType', isp5Function: false}],
'dFdx': [{ args: ['genType'], returnType: 'genType', isp5Function: false}],
'dFdy': [{ args: ['genType'], returnType: 'genType', isp5Function: false}],
'exp': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'exp2': [{ args: ['genType'], returnType: 'genType', isp5Function: false}],
'floor': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'fma': [{ args: ['genType', 'genType', 'genType'], returnType: 'genType', isp5Function: false}],
'fract': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'fwidth': [{ args: ['genType'], returnType: 'genType', isp5Function: false}],
'inversesqrt': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
// 'isinf': [{}],
// 'isnan': [{}],
'log': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'log2': [{ args: ['genType'], returnType: 'genType', isp5Function: false}],
'max': [
{ args: ['genType', 'genType'], returnType: 'genType', isp5Function: true},
{ args: ['genType', 'float1'], returnType: 'genType', isp5Function: true},
abs: [
{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true},
{ params: [GenType.FLOAT], returnType: GenType.INT, isp5Function: true}
],
ceil: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
clamp: [
{ params: [GenType.FLOAT, GenType.FLOAT, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false},
{ params: [GenType.FLOAT,DataType.float1,DataType.float1], returnType: GenType.FLOAT, isp5Function: false},
{ params: [GenType.INT, GenType.INT, GenType.INT], returnType: GenType.INT, isp5Function: false},
{ params: [GenType.INT, DataType.int1, DataType.int1], returnType: GenType.INT, isp5Function: false},
],
dFdx: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
dFdy: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
exp: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
exp2: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
floor: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
fma: [{ params: [GenType.FLOAT, GenType.FLOAT, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
fract: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
fwidth: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
inversesqrt: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
// "isinf": [{}],
// "isnan": [{}],
log: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
log2: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
max: [
{ params: [GenType.FLOAT, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true},
{ params: [GenType.FLOAT,DataType.float1], returnType: GenType.FLOAT, isp5Function: true},
{ params: [GenType.INT, GenType.INT], returnType: GenType.INT, isp5Function: true},
{ params: [GenType.INT, DataType.int1], returnType: GenType.INT, isp5Function: true},
],
'min': [
{ args: ['genType', 'genType'], returnType: 'genType', isp5Function: true},
{ args: ['genType', 'float1'], returnType: 'genType', isp5Function: true},
min: [
{ params: [GenType.FLOAT, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true},
{ params: [GenType.FLOAT,DataType.float1], returnType: GenType.FLOAT, isp5Function: true},
{ params: [GenType.INT, GenType.INT], returnType: GenType.INT, isp5Function: true},
{ params: [GenType.INT, DataType.int1], returnType: GenType.INT, isp5Function: true},
],
'mix': [
{ args: ['genType', 'genType', 'genType'], returnType: 'genType', isp5Function: false},
{ args: ['genType', 'genType', 'float1'], returnType: 'genType', isp5Function: false},
mix: [
{ params: [GenType.FLOAT, GenType.FLOAT, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false},
{ params: [GenType.FLOAT, GenType.FLOAT,DataType.float1], returnType: GenType.FLOAT, isp5Function: false},
{ params: [GenType.FLOAT, GenType.FLOAT, GenType.BOOL], returnType: GenType.FLOAT, isp5Function: false},
],
// 'mod': [{}],
// 'modf': [{}],
'pow': [{ args: ['genType', 'genType'], returnType: 'genType', isp5Function: true}],
'round': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'roundEven': [{ args: ['genType'], returnType: 'genType', isp5Function: false}],
// 'sign': [{}],
'smoothstep': [
{ args: ['genType', 'genType', 'genType'], returnType: 'genType', isp5Function: false},
{ args: ['float1', 'float1', 'genType'], returnType: 'genType', isp5Function: false},
mod: [
{ params: [GenType.FLOAT, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true},
{ params: [GenType.FLOAT,DataType.float1], returnType: GenType.FLOAT, isp5Function: true},
],
'sqrt': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
'step': [{ args: ['genType', 'genType'], returnType: 'genType', isp5Function: false}],
'trunc': [{ args: ['genType'], returnType: 'genType', isp5Function: false}],
// "modf": [{}],
pow: [{ params: [GenType.FLOAT, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
round: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
roundEven: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
sign: [
{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false},
{ params: [GenType.INT], returnType: GenType.INT, isp5Function: false},
],
smoothstep: [
{ params: [GenType.FLOAT, GenType.FLOAT, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false},
{ params: [ DataType.float1,DataType.float1, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false},
],
sqrt: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
step: [{ params: [GenType.FLOAT, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
trunc: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],

////////// Vector //////////
'cross': [{ args: ['vec3', 'vec3'], returnType: 'vec3', isp5Function: true}],
'distance': [{ args: ['genType', 'genType'], returnType: 'float1', isp5Function: true}],
'dot': [{ args: ['genType', 'genType'], returnType: 'float1', isp5Function: true}],
// 'equal': [{}],
'faceforward': [{ args: ['genType', 'genType', 'genType'], returnType: 'genType', isp5Function: false}],
'length': [{ args: ['genType'], returnType: 'float1', isp5Function: false}],
'normalize': [{ args: ['genType'], returnType: 'genType', isp5Function: true}],
// 'notEqual': [{}],
'reflect': [{ args: ['genType', 'genType'], returnType: 'genType', isp5Function: false}],
'refract': [{ args: ['genType', 'genType', 'float1'], returnType: 'genType', isp5Function: false}],
cross: [{ params: [DataType.float3, DataType.float3], returnType: DataType.float3, isp5Function: true}],
distance: [{ params: [GenType.FLOAT, GenType.FLOAT], returnType:DataType.float1, isp5Function: true}],
dot: [{ params: [GenType.FLOAT, GenType.FLOAT], returnType:DataType.float1, isp5Function: true}],
equal: [
{ params: [GenType.FLOAT, GenType.FLOAT], returnType: GenType.BOOL, isp5Function: false},
{ params: [GenType.INT, GenType.INT], returnType: GenType.BOOL, isp5Function: false},
{ params: [GenType.BOOL, GenType.BOOL], returnType: GenType.BOOL, isp5Function: false},
],
faceforward: [{ params: [GenType.FLOAT, GenType.FLOAT, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
length: [{ params: [GenType.FLOAT], returnType:DataType.float1, isp5Function: false}],
normalize: [{ params: [GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: true}],
notEqual: [
{ params: [GenType.FLOAT, GenType.FLOAT], returnType: GenType.BOOL, isp5Function: false},
{ params: [GenType.INT, GenType.INT], returnType: GenType.BOOL, isp5Function: false},
{ params: [GenType.BOOL, GenType.BOOL], returnType: GenType.BOOL, isp5Function: false},
],
reflect: [{ params: [GenType.FLOAT, GenType.FLOAT], returnType: GenType.FLOAT, isp5Function: false}],
refract: [{ params: [GenType.FLOAT, GenType.FLOAT,DataType.float1], returnType: GenType.FLOAT, isp5Function: false}],

////////// Texture sampling //////////
'texture': [{args: ['sampler2D', 'float2'], returnType:'float4', isp5Function: true}],
texture: [{params: ["texture2D", DataType.float2], returnType:DataType.float4, isp5Function: true}],
}

export conststrandsShaderFunctions = {
export conststrandsBuiltinFunctions = {
...builtInGLSLFunctions,
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp