About Store Forum Documentation Contact
Donations:
345$/mo



Post Reply 
Custom masks for 2D shaders.
Author Message
georgatos7 Offline
Member

Post: #1
Custom masks for 2D shaders.
Lately i have been experimenting with 2D shaders for various post process effects but i'm at the stage were i would like to be able to start masking them to be able to distinguish for example the lens flare sources from the glow sources.

So what i need is the 2D shader to access things like a MaterialSpecular() or MaterialGlow() buffer or to be able to sample some specific textures for each fragment it is processing.

The obvious solution would have been to use the RTT technique to store the information i want and then pass it to my 2D shader for further sampling/masking but the things you have access outside the object shaders are the rendered RGB color, the alpha which looks like it is the MaterialGlow() * GlowTextureValue and the newly added Renderer Stages.

But what if you want something more specific like the MaterialSpecular() for the fragment you are sampling in the 2D Shader?

Is there a specific way i should approach this? Or even can the following idea be considered viable?

For Every Frame
1) Render the whole scene normally and store to rttRGBA.
2) Change at runtime the shaders of all the objects by using "D.setGetShaderFunc(GetShader)" and "D.setShader(null)" with a single shader that would expose the wanted values.
3) Re-render the whole scene and store to rttMASK.
4) Change the shader function back to default with "D.setGetShaderFunc(null)" and "D.setShader(null)".
5) Send rttRGBA and rttMASK to 2D Shader.

Would this be viable performance-wise or is there a better way to approach this? Or maybe the access to the source code is necessary for a viable solution?
(This post was last modified: 11-29-2014 03:36 AM by georgatos7.)
11-29-2014 03:26 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Custom masks for 2D shaders.
Hello,

The specular intensity of the material in deferred renderer is stored in w channel of the normal render target.
To access that you would need to grab the source code, which I highly recommend smile
11-29-2014 04:21 AM
Find all posts by this user Quote this message in a reply
georgatos7 Offline
Member

Post: #3
RE: Custom masks for 2D shaders.
Awesome, thanks Esenthel.
(This post was last modified: 11-29-2014 01:42 PM by georgatos7.)
11-29-2014 12:30 PM
Find all posts by this user Quote this message in a reply
Post Reply