Jump to content

How to use renderProcedurals() in C++ application


photo

Recommended Posts

I have two questiones.

 

first:

 

I want to use a procedural texture in the shader, but i don't know how to complete the engine.render.renderProcedurals() function in the C++ side. For some reason i couldn't use the Unigine Script(All the code was C++,write again use script will be a long time).

 

I think just s few code in the main() method will finish it. Is it Right?

 

Here is what i do, but it was wrong:

 

    object : a objectMeshDynamicPtr with vertex and material, the material is the same as example "objectDynamic particles physics  shader"

    while(!engine->isDone())

    {

             Unigine ::Render *myRender = Unigine::Render::get();

             MaterialPtr material = object->getMaterialInherit(0);

             Unigine::Vector<MaterialPtr> materialVector;

             materialVector.append(material);

             myRender->renderProcedurals(materialVector);

 

             engine->update();

             engine->render();

             engine->swap();

     }

 

second:

I drew an object that its shape wil be dynamic changed use the vertex shader programe.To get the correct lighting effects I need to compute normal,tangent,binormal and texcoord for every vertex in the vertex shader(to use the Unigine's lighting shader). 

I want to ask that is the vertex texcoord necessary?

In the Unigine SDK, Without vertex teexcoord you can also compute the  normal,tangent,binormal information.which is right?

the normal information export in the vertex shader is the world space normal or the normal in the TBN space?

 

To compute TBN information, I need to use post pass with geometry shader(to get 3 vertexes for TBN compute ) , and then export the TBN information use procedural texture. So this is the first question.I don't know if it's the wrong way for TBN compute.

 

 

 

 

Link to comment

Hi Xiaofeng,

 

second:

I drew an object that its shape wil be dynamic changed use the vertex shader programe.To get the correct lighting effects I need to compute normal,tangent,binormal and texcoord for every vertex in the vertex shader(to use the Unigine's lighting shader). 

You can check our shaders creation tutorial (Unigine 2.1+ SDK is required): https://developer.unigine.com/en/docs/2.2.1/code/uusl/create_deferred 

In that article you can find how to calculate normals so the deferred lightning will work as expected.

 

first:

 

I want to use a procedural texture in the shader, but i don't know how to complete the engine.render.renderProcedurals() function in the C++ side. For some reason i couldn't use the Unigine Script(All the code was C++,write again use script will be a long time).

It is highly recommended right now to write your custom application logic inside new WorldLogic / SystemLogic / EditorLogic classes: https://developer.unigine.com/en/docs/2.2.1/code/execution_sequence/app_logic_system

Running API function inside infinite while loop is unsafe and can lead to unexpected behavior.

 

You can create new project with C++ API inside SDK Browser to check how this new logic is working.

 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...