Skip to main content
Participant
June 13, 2019
Question

Get Filters - Render - Lighting Effects into a script?

  • June 13, 2019
  • 4 replies
  • 735 views

Hello everyone !

For a project I have to use the render "Lighting Effects" filter on a large amount of pictures. I wanted to create a script which allowed me to do so, but I can't find a javascript function to apply this filter. (I'm looking for a function similar to ArtLayer.applyGaussianBlur() )

Does anyone know if there is one? I've looked through all of the javascript ref but I haven't found any clue...

I'm using Photoshop CC 2018.

Thank you !

Nolan

This topic has been closed for replies.

4 replies

Participant
June 16, 2019

Ok thanks JJMack​ !

The problem I have is that I have to apply random parameters to the filter, that's why I can't use an action... (At least I believe it is impossible to apply random parameters to an action, right?)

Stephen Marsh
Community Expert
Community Expert
June 16, 2019

Perhaps a hybrid approach, where you have an action set containing a large list of LE action variations, which a script can randomly call?

Stephen Marsh
Community Expert
Community Expert
June 15, 2019

Since actions do play nice with the LE filter, why can't you use an action?

JJMack
Community Expert
Community Expert
June 13, 2019

There are many Photoshop features the are not covers directly by Adobe Photoshop Scripting DOM.  Many feature need to be scripted using Action manager code.  Render lighting Effects seems to be a workspace. I see Photoshop record two steps when you use it. The first step does not work is a script the second step does render the effect I create in the workspace. You may be able to turn one its dialog toe  may it interactive in your script.

cocop97495681  wrote

Hello everyone !

For a project I have to use the render "Lighting Effects" filter on a large amount of pictures. I wanted to create a script which allowed me to do so, but I can't find a javascript function to apply this filter. (I'm looking for a function similar to ArtLayer.applyGaussianBlur() )

Does anyone know if there is one? I've looked through all of the javascript ref but I haven't found any clue...

I'm using Photoshop CC 2018.

Thank you !

Nolan

/ ======================Soptlight=================================

var idlightFilterLightingEffects = stringIDToTypeID( "lightFilterLightingEffects" );

    var desc15 = new ActionDescriptor();

    var idkthreeDLights = stringIDToTypeID( "k3DLights" );

        var list1 = new ActionList();

            var desc16 = new ActionDescriptor();

            var idNm = charIDToTypeID( "Nm  " );

            desc16.putString( idNm, """Spot Light 1""" );

            var idRd = charIDToTypeID( "Rd  " );

            desc16.putDouble( idRd, 1.000000 );

            var idGrn = charIDToTypeID( "Grn " );

            desc16.putDouble( idGrn, 1.000000 );

            var idBl = charIDToTypeID( "Bl  " );

            desc16.putDouble( idBl, 1.000000 );

            var idhots = charIDToTypeID( "hots" );

            desc16.putDouble( idhots, 2.000000 );

            var idFlOf = charIDToTypeID( "FlOf" );

            desc16.putDouble( idFlOf, 90.000000 );

            var idshdw = charIDToTypeID( "shdw" );

            desc16.putInteger( idshdw, 1 );

            var idattn = charIDToTypeID( "attn" );

            desc16.putBoolean( idattn, false );

            var idattt = charIDToTypeID( "attt" );

            desc16.putInteger( idattt, 0 );

            var idatta = charIDToTypeID( "atta" );

            desc16.putDouble( idatta, 0.000000 );

            var idattb = charIDToTypeID( "attb" );

            desc16.putDouble( idattb, 0.000000 );

            var idattc = charIDToTypeID( "attc" );

            desc16.putDouble( idattc, 0.000000 );

            var idorad = charIDToTypeID( "orad" );

            desc16.putDouble( idorad, 0.000000 );

            var idirad = charIDToTypeID( "irad" );

            desc16.putDouble( idirad, 0.000000 );

            var idmult = charIDToTypeID( "mult" );

            desc16.putDouble( idmult, 1.000000 );

            var idType = charIDToTypeID( "Type" );

            desc16.putInteger( idType, 1 );

            var idison = charIDToTypeID( "ison" );

            desc16.putBoolean( idison, true );

            var idssml = charIDToTypeID( "ssml" );

            desc16.putDouble( idssml, 0.000000 );

            var idafon = charIDToTypeID( "afon" );

            desc16.putBoolean( idafon, true );

            var idafpw = charIDToTypeID( "afpw" );

            desc16.putDouble( idafpw, 3.000000 );

            var idkeythreeDMatrix = stringIDToTypeID( "key3DMatrix" );

                var desc17 = new ActionDescriptor();

                var idkeythreeDMatrixData = stringIDToTypeID( "key3DMatrixData" );

                desc17.putData( idkeythreeDMatrixData, String.fromCharCode( 151, 18, 15, 63, 151, 18, 15, 63, 107, 186, 28, 191, 0, 0, 0, 0, 172, 182, 52, 191, 172, 182, 52, 63, 0, 0, 0, 0, 0, 0, 0, 0,

112, 128, 221, 62, 112, 128, 221, 62, 214, 51, 74, 63, 0, 0, 0, 0, 148, 174, 216, 68, 74, 215, 16, 69, 161, 121, 78, 67, 0, 0, 128, 63

) );

                var idkeythreeDMatrixDataFloats = stringIDToTypeID( "key3DMatrixDataFloats" );

                    var list2 = new ActionList();

                    list2.putDouble( 0.558877 );

                    list2.putDouble( 0.558877 );

                    list2.putDouble( -0.612220 );

                    list2.putDouble( 0.000000 );

                    list2.putDouble( -0.705912 );

                    list2.putDouble( 0.705912 );

                    list2.putDouble( 0.000000 );

                    list2.putDouble( 0.000000 );

                    list2.putDouble( 0.432621 );

                    list2.putDouble( 0.432621 );

                    list2.putDouble( 0.789853 );

                    list2.putDouble( 0.000000 );

                    list2.putDouble( 1733.455566 );

                    list2.putDouble( 2317.455566 );

                    list2.putDouble( 206.475113 );

                    list2.putDouble( 1.000000 );

                desc17.putList( idkeythreeDMatrixDataFloats, list2 );

            var idkeythreeDMatrix = stringIDToTypeID( "key3DMatrix" );

            desc16.putObject( idkeythreeDMatrix, idkeythreeDMatrix, desc17 );

            var idX = charIDToTypeID( "X   " );

            desc16.putDouble( idX, 1733.455566 );

            var idY = charIDToTypeID( "Y   " );

            desc16.putDouble( idY, 2317.455566 );

            var idZ = charIDToTypeID( "Z   " );

            desc16.putDouble( idZ, 206.475113 );

            var idtarx = charIDToTypeID( "tarx" );

            desc16.putDouble( idtarx, 1729.129395 );

            var idtary = charIDToTypeID( "tary" );

            desc16.putDouble( idtary, 2313.129395 );

            var idtarz = charIDToTypeID( "tarz" );

            desc16.putDouble( idtarz, 198.576584 );

            var idkeythreeDPosition = stringIDToTypeID( "key3DPosition" );

                var desc18 = new ActionDescriptor();

                var idkeythreeDXPos = stringIDToTypeID( "key3DXPos" );

                desc18.putDouble( idkeythreeDXPos, 0.000000 );

                var idkeythreeDYPos = stringIDToTypeID( "key3DYPos" );

                desc18.putDouble( idkeythreeDYPos, 0.000000 );

                var idkeythreeDZPos = stringIDToTypeID( "key3DZPos" );

                desc18.putDouble( idkeythreeDZPos, 0.000000 );

                var idkeythreeDXAngle = stringIDToTypeID( "key3DXAngle" );

                desc18.putDouble( idkeythreeDXAngle, -0.000000 );

                var idkeythreeDYAngle = stringIDToTypeID( "key3DYAngle" );

                desc18.putDouble( idkeythreeDYAngle, 37.750160 );

                var idkeythreeDZAngle = stringIDToTypeID( "key3DZAngle" );

                desc18.putDouble( idkeythreeDZAngle, -45.000000 );

            var idkeythreeDPosition = stringIDToTypeID( "key3DPosition" );

            desc16.putObject( idkeythreeDPosition, idkeythreeDPosition, desc18 );

        var idkeythreeDLightMode = stringIDToTypeID( "key3DLightMode" );

        list1.putObject( idkeythreeDLightMode, desc16 );

    desc15.putList( idkthreeDLights, list1 );

    var idkeythreeDCurrentCameraPosition = stringIDToTypeID( "key3DCurrentCameraPosition" );

        var desc19 = new ActionDescriptor();

        var idkeythreeDXPos = stringIDToTypeID( "key3DXPos" );

        desc19.putDouble( idkeythreeDXPos, 1168.000000 );

        var idkeythreeDYPos = stringIDToTypeID( "key3DYPos" );

        desc19.putDouble( idkeythreeDYPos, 1752.000000 );

        var idkeythreeDZPos = stringIDToTypeID( "key3DZPos" );

        desc19.putDouble( idkeythreeDZPos, 6538.553223 );

        var idkeythreeDXAngle = stringIDToTypeID( "key3DXAngle" );

        desc19.putDouble( idkeythreeDXAngle, -180.000000 );

        var idkeythreeDYAngle = stringIDToTypeID( "key3DYAngle" );

        desc19.putDouble( idkeythreeDYAngle, -0.000000 );

        var idkeythreeDZAngle = stringIDToTypeID( "key3DZAngle" );

        desc19.putDouble( idkeythreeDZAngle, -180.000000 );

    var idkeythreeDCurrentCameraPosition = stringIDToTypeID( "key3DCurrentCameraPosition" );

    desc15.putObject( idkeythreeDCurrentCameraPosition, idkeythreeDCurrentCameraPosition, desc19 );

    var idGlos = charIDToTypeID( "Glos" );

    desc15.putInteger( idGlos, 0 );

    var idMtrl = charIDToTypeID( "Mtrl" );

    desc15.putInteger( idMtrl, 0 );

    var idExps = charIDToTypeID( "Exps" );

    desc15.putInteger( idExps, 0 );

    var idAmbB = charIDToTypeID( "AmbB" );

    desc15.putInteger( idAmbB, 0 );

    var idAmbC = charIDToTypeID( "AmbC" );

        var desc20 = new ActionDescriptor();

        var idRd = charIDToTypeID( "Rd  " );

        desc20.putDouble( idRd, 255.000000 );

        var idGrn = charIDToTypeID( "Grn " );

        desc20.putDouble( idGrn, 255.000000 );

        var idBl = charIDToTypeID( "Bl  " );

        desc20.putDouble( idBl, 255.000000 );

    var idkeythreeDFaceColor = stringIDToTypeID( "key3DFaceColor" );

    desc15.putObject( idAmbC, idkeythreeDFaceColor, desc20 );

    var idBmpA = charIDToTypeID( "BmpA" );

    desc15.putInteger( idBmpA, 0 );

    var idBmpC = charIDToTypeID( "BmpC" );

        var ref2 = new ActionReference();

        var idname = charIDToTypeID( "name" );

        ref2.putName( idname, "None" );

    desc15.putReference( idBmpC, ref2 );

    var idWdth = charIDToTypeID( "Wdth" );

    desc15.putDouble( idWdth, 2336.000000 );

    var idHght = charIDToTypeID( "Hght" );

    desc15.putDouble( idHght, 3504.000000 );

executeAction( idlightFilterLightingEffects, desc15, DialogModes.NO );

JJMack
Participant
June 16, 2019

JJMack could you explain what does your second step exactly ? With the code that you post I am able to run a javascript that creates a light effect, but I am not able to apply random parameters to it...

JJMack
Community Expert
Community Expert
June 16, 2019

The second step renders the spotlight lighting effect.  With the scriplistener you could create a lighting effect JavaScript function and you could use random numbers with the function.  However, render lighting effect is a very complex feature it cans render so many lighting effects and Adobe has some many presets you would most likely  want to randomize a particular effect.  The Image plays a huge part you need to set values for many settings that will be approbate for the image you are rendering the effect on.

The Clean SL script cleans the script listener code to a more or less readable JavaScript  function and uses the function to render the lighting effect you recorded with the scriptlistner.   I would need to play with the function to understend what paramaters even do.  The function has like 50 Paramaters.

JJMack
June 13, 2019