Page 1 of 1

Manual Specular Implementation Issue?

PostPosted: Thu Oct 26, 2017 9:33 pm
by mehrdad995
Hi everyone.
I've recently switched to amplify from shader forge.
everything seems great but some really simple issues are really giving me headaches.
1) my specular/gloss seems to be calculated in vertex shading!
Image
2) by zooming camera in and out, the specular size change as well!
Image
but in shader forge or even standard shader not only the specular is smooth but its size doesn't change on different zooming levels.
I know there is a node only to calculate lighting when in custom light. that works great but I want to have control over parts and need to implement it manually.

my current shader function
Image

thanks in advance

Re: Manual Specular Implementation Issue?

PostPosted: Fri Oct 27, 2017 10:20 am
by Ricardo Teixeira
mehrdad995 wrote:Hi everyone.
I've recently switched to amplify from shader forge.
everything seems great but some really simple issues are really giving me headaches.
1) my specular/gloss seems to be calculated in vertex shading!
Image
2) by zooming camera in and out, the specular size change as well!
Image
but in shader forge or even standard shader not only the specular is smooth but its size doesn't change on different zooming levels.
I know there is a node only to calculate lighting when in custom light. that works great but I want to have control over parts and need to implement it manually.
my current shader function
Image
thanks in advance


Greetings,

Thanks for getting in touch, we would be happy to help. Are you using the World Reflection node for any particularly reason? Below is the usual setup, be sure to normalize the World Normal position.

Image

If the problem persists, please share a sample so that I can forward it to the ASE developer for further examination.

Thanks!

Re: Manual Specular Implementation Issue?

PostPosted: Fri Oct 27, 2017 7:04 pm
by mehrdad995
Ricardo Teixeira wrote:
Greetings,

Thanks for getting in touch, we would be happy to help. Are you using the World Reflection node for any particularly reason? Below is the usual setup, be sure to normalize the World Normal position.

Image

If the problem persists, please share a sample so that I can forward it to the ASE developer for further examination.

Thanks!


Thank you so much Ricardo. I really don't know how to return the favor.
my bad, I had to use "half-direction" for proper blinn-phong specular model.
regarding to this post http://amplify.pt/forum/viewtopic.php?p=1631#p1631
the dot product of "View Dir" and "Light Direction" should result in the "half-direction".
the same shader produced in both Amplify and Shader-forge results in a totally different shadings!
the one generated by Amplify isn't right and again its specular shine's size change on camera position change(seems like projection matrix issue, i'm not sure though).

The Shader forge node setup :
Image
It's result :
Image

The Amplify node setup :
Image
It's result :
Image

Amplify generated shader:
https://mega.nz/#!ghggRa6Z!ympPVOMz0ciCJKSWTvdH2B1UWQBiCfbCzpe_3ZfmIEs

Shader-Forge generated shader:
https://mega.nz/#!JhwzxIiZ!T-jMqfyv7x1q2TCDnlRUHlaPZjGlIPYpmn7-akycnWU

Re: Manual Specular Implementation Issue?

PostPosted: Sat Oct 28, 2017 9:00 pm
by Amplify_Borba
Hello, Borba here, Ricardo is currently unavailable so I'll be replying in his place.

Thank you for the additional information and for providing shader samples, we'll be forwarding these to the developers and will get back to you once we have any new developments on this issue.

Also, did you try setting the View Direction's coordinate space to Tangent?

Re: Manual Specular Implementation Issue?

PostPosted: Sun Oct 29, 2017 3:50 pm
by mehrdad995
Thank you so much Borba.
yes I did, It behaves even more weird after that.

world space:
https://www.dropbox.com/s/wx4w6y5bb6xu5th/WorldSpace.gif

tangent space:
https://www.dropbox.com/s/pn5we38md1qsek0/TangentSpace.gif

Re: Manual Specular Implementation Issue?

PostPosted: Mon Oct 30, 2017 10:54 am
by Amplify_RnD_Rick
Hi mehrdad995,

I've looked at the shader you shared and the reason it's giving those strange results is because your half vector is not calculated correctly .
The Blinn-Phong half vector is calculated by summing the view direction with the light direction and then normalizing the result.

Here's your sample with the fixed half-vector:
HalfVector.JPG
HalfVector.JPG (85.62 KiB) Viewed 5527 times


Please don't hesitate on reaching us if you have further questions or stumble into any issues!

Re: Manual Specular Implementation Issue?

PostPosted: Mon Oct 30, 2017 12:27 pm
by mehrdad995
Hi Rick
I'm at a loss for words, I don't know how to describe how awesome you guys are.
that totally fixed my issue.
thanks you all once again for this precious support <3

Re: Manual Specular Implementation Issue?

PostPosted: Mon Oct 30, 2017 2:27 pm
by Amplify_Borba
mehrdad995 wrote:Hi Rick
I'm at a loss for words, I don't know how to describe how awesome you guys are.
that totally fixed my issue.
thanks you all once again for this precious support <3


No worries, we're always glad to be of assistance!

We're also adding a Shader Function in a future update that will perform the "Half Vector" calculation for your convenience thanks to your feedback, it was extremely helpful and much appreciated!

Have you had the chance to rate and review Amplify Shader Editor? It would be awesome if you could share your experience with the Unity community, the Unity Asset Store thrives on user interaction and direct feedback.
Every bit helps, your feedback is extremely valuable to us!

Feel free to get back in touch if you have further issues or questions, thanks!