<div><div dir="auto">Yes the Coordinate note could be shared by DEF / USE. There is no aliasing -- whether coordinates are shared by DEF / USE or just repeated precisely the same, it results in equal screen positions or pixels.</div></div><div dir="auto"><br></div><div dir="auto">Regards,</div><div dir="auto">Michalis</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">W dniu czw., 12.03.2020 o 04:36 Don Brutzman <<a href="mailto:brutzman@nps.edu">brutzman@nps.edu</a>> napisał(a):<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Looking forward to unification of front and back Materials.<br>
<br>
The use case translation is interesting.  For the second version, with two IFS nodes, am assuming you have consistent Coordinate nodes (hopefully via DEF/USE).  Not sure the browser would be expected to detect that they are identical however, especially if coordinate points are repeated.<br>
<br>
Wouldn't aliasing effects be possible/likely if the two passes are performed independently?  Two passes as Doug proposes would be traversing the same geometry and so could avoid that problem.<br>
<br>
On 3/9/2020 2:33 PM, Michalis Kamburelis wrote:<br>
> Absolutely.<br>
> <br>
> 2-pass rendering is a valid way to implement different front/back<br>
> material parameters. Although it will not be as efficient as doing it<br>
> in 1 pass (and checking gl_FrontFacing). But it's unsure whether the<br>
> optimization matters (you would need a huge scene using extensively<br>
> two-sided materials with different front/back parameters to feel the<br>
> optimization).<br>
> <br>
> Note that you don't need different shaders for front/back (unless you<br>
> utilize some optimizations that assume knowledge about materials, e.g.<br>
> CGE optimizes materials with specularColor = zero specially, by not<br>
> including the specular computation). In normal case, you can use the<br>
> same shader, just pass different parameters when it's front, different<br>
> when it's back. Culling is done by glCullFace(GL_FRONT),<br>
> glCullFace(GL_BACK), so it happens outside of the shader code.<br>
> <br>
> I actually proposed this at some point as an upgrade path from<br>
> TwoSidedMaterial, and then we would not even need to add<br>
> "backMaterial". In CGE (we don't support TwoSidedMaterial with<br>
> separateBackColor=TRUE, or backMaterial, for now), as well as in Unity<br>
> and probably some others, it's a standard way to get 2-sided materials<br>
> with different colors.<br>
> <br>
> IOW, you can transform<br>
> <br>
> """<br>
> Shape {<br>
>    appearance Appearance {<br>
>      material Material { diffuseColor 1 1 0 }<br>
>      backMaterial Material { diffuseColor 0 0 1 }<br>
>    }<br>
>    geometry IndexedFaceSet { ccw TRUE solid FALSE ... }<br>
> }<br>
> """<br>
> <br>
> into this:<br>
> <br>
> """<br>
> Shape {<br>
>    appearance Appearance {<br>
>      material Material { diffuseColor 1 1 0 }<br>
>    }<br>
>    geometry IndexedFaceSet { ccw TRUE solid TRUE ... }<br>
> }<br>
> Shape {<br>
>    appearance Appearance {<br>
>      material Material { diffuseColor 0 0 1 }<br>
>    }<br>
>    geometry IndexedFaceSet { ccw FALSE solid TRUE ... }<br>
> }<br>
> """<br>
> <br>
> Regards,<br>
> Michalis<br>
> <br>
> <br>
> <br>
> pon., 9 mar 2020 o 21:24 GPU Group <<a href="mailto:gpugroup@gmail.com" target="_blank">gpugroup@gmail.com</a>> napisał(a):<br>
>><br>
>> OK one more idea I haven't tried:<br>
>> Could a browser loop on the CPU side, drawing the same object twice, once with front material the front facing fragments, once with back material drawing back facing fragments -different compiled shaders- and setting one uniform or #define in the shader to say to draw front or back side of fragments?<br>
>> If so then that would simplify supporting front/back materials.<br>
>> -Doug<br>
>><br>
>> On Mon, Mar 9, 2020 at 7:55 AM Michalis Kamburelis <<a href="mailto:michalis.kambi@gmail.com" target="_blank">michalis.kambi@gmail.com</a>> wrote:<br>
>>><br>
>>> AD 1 - Yes, using backMaterial will require using containerField in X3D XML.<br>
>>><br>
>>> AD 2 - The specification of backMaterial will deliberately contain<br>
>>> wording to make implementation easier.<br>
>>><br>
>>> Namely:<br>
>>><br>
>>> - backMaterial can be <> NULL only if material <> NULL<br>
>>><br>
>>> - when both material and backMaterial are <> NULL, they must indicate<br>
>>> *the same* node class, IOW:<br>
>>><br>
>>>      - they must both be Material<br>
>>>      - or they must both be UnlitMaterial<br>
>>>      - or they must both be PhysicalMaterial<br>
>>><br>
>>> - moreover, when both material and backMaterial are <> NULL, they must<br>
>>> have equal values for all xxxTexture and xxxTextureChannel fields.<br>
>>> This means that the only difference can be in vector/scalar<br>
>>> parameters. This means that e.g. you cannot use cubemap for<br>
>>> diffuseTexture on front, and 3D texture for diffuseTexture on back.<br>
>>><br>
>>>      (Browsers are of course free to "lift" this limitation and allow<br>
>>> more. But I would prefer to keep the required functionality of it, in<br>
>>> X3D 4.0, simple.)<br>
>>><br>
>>> - Indeed we will add wording to prohibit placing TwoSidedMaterial in<br>
>>> backMaterial :) Added to my TODO.<br>
>>><br>
>>> - Note that the requirement to implement backMaterial will be rather<br>
>>> high level of the appropriate component. I don't want to force all<br>
>>> browsers to implement this. I doubt that CGE will actually implement<br>
>>> it -- the use-cases for this are rather small, i.e. I never heard<br>
>>> anyone ask me to support TwoSidedMaterial with separateBackColor=TRUE<br>
>>> :)<br>
>>><br>
>>> Regards,<br>
>>> Michalis<br>
<br>
<br>
all the best, Don<br>
-- <br>
Don Brutzman  Naval Postgraduate School, Code USW/Br       <a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a><br>
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149<br>
X3D graphics, virtual worlds, navy robotics <a href="http://faculty.nps.edu/brutzman" rel="noreferrer" target="_blank">http://faculty.nps.edu/brutzman</a><br>
</blockquote></div></div>