[Papervision3D] mirrored shading materials on sphere's
Marcel van Duijn
coding at marcelvanduijn.com
Tue Apr 14 00:43:09 PDT 2009
Hi Paul,
thanks for your response. I solved it in the mean time. Its a simple fix,
and I agree that its best to update the EnvMapMaterial class so that
everything works as intended. It was as simple as fixing the implementation
of .backenvmap in EnvMapMaterial.drawTriangle(). I have tested it by adding
these lines to the drawTriangle method:
var map:BitmapData = (useMap == null) ? _lightMap :
useMap;
graphics.beginBitmapFill( map, transformMatrix, false,
false);
and setting the .backenvmap property of the material (which is a public
property).
I agree that it would be nice to update the EnvMapMaterial constructor to
have a default backenvmap BitmapData object. Maybe its a good idea to
implement the parameter in the constructors of materials that extend on
EnvMapMaterial as well. Because uptill now you could only set it through the
public property.
I posted a request for this fix yesterday to this list. I'm not sure if it
ends up in the right hands so that someone handling this part of PV can fix
it.
Chrs,
Marcel
Paul Tondeur wrote:
>
> Hi Marcel,
>
> I've just noticed the same behaviour as you did. As far as I can see
> it materials that inherit from EnvMapMaterial calculate their
> materials incorrectly. As a workaround you could use a shader instead
> of a PhongShadeMaterial:
> Place the following code code in case 1 and you'll get the expected
> results:
>
> var bmdBase:BitmapData = new BitmapData(250,250,false,0xffffff);
> var bitmapMat:BitmapMaterial = new BitmapMaterial(bmdBase);
> var phongShader:PhongShader = new PhongShader(light,0xff3300,0x0, 3);
> m = new ShadedMaterial(bitmapMat, phongShader);
>
> However, I wanted to figure out where this was coming from. After a
> long, long search I found out about the little detail that the
> envMapMaterial.drawTriangle method has a bitmapfill made of the
> lightmap, instead of the useMap bitmap. This happens exactly in your
> code from below. So I changed that to:
>
> graphics.beginBitmapFill( useMap, transformMatrix, false, false);
>
> However, that introduces a new problem, as the backenvmap was not
> defined by the PhongMaterial or CellMaterial. Both can be solved by
> passing the second color value as the fourth parameter to the super
> class:
> super(light, LightMaps.getPhongMap(lightColor, ambientColor,
> specularLevel), null, ambientColor);
> and:
> super(light, LightMaps.getCellMap(color_1, color_2, steps), null,
> color_2);
>
> To make this work the constructor of EnvMapMaterial needs to be
> changed a little bit, similar as the constructor EnvMapShader. When no
> backenvmap bitmapdata has been provided, we need to define one manually.
> if(!backenvmap){
> this.backenvmap = new BitmapData(1,1,false, ambientColor);
> }else{
> this.backenvmap = backenvmap;
> }
>
> As long as i've not overseen something, I think it's good to update
> the Papervision source with this little adjustment? I've attached the
> files for this purpose. Hope this helps:-)
>
> Paul
>
>
> On Apr 13, 2009, at 4:13 PM, Marcel van Duijn wrote:
>
>>
>> Hi,
>>
>> I have investigated the problem a bit further and noticed the
>> following.
>>
>> Papervisions' EnvMapMaterial has a property .backenvmap. This
>> property is
>> utilized in EnvMapMaterial.drawTriangle but the implementation seems
>> incorrect so that the backenvmap is actually never used???
>>
>> The method seems to choose between the map to draw from (lightMap /
>> backenvmap) based on the angle of the face with the light source.
>> For angles
>>> 90 or < -90 the backenv-map should be used (or something like that).
>> But the actually drawing of the map hardcodedly uses 'lightMap' as
>> the map
>> to draw from. So backenvmap isn't used at all right???
>>
>> See this snapshot from Papervision's EnvMapMaterial.drawTriangle():
>>
>> [code=actionscript]
>> if(face3D.faceNormal.x * lightMatrix.n31 + face3D.faceNormal.y *
>> lightMatrix.n32 + face3D.faceNormal.z * lightMatrix.n33 > 0){
>> useMap = _lightMap;
>> }else{
>> useMap = backenvmap;
>> }
>> graphics.beginBitmapFill( _lightMap, transformMatrix, false,
>> false);
>> [/code]
>>
>> Would this be an explanation for the problem of my post? As I'm kind
>> of a
>> novice to PV I cant imagine that this hasnt been noticed...
>>
>> Could someone confirm or explain? Thanks
>>
>>
>>
>>
>> Marcel van Duijn wrote:
>>>
>>> Hi,
>>>
>>> can anyone explain why the non-yellow spheres in this movie
>>> http://www.marcelvanduijn.com/test/Materials_Shading_MulitpleViewports_Interaction.html
>>> http://www.marcelvanduijn.com/test/Materials_Shading_MulitpleViewports_Interaction.html
>>> have their shading materials mirrored? The light source shows on both
>>> sides of these spheres. The yellow spheres behave as expected.
>>>
>>> I did notice the materials extend on EnvMapMaterial or use
>>> EnvMapShader.
>>> I'm new to PV3D and materials, shading etc...
>>>
>>> thanks
>>>
>>> Marcel
>>>
>>> PS:
>>> http://www.nabble.com/file/p23010598/Materials_Shading_MulitpleViewports_Interaction.as
>>> Materials_Shading_MulitpleViewports_Interaction.as
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/mirrored-shading-materials-on-sphere%27s-tp23010598p23022832.html
>> Sent from the Papervision3D mailing list archive at Nabble.com.
>>
>>
>> _______________________________________________
>> Papervision3D mailing list
>> Papervision3D at osflash.org
>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>
--
View this message in context: http://www.nabble.com/mirrored-shading-materials-on-sphere%27s-tp23010598p23034649.html
Sent from the Papervision3D mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20090414/0facd7fd/attachment-0001.html>
More information about the Papervision3D
mailing list