Skip to content

Instantly share code, notes, and snippets.

@jeremybep
Last active March 7, 2023 14:17
Show Gist options
  • Save jeremybep/5af88420687ab260a6590aa60f0e85f1 to your computer and use it in GitHub Desktop.
Save jeremybep/5af88420687ab260a6590aa60f0e85f1 to your computer and use it in GitHub Desktop.
3dsmax - maxscript snippets

Sélection du moteur de rendu VRay

renderers.current = VRay()
vr=renderers.current

Panneau des préférences de 3dsmax

Sélection Gamma

IDisplayGamma.colorCorrectionMode = #gamma

Valeur gamma

IDisplayGamma.gamma = 2.2

Materials et colors affect

IDisplayGamma.affectColorPickers = true
IDisplayGamma.affectMEdit = true 

Gamma in/out

fileInGamma = 2.2 
fileOutGamma = 2.2

Panneau V-Ray

Charger des presets

renderPresets.Loadall 0 "X:\\Path\\preset\\preset.rps"

Format de sortie

renderheight= 1920
renderwidth= 1080

Global switch

vr.options_probabilisticLights = false
vr.options_overrideDepth_on = true
vr.options_maxRayIntensity_on = false

Adaptive Subdivision image sampler

vr.imageSampler_type = 2 -- 0=Fixed, 1=Adaptive, 2=Adaptive subdv, 3=Progressive
vr.filter_on = true
vr.filter_kernel = Area() --  Cubic(), Video(), Soften(), Blend()...ect
vr.adaptiveSubdivision_minRate = -1
vr.adaptiveSubdivision_maxRate = 2
vr.imageSampler_shadingRate = 1
vr.adaptiveSubdivision_threshold = 0.05
vr.dmc_subdivs_mult = 1

Adaptive image sampler

vr.imageSampler_type = 1 -- 0=Fixed, 1=Adaptive, 2=Adaptive subdv, 3=Progressive
vr.filter_on = true
vr.filter_kernel = Area() --  Cubic(), Video(), Soften(), Blend()...ect
vr.twoLevel_baseSubdivs = 1
vr.twoLevel_fineSubdivs = 8
vr.imageSampler_shadingRate = 10

Global DMC

vr.dmc_earlyTermination_amount = 1
vr.dmc_earlyTermination_minSamples = 8
vr.dmc_earlyTermination_threshold = 0.01

Environement (en relation avec Config de vrayHDRI)

vr.environment_gi_on = true
vr.environment_gi_color = color 204 230 255
vr.environment_gi_map_on = true

Config de vrayHDRI (en relation avec Environement)

hdr = VRayhdri()
hdr.HDRIMapName = "X:\\chemin\\de\\votre\\hdri.hdr"
hdr.mapType = 2
hdr.horizontalRotation = 55
hdr.multiplier = 3.0
vr.environment_gi_map = hdr

GI

vr.gi_on = true
vr.gi_primary_type = 3  --  0=Irradiance map, 1=Photon map, 2=Brute force, 3=Light cache
vr.gi_secondary_type = 3  --  0=None, 1=Photon map, 2=Brute force, 3=Light cache 
vr.dmcgi_subdivs = 128	-- Subdivs de GI en Brute Force

LightCache

vr.lightcache_subdivs = 444
vr.lightcache_sampleSize = 0.02
vr.lightcache_storeDirectLight = 0
vr.lightcache_multipleViews = false
vr.lightcache_prefilter_on = true
vr.lightcache_prefilter_samples = 64
vr.lightcache_retrace_on = false
vr.lightcache_useForGlossyRays = true
vr.lightcache_bounces = 100
vr.lightcache_adaptiveTracing = false
vr.lightcache_retrace_on = false
vr.lightcache_adaptiveTracing_dirsOnly = false
vr.lightcache_filter_type = 2
vr.lightcache_filter_size = 0.06
vr.lightcache_mode = 0

IrrMAP

vr.gi_irradmap_preset = 1
vr.gi_irradmap_minRate = -4
vr.gi_irradmap_maxRate = -3
vr.gi_irradmap_subdivs = 33
vr.gi_irradmap_interpSamples = 20
vr.gi_irradmap_showCalcPhase = true
vr.gi_irradmap_showDirectLight = false
vr.gi_irradmap_colorThreshold = 0.4
vr.gi_irradmap_normalThreshold = 0.3
vr.gi_irradmap_distThreshold = 0.1

Settings

vr.system_region_x = 48
vr.system_region_y = 48
vr.system_region_sequence = 3
vr.system_region_sequence_reverse = 0
vr.system_embree_on = true
vr.system_raycaster_memLimit = 0
vr.system_embree_hair = false

Color mapping

vr.colorMapping_type = 0
vr.colorMapping_gamma = 1
vr.colorMapping_affectBackground = false
vr.colorMapping_linearWorkflow = false
vr.colorMapping_darkMult = 1
vr.colorMapping_brightMult = 1

Matériaux V-Ray

Trace Refrac/Reflect, Preservation, UseIrr

for a in (getClassInstances VrayMtl) do
(
    a.option_traceRefraction = false
    a.option_traceReflection = false --(si pas besoin)
    a.preservationMode = 1 --(switch dans les Options VrayMtl "preservation mode en Mono") 
    a.option_useirradmap = false --( pas de IRRMAP par defaut donc supp de UseirrMap)
)			 

Changer valeur du Blur (Coordinates)

for a in getclassinstances VRayMtl do
(
    a.texmap_diffuse.coords.blur = val
)

Désactive/Active TexMap Displace

for a in getclassinstances VRayMtl do
(
    a.texmap_displacement_on = off
)

Subdivision (Light, Mat)

VRayMap, VRayLightMtl, VRayFastSSS2, VRayFastSSS, VRayMtl, VRayLight, VRayIES, VRayShadow

val = 8
 
for a in getclassinstances VRayMap do
            (
                a.reflect_subdivs = val
                a.refract_subdivs = val
            )
 
 
for a in getclassinstances VRayLightMtl do
            (
                a.directLight_subdivs = val
            )
 
 
for a in getclassinstances VRayFastSSS2 do
            (
                a.specular_subdivs = val
                a.single_scatter_subdivs = val
            )
 
 
for a in getclassinstances VRayFastSSS do
            (
                a.subdivs = val
            )
 
 
for a in getclassinstances VRayMtl do
            (
                a.reflection_subdivs = val
                a.refraction_subdivs = val
                a.option_useirradmap = true
            )
 
 
 
for a in getclassinstances VRayLight do
            (
                a.subdivs = val
                a.storeWithIrradMap = false
            )
 
 
 
for a in getclassinstances VRaySun do
            (
                a.shadow_subdivs = val
            )
 
 
 
for a in getclassinstances VRayIES do
            (
                a.shape_subdivs = val
            )
 
 
 
for a in getclassinstances VRayShadow do
            (
                a.subdivs = val
            )

RenderElement

Sélection des Render Element courant

r = maxOps.GetCurRenderElementMgr()

Active/Désactive les Render Element

r.SetElementsActive

Supprime les Render Element

r.removeallrenderelements()

Ajout des Render Element

r.AddRenderElement (VrayRawGlobalIllumination elementname:"RawGI")
r.AddRenderElement (VrayRawLighting elementname:"RawLighting")
r.AddRenderElement (VrayReflection elementname:"Reflection")
r.AddRenderElement (VrayRefraction elementname:"Refraction")
r.AddRenderElement (VrayRawShadow elementname:"Shadow")			
r.AddRenderElement (VrayDiffuseFilter elementname:"Diffuse")
r.AddRenderElement (VraySpecular elementname:"Specular")
r.AddRenderElement (VrayMtlReflectGlossiness elementname:"ReflectGlossiness")
r.AddRenderElement (VraySelfillumination elementname:"Selfillumination")
r.AddRenderElement (VRayNormals elementname:"Normal")
r.AddRenderElement (VRayZDepth elementname:"VRayZDepth")
r.AddRenderElement (VrayVelocity elementname:"Velocity")
r.AddRenderElement (VRayExtraTex elementname:"PositionPass")
r.AddRenderElement (VRayExtraTex elementname:"AO")

Configurer la pass VRayZDepth

Par rapport à la liste ci-dessus

elementCount = r.NumRenderElements()  --Enumeration des Render Element courant
z = r.GetRenderElement (elementCount-4)  --Selection de bas (-4) en haut pour selectionner "VRayZDepth"
z.vrayVFB = true
z.clamp_zdepth = true
z.zdepth_min = 200
z.zdepth_max = 3000
z.invert_zdepth = true

Configurer la pass Velocity

Par rapport à la liste ci-dessus

elementCount = r.NumRenderElements()  --Enumeration des Render Element courant
g = r.GetRenderElement (elementCount-3)  --Selection de bas (-3) en haut pour selectionner "Velocity"
g.vrayVFB = false
g.clamp_velocity = false
g.max_velocity = 100
g.ignore_z_direction = true

Configurer la pass de position en point to camera (sans AA)

Par rapport à la liste ci-dessus

elementCount = r.NumRenderElements()  --Enumeration des Render Element courant
g = r.GetRenderElement (elementCount-2)  --Selection de bas (-2) en haut pour selectionner "PositionPass"
ppass = VRaySamplerInfoTex()
ppass.name = "PositionPass"
ppass.type = 0
ppass.coord_system = 2
g.texture = ppass
g.consider_for_antialiasing = false

Configurer la pass AO

Par rapport à la liste ci-dessus

elementCount = r.NumRenderElements()
k = r.GetRenderElement (elementCount-1)
vdirt = VRayDirt()
vdirt.name = "AO"
vdirt.radius = 16
vdirt.subdivs = 200
k.texture = vdirt

Divers

Rafraichissement du panneau Render Setup:

renderSceneDialog.update()		

Décharger la RAM

freeSceneBitmaps(); gc light:true

Merger un fichier

mergeMAXFile "X:\\path\\de\\votre\\fichier.max"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment