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


All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Generate Normals in shader
PostPosted: Thu Dec 01, 2011 9:22 am 

Joined: Thu Apr 21, 2011 1:13 am
Posts: 18
Since switching to the CubicSurfaceExtractor from CubicSurfaceExtractorWithNormals
I have been having a lot of issues getting normals calculated through shaders.

I have searched every post in this forum and googled many variations of questions relating to this. No matter what I try shader wise I can't seem to get normals to calculate.

I am using vertex colouring instead of texturing each voxel and I need normals strictly for lighting.

So I should calculate the shaders like shown below in the _FP and then generate lighting before exiting the _FP?
Code:
float3 worldNormal = cross(ddy(inWorldPosition.xyz), ddx(inWorldPosition.xyz));
worldNormal = normalize(worldNormal);


Going to keep plugging away at it but I would appreciate any insight on what my pitfalls might be :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Generate Normals in shader
PostPosted: Sat Dec 03, 2011 12:15 am 

Joined: Sat Sep 18, 2010 9:45 pm
Posts: 189
Hard to say, your snippet looks correct tho. You may want to post the entire shader code if it's not too large.

Also, I suggest coloring your blocks with the normal to visually debug it.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Generate Normals in shader
PostPosted: Sat Dec 03, 2011 4:40 am 

Joined: Thu Apr 21, 2011 1:13 am
Posts: 18
I can get the normals working to project textures through a shader.
But I think I'm using the wrong semantics for what I want to achieve.

I'll keep playing around with it and post what I have soon if I can't figure it out.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Generate Normals in shader
PostPosted: Sat Dec 03, 2011 7:16 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
[quote="Will Smith"]I can get the normals working to project textures through a shader.[quote]

Can you elaborate on the problem? You mean the normals work for projective texturing but not for lighting?

At any rate, as beyzend says you should debug it by mapping the normals to colours. So take off any texturing, etc and set the RGB value of each fragment to the XYZ value of the normal. Note that negative normals will then be black, so you might want to do some scaling/shifting to adjust this. Then you can 'see' the normal to each surface.


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 4 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