Forward3D piece(and others) as more function-like (in-out)

What it says on the tin: a place to discuss proposed new features.
Post Reply
hyyou
Gremlin
Posts: 173
Joined: Wed Feb 03, 2016 2:24 am
x 17
Contact:

Forward3D piece(and others) as more function-like (in-out)

Post by hyyou »

In "Forward3D_piece_ps.glsl", the shader access global variable in a very hard-coded way.

For example Notice that the forward3D access inPs.pos directly :-

Code: Select all

float fSlice = log2( max( -inPs.pos.z - .... 
My wish
The Ogre's official piece should use more-local-like name e.g. forward3D_inPsPos, and the external "caller" responsible to pass it like:-

Code: Select all

vec3 forward3D_inPsPos=inPs.pos;  //user code
 .... insert piece "forward3dLighting" .... which use "forward3D_inPsPos" instead of "inPs.pos"
 ..... float fSlice = log2( max( -forward3D_inPsPos.z - .... 
This will promote decoupling.
If it is done, in custom HLMS implemention, I don't have to try to identify the fields the Forward3D sneakily want, and riskily rename mine to match it.

Another interpretation
It is hard to explain, so here is another attempt:-

Current pixel shader is roughly-like :-

Code: Select all

input: inPs
algorithm :{
     my hlms
     forward3D block (access inPs.pos)
}
I wish it to be :-

Code: Select all

input: inPs
algorithm :{
     my hlms
     vec3 forward3D_inPsPos = inPs.pos;       //<-- still my code
     //^--- like a parameter to a Forward3D function
     forward3D block (access forward3D_inPsPos)
}
P.S.
Many other places are also hard-coded, but I am not sure whether it should be/easy-to encapsulate :-

Code: Select all

float f3dMinDistance	= passBuf.f3dData.x;
^ The passBuf should probably be aliased as forward3d_passBuf before passing to forward3D block.

Code: Select all

vec3 tmpColour = BRDF( lightDir, viewDir, NdotV, lightDiffuse.xyz, lightSpecular );
^ Forward3D should provide forward3D_out_lightDir, forward3D_out_viewDir, forward3D_out_NdotV .... , and call a dummy BRDF_USED, and let user hook to the default BRDF it manually.

If this post is too hard to understand, please tell me, I will try even harder.
I am not sure if it is a good idea though.
Custom C++ HLMS implementation is used by just a few user anyway.
Post Reply