Как создать эффект блеска на stage3D? - PullRequest
0 голосов
/ 09 сентября 2018

У меня есть материал на x3d:

<Material diffuseColor='0.502 0.678 0.804' specularColor='1.989 1.989 1.989' transparency='0.000' shininess='0.221' />

но когда я отрисовываю его на stage3d, эффект блеска теряется.

это мой фрагментный шейдер

// Fragment shader
var fragSource:String = "" + 
"tex ft0, v0, fs0 <2d,linear,nomip>\n" + // read from texture
"nrm ft1.xyz, v1.xyz\n" + // renormalize normal
"dp3 ft1, fc2.xyz, ft1.xyz \n" + // directional light contribution
"neg ft1, ft1 \n" + // negation because we have a vector "from" light 
"max ft1, ft1, fc0 \n"+ // clamp to [0, dot]

"mul ft1, ft1, fc3 \n"+ // contribution from light
"mul ft1, ft1, ft0 \n"+ // contribution from light + texture

"mul ft2, ft1, fc4 \n"+

"add oc, ft2, fc1"; // final color as surface + ambient

Есть ли что-то, что я должен сделать по-другому, чтобы этот эффект был виден?

Может, мне стоит что-то изменить на уровне рендеринга?

Вот как я отображаю:

context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, Vector.<Number>([0,0,0,0]));  //fc0, for clamping negative values to zero
                context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 1, obj.EmbientColor);  //fc1, ambient lighting (1/4 of full intensity)
                context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 2, Vector.<Number>([obj.LightPos.x,obj.LightPos.y,obj.LightPos.z,1]));  // Light Direction
                context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 3, Vector.<Number>([2, 2, 2, 11]));  // Light Color
                context3D.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 4, obj.MaterialColor );  // meshe color
...