Use Shader to manipulate Vertices

So i managed to write a simple Project that outputs a Triangle or Quad. Now i want to manipulate the Vertices in a Shader. But where? I have a VertexFactory and SceneProxy setup but i don’t know where in the *.ush File i can change the Vertices. Do i need a separate Geometry-Shader?
I’m so confused with all those Shader files :frowning:

Hm, after some reading here in the Forum. It seems Geometry-Shaders are not easy to use. I used some Code from the Engine Source but it crashes the Editor at loading.
With some weird Windows String comparison error. Is there nobody that has a hint how to do it?
Can’t be that nobody tried it before…

Does somebody have an Example how to make a simple pass thru DrawingPolicy?

Made some “progress”. But have a big Problem. Where should i call FMeshDrawingPolicy::DrawMesh()?
The Problem is i don’t have a valid FRHICommandList, which is required by DrawMesh().
Please give me some Info, i am getting nuts with this :smiley:

Edit: So i found a way to do it. I need to change the Render(…) Function that i calls my custom Render-commands. Now i want to know if there is a Solution without changing Engine Code.
The thing i don’t know is if it is possible to use a custom DrawingPolicyFactory and add it with a Plugin.

I will post the Render thing and changes when i am done.

So, it seems to work. However i don’t see the Result :smiley: it doesn’t crash or throw an Error, just nothing on the Screen. I tried to write Shaders that just passthru the Data.
Maybe i did something wrong there. Here is the Vertex and Geometry Shader:


#include "BasePassVertexCommon.ush"




float testValueVS;
float testValueGS;
void Main(
    FVertexFactoryInput Input,
    out FBasePassVSToPS OutParameters
    )
{
    ResolvedView = ResolveView();

    FVertexFactoryIntermediates VFIntermediates = GetVertexFactoryIntermediates(Input);
    float4 WorldPositionExcludingWPO = VertexFactoryGetWorldPosition(Input, VFIntermediates);
    float4 WorldPosition = WorldPositionExcludingWPO;
    float4 ClipSpacePosition;
    float3x3 TangentToLocal = VertexFactoryGetTangentToLocal(Input, VFIntermediates);

    FMaterialVertexParameters VertexParameters = GetMaterialVertexParameters(Input, VFIntermediates, WorldPosition.xyz, TangentToLocal);
    WorldPosition.xyz += GetMaterialWorldPositionOffset(VertexParameters);

    OutParameters.Position = WorldPosition;


    OutputVertexID( OutParameters );
}

struct FBasePassGSToPS
{
    FVertexFactoryInterpolantsVSToPS FactoryInterpolants;
    FBasePassInterpolantsVSToPS BasePassInterpolants;
    float4 Position : SV_POSITION;
};

[maxvertexcount(3)]
void MainGS(triangle FBasePassVSToPS input[3], inout TriangleStream<FBasePassGSToPS> OutStream)
{
    FBasePassGSToPS outputVert[3];


    // Send triangles
    outputVert[0].Position = input[0].Position;
    outputVert[0].BasePassInterpolants = input[0].BasePassInterpolants;
    outputVert[0].FactoryInterpolants = input[0].FactoryInterpolants;
    OutStream.Append(outputVert[0]);

    outputVert[1].Position = input[1].Position;
    outputVert[1].BasePassInterpolants = input[1].BasePassInterpolants;
    outputVert[1].FactoryInterpolants = input[1].FactoryInterpolants;
    OutStream.Append(outputVert[1]);

    outputVert[2].Position = input[2].Position;
    outputVert[2].BasePassInterpolants = input[2].BasePassInterpolants;
    outputVert[2].FactoryInterpolants = input[2].FactoryInterpolants;
    OutStream.Append(outputVert[2]);

    OutStream.RestartStrip();
}

I did a total new approach. Now i use a Compute Shader to calculate the Vertices. This works better than i thought. Here some screens.
Performance is about 80-120 fps. It jumps up and down depending how close you are to the Sphere. The subdivision of the Triangles is based on Leah Lindner – Graphics Programmer | Game Developer