Skip to content

Commit

Permalink
restructuring the code for customRender
Browse files Browse the repository at this point in the history
see #1220
  • Loading branch information
t3kt committed May 28, 2024
1 parent 132dab7 commit 5beb63a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 65 deletions.
Binary file modified src/operators/output/customRender.tox
Binary file not shown.
40 changes: 5 additions & 35 deletions src/operators/output/customRender.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!rop
meta: !meta
opType: raytk.operators.output.customRender
opVersion: '15'
opVersion: '16'
opStatus: alpha
paramPages:
- !page
Expand Down Expand Up @@ -183,45 +183,15 @@ opDef: !def
enable: true
typeSpec: !ropTypes
coordType: !coordT
Allcoordtype: !expr
expr: parent().par.Coordtype == 'auto'
Coordtypefloat: !expr
expr: parent().par.Coordtype == 'float'
Coordtypevec2: !expr
expr: parent().par.Coordtype == 'vec2'
Coordtypevec3: !expr
expr: parent().par.Coordtype == 'vec3'
Allcoordtype: true
contextType: !contextT
Allcontexttype: !expr
expr: parent().par.Contexttype == 'auto'
Contexttypecontext: !expr
expr: parent().par.Contexttype == 'Context'
Contexttypematerialcontext: !expr
expr: parent().par.Contexttype == 'MaterialContext'
Contexttypecameracontext: !expr
expr: parent().par.Contexttype == 'CameraContext'
Contexttypelightcontext: !expr
expr: parent().par.Contexttype == 'LightContext'
Contexttyperaycontext: !expr
expr: parent().par.Contexttype == 'RayContext'
Allcontexttype: true
returnType: !returnT
Returntypesdf: !expr
expr: parent().par.Returntype == 'Sdf'
Returntypefloat: !expr
expr: parent().par.Returntype == 'float'
Returntypevec4: !expr
expr: parent().par.Returntype == 'vec4'
Returntyperay: !expr
expr: parent().par.Returntype == 'Ray'
Returntypelight: !expr
expr: parent().par.Returntype == 'Light'
function: !text
file: src/operators/output/customRender_function.glsl
name: functionTemplate
Allreturntype: true
function: functionTemplate
displayCategory: Render
inputs:
- !input
Required: true
coordType: !coordT
Allcoordtype: true
contextType: !contextT
Expand Down
17 changes: 17 additions & 0 deletions src/operators/output/customRender_body.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
void main() {
#ifdef RAYTK_HAS_INIT
init();
#endif
initOutputs();

vec2 resolution = uTDOutputInfo.res.zw;
vec2 fragCoord = vUV.st;//*resolution;
fragCoord.x *= uTDOutputInfo.res.z/uTDOutputInfo.res.w;
vec2 p = fragCoord*2. - vec2(1.);

pushStage(RAYTK_STAGE_PRIMARY);

Context ctx = createDefaultContext();

customMain(fragCoord, p, ctx);
}
25 changes: 0 additions & 25 deletions src/operators/output/customRender_defaultBodyTemplate.glsl

This file was deleted.

6 changes: 6 additions & 0 deletions src/operators/output/customRender_defaultMainCode.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void customMain(vec2 fragCoord, vec2 p, Context ctx) {
vec4 res1 = fillToVec4(thismap(p, ctx));
#ifdef OUTPUT_COLOR
colorOut = TDOutputSwizzle(res1);
#endif
}
7 changes: 6 additions & 1 deletion src/operators/output/customRender_function.glsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
ReturnT thismap(CoordT p, ContextT ctx) {
return inputOp1(p, ctx);
ReturnT res;
initDefVal(res);
#ifdef THIS_HAS_INPUT_1
res = inputOp1(p, ctx);
#endif
return res;
}
8 changes: 4 additions & 4 deletions src/operators/output/customRender_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

def onCreateParPulse(action: str):
o = parent()
if action == 'Createbodytemplate':
par = o.par.Bodytemplate
template = op('default_body_template')
suffix = '_body'
if action == 'Createmaincode':
par = o.par.Maincode
template = op('defaultMainCode')
suffix = '_main'
offsetX = 0
desc = 'shader body'
opType = textDAT
Expand Down

0 comments on commit 5beb63a

Please sign in to comment.