Scripted Textures

Moderator: GZDoom Developers

User avatar
Marisa the Magician
 
 
Posts: 3853
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia

Scripted Textures

Post by Marisa the Magician »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48376
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Scriptable Canvas Textures

Post by Graf Zahl »

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
User avatar
Marisa the Magician
 
 
Posts: 3853
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia

Re: Scriptable Canvas Textures

Post by Marisa the Magician »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48376
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Scriptable Canvas Textures

Post by Graf Zahl »

We need *what*? You got to be a bit more precise about your intents.
User avatar
Nash
 
 
Posts: 17326
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Scriptable Canvas Textures

Post by Nash »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48376
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Scriptable Canvas Textures

Post by Graf Zahl »

The suggestion says "scriptable canvas texture', so this needs clarification.
User avatar
Rachael
Admin
Posts: 13108
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: Scriptable Canvas Textures

Post by Rachael »

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).
User avatar
Marisa the Magician
 
 
Posts: 3853
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia

Re: Scripted Textures

Post by Marisa the Magician »

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.
User avatar
Marisa the Magician
 
 
Posts: 3853
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia

Re: Scripted Textures

Post by Marisa the Magician »

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. :cheers:
Gez
 
 
Posts: 17689
Joined: Fri Jul 06, 2007 3:22 pm

Re: Scripted Textures

Post by Gez »

So, technically, could the PSX fire sky be implemented this way now? What would the code look like?
User avatar
Marisa the Magician
 
 
Posts: 3853
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia

Re: Scripted Textures

Post by Marisa the Magician »

Probably a lot of calls to drawtexture with a 1x1 pixel texture. :wink:
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48376
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Scripted Textures

Post by Graf Zahl »

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
User avatar
Rachael
Admin
Posts: 13108
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: Scripted Textures

Post by Rachael »

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.
User avatar
Major Cooke
Posts: 8095
Joined: Sun Jan 28, 2007 3:55 pm

Re: Scripted Textures

Post by Major Cooke »

And out of curiosity, how does one do this now? I'd love to see an example!

Or the main functions can work.
User avatar
Nash
 
 
Posts: 17326
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Scripted Textures

Post by Nash »

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!");
 

Return to “Closed Feature Suggestions [GZDoom]”