Triplanar fix
This commit is contained in:
parent
9d63b8e7a5
commit
796da02fc2
|
@ -48,7 +48,7 @@ class Cycles {
|
|||
public static var parse_height_as_channel = false;
|
||||
public static var parse_emission = false;
|
||||
public static var parse_subsurface = false;
|
||||
public static var triplanar = false; // Sample using texCoord0/1/2 & texCoordBlend
|
||||
public static var triplanar = false; // Sample using texCoord/1/2 & texCoordBlend
|
||||
|
||||
public static var arm_export_tangents = true;
|
||||
public static var out_normaltan:String; // Raw tangent space normal parsed from normal map
|
||||
|
@ -130,11 +130,18 @@ class Cycles {
|
|||
if (frag.vVec) vert.wposition = true;
|
||||
|
||||
if (frag.bposition) {
|
||||
vert.add_out('vec3 bposition');
|
||||
if (frag.ndcpos) {
|
||||
if (triplanar) {
|
||||
frag.write_attrib('vec3 bposition = vec3(
|
||||
texCoord1.x * texCoordBlend.y + texCoord2.x * texCoordBlend.z,
|
||||
texCoord.x * texCoordBlend.x + texCoord2.y * texCoordBlend.z,
|
||||
texCoord.y * texCoordBlend.x + texCoord1.y * texCoordBlend.y);');
|
||||
}
|
||||
else if (frag.ndcpos) {
|
||||
vert.add_out('vec3 bposition');
|
||||
vert.write('bposition = (ndc.xyz / ndc.w);');
|
||||
}
|
||||
else {
|
||||
vert.add_out('vec3 bposition');
|
||||
vert.add_uniform('vec3 dim', '_dim');
|
||||
vert.add_uniform('vec3 hdim', '_halfDim');
|
||||
vert.write_attrib('bposition = (pos.xyz + hdim) / dim;');
|
||||
|
@ -1748,7 +1755,7 @@ class Cycles {
|
|||
|
||||
if (triplanar) {
|
||||
curshader.write('vec4 $tex_store = vec4(0.0, 0.0, 0.0, 0.0);');
|
||||
curshader.write('if (texCoordBlend.x > 0) $tex_store += texture($tex_name, ${uv_name}0.xy) * texCoordBlend.x;');
|
||||
curshader.write('if (texCoordBlend.x > 0) $tex_store += texture($tex_name, ${uv_name}.xy) * texCoordBlend.x;');
|
||||
curshader.write('if (texCoordBlend.y > 0) $tex_store += texture($tex_name, ${uv_name}1.xy) * texCoordBlend.y;');
|
||||
curshader.write('if (texCoordBlend.z > 0) $tex_store += texture($tex_name, ${uv_name}2.xy) * texCoordBlend.z;');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue