mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
go back to using raw wsNormal with a few additional prep-lines for if that hasn't been made a var for that shader yet
This commit is contained in:
parent
ae752a04e8
commit
80c9f35ee1
2 changed files with 25 additions and 15 deletions
|
|
@ -3102,23 +3102,33 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
||||||
LangElement* colorDecl = new DecOp(matinfo);
|
LangElement* colorDecl = new DecOp(matinfo);
|
||||||
meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
|
meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||||
|
Var* worldToTangent = getInWorldToTangent(componentList);
|
||||||
|
|
||||||
Var *bumpNormal = (Var*)LangElement::find("bumpNormal");
|
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||||
if (!bumpNormal)
|
if (!wsNormal)
|
||||||
{
|
{
|
||||||
bumpNormal = new Var("bumpNormal", "float4");
|
wsNormal = connectComp->getElement(RT_TEXCOORD);
|
||||||
LangElement* colorDecl = new DecOp(bumpNormal);
|
wsNormal->setName("wsNormal");
|
||||||
meta->addStatement(new GenOp(" @ = float4(1.0,0.0,0.0,0.0);\r\n", colorDecl)); //default to identity normal
|
wsNormal->setStructName("IN");
|
||||||
|
wsNormal->setType("float3");
|
||||||
|
|
||||||
|
// If we loaded the normal its our responsibility
|
||||||
|
// to normalize it... the interpolators won't.
|
||||||
|
//
|
||||||
|
// Note we cast to half here to get partial precision
|
||||||
|
// optimized code which is an acceptable loss of
|
||||||
|
// precision for normals and performs much better
|
||||||
|
// on older Geforce cards.
|
||||||
|
//
|
||||||
|
meta->addStatement(new GenOp(" @ = normalize( half3( @ ) );\r\n", wsNormal, wsNormal));
|
||||||
}
|
}
|
||||||
|
|
||||||
Var *wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
|
||||||
|
|
||||||
Var *worldToTangent = getInWorldToTangent(componentList);
|
|
||||||
|
|
||||||
//Reflection vec
|
//Reflection vec
|
||||||
Var *surface = new Var("surface", "Surface");
|
Var* surface = new Var("surface", "Surface");
|
||||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@,@,float3x3(@));\r\n\n", new DecOp(surface), diffuseColor, bumpNormal, matinfo,
|
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, wsNormal, matinfo,
|
||||||
inTex, wsPosition, wsEyePos, wsView, worldToTangent));
|
inTex, wsPosition, wsEyePos, wsView));
|
||||||
String computeForwardProbes = String::String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
String computeForwardProbes = String::String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||||
computeForwardProbes += String::String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t");
|
computeForwardProbes += String::String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t");
|
||||||
computeForwardProbes += String::String("TORQUE_SAMPLERCUBE_MAKEARG(@), TORQUE_SAMPLERCUBE_MAKEARG(@), \r\n\t\t");
|
computeForwardProbes += String::String("TORQUE_SAMPLERCUBE_MAKEARG(@), TORQUE_SAMPLERCUBE_MAKEARG(@), \r\n\t\t");
|
||||||
|
|
|
||||||
|
|
@ -148,14 +148,14 @@ inline Surface createSurface(float4 gbuffer0, TORQUE_SAMPLER2D(gbufferTex1), TOR
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Surface createForwardSurface(float4 baseColor, float4 normal, float4 pbrProperties, in float2 uv,
|
inline Surface createForwardSurface(float4 baseColor, float3 normal, float4 pbrProperties, in float2 uv,
|
||||||
in float3 wsPosition, in float3 wsEyePos, in float3 wsEyeRay, in float3x3 worldToTangent)
|
in float3 wsPosition, in float3 wsEyePos, in float3 wsEyeRay)
|
||||||
{
|
{
|
||||||
Surface surface = (Surface)0;
|
Surface surface = (Surface)0;
|
||||||
|
|
||||||
surface.depth = 0;
|
surface.depth = 0;
|
||||||
surface.P = wsPosition;
|
surface.P = wsPosition;
|
||||||
surface.N = normalize( mul( normal.xyz, worldToTangent ) );
|
surface.N = normal;
|
||||||
surface.V = normalize(wsEyePos - surface.P);
|
surface.V = normalize(wsEyePos - surface.P);
|
||||||
surface.baseColor = baseColor;
|
surface.baseColor = baseColor;
|
||||||
const float minRoughness=1e-4;
|
const float minRoughness=1e-4;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue