Patching the edge shader

::here is an attempt at putting together a draft for a patched version of Edge
the assembly of texcoords and sampler nodes is not clear atm, also got lost in filetypes
having it working at some point could make for a basic effect patching help patch
edge.vl (136.7 KB)
anyone care to explain missing parts is welcome ::

edge 01.vl (147.6 KB)

did some cleaning up,
added comments to the sections that dont click together,
mostly its seems because of filetypes that do not match:

GpuInteger32 vs GpuFloat32
GpuValueVector4 vs GpuValueGpuVector4
GpuValueFloat32 vs GpuFloat32
GpuVector4 vs GpuValueVector4

trying to split into basic questions,

does this part of the patch seem to do what is written in the 3 lines of code ?
if so, how am i supposed to connect log2(gpu.int32) to lod(gpu.float32) ?

looking at the code of Edge, I wouldn’t patch it, that would be a big graph of nodes… why not just make a new TextureFX?

float4 q(float2 x,float2 off,float v){return InputTexture.SampleLevel(s0,x+off/R,v);}

float4 pEDGE(float4 PosWVP:SV_POSITION,float2 x:TEXCOORD0):SV_Target{
    float rad=max(Radius,0);
    float3 e=float3(1,-1,0)*rad;
    float v=log2(rad);
    float4 cx=q(x,e.xy,v)+q(x,e.xz,v)+q(x,e.xx,v)-q(x,e.yy,v)-q(x,e.yz,v)-q(x,e.yx,v);
    float4 cy=q(x,e.yy,v)+q(x,e.zy,v)+q(x,e.xy,v)-q(x,e.yx,v)-q(x,e.zx,v)-q(x,e.xx,v);
    float4 c=sqrt(cx*cx+cy*cy)*Bright*pow(2,rad/max(R.x,R.y))/sqrt(saturate(rad)+.001);
    return c;

The ShaderFX nodes are more meant to plug together parts of shaders, patching algorithms with them is possible, but just a lot of work and has not much benefit, except not using code, or of course, learning something about shader patching.

so you seem to mix two shader patching systems, GpuValue<T> is a shader patching system from the VL.Fuse library. and GPU<T> is a type from the VL.Stride ShaderFX system. they are not really compatible in that sense, as they work differently in how they build the shader.

however, they both do a very similar thing. so what you are doing is probably best done exclusively with Fuse nodes and then in the end, use a ToShaderFX node to convert the output to GPU<Vecort4>.

have a look at this discussion: You're invited to talk on Matrix which i will add to the gray book soon.

1 Like

except not using code, or of course, learning something about shader patching


use a ToShaderFX node to convert the output to `GPU

thanks for clarifying
but what is missing in this texture to sampler to shaderfx basic patch ?

image to fuse to shaderfx .vl (16.9 KB)

kind of stuck at the fuse sampler, as mentioned here

Fuse can’t deal with a GpuValue<Spread<…>>

can i implement the kernel operations without making use of GpuValue<Spread<>> ?

in theory yes, this is not possible. but to upload a spread to the GPU you need to use a buffer. but it might be simpler to just use a buffer input directly…

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.