POV-Ray : Newsgroups : povray.advanced-users : LDraw user needs POV help : Re: LDraw user needs POV help Server Time
24 May 2024 11:06:41 EDT (-0400)
  Re: LDraw user needs POV help  
From: Roland Melkert
Date: 21 Nov 2016 15:55:01
Message: <web.58335ef8a94cadc5369a059c0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 19.11.2016 um 01:20 schrieb Roland Melkert:
>
> >> That said, maybe I can add a switch to layered textures in POV-Ray that
> >> would cause the alpha channel of a layer to knock out not only that
> >> layer's diffuse component, but also highlights and reflection. I guess
> >> such a switch might come in handy for non-LDraw users as well.
> > That would be very helpful especially when coming from an OpenGL background.
>
> Done. If you like to test-drive the extension, have a look at this version:
>
> https://github.com/POV-Ray/povray/releases/tag/v3.7.1-x.knockout.8881807
>
> The syntax isn't finalized yet.
use_alpha on on the 2nd texture's finish seems to work great, no more double
ambient/reflection exposure for the transparent part of the image.

This prevents having to generate different textures for transparent or non
transparent png's. It also improves the overall surface as the non transparent
parts now use the finish block of the image_map pigment while all transparent
pixels use the one from the lower rgb pigment. This results in even surface
behavior.

Will this be added for the normal block too?


Thanks for implementing this test.


I used it like so:

#macro ldrawTexPlastic(ldCode, pngIdx)

 #local doPng=(pngIdx>=0);
 #local idx=getColorIndex(ldCode);
 #local r=ldColor[idx][1];
 #local g=ldColor[idx][2];
 #local b=ldColor[idx][3];
 #local a=ldColor[idx][4];

 #local basePigment=
   pigment {

    #if (a<1.0)
     srgbft <r,g,b, 0.85, 0.2>
    #else
     srgb <r,g,b>
    #end
   }
  ;

 #local baseNormal=
  normal {
   bumps 0.005
   scale 0.5
   turbulence 0
  }
 ;

 #macro fin(ua)
   diffuse 1
   brilliance 1
   conserve_energy

   specular albedo 0.6
   roughness 0.02

   reflection 0.15

   #if (ua)
     use_alpha on
   #end
 #end

 #local baseFinish=finish { fin(false) }

 #if (doPng)
   #local pngPigment=
    pigment {
     uv_mapping
     image_map {
      png getPngName(pngIdx)
      map_type 0
      interpolate 2
     }
    }
  ;

  #local pngFinish=finish { fin(true) }

  #local result=
    texture {
     pigment { basePigment }
     normal { baseNormal }
     finish { baseFinish }
    }
    texture {
     pigment { pngPigment }
     normal { baseNormal }
     finish { pngFinish }
    }
   ;
   result
 #else
   pigment { basePigment }
   normal { baseNormal }
   finish { baseFinish }
 #end
#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.