Author Topic: Plane9 shader edit  (Read 2500 times)

0 Members and 1 Guest are viewing this topic.

Offline Xetick

  • Atari ST
  • ***
  • Posts: 132
  • Karma: 80
    • View Profile
    • Plane9
Plane9 shader edit
« on: January 25, 2010 »
After seeing shader toy I though it would be time to go ahead and try to get a shader edit node into the music visualizer/screensaver Plane9.

So I have now added a test node that you can feed a cgfx shader. The shader is currently compiled in realtime. In other words every time you change a character in the shader it is recompiled and you get instant feed back. Not sure if I can/should keep it that way. A preprocessor expression parser also exists. So you can get input from outside the shader. Have the preprocessor adjust/create the values and then feed the shader with them. Just to offload the shader.

However since my experience with demo shaders is limited my question is just how much should the shader code be simplified. Currently I predefine a number of global variables like gWVP (WorldViewProjection) and the rest of the matrices "gTime, gIn1, gIn2, gColor, gTex1, gTex2" and the "vertexinput" structure is also auto injected into the shader code. But should I try to simplify it more. Like remove the "technique" and try to auto add that around the passes. An example of how it currently looks can be seen in the screenshot below.

Plane9 - Home of the Plane9 3d screensaver/music visualizer
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Plane9 shader edit
« Reply #1 on: January 25, 2010 »
At a guess, you'd only need to simplify it if you wanted it to run on lower spec hardware, or you need to cram more in if it gets too slow.  Or if you're writing a < 4k demo and space is at a premium.

Jim
Challenge Trophies Won:

Offline Xetick

  • Atari ST
  • ***
  • Posts: 132
  • Karma: 80
    • View Profile
    • Plane9
Re: Plane9 shader edit
« Reply #2 on: January 25, 2010 »
Sorry, I didn't mean the actual shader. As such size isn't of any greater concern for this project.

But imagine you would want to use this editor yourself to experiment to create a new shader. Would you want it be simpler so the edit window wouldn't contain as much or would you rather have a lot and full control.

One example would be that I could remove both "technique" and "pass" but then I could only support one pass and the pixel and vertex programs would have to be named exactly as in the screenshot.

However I have been playing around with it a bit more now and I think I have hit a sweet spot of clutter vs control. Its a bit annoying to have to look at the PSInput structure but quite a lot of shader probably need to send other data from the vertex to the pixel shader.

BTW. I just managed to convert the awesome To the road of ribbon shader to this format and its pretty neat to be able to wrap it around a sphere and what not. I'm still amazed of how that intro looks from that little shader.

« Last Edit: January 25, 2010 by Xetick »
Plane9 - Home of the Plane9 3d screensaver/music visualizer
Challenge Trophies Won: