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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Material and C++

I'm create game about pirates and I need water for it, so I'm trying to implement Gerstner wave function https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch01.html Equation 1. (tried also 8a)

And I need to do it on both GPU and CPU so I have done this on both and it returns different values?

What's the difference between HLSL float and C++ float? Can floating precision be problem here?

C++ code:

 float AGerstnerSimple::GetWaveHeight(FVector2D position, FVector2D dirrection, float waveLength, float speed, float amplitude, float powerK, float time)
     double wi = 2 / waveLength;
     double p = speed * 2 / waveLength;
     double dotResult = dirrection.X * position.X + dirrection.Y * position.Y;
     double result = amplitude * FMath::Sin(FVector2D::DotProduct(dirrection, position) * wi + time * p);
     return result;

And HLSL code tried material nodes but I used this to be sure(Use as custom node):

 float wi = 2 / WaveLength;
 float p = Speed * 2 / WaveLength;
 float dotResult = DirrectionX * PositionX + DirrectionY * PositionY; // Here is inaccuracy
 //float result = Amplitude * sin(dot(Dirrection, Positionn) * wi + Time * p);
 float result = Amplitude * sin(dotResult * wi + Time * p);
 return result;

Can somebody help me figure it out?

Thanks for any help!

Product Version: UE 4.20
more ▼

asked Aug 23 '18 at 01:04 PM in C++ Programming

avatar image

296 4 10 14

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

0 answers: sort voted first
Be the first one to answer this question
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