How to write text in the viewport in real-time
3435 8 3-
- bashorton
- Member
- 20 posts
- Joined: Feb. 2022
- Offline
-
- bashorton
- Member
- 20 posts
- Joined: Feb. 2022
- Offline
-
- GOgraphR
- Member
- 72 posts
- Joined: Oct. 2018
- Offline
-
- bashorton
- Member
- 20 posts
- Joined: Feb. 2022
- Offline
GOgraphRSorry, I don't quite understand how to implement this, could you send the hip file?
How about this snippet?string tMsg="The Message"; for (int i=0;i<len(tMsg) && i<@Frame;i++){ #tweakpoint 3 int np=addpoint(0,set(i,0,0)) #tweakpoint 1 setpointattrib(0,"L",np,tMsg[i],"set") #tweakpoint 2 }
Assuming this is what you want to achieve:
-
- GOgraphR
- Member
- 72 posts
- Joined: Oct. 2018
- Offline
-
- bashorton
- Member
- 20 posts
- Joined: Feb. 2022
- Offline
GOgraphRThanks so much! It's not quite what I was looking for but interesting technique.bashorton
Sorry, I don't quite understand how to implement this, could you send the hip file?
Ok, I am backing down...
It is quite identical to your setup. And that led to the assumption I made.
I actually figured out a way to do what I wanted in python which reads text from an external text file. This is written in visual studio with auto save set to 10ms.
-
- GOgraphR
- Member
- 72 posts
- Joined: Oct. 2018
- Offline
Just noticed. You can save a few sops:
The match size sop can save you a transform.
and I have instead of the VOP this pointWrangle which is pretty much to the same effect
to project to the camera. "dist" is a slider, that moves the "HUD" near/far.
I have done my HUD with a COP. That saves geometry count. Your Font-SOP approach increases geometry count

I store the Text in detail attribs, which are read in by a COP-Font, some adds,to compose final HUD image and taht's it.
COP-SOP is set to quad with UVs, UV quickshade get its texture from "op:/obj/HUD/cop/OUT_HUD_TXT" then the match size and a Wrangle as described above.
In the HUD, currently I have a Python-SOP and a SOP Solver, to "compute" time between two frames, and display "UL" shows elapsed rendertime,current Date/Time and Start Date/Time. Which gets "rendered".
Could you explain what exactly you want to achieve as I think I don't got it... (*sorry*)
:S
The match size sop can save you a transform.
- Set "Target" position to (0.5 ; 0.5 ; 0) and size (1;1;1)
- Set Scale to fit
- Unset Uniform scale
and I have instead of the VOP this pointWrangle which is pretty much to the same effect
vector Pt=@P; Pt.z-=chf("dist"); @P=fromNDC("/obj/cam1",Pt);
I have done my HUD with a COP. That saves geometry count. Your Font-SOP approach increases geometry count
I store the Text in detail attribs, which are read in by a COP-Font, some adds,to compose final HUD image and taht's it.
COP-SOP is set to quad with UVs, UV quickshade get its texture from "op:/obj/HUD/cop/OUT_HUD_TXT" then the match size and a Wrangle as described above.
In the HUD, currently I have a Python-SOP and a SOP Solver, to "compute" time between two frames, and display "UL" shows elapsed rendertime,current Date/Time and Start Date/Time. Which gets "rendered".
Image Not Found
Could you explain what exactly you want to achieve as I think I don't got it... (*sorry*)
:S
Edited by GOgraphR - May 11, 2023 16:20:49
-
- bashorton
- Member
- 20 posts
- Joined: Feb. 2022
- Offline
GOgraphRInteresting approach! Quite a bit over my head honestly without the hip file.
Just noticed. You can save a few sops:
The match size sop can save you a transform.This transforms your Input 1 to the "uniform" coordinates.
- Set "Target" position to (0.5 ; 0.5 ; 0) and size (1;1;1)
- Set Scale to fit
- Unset Uniform scale
and I have instead of the VOP this pointWrangle which is pretty much to the same effectto project to the camera. "dist" is a slider, that moves the "HUD" near/far.vector Pt=@P; Pt.z-=chf("dist"); @P=fromNDC("/obj/cam1",Pt);
I have done my HUD with a COP. That saves geometry count. Your Font-SOP approach increases geometry countImage Not Found
I store the Text in detail attribs, which are read in by a COP-Font, some adds,to compose final HUD image and taht's it.
COP-SOP is set to quad with UVs, UV quickshade get its texture from "op:/obj/HUD/cop/OUT_HUD_TXT" then the match size and a Wrangle as described above.
In the HUD, currently I have a Python-SOP and a SOP Solver, to "compute" time between two frames, and display "UL" shows elapsed rendertime,current Date/Time and Start Date/Time. Which gets "rendered".Image Not Found
Could you explain what exactly you want to achieve as I think I don't got it... (*sorry*):S
Basically with my approach, I have an external text file in visual studio that auto saves as I type in it. Then I have a python node in houdini that reads this text then inputs it into the text box of the font sop. If I type in the external text file while the playbar is running, the text appears in real time in the font sop. Hope that makes sense.
-
- GOgraphR
- Member
- 72 posts
- Joined: Oct. 2018
- Offline
bashorton
Interesting approach! Quite a bit over my head honestly without the hip file.
Don't worry that's really not that far away from your solution.
You want my *hipnc? It's more suitable for render time, not really comparable to your solution. Would need some cleanup.
I just noticed the FontCOP has an option to read a file.
I do not know how much text you want to do this way, so you might run into an "overflow" that may ruin your layout.
You might want to figure out how much text fits in there, and then
with open(file_path, 'r') as f: text = f.read()[-500:-1] # If the fontSOP setup allows for max 500 chars
Or read the file line by line, and then leave the last few lines that still fit in
text.Otherwise I don't know how/what to improve on your solution.
OTOH, if it does what you intend to do. Be it!! (So it is coded! So it shall be done!!)
Hope I could help you
-
- Quick Links

