•      Sign In
• Create Account

#ActualDaniel Wilson

Posted 06 August 2012 - 09:33 AM

Hi, I am working on implementing a subsurface scattering light shader and have it all coded I just need to debug. I have a question I cannot solve though, say I have the attenuated light vector that has come from the light, scattered as it enters the surface of the object, and now goes to the viewers eye. What would I do with this output vector for for a mesh that has a standard Blinn-Phong shader? The image has the vector I am talking about, vector PC

In my normal lighting shader I have this:


float3 l = normalize(IN.light.xyz - IN.oPosition);
float3 v = normalize(IN.oPosition);

// compute diffuse and specular terms
float diff = saturate(dot(l,IN.normal));
float spec = saturate(dot(normalize(l-v),IN.normal));
spec = pow(spec, shine);
// attenuation factor
float att = saturate(dot(l, IN.normal));

// compute final color
float3 finalcolor;
finalcolor =  ambient.xyz*color.xyz +
att*(color.xyz*diffuse.xyz*diff +
specular*spec);

return float4(finalcolor.xyz, 1.0);


With no normal map or anything, how might I slot PC into this code. I'm thinking it would replace the view direction v that I have. Someone else told me the *= it with the final colour, but that just produces weird rainbow type colours, and my light is white

#2Daniel Wilson

Posted 06 August 2012 - 09:19 AM

Hi, I am working on implementing a subsurface scattering light shader and have it all coded I just need to debug. I have a question I cannot solve though, say I have the attenuated light vector that has come from the light, scattered as it enters the surface of the object, and now goes to the viewers eye. What would I do with this output vector for for a mesh that has a standard Blinn-Phong shader? The image has the vector I am talking about, vector PC

In my normal lighting shader I have this:


float3 l = normalize(IN.light.xyz - IN.oPosition);
float3 v = normalize(IN.oPosition);

// compute diffuse and specular terms
float diff = saturate(dot(l,IN.normal));
float spec = saturate(dot(normalize(l-v),IN.normal));
spec = pow(spec, shine);
// attenuation factor
float att = saturate(dot(l, IN.normal));

// compute final color
float3 finalcolor;
finalcolor =  ambient.xyz*color.xyz +
att*(color.xyz*diffuse.xyz*diff +
specular*spec);

return float4(finalcolor.xyz, 1.0);


With no normal map or anything, how might I slot PC into this code. I'm thinking it would replace the view direction v that I have. Someone else told me the *= it with the final colour, but that just produces weird rainbow type colours, and my light is white

#1Daniel Wilson

Posted 05 July 2012 - 11:22 AM

Hi, I am working on implementing a subsurface scattering light shader and have it all coded I just need to debug. I have a question I cannot solve though, say I have the attenuated light vector that has come from the light, scattered as it enters the surface of the object, and now goes to the viewers eye. What would I do with this output vector for for a mesh that has a standard Blinn-Phong shader? The image has the vector I am talking about, vector PC

In my normal lighting shader I have this:


float3 l = normalize(IN.light.xyz - IN.oPosition);
float3 v = normalize(IN.oPosition);

// compute diffuse and specular terms
float diff = saturate(dot(l,IN.normal));
float spec = saturate(dot(normalize(l-v),IN.normal));
spec = pow(spec, shine);
// attenuation factor
float att = saturate(dot(l, IN.normal));

// compute final color
float3 finalcolor;
finalcolor =  ambient.xyz*color.xyz +
att*(color.xyz*diffuse.xyz*diff +
specular*spec);

return float4(finalcolor.xyz, 1.0);


With no normal map or anything, how might I slot PC into this code. I'm thinking it would replace the view direction v that I have. Someone else told me the *= it with the final colour, but that just produces weird rainbow type colours, and my light is white

PARTNERS