x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Problem binding Shader Parameter to VertexFactory

So i was playing around with VertexFactory and SceneProxy to simply draw a Quad or Triangle. It works. Now i wanted to set an Array of Integers or Floats that is present for each vertex so i can pick the number i need from the Array. But i can't bind the Array to the Shader.

 FPlanetShaderParameters* FPlanetVertexFactory::ConstructShaderParameters(EShaderFrequency ShaderFrequency)
 {
     if (ShaderFrequency == SF_Vertex)
     {
         return new FPlanetShaderParameters();
     }
 
     return nullptr;
 }

 void FPlanetShaderParameters::Bind(const class FShaderParameterMap& ParameterMap)
 {
     testValues.Bind(ParameterMap, TEXT("testValue"), SPF_Mandatory);
 }
 
 void FPlanetShaderParameters::Serialize(FArchive& Ar)
 {
     Ar << testValues;
 }
 
 void FPlanetShaderParameters::SetMesh(FRHICommandList & RHICmdList, FShader * Shader, const FVertexFactory * VertexFactory, const FSceneView & View, const FMeshBatchElement & BatchElement, uint32 DataFlags) const
 {
     FShaderParameterMap testMap;
     FRHIVertexShader* VS = Shader->GetVertexShader();
     TArray<float> testFloat;
     testFloat.Add(1.f);
     testFloat.Add(2.f);
     testFloat.Add(3.f);
     testFloat.Add(4.f);
 
     SetShaderValue(RHICmdList, VS, testValues, testFloat, 4);
 }

Somehow Bind(...) never gets called. But SetMesh(...) does... I checked Implementations in the Engine Code and couldn't find a Solution

Product Version: UE 4.21
Tags:
more ▼

asked May 20 '19 at 02:34 PM in C++ Programming

avatar image

HOUmmel
43 3 8 10

avatar image HOUmmel May 20 '19 at 06:01 PM

Please close this Question

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Let's discuss :

Yes, in the landscape module , FLandscapeVertexFactoryVertexShaderParameters::Bind is nerver called, you can ue_log to check that .but GetElementShaderBindings is called every frame and in that member method, you can see it's member parameters are actually bound.

I wonder why, maybe bind will be called only once and after being Serialized it will never be called?

more ▼

answered Jun 17 '19 at 01:12 PM

avatar image

knziha
1 1 3

avatar image knziha Jun 17 '19 at 01:38 PM

Okay I guess the serialized archive will act as a key and unless the key has changed the shaderparamters won's be re bound, is it the mechanism ?

avatar image HOUmmel Jun 17 '19 at 06:01 PM

Shader parameters are bound when you start the editor. i can't remember if this was the issue

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question