genesis and double side shading feature (question)

nyanyannyanyan Posts: 22
edited June 2012 in Daz Studio Discussion

I want to know how to use double side shading feature of 3Dlight in DS4 against genesis.

My shader uses double side shading feature of 3Dlight in DAZ Studio4.
It works for A3, belbel, V4,and so on.
But it does not work for genesis.

If anyone show me code how to do it, I am very very very happy.

Thank you for your reading.

Post edited by nyanyan on

Comments

  • Richard HaseltineRichard Haseltine Posts: 96,849
    edited December 1969

    It should just work, especially if it works for some items. What exactly are you doing, and what are you getting as as result?

  • ReDaveReDave Posts: 815
    edited June 2012

    If you have the DS4.5 release candidate it contains the Ambient Occlusion scripted renderer scripts that do include a command about double-sided surfaces.
    However, since it works for you for older figures, it's probably just a Genesis bug.

    Post edited by ReDave on
  • nyanyannyanyan Posts: 22
    edited December 1969

    I put a sample shader at http://www.geocities.jp/nyankko15/DAZStudio/tmp/doublesidetest.zip
    It contains sourcecode.

    keypoint are 2.
    1. code : Shader.setIntegerAttrib("sides", "integer doubleshaded",1);
    where: scripts/support/Eilir/s2_test/s2_simple_surfaceAttribs.ds

    2. in shader suorce code
    determine whetter it is forward sourface or reverse surafce
    by sign = sign(N.Ng);

    code snippet:

    float sign = sign(N.Ng);
    ....
    if(sign >=0){
    Oi = Ot;
    Ci = Oi*Ct;
    }else{
    Oi = rOt;
    Ci = Oi*rCt;
    }

    result:
    by this shader , I can set forward color , forward opacity, reverse color ,reverse opacity.
    If I apply this shader to sphere and
    set forward color red and revers color blue and forward opacity 1 then sphere is painted by red
    and if set forward opacity 0 then shpere is painted by blue,
    but if I apply this shader to Genesis,
    If I set forward opacity 0 then Genesis is not painted.transparency at all.
    It should be painted blue.

    By this result , I think
    sign = sign(N.Ng);
    is >= 0 allways

    I wonder why this is occure.
    Perhaps keypoint 1 does not work against Genesis.
    About Genesis , RIB structure is deferent from other figures.
    When I set renderoption to RIB output, I can see Genesis
    structure is deferent from other figures.
    I think it affect to keypoint1.

    If I converted(Exported) Genesis to Poser and load on DS4
    then the shader works . Because exporeted Genesis's Structure
    is same as other figures.
    But Exproted Genesis is not good for DS4.

    Perhaps there is a way to use double side shadiing against Genesis sturucture
    I want to know the way how to do it. Realy very very much.

    Thank you for your reading, thinking.
    PS this shader is generated by Eilir (for DS2) and compiled by DS4's RSL Editor

  • ReDaveReDave Posts: 815
    edited December 1969

    NyaNyan said:

    PS this shader is generated by Eilir (for DS2) and compiled by DS4's RSL Editor
    I think this explains actually. In the days of Eilir, the geometry of the existing figures (up to V4/M4) was attached to nodes, but in Genesis the geometry is on the root so the support scripts probably return no geometry.
    I found this in My Library/shaders/s2_test/s2_test.ds which may be one of the culprits:
    
    function processMaterials( oNode, aMaterials ){
      var oObject = oNode.getObject();
      if( oObject != undefined ){
       var nShapes = oObject.getNumShapes();
       for( var s = 0; s < nShapes; s++ ){
        var oShape = oObject.getShape( s );
        if( oShape != undefined ){
         var nMaterials = oShape.getNumMaterials();
         for( var m = 0; m < nMaterials; m++ ){
          var oMaterial = oShape.getMaterial( m );
          if( isInArrayByName( aMaterials, oMaterial ) != -1 ){
           buildMaterial( oShape, oMaterial );
          }
         }
        }
       }
      }
     

    I'm not knowledgeable enough to fix it myself. :-S
  • Richard HaseltineRichard Haseltine Posts: 96,849
    edited June 2012

    I'm not sure if that is the root, but if it is you might try something like this instead of var oObject = oNode.getObject();

    var oObject = oNode.getObject();
    if ( oNode.inherits( "DzBone" ) ) {
     if ( oNode.getFigure().inherits( "DzFigure" ) ) {
      oObject = oNode.getFigure().getObject() )
     }
    }

    However, I think that would risk rendering the same object multiple times - if possible it would be better to handle this at the nod gathering stage, so that there was a single oNode for each Genesis (or other TriAx) figure, rather than one for each bone.

    Post edited by Richard Haseltine on
  • nyanyannyanyan Posts: 22
    edited December 1969

    Thank you for your reply.
    I have not enough knowledge but I will try as soon as I can have time.

  • nyanyannyanyan Posts: 22
    edited December 1969

    I tried


    var oObject = oNode.getObject();
    if ( oNode.inherits( "DzBone" ) ) {
    if ( oNode.getFigure().inherits( "DzFigure" ) ) {
    oObject = oNode.getFigure().getObject() )
    }
    }

    then parse error occured when reading scirpt file..
    I replaced ")" to ";" as follow


    var oObject = oNode.getObject();
    if ( oNode.inherits( "DzBone" ) ) {
    if ( oNode.getFigure().inherits( "DzFigure" ) ) {
    oObject = oNode.getFigure().getObject() ;
    }
    }

    then

    Executing DAZ Script file: C:/Documents and Settings/saito/My Documents/Daz 3D/Studio/My Library/Shaders/_Eilir Custom Shaders/test/s2_test/s2_test.ds
    WARNING: Script Error: Line 405
    WARNING: TypeError: Result of expression 'oNode.getFigure' [undefined] is not a function.
    WARNING: Stack Trace:
    ()@:405
    Error in script execution!

    occured when read script file.


    And by the way
    with original script file
    at forward surface the shader works well.
    Only at reverse surface the shader don't work.
  • Richard HaseltineRichard Haseltine Posts: 96,849
    edited December 1969

    Sorry, that's what comes of working from memory - getFigure() should be getSkeleton()

  • nyanyannyanyan Posts: 22
    edited December 1969

    Thank you.
    But result of rendering is the same as original script.
    if forward opacity is 0% then not painted at all ( reverse opacity is 100%)
    where it should be painted by reverse color.
    If forward opacity is 100% then painted by foward color.

  • ReDaveReDave Posts: 815
    edited December 1969

    I'd file a bug report and/or send a PM to ketthrove, he's the most likely to know what is wrong.

  • nyanyannyanyan Posts: 22
    edited December 1969

    Ah, yeah
    But Eilir is a free soft , and commercial version of it is a shader mixer and shader builder.
    He has no responsibility to do anything at all.

Sign In or Register to comment.