Jump to content

[SOLVED] Custom Deferred Material Problem


photo

Recommended Posts

Hi There,

It was easy to understand and implement the behavior as defined at 

https://developer.unigine.com/en/docs/2.11/code/uusl/create_deferred?rlang=cpp

I have attached the ULON material file. XML material file, Vertex and Fragment shader. Mostly copied from the above tutorial.

But when I did the same with ULON and material file formats, I receive  two problems.

  1. The object renders black. So I though gbufferdefault is setting black color. But setting color to gbuffer.albedo = vec3(1.0, 0.0, 0.0); didn't work. It renders black.
  2. I can not create a child material out of this. Nothing happens.

Here is the screen shot.

image.thumb.png.5466d9e73339f5d108a6f89746f4b637.png

Please advise,

Regards,

Rohit

 

 

Edited by rohit.gonsalves
Changed the title to Solved
Link to comment
  • rohit.gonsalves changed the title to Custom Deferred Material Problem

Thanks Morbid,

Understood the problem and solution provided, answered the question.

The second issue is still there. I can not create a child material out of it.

Please advise.

Rohit

 

Link to comment

You're welcome, Rohit.

As for the other issue I'm not sure I follow you. I put the shaders and materials into data folder, changed paths to the shaders. After running the editor I'm free to inherit your material. Is the code the same you're using? Nothing changed?

Is your material packed in UNG archive?

image.png

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

Link to comment

Dear Morbid,

You are right. When I put this material in data folder and changed the path for vertex and pixel shader. It did work and I could able to inherit the materiel child.

image.png.b1909fd3f071a3ae19c2aa9c570d81b4.png

But I found two material Gotchas.........

1] I put the material to the mount point, I couldn't able to inherit it. I mean nothing happens.

2] I put the material to SDK\data\core\materials and shaders at respective places. and then created a new project for UNG packaging. No inheritance.

3] But with data folder it works.

Now in case of 3rd point, If I assign a child material of custom material to material_ball and use Shift + Translate; I have transparent material ball. This is some kind of an issue.

image.thumb.png.b580a1e5ee08c060063f8161d11f0714.png

These are the cases. I think probably a fix is needed for this.

Regards,

Rohit

Edited by rohit.gonsalves
Link to comment

Rohit, inheritance works for me every time. How I tested:

  1. Put your basemat and shaders into <sdk>/data/core and created a project
  2. Put the same files in data folder
  3. Made manually UNG archive with your material
  4. Created a mount point (make sure you're making a Read/Write mount) with custom material

Inherit worked in every case. Can you send me core.ung where I can reproduce this issue?

On 7/24/2020 at 11:54 PM, rohit.gonsalves said:

Now in case of 3rd point, If I assign a child material of custom material to material_ball and use Shift + Translate; I have transparent material ball. This is some kind of an issue.

Reproduced this. We'll take a look at this closer this week.

Thanks.

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

Link to comment

Got feedback regarding clone issue. It's because you should've used material instancing. Engine has built-in optimization for similar materials rendering.

Replace this part

float4 row_0 = s_transform[0];
float4 row_1 = s_transform[1];
float4 row_2 = s_transform[2];

With:

float4x4 transform = getObjectTransform(IN_INSTANCE);
float4 row_0 = getRow(transform, 0);
float4 row_1 = getRow(transform, 1);
float4 row_2 = getRow(transform, 2);

Also you'll need to manifest this:

STRUCT(VERTEX_IN)
	INIT_ATTRIBUTE(float4,0,POSITION)	// Vertex position
	INIT_ATTRIBUTE(float4,1,TEXCOORD0)	// Vertex texcoord (uv)
	INIT_ATTRIBUTE(float4,2,TEXCOORD1)	// Vertex basis tangent
	INIT_ATTRIBUTE(float4,3,TEXCOORD2)	// Vertex color
	INIT_INSTANCE
END

And add 

INIT_INSTANCE

Hope this helps.

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

Link to comment

Dear @morbid,

Thanks for looking into these issue. Did not able to check INIT_INSTANCE yet. 

Will do tomorrow and update regarding that too.

Quote

do you store meta files of your materials in core folder or ung archive?

No. Actually, I am mounting the path from external directory. When this happens, Editor is not creating any meta file for it. 

 Editor internally checks this .meta files for inheritance, doesn't it?

If this is the case then I will create meta files by placing it in data folder first and then will copy the same meta file to mount point too. Lets see if that would work. Will keep you posted.

Rohit

Link to comment

Editor works with assets only, a file without *.meta is not an asset.

Editor also uses core folder as read only, so if you manually place some files in core meta won't be created automatically. As for the mounting point — please check if it's not read only.

Thanks!

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

Link to comment

Dear @morbid,

There is no more clone issue after the INIT_INSTANCE and other changes. This is done. :-) Thank you.

I am still not able to create a child material from mounted path. I will surely give it a another take with fresh mind. Please allow some time for this test.

Will keep you posted.

Rohit

Link to comment
  • 1 month later...

Dear @morbid

After making my external mount path writable, the editor created the .meta files and I can create the child material. Thank you very much for all the help to understand it better.

Rohit

Link to comment
  • silent changed the title to [SOLVED] Custom Deferred Material Problem
×
×
  • Create New...