如何在stage3D上产生发光效果?

时间:2018-09-08 21:05:48

标签: actionscript-3 flash air flash-builder stage3d

我在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

0 个答案:

没有答案