Graphics

Reply
Accepted Solution

Shaders' common code

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? 

Please use plain text.

Re: Shaders' common code

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.

Martin Caine
Founder and Lead Programmer of Retroburn Game Studios

Twitter | LinkedIn | Facebook
Please use plain text.

Rif.: Shaders' common code

[ Edited ]

So in any case i have to copy the code. :smileysad:

Thanks :smileywink: 

 

EDIT:

could you please tell me how to do and use functions in shaders? Thanks again :smileyhappy:

Please use plain text.

Rif.: Shaders' common code

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 );

 

Martin Caine
Founder and Lead Programmer of Retroburn Game Studios

Twitter | LinkedIn | Facebook
Please use plain text.

Re: Shaders' common code

Hi:

 

You can use #include directive and make sure that file it's no build action =). I Used it and works.

 

Cheers

Please use plain text.

Re: Shaders' common code

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

Martin Caine
Founder and Lead Programmer of Retroburn Game Studios

Twitter | LinkedIn | Facebook
Please use plain text.

Re: Shaders' common code

Hi:

 

Great =D.

 

Cheers,

Please use plain text.

Rif.: Shaders' common code

Thanks to you all! :smileyvery-happy:

Please use plain text.

Re: Shaders' common code

=D.

Please use plain text.

Rif.: Shaders' common code

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? 

Please use plain text.
This widget could not be displayed.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

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を一度ログアウトし、再度ログインしてください。






Recent News