on 23-07-2012 10:55 AM
Maybe my question is dumb, but i want to know if it is possible to manage the common code of the various shaders i made.
Example: I would like to make a function that operates based on the distance, another that operates based on vertex color, another based on pixel color etc, and then making shaders that call one or more of them for a single drawing operation.
Is it possible?
Solved! Go to Solution.
on 23-07-2012 12:32 PM
It's 'possible' but your functions need to be contained within the same file as your vertex or fragment shader functions. You'll have to copy the functions between shader files if you want to use them in multiple shaders. Almost all shader systems work this way.
23-07-2012 12:45 PM - edited 23-07-2012 12:47 PM
So in any case i have to copy the code. ![]()
Thanks
EDIT:
could you please tell me how to do and use functions in shaders? Thanks again ![]()
on 23-07-2012 02:04 PM
You use functions just the same way as you do in C/C#:
float4 DoSomething( float4 colour )
{
return float4(colour.rgb * 0.5f,colour.a);
}
... (in main)
float4 colour = DoSomething( vertexColour );
on 23-07-2012 02:30 PM
Hi:
You can use #include directive and make sure that file it's no build action =). I Used it and works.
Cheers
on 23-07-2012 02:33 PM
Ha, cool. I didn't even know you could use #include in shaders and I've written bloody hundreds over the last few years :-p
on 23-07-2012 03:19 PM
Hi:
Great =D.
Cheers,
on 23-07-2012 04:44 PM
Thanks to you all! ![]()
on 23-07-2012 05:01 PM
=D.
on 24-07-2012 11:25 AM
I tried making functions in a shader and then including the file in another shader, if in the included shader there's the main i get an error saying that there's already a main, if not i get an error saying that the shader needs a main...
What's the correct way?
PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.
フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと
PSM DevPortalを一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870