Metlivi Studio

Blender में Procedural Material बनाए रखते हुए Instanced Cubes को Sampled Colors कैसे दें

हर instanced cube को उसका procedural material बनाए रखते हुए sampled color देने के लिए, sampled color को instancing points पर store करें, फिर cube के मौजूदा shader में उस attribute को पढ़ें। इसे material की color branch से जोड़ें और roughness, bump, coat तथा shader output के connections जस के तस रखें।

इस गाइड में Blender 4.5 LTS के node नाम इस्तेमाल किए गए हैं। इसमें हर cube के लिए एक color देने का तरीका बताया गया है—उदाहरण के लिए, ऐसा block mosaic जो धारीदार storage box के रंगीन हिस्सों का अनुसरण करे और साथ ही साझा textured plastic finish बनाए रखे।

तय करें कि Material के कौन-से हिस्से Procedural बने रहें

सबसे पहले वह connection ढूँढ़ें जो अभी cube material का Base Color दे रहा है। बाकी material graph को उपलब्ध रखें: roughness या bump चलाने वाला procedural texture अपना काम जारी रख सकता है, जबकि sampled attribute color देता है। Principled BSDF में base color, roughness, normal और coat properties के लिए अलग-अलग inputs होते हैं। Blender Manual: Principled BSDF

यहाँ दो उपयोगी विकल्प हैं। पहचाने जा सकने वाले sampled palette के लिए, केवल मौजूदा base-color input को बदलें। Procedural color variation भी बनाए रखने के लिए, sampled color को मौजूदा color branch के साथ मिलाएँ। इस दूसरे विकल्प से sampled colors बदल जाते हैं; तय करें कि source palette से मेल खाना ज़्यादा ज़रूरी है या पुराना रंगीन pattern बनाए रखना।

एक cube का sampled base color एक ही हो सकता है, फिर भी lighting के कारण उसके अलग-अलग faces की brightness अलग दिख सकती है। लक्ष्य हर cube को एक सुसंगत रंग देना है और साथ ही मौजूदा surface finish को दिखाई देते रहने देना है।

ऐसा Source तैयार करें जिसमें सचमुच Color Data हो

आपको scene के तीन हिस्से चाहिए: उपलब्ध color data वाला source mesh, cube placement points वाला geometry stream और procedural material assigned वाला cube prototype। यदि cube distribution पहले से काम कर रहा है, तो उसे बनाए रखें और नीचे दिए गए attribute-transfer चरण जोड़ें।

मुख्य workflow में मान लें कि source mesh में source_color नाम का color attribute है। जहाँ भी यह नाम आए, उसकी जगह अपने attribute का असली नाम रखें। Geometry Nodes में Named Attribute node उस context में attribute पढ़ता है जहाँ उसका output evaluate होता है; उसका Exists output यह पुष्टि करने में मदद कर सकता है कि attribute मौजूद है। Blender Manual: Named Attribute Node

यदि source के colors किसी image से आते हैं, तो Geometry Nodes में image lookup दोहराएँ: Vector पर set किया गया Named Attribute node, जिसमें source के UV-map का नाम हो, उसके output को Image Texture node के Vector input से जोड़ें। Source image चुनें और अगले section में sampling value के रूप में उसका Color output इस्तेमाल करें। UV coordinates स्पष्ट रूप से जोड़ें: वरना Geometry Nodes का image texture डिफ़ॉल्ट रूप से position coordinates इस्तेमाल करता है। Blender Manual: Image Texture Node

यह न मानें कि mesh प्राप्त करने से उसका तैयार shader appearance भी मिल जाता है। Sample Nearest Surface source mesh पर दिए गए field को evaluate करता है। इसका व्यावहारिक अर्थ है कि आपको वह color attribute, image lookup या कोई अन्य दोहराया जा सकने वाला color field देना होगा जिसे आप transfer करना चाहते हैं; यह node पूरी rendered material को sample करने के लिए input नहीं देता। Blender Manual: Sample Nearest Surface Node

हर Cube के Placement Point पर Source को Sample करें

वह Geometry Nodes modifier खोलें जो cubes बनाता है और colored source mesh को target करते हुए Object Info node जोड़ें। As Instance बंद करें, ताकि sampling node को mesh geometry मिले। Transform space को Relative पर set करें, ताकि source modified object के coordinate space में आए और scene में उसका स्थान बना रहे। Blender Manual: Object Info Node

Sample Nearest Surface जोड़ें और उसका data type Color पर set करें। ये connections बनाएँ:

  1. Source Object Info → Geometry को Sample Nearest Surface → Mesh से जोड़ें।
  2. Named Attribute node को Color पर set करें और नाम source_color दें। उसके Attribute output को sampler के Value input से जोड़ें। Image source के लिए ऊपर बताई image-color branch इस्तेमाल करें।
  3. Position node को Sample Position से जोड़ें।
  4. Group inputs को उनके matching defaults पर रहने दें, जब तक आप जान-बूझकर sampling groups इस्तेमाल न कर रहे हों।

Sampler source mesh पर color field evaluate करता है और हर दिए गए position के लिए सबसे नज़दीकी surface location ढूँढ़ता है। यह surface पर non-face attributes को interpolate करता है, इसलिए source gradient से बीच के रंग भी बन सकते हैं। Loose vertices और edges को अनदेखा किया जाता है, क्योंकि यह node mesh surfaces को sample करता है। Blender Manual: Sample Nearest Surface Node

Voxel जैसी व्यवस्था में, किसी अंदरूनी cube को सबसे नज़दीकी बाहरी सतह का रंग मिलेगा। पतली वस्तु पर, पास वाला विपरीत face रंग दे सकता है। यह चुने गए nearest-surface नियम के अनुसार है; यदि आपको एक ही दिशा से project किए गए रंग चाहिए, तो sampling का यह तरीका बदलना होगा।

Instances बनाने से पहले Color Store करें

Store Named Attribute को placement-point geometry stream में, Instance on Points से ठीक पहले जोड़ें। Data type Color, domain Point और नाम cube_sample_color रखें। हर point के लिए Selection चालू रहने दें और sampler का color output Value से जोड़ें। यह node अपने से गुजरने वाली geometry पर evaluated field लिखता है। Blender Manual: Store Named Attribute Node

अब geometry path इस तरह होना चाहिए: placement points → Store Named Attribute → Instance on Points → Group Output। Stored geometry को instancer के Points input से और material वाले cube prototype को उसके Instance input से जोड़ें।

यहाँ attribute कहाँ रखा जाता है, यह अहम है। Attribute उस geometry पर store करें जो placement points देती है, साझा prototype cube पर नहीं। Blender input points के attributes को generated instance domain पर उपलब्ध कराता है, जिससे हर instance का अलग color assignment उसके साथ जाता है। Blender Manual: Instance on Points Node

इस व्यवस्था से sampling का समय भी तय होता है। यदि attribute store करने से पहले points को move करते हैं, तो उनकी नई positions उनके sampled colors तय करती हैं। यदि बाद में बने हुए instances को move करते हैं, तो उन्हें पहले से दिए गए colors ही रहते हैं। क्रम इस आधार पर चुनें कि cubes अपने colors साथ लेकर चलें या अपनी अंतिम locations पर colors लें।

मौजूदा Cube Material के भीतर Sampled Color पढ़ें

Shader Editor में prototype cube को assigned material खोलें। Attribute node जोड़ें, उसका attribute type Instancer पर set करें और ठीक-ठीक cube_sample_color लिखें। Material के color input के लिए उसका Color output इस्तेमाल करें। Instancer lookup स्पष्ट रूप से Geometry Nodes instance attributes खोजता है। Blender Manual: Attribute Node

पहली जाँच के लिए, Attribute → Color को सीधे मौजूदा Principled BSDF के Base Color से जोड़ें। मौजूदा roughness, bump और coat connections के साथ BSDF का Material Output से connection भी बनाए रखें। आप उस material के color input को बदल रहे हैं जो पहले से मनचाही finish देता है।

Transfer काम करने लगे, तो Color data type पर set किए गए Mix node से मनचाहा procedural color modulation वापस जोड़ें। सामान्य Mix, Factor के अनुसार पुराने procedural color और sampled color को blend करता है। इसके बजाय, sampled palette में गहरे रंगों की variation जोड़ने के लिए neutral gray-to-white procedural pattern के साथ Multiply इस्तेमाल करें। Blender के color-mixing node में ये दोनों blending modes उपलब्ध हैं। Blender Manual: Mix Color Node

शुरुआत के उदाहरण के तौर पर, sampled color को ऐसे procedural pattern से multiply करें जो 0.8 gray से white तक हो और Factor 1.0 पर set हो। इससे हल्की dark variation जुड़ती है। पुराने pattern में बहुत गहरे रंग होने पर resulting hues भी बदल जाएँगे, इसलिए sampling सही है या नहीं यह जाँचते समय direct connection इस्तेमाल करें।

रंग खोए बिना Realized Cubes के साथ काम करें

यदि आगे का workflow instances को support करता है, तो cubes को instances ही रहने दें। Instancing geometry की नकल बनाने के बजाय shared geometry का reference इस्तेमाल करता है, जबकि realization वास्तविक geometry बनाता है और processing cost बढ़ा सकता है। Blender Manual: Instance on Points Node, Blender Manual: Realize Instances Node

यदि बाद के किसी operation के लिए वास्तविक meshes चाहिए, तो Instance on Points के बाद Realize Instances जोड़ें, फिर shader में Attribute type को Instancer से बदलकर Geometry करें। Named instance attributes realized geometry पर पहुँच जाते हैं, जहाँ geometry lookup उन्हें पढ़ सकता है। Prototype पर cube_sample_color बनाने से बचें: जब वही attribute prototype geometry और instance दोनों पर मौजूद हो, तो realization के दौरान prototype की values को प्राथमिकता मिलती है। Blender Manual: Realize Instances Node, Blender Manual: Attribute Node

हर cube के लिए एक sample वाला assignment बनाए रखने के लिए realization से पहले color store करें। Realized cube vertices पर नया position-based sample evaluate करने से एक ही cube के अलग-अलग vertices को अलग-अलग colors मिल सकते हैं।

तीन नियंत्रित चरणों में नतीजा जाँचें

पूरी व्यवस्था जाँचने से पहले cubes के एक छोटे हिस्से का इस्तेमाल करें। नीचे दिया गया diagnostic क्रम attribute transport, source sampling और material appearance को अलग-अलग जाँचता है। यह आपके scene के लिए सुझाई गई जाँच है, पूरे हो चुके render का दावा नहीं।

  1. Transport जाँचें। Store Named Attribute → Value से sampled field को अस्थायी रूप से disconnect करें और वहाँ गहरा नारंगी color चुनें। Shader attribute को सीधे Base Color से जोड़ने पर हर generated cube नारंगी होना चाहिए।
  2. Sampling जाँचें। Sampled field फिर से जोड़ें। Source के दो साफ़ तौर पर अलग दिखने वाले क्षेत्रों के पास के cubes की तुलना करें। उनके base colors उन क्षेत्रों के अनुसार होने चाहिए; source attribute interpolate होने पर बीच के रंग भी दिख सकते हैं।
  3. Finish जाँचें। Material Preview या lit render में cubes देखें। मूल roughness variation, bump detail और coat highlights देखें। फिर चाहें तो procedural color mixing चालू करें।
दिखाई देने वाली समस्या पहले यह जाँचें
Constant-orange check के दौरान cubes काले रहते हैं Attribute name, shader lookup type और prototype को assigned material की पुष्टि करें।
Constant orange काम करता है, पर source colors नहीं आते Source attribute name, source mesh connection और image इस्तेमाल करने पर UV lookup जाँचें।
Colors जगह से हटे हुए दिखाई देते हैं Source transform space और sampling में इस्तेमाल हुई point positions जाँचें।
एक cube में अनचाहे color gradients हैं जाँचें कि sampling realized mesh vertices पर evaluate तो नहीं हुई।
Realization के बाद colors बदल जाते हैं Shader lookup को Geometry पर बदलें और prototype में उसी नाम का attribute देखें।
Sampled hues मटमैले हो जाते हैं Procedural color blend को bypass करके सीधे sampled color देखें।

धारीदार storage-box उदाहरण में लक्ष्य सीधा है: हर stripe के पास के cubes को उसी stripe का रंग मिले, जबकि उनका साझा material वही textured plastic finish दिखाता रहे। यह छोटी तुलना काम करने लगे, तो यही connections पूरी distribution पर लागू करें। पूरी प्रक्रिया में काम का बँटवारा यही रहता है: Geometry Nodes हर cube को color देता है और मौजूदा shader तय करता है कि वह रंगीन surface light पर कैसी प्रतिक्रिया दे।

स्रोत