Scripted Textures
Moderator: GZDoom Developers
-
-
- Posts: 3875
- Joined: Fri Feb 08, 2008 9:15 am
- Preferred Pronouns: She/Her
- Operating System Version (Optional): (btw I use) Arch
- Graphics Processor: nVidia with Vulkan support
- Location: Vigo, Galicia
Scripted Textures
Interest for this kind of thing has resurfaced again. You may remember the horrendous hack that was phantombeta implementing the psx fire as a camera texture displaying a grid of sectors changing color. Someone really needs to put an end to this madness and actually make this. I don't know if I could, though, it sounds like such a monumental task and I don't have enough time to work on anything like that. The way I'm thinking about it would involve moving all the 2d drawing code back to the DCanvas class, then make it so the Screen.* API works on instances of it rather than on the global screen framebuffer (which would be moved to the zscript globals, for backwards compatibility). Obviously ANIMDEFS would have to be expanded for creating these, just like it does for camera textures.
There really shouldn't be any concerns over performance when it comes to this, since we'd be using the renderer's own facilities for drawing, rather than working on raw pixels.
There really shouldn't be any concerns over performance when it comes to this, since we'd be using the renderer's own facilities for drawing, rather than working on raw pixels.
-
- Lead GZDoom+Raze Developer
- Posts: 48519
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Scriptable Canvas Textures
Forget the canvas, that part will never work. The 2D drawing is completely hardware accelerated, the canvas is just a software buffer.
This is certainly doable but will require quite a bit of backend work - and if you want software renderer support some exporting facility of the created texture
This is certainly doable but will require quite a bit of backend work - and if you want software renderer support some exporting facility of the created texture
-
-
- Posts: 3875
- Joined: Fri Feb 08, 2008 9:15 am
- Preferred Pronouns: She/Her
- Operating System Version (Optional): (btw I use) Arch
- Graphics Processor: nVidia with Vulkan support
- Location: Vigo, Galicia
Re: Scriptable Canvas Textures
OK, massive frustration with a gross hack involving camera textures not working properly depending on the map has forced me to bump this thread. WE ABSOLUTELY NEED THIS.
-
- Lead GZDoom+Raze Developer
- Posts: 48519
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Scriptable Canvas Textures
We need *what*? You got to be a bit more precise about your intents.
-
-
- Posts: 17342
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: Scriptable Canvas Textures
I think what Marisa is saying is that people have been abusing camera textures to approximate scriptable textures (with varying degrees of success) and we all know what happens when features are used in ways they're not designed to do, therefore she's suggesting proper, Unreal Engine-style scriptable textures.
-
- Lead GZDoom+Raze Developer
- Posts: 48519
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Scriptable Canvas Textures
The suggestion says "scriptable canvas texture', so this needs clarification.
-
- Admin
- Posts: 13204
- Joined: Tue Jan 13, 2004 1:31 pm
- Preferred Pronouns: She/Her
Re: Scriptable Canvas Textures
I think a better name for this thread would be "Scriptable Textures" - which would work for both canvas and materials (i.e. object or geometry textures).
-
-
- Posts: 3875
- Joined: Fri Feb 08, 2008 9:15 am
- Preferred Pronouns: She/Her
- Operating System Version (Optional): (btw I use) Arch
- Graphics Processor: nVidia with Vulkan support
- Location: Vigo, Galicia
Re: Scripted Textures
Changed the thread title.
What I'm proposing, in simpler terms, is textures that can be drawn to from ZScript, like one would do drawing on the screen itself.
What I'm proposing, in simpler terms, is textures that can be drawn to from ZScript, like one would do drawing on the screen itself.
-
-
- Posts: 3875
- Joined: Fri Feb 08, 2008 9:15 am
- Preferred Pronouns: She/Her
- Operating System Version (Optional): (btw I use) Arch
- Graphics Processor: nVidia with Vulkan support
- Location: Vigo, Galicia
Re: Scripted Textures
Well, it's been some time, but I guess this one can be closed as [Added].
Absolutely huge thanks to dpJudas for making the dream come true.
Absolutely huge thanks to dpJudas for making the dream come true.

-
-
- Posts: 17719
- Joined: Fri Jul 06, 2007 3:22 pm
Re: Scripted Textures
So, technically, could the PSX fire sky be implemented this way now? What would the code look like?
-
-
- Posts: 3875
- Joined: Fri Feb 08, 2008 9:15 am
- Preferred Pronouns: She/Her
- Operating System Version (Optional): (btw I use) Arch
- Graphics Processor: nVidia with Vulkan support
- Location: Vigo, Galicia
Re: Scripted Textures
Probably a lot of calls to drawtexture with a 1x1 pixel texture. 

-
- Lead GZDoom+Raze Developer
- Posts: 48519
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Scripted Textures
ZScript may be too slow to do textures that are programmatically generated per pixel. Even in the best of cases it may be too slow even with JIT due to all the range checks
-
- Admin
- Posts: 13204
- Joined: Tue Jan 13, 2004 1:31 pm
- Preferred Pronouns: She/Her
Re: Scripted Textures
For per-pixel we can reduce range checks to one check by allowing a special per-pixel texelation command to have a single one-dimensional addressing scheme which will access the entire texture. That should increase the speed of per-texel scripting a little bit. Bonus: cast it to an unsigned integer to reduce the checking even further since negatives will then always fail the check.
-
- Posts: 8109
- Joined: Sun Jan 28, 2007 3:55 pm
Re: Scripted Textures
And out of curiosity, how does one do this now? I'd love to see an example!
Or the main functions can work.
Or the main functions can work.
-
-
- Posts: 17342
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: Scripted Textures
From the pull request thread by dpJudas:
This adds support for creating canvas textures in ANIMDEFS using same syntax as for camera textures (except the keyword is canvastexture instead).
On the zscript side the texture can be drawn into using the following method:
Code: Select all
Canvas canvas = TexMan.GetCanvas("mycanvastexture"); canvas.Clear(0, 0, 64, 128, Screen.PaletteColor(123)); canvas.DrawText(bigfont, Font.CR_ORANGE, 0, 0, "HELLO!");