It is currently Sat Aug 22, 2020 4:54 am


All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Shader wants normals but mesh doesn't have them
PostPosted: Sun Nov 10, 2013 6:28 am 
User avatar

Joined: Tue Feb 05, 2013 5:44 pm
Posts: 33
I imported a colored cubes volume from images and attempted to add the SSAO effect to the camera. This error message appears at the bottom of the Unity window:

"Shader wants normals but mesh doesn't have them"

I'm currently evaluating a switch to Unity for my game. I'm using the 30 day trial to check out some of the image effects like SSAO.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Shader wants normals but mesh doesn't have them
PostPosted: Sun Nov 10, 2013 8:23 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Hmmm... that's interesting. Basically it's correct - we don't generate per-vertex normals for the mesh data because we instead compute them in the fragment shader. But this has only been tested with basic lighting and not with deferred shading or post-processing effects. So perhaps there is a problem here.

As a fallback we could provide the per-vertex normals but it requires duplicating a lot of vertex data, for example a single cube then requires 24 vertices rather than eight.

This will need some investigation and unfortunatly I don't have Unity Pro. I'll probably use my 30-day trial at some point soon so I'll try to look at it then. Until then the bug has been logged here: https://bitbucket.org/volumesoffun/cubi ... oesnt-have


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Shader wants normals but mesh doesn't have them
PostPosted: Mon Nov 11, 2013 3:41 am 
User avatar

Joined: Tue Feb 05, 2013 5:44 pm
Posts: 33
David Williams wrote:
Hmmm... that's interesting. Basically it's correct - we don't generate per-vertex normals for the mesh data because we instead compute them in the fragment shader. But this has only been tested with basic lighting and not with deferred shading or post-processing effects. So perhaps there is a problem here.

As a fallback we could provide the per-vertex normals but it requires duplicating a lot of vertex data, for example a single cube then requires 24 vertices rather than eight.

This will need some investigation and unfortunatly I don't have Unity Pro. I'll probably use my 30-day trial at some point soon so I'll try to look at it then. Until then the bug has been logged here: https://bitbucket.org/volumesoffun/cubi ... oesnt-have


Might it be possible to modify the SSAO shader just for testing purposes? Any tips?

I'd like to see if a switch to Unity is viable before my 30 day trial is over :?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Shader wants normals but mesh doesn't have them
PostPosted: Mon Nov 11, 2013 12:25 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I have a couple of ideas. Firstly, you might find that it actually works despite the error message. Unity assumes that there are no surface normals because they are not contained in the vertex data, but it has no way of knowing that they are actually being generated in the fragment shader. They are still being written to the 'Normal' attribute of the 'SurfaceOutput' structure.

Have a look at our shader here. Note that the vertex shader creates dummy values for the normal and tangents. We had a similar error with 'Shader wants tangents but the mesh doesn't have them' and this fixed it. The actual normal is computed in the first line of the fragment shader, and we never compute or use the tangents.

I don't know how the SSAO system in Unity works, but maybe you can tweak the shader code with something similar. Or maybe it needs to know about the Cubiquity custom vertex shader?

Lastly, you can probably create real vertex normals with Mesh.RecalculateNormals(). However, they will be smoothed normals and won't match the ones which our shader computes. Not sure how much that matters for SSAO. This function call could be added to the 'BuildMeshFromNodeHandle' function in the ColoredCubesVolume (be aware that the TerrainVolume has this function too, so get the right one).


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net