r/GraphicsProgramming • • Oct 19 '26

Question Looking for guidance on evaluating shader cost for procedural texture generation (research project)

I’m working on a research project where the goal is to take a real texture and generate a procedural material/shader that approximates it.
The system produces a node‑based procedural graph with tuned parameters, plus an optional fallback texture layer. The output is a GLSL/HLSL/WGSL shader that reconstructs the material.

The motivation is practical:
In multi‑region deployments and cloud gaming backends, moving fewer textures can reduce storage and distribution overhead.
But the trade‑off is shader cost — and that’s the part I’m trying to evaluate properly.

I’m trying to understand how to estimate the cost of a procedural material shader compared to using a fixed texture.
I need a reasonable way to judge when the procedural version becomes “too expensive,” and how people typically model or approximate that cost in real pipelines.

I’d really appreciate insight from graphics programmers who have experience with:
• analyzing or estimating shader cost
• comparing shader‑based materials vs texture‑based materials
• heuristics or rules‑of‑thumb used in production
• pitfalls when evaluating procedural materials

I’ll leave the link to the full proposal in the comments for anyone interested.

0 Upvotes

12 comments sorted by

4

u/waramped Oct 19 '26
  1. I would recommend rewriting your proposal in your own words rather than use AI to write it, it will present better to people who might be interested in helping. If English isn't your first language, write it in your own words anyway and then just translate it. Writing (and therefore having to think about what you are saying) these things yourself is pretty crucial to laying a mental framework for yourself.
  2. Broadly speaking, you have 2 chokepoints in shaders: Memory bandwidth/latency and ALU throughput.
    So, moving a texture over to ALU instead of memory will only benefit you if your bottleneck is bandwidth or latency. That's not overly common. But, as always, you will need to profile your shaders to know for sure. If you can approximate a texture in less execution time than it takes to roundtrip to memory, then it will overall be a win, but figuring that out is going to be very complicated, and will be different on different hardware.

The benefits of procedural textures are that you can analytically filter them to get better quality "mips", and even potentially reduce the instruction cost depending on the pixel footprint. (Don't need to add high frequency noise details if the texture would be reading from a very low mip, etc).

The downsides is that they are just generally slower than simply reading a texture from memory (but, profile first).

3

u/scallywag_software Oct 19 '26

(2) is exactly what I was going to say. I guess in OPs case there's another axis to consider.. network latency/bandwidth. I could imagine a world where the network bandwidth is the biggest problem, and a hybrid solution might make sense. ie.

  1. Fetch procedural texture params.
  2. Generate texture at runtime and cache it.
  3. Sample generated texture as usual.

Additionally, OP, if you really do want a way of estimating the actual runtime cost, something like this might help : http://infolab.stanford.edu/~datar/courses/cs361a/papers/quantiles.pdf

2

u/IdeaCrafter96 Oct 19 '26

Good point about the network axis — that’s exactly the environment I’m thinking about. In a cloud setup, moving large texture sets around regions is often more expensive than doing a one‑time ALU pass, so a hybrid approach like the one you described is pretty close to what I’m aiming for.

Thanks for the link as well. I skimmed the paper earlier today — it’s not directly about shaders, but the idea of estimating cost through sampled distributions instead of full evaluation is interesting. I might actually try applying something similar to approximate the cost of the procedural graph without running it at full resolution.

2

u/scallywag_software Oct 20 '26 edited Oct 20 '26

I'm curious about the thing that generates the shader in the first place. Do you have a working prototype for that? I looked at the proposal and it's pretty bare on details.

For context, I'm currently doing the 3D version of that pipeline for a voxel engine and I'm curious about your approach.

EDIT: Also, are you aware of the original texture synthesis algorithm, model synthesis (same author), and wave function collapse? I wondered if you're piggy-backing off the texture synthesis name because it's a similar concept, or similar algorithm

1

u/IdeaCrafter96 Oct 20 '26

I do have a working prototype, but it’s still early, which is why the proposal doesn’t go deep into implementation details yet. The current version handles 2D textures only — it analyzes frequency content, detects periodicity, picks operators (noise, blends, filters), tunes parameters, and generates a shader function that reconstructs the appearance. It outputs valid GLSL/HLSL/WGSL, but the graph simplification and fallback logic still need more work.

Regarding the 3D side: I’m not doing volumetric reconstruction yet, but I’ve spent some time thinking about what the 3D version would require. A direct extension of the 2D pipeline doesn’t work — you need volumetric operators (3D Worley, 3D Perlin/Simplex, 3D FBM, volumetric warps), and the cost model becomes more complicated because the footprint of 3D noise grows fast. You also have to deal with anisotropy and directional structure in a way that’s less obvious than in 2D textures. So the 3D pipeline is a different beast, and I’m curious how you’re approaching operator selection and cost modeling in your voxel engine.

As for texture synthesis, model synthesis, and WFC — I’m familiar with all three. This project isn’t using those algorithms directly. I’m not trying to synthesize new textures or generate variations; the goal is to reconstruct an existing texture using a procedural graph. So the “texture synthesis” angle is more about the general idea of reconstructing structure, not about reusing the classic algorithms.

If you’re willing to share more about your 3D pipeline, I’d be interested in hearing how you’re handling volumetric operators, cost estimation, and how you decide when a procedural volume becomes too expensive compared to storing a baked 3D texture.

1

u/IdeaCrafter96 Oct 19 '26

Thanks for the reply. Your breakdown of ALU vs memory bandwidth makes sense. On most GPUs, texture fetches are extremely optimized, so replacing them with ALU work usually isn’t worth it unless the hardware is already stalled on memory. That’s why I’m not planning to run the procedural graph every frame.

The idea is to evaluate the graph once (or rarely) and use the baked result as a normal texture. So the cost I’m trying to understand isn’t the per‑frame shader cost, but the one‑time evaluation cost compared to the storage and distribution savings in multi‑region setups.

This is mostly motivated by cloud gaming and distributed backends, where moving large texture sets around regions tends to be more expensive than GPU compute. In that environment, ALU is cheap and scalable, while storage replication and cold‑start asset loading are the real bottlenecks.

Your point about analytical filtering is interesting. That might actually be another advantage of having a procedural source, depending on how the graph is structured.

2

u/Fancy-Plantain6910 Oct 21 '26

Since you're baking once and caching, I'd benchmark the cold-start asset pipeline rather than use per-frame shader cost as the main metric.

Compare two paths at matched visual quality and final GPU format:

- Existing texture: fetch, decode/transcode, upload.

- Recipe: fetch parameters, compile the pipeline, bake, generate mips, and compress if needed.

Log wall-clock time for the full path and GPU time for the bake separately. Include peak memory, transferred bytes and cached bytes. Run cold and warm cache cases on target hardware; a GPU timestamp alone misses compilation and network costs.

Then estimate cost per cache miss or deployment. Graph node counts might help fit a predictor once you have measurements, but I wouldn't use them as a portable cost estimate by themselves.

1

u/IdeaCrafter96 Oct 21 '26

Yeah, that lines up with what I’m trying to measure. The per‑frame shader cost isn’t really relevant here — the interesting part is the cold‑start path in a multi‑region setup. So comparing the two pipelines at the same visual quality is probably the only comparison that makes sense.

I’ll set up benchmarks around the two paths you described:
texture → decode/transcode → upload
vs
recipe → bake → mip gen → compress → upload.

Wall‑clock timing, GPU bake time, peak memory, transferred bytes, cache behavior — that should give enough data to see where the break‑even point is. Cold vs warm cache is also relevant for the environment I’m targeting.

The graph‑complexity idea (node count, operator types, maybe frequency bands) as a rough predictor for bake cost is interesting. I’ve been thinking about something similar but haven’t turned it into an actual model yet. Might be a decent way to avoid running the full bake when the graph is obviously too heavy.

I’ll structure the evaluation around this approach.

1

u/speps Oct 19 '26

The idea is good, but it only makes sense if you’re going to cache the result which would mean same VRAM cost as plain textures, maybe even more if you don’t recompress to a GPU tiled format. Something like Mega Texture (id Tech 5) for example, but procedural shader based, would be interesting. Evaluating it fully every frame would be wasteful and only needed if animated.

-1

u/IdeaCrafter96 Oct 19 '26

Thanks for the insight — and yes, caching is absolutely part of the plan.
The system isn’t meant to evaluate the full procedural graph every frame.
The idea is closer to a pre‑bake pipeline:

  1. AI generates a procedural graph + shader.
  2. The shader is evaluated once (or infrequently) to produce a texture atlas / tile set.
  3. The runtime uses the baked result, not the procedural graph.

So the procedural version becomes a distribution‑time optimization, not a per‑frame cost.

This is especially relevant for cloud gaming / multi‑region deployments, where:

  • storage replication
  • cross‑region texture distribution
  • bandwidth
  • cold‑start asset loading

are more expensive than GPU compute.

In that environment, CPU/GPU cost is cheap and scalable, while storage and asset movement are the real bottlenecks.
So the procedural graph is used to reduce asset footprint, not to replace texture sampling during gameplay.

Your MegaTexture analogy is spot‑on — except the source would be a procedural shader instead of a giant bitmap.

I appreciate the feedback; it helps clarify how to frame the cost model more accurately.

-2

u/IdeaCrafter96 Oct 19 '26

Here’s the full proposal for anyone interested in the technical details, architecture, and evaluation notes: https://github.com/IdeaCrafter96/texture-synthesis-ai

0

u/[deleted] Oct 21 '26

[deleted] — view deleted comment

1

u/IdeaCrafter96 Oct 21 '26

Good point about cache‑key cardinality. “Bake once” only holds if the output configuration stays identical, and in a multi‑region setup that’s not guaranteed. Resolution, format, colour space, mip strategy, compression target — each of those can create a separate cache entry, and eviction can force rebakes even when the recipe doesn’t change.

The simple model you wrote (K*G < (B−R)*E) is actually a useful way to frame the problem. The missing piece for me is exactly what you mentioned: K isn’t a constant. I need to measure it from a real deployment trace instead of assuming K=1. Depending on how often variants get requested or evicted, the economics can flip.

A small graph can lose if it gets baked repeatedly, and a heavier graph can win if one cached output serves a lot of sessions. That’s a dimension I haven’t explicitly modeled yet, so I’ll add cache‑key cardinality and cache behavior to the evaluation plan.