* Render lights: uniform light list, solo and mute, and the Light editor * Render lights: Lighting and Light editors to the approved design * Render lights: the scale-test frame carries the product light list * Restore the stable Render light mute target on the shared eye control * fix: validate the viewport BRDF probe with current shader dependencies * fix: compile legacy lighting controls only for tests * fix: scope the legacy lighting preset import to tests * fix: reuse the merged Add Light label and translations * test: enable the implemented Add Light radial action * fix: restrict the legacy CPU vector editor to tests * test: reveal Output before checking Lights browser focus * test: use the published Browser card rectangle for Output scrolling * test: reveal Output children before exercising editor navigation
This commit is contained in:
@@ -0,0 +1,362 @@
|
||||
{
|
||||
"en": {
|
||||
"render.lighting_aim_point": "Aim point",
|
||||
"render.lighting_apply": "Apply preset",
|
||||
"render.lighting_area_samples": "Area samples",
|
||||
"render.lighting_budget": "Budget",
|
||||
"render.lighting_budget_help": "Counts are read-only. Add, duplicate or delete lights to change them; the method sets the limits.",
|
||||
"render.lighting_colour": "Colour",
|
||||
"render.lighting_consent": "Replace the directional lights with this preset",
|
||||
"render.lighting_custom": "Custom lights",
|
||||
"render.lighting_custom_help": "Choosing Custom turns the preset into editable lights, one row each in the tree.",
|
||||
"render.lighting_direction": "Direction X Y Z",
|
||||
"render.lighting_direction_help": "Or type a direction toward the light (X Y Z).",
|
||||
"render.lighting_edge_u": "Side U vector",
|
||||
"render.lighting_edge_v": "Side V vector",
|
||||
"render.lighting_falloff": "Falloff",
|
||||
"render.lighting_falloff_help": "Intensity is quoted at the reference distance.",
|
||||
"render.lighting_height": "Height V",
|
||||
"render.lighting_minimum": "Minimum",
|
||||
"render.lighting_mute": "Mute this light",
|
||||
"render.lighting_point": "Point",
|
||||
"render.lighting_preset": "Studio preset",
|
||||
"render.lighting_preset_cpu": "Directional studio presets require CPU ray tracing. GPU lighting uses explicit Sun and Area lights.",
|
||||
"render.lighting_preset_row": "Preset",
|
||||
"render.lighting_radiance": "Radiance",
|
||||
"render.lighting_reference": "Reference",
|
||||
"render.lighting_review_help": "Replaces the directional light list. Keeps point and area lights, environment, shadows, camera and all other shot settings.",
|
||||
"render.lighting_review_title": "Review lighting preset",
|
||||
"render.lighting_samples_cpu": "Area-light samples apply to CPU ray tracing.",
|
||||
"render.lighting_samples_need_area": "Add a CPU area light to set area samples.",
|
||||
"render.lighting_samples_reason": "Area samples must be 1, 4, 16 or 64.",
|
||||
"render.lighting_shadow_cpu": "The shadow switch requires CPU ray tracing. GPU path tracing always casts shadows.",
|
||||
"render.lighting_shadows": "Cast shadows",
|
||||
"render.lighting_shadows_section": "Shadows and sampling",
|
||||
"render.lighting_shape": "Shape",
|
||||
"render.lighting_solo": "Solo this light",
|
||||
"render.lighting_source": "Source",
|
||||
"render.lighting_source_section": "Light source",
|
||||
"render.lighting_spot_preserved": "This point light retains its saved spot cone until its type is changed.",
|
||||
"render.lighting_sun_distance": "Sun direction is independent of distance and aim point.",
|
||||
"render.lighting_unsupported": "unsupported",
|
||||
"render.lighting_used": "{used} of {limit}",
|
||||
"render.lighting_width": "Width U",
|
||||
"render.lighting_world_position": "World X Y Z",
|
||||
"render.lighting_distance_unit": " × size"
|
||||
},
|
||||
"de": {
|
||||
"render.lighting_aim_point": "Zielpunkt",
|
||||
"render.lighting_apply": "Vorgabe anwenden",
|
||||
"render.lighting_area_samples": "Flächenlicht-Samples",
|
||||
"render.lighting_budget": "Budget",
|
||||
"render.lighting_budget_help": "Die Anzahl ist schreibgeschützt. Lichter hinzufügen, duplizieren oder löschen; die Methode bestimmt die Grenzen.",
|
||||
"render.lighting_colour": "Farbe",
|
||||
"render.lighting_consent": "Richtungslichter durch diese Vorgabe ersetzen",
|
||||
"render.lighting_custom": "Eigene Lichter",
|
||||
"render.lighting_custom_help": "Eigene Lichter wandelt die Vorgabe in bearbeitbare Lichter mit je einer Zeile im Baum um.",
|
||||
"render.lighting_direction": "Richtung X Y Z",
|
||||
"render.lighting_direction_help": "Oder eine Richtung zum Licht eingeben (X Y Z).",
|
||||
"render.lighting_edge_u": "Seitenvektor U",
|
||||
"render.lighting_edge_v": "Seitenvektor V",
|
||||
"render.lighting_falloff": "Abschwächung",
|
||||
"render.lighting_falloff_help": "Die Intensität gilt im Referenzabstand.",
|
||||
"render.lighting_height": "Höhe V",
|
||||
"render.lighting_minimum": "Minimum",
|
||||
"render.lighting_mute": "Dieses Licht stummschalten",
|
||||
"render.lighting_point": "Punkt",
|
||||
"render.lighting_preset": "Studiovorgabe",
|
||||
"render.lighting_preset_cpu": "Richtungslicht-Vorgaben benötigen CPU-Raytracing. GPU-Beleuchtung verwendet explizite Sonnen- und Flächenlichter.",
|
||||
"render.lighting_preset_row": "Vorgabe",
|
||||
"render.lighting_radiance": "Strahldichte",
|
||||
"render.lighting_reference": "Referenz",
|
||||
"render.lighting_review_help": "Ersetzt die Richtungslichter. Punkt- und Flächenlichter, Umgebung, Schatten, Kamera und alle anderen Einstellungen bleiben erhalten.",
|
||||
"render.lighting_review_title": "Beleuchtungsvorgabe prüfen",
|
||||
"render.lighting_samples_cpu": "Flächenlicht-Samples gelten für CPU-Raytracing.",
|
||||
"render.lighting_samples_need_area": "Ein CPU-Flächenlicht hinzufügen, um Samples einzustellen.",
|
||||
"render.lighting_samples_reason": "Flächenlicht-Samples müssen 1, 4, 16 oder 64 sein.",
|
||||
"render.lighting_shadow_cpu": "Der Schattenschalter benötigt CPU-Raytracing. GPU-Pfadverfolgung wirft immer Schatten.",
|
||||
"render.lighting_shadows": "Schatten werfen",
|
||||
"render.lighting_shadows_section": "Schatten und Sampling",
|
||||
"render.lighting_shape": "Form",
|
||||
"render.lighting_solo": "Nur dieses Licht",
|
||||
"render.lighting_source": "Quelle",
|
||||
"render.lighting_source_section": "Lichtquelle",
|
||||
"render.lighting_spot_preserved": "Dieses Punktlicht behält seinen gespeicherten Lichtkegel bis zur Typänderung.",
|
||||
"render.lighting_sun_distance": "Die Sonnenrichtung ist unabhängig von Abstand und Zielpunkt.",
|
||||
"render.lighting_unsupported": "nicht unterstützt",
|
||||
"render.lighting_used": "{used} von {limit}",
|
||||
"render.lighting_width": "Breite U",
|
||||
"render.lighting_world_position": "Welt X Y Z",
|
||||
"render.lighting_distance_unit": " × Größe"
|
||||
},
|
||||
"ja": {
|
||||
"render.lighting_aim_point": "注視点",
|
||||
"render.lighting_apply": "プリセットを適用",
|
||||
"render.lighting_area_samples": "面光源サンプル",
|
||||
"render.lighting_budget": "上限",
|
||||
"render.lighting_budget_help": "個数は読み取り専用です。追加・複製・削除で変更します。上限は方式で決まります。",
|
||||
"render.lighting_colour": "色",
|
||||
"render.lighting_consent": "平行光源をこのプリセットで置き換える",
|
||||
"render.lighting_custom": "カスタム光源",
|
||||
"render.lighting_custom_help": "カスタムを選ぶと、プリセットの各光源をツリーで編集できます。",
|
||||
"render.lighting_direction": "方向 X Y Z",
|
||||
"render.lighting_direction_help": "または光源に向かう方向を入力 (X Y Z)。",
|
||||
"render.lighting_edge_u": "辺 U ベクトル",
|
||||
"render.lighting_edge_v": "辺 V ベクトル",
|
||||
"render.lighting_falloff": "減衰",
|
||||
"render.lighting_falloff_help": "強度は基準距離での値です。",
|
||||
"render.lighting_height": "高さ V",
|
||||
"render.lighting_minimum": "最小",
|
||||
"render.lighting_mute": "この光源をミュート",
|
||||
"render.lighting_point": "点",
|
||||
"render.lighting_preset": "スタジオプリセット",
|
||||
"render.lighting_preset_cpu": "平行光源プリセットはCPUレイトレーシング用です。GPUでは太陽光と面光源を使います。",
|
||||
"render.lighting_preset_row": "プリセット",
|
||||
"render.lighting_radiance": "放射輝度",
|
||||
"render.lighting_reference": "基準",
|
||||
"render.lighting_review_help": "平行光源リストを置き換えます。点光源、面光源、環境、影、カメラ、その他のショット設定は保持します。",
|
||||
"render.lighting_review_title": "照明プリセットの確認",
|
||||
"render.lighting_samples_cpu": "面光源のサンプル数はCPUレイトレーシングに適用されます。",
|
||||
"render.lighting_samples_need_area": "サンプル数を設定するにはCPU面光源を追加してください。",
|
||||
"render.lighting_samples_reason": "面光源サンプル数は1、4、16、64のいずれかです。",
|
||||
"render.lighting_shadow_cpu": "影の切り替えはCPUレイトレーシング用です。GPUでは常に影を計算します。",
|
||||
"render.lighting_shadows": "影を落とす",
|
||||
"render.lighting_shadows_section": "影とサンプリング",
|
||||
"render.lighting_shape": "形状",
|
||||
"render.lighting_solo": "この光源のみ",
|
||||
"render.lighting_source": "光源",
|
||||
"render.lighting_source_section": "光源",
|
||||
"render.lighting_spot_preserved": "この点光源のスポット円錐は、種類を変更するまで保持されます。",
|
||||
"render.lighting_sun_distance": "太陽光の方向は距離と注視点に依存しません。",
|
||||
"render.lighting_unsupported": "未対応",
|
||||
"render.lighting_used": "{used} / {limit}",
|
||||
"render.lighting_width": "幅 U",
|
||||
"render.lighting_world_position": "ワールド X Y Z",
|
||||
"render.lighting_distance_unit": " × サイズ"
|
||||
},
|
||||
"zh": {
|
||||
"render.lighting_aim_point": "目标点",
|
||||
"render.lighting_apply": "应用预设",
|
||||
"render.lighting_area_samples": "面光源采样",
|
||||
"render.lighting_budget": "预算",
|
||||
"render.lighting_budget_help": "数量为只读。通过添加、复制或删除灯光来更改;上限由渲染方式决定。",
|
||||
"render.lighting_colour": "颜色",
|
||||
"render.lighting_consent": "用此预设替换平行光源",
|
||||
"render.lighting_custom": "自定义灯光",
|
||||
"render.lighting_custom_help": "选择自定义后,预设将变为可编辑灯光,每个灯光在树中占一行。",
|
||||
"render.lighting_direction": "方向 X Y Z",
|
||||
"render.lighting_direction_help": "或输入朝向光源的方向 (X Y Z)。",
|
||||
"render.lighting_edge_u": "边 U 向量",
|
||||
"render.lighting_edge_v": "边 V 向量",
|
||||
"render.lighting_falloff": "衰减",
|
||||
"render.lighting_falloff_help": "强度以参考距离处的数值表示。",
|
||||
"render.lighting_height": "高度 V",
|
||||
"render.lighting_minimum": "最小值",
|
||||
"render.lighting_mute": "禁用此灯光",
|
||||
"render.lighting_point": "点",
|
||||
"render.lighting_preset": "摄影棚预设",
|
||||
"render.lighting_preset_cpu": "平行光摄影棚预设需要 CPU 光线追踪。GPU 照明使用显式的太阳光和面光源。",
|
||||
"render.lighting_preset_row": "预设",
|
||||
"render.lighting_radiance": "辐射亮度",
|
||||
"render.lighting_reference": "参考值",
|
||||
"render.lighting_review_help": "替换平行光源列表。保留点光源、面光源、环境、阴影、相机及其他镜头设置。",
|
||||
"render.lighting_review_title": "检查照明预设",
|
||||
"render.lighting_samples_cpu": "面光源采样仅适用于 CPU 光线追踪。",
|
||||
"render.lighting_samples_need_area": "添加 CPU 面光源以设置采样数。",
|
||||
"render.lighting_samples_reason": "面光源采样数必须为 1、4、16 或 64。",
|
||||
"render.lighting_shadow_cpu": "阴影开关需要 CPU 光线追踪。GPU 路径追踪始终投射阴影。",
|
||||
"render.lighting_shadows": "投射阴影",
|
||||
"render.lighting_shadows_section": "阴影与采样",
|
||||
"render.lighting_shape": "形状",
|
||||
"render.lighting_solo": "仅此灯光",
|
||||
"render.lighting_source": "来源",
|
||||
"render.lighting_source_section": "光源",
|
||||
"render.lighting_spot_preserved": "此点光源保留已保存的聚光锥,直到更改其类型。",
|
||||
"render.lighting_sun_distance": "太阳光方向与距离和目标点无关。",
|
||||
"render.lighting_unsupported": "不支持",
|
||||
"render.lighting_used": "{used} / {limit}",
|
||||
"render.lighting_width": "宽度 U",
|
||||
"render.lighting_world_position": "世界坐标 X Y Z",
|
||||
"render.lighting_distance_unit": " × 尺寸"
|
||||
},
|
||||
"ko": {
|
||||
"render.lighting_aim_point": "조준점",
|
||||
"render.lighting_apply": "프리셋 적용",
|
||||
"render.lighting_area_samples": "영역 샘플",
|
||||
"render.lighting_budget": "한도",
|
||||
"render.lighting_budget_help": "개수는 읽기 전용입니다. 조명을 추가, 복제 또는 삭제하세요. 한도는 방식에 따라 정해집니다.",
|
||||
"render.lighting_colour": "색상",
|
||||
"render.lighting_consent": "이 프리셋으로 방향 조명 교체",
|
||||
"render.lighting_custom": "사용자 조명",
|
||||
"render.lighting_custom_help": "사용자 조명을 선택하면 프리셋이 트리의 각 행에서 편집 가능한 조명으로 변환됩니다.",
|
||||
"render.lighting_direction": "방향 X Y Z",
|
||||
"render.lighting_direction_help": "또는 조명 방향을 입력하세요 (X Y Z).",
|
||||
"render.lighting_edge_u": "변 U 벡터",
|
||||
"render.lighting_edge_v": "변 V 벡터",
|
||||
"render.lighting_falloff": "감쇠",
|
||||
"render.lighting_falloff_help": "강도는 기준 거리에서의 값입니다.",
|
||||
"render.lighting_height": "높이 V",
|
||||
"render.lighting_minimum": "최솟값",
|
||||
"render.lighting_mute": "이 조명 끄기",
|
||||
"render.lighting_point": "점",
|
||||
"render.lighting_preset": "스튜디오 프리셋",
|
||||
"render.lighting_preset_cpu": "방향 조명 프리셋에는 CPU 레이 트레이싱이 필요합니다. GPU는 명시적 태양 및 영역 조명을 사용합니다.",
|
||||
"render.lighting_preset_row": "프리셋",
|
||||
"render.lighting_radiance": "복사휘도",
|
||||
"render.lighting_reference": "기준",
|
||||
"render.lighting_review_help": "방향 조명 목록을 교체합니다. 점 및 영역 조명, 환경, 그림자, 카메라와 다른 샷 설정은 유지합니다.",
|
||||
"render.lighting_review_title": "조명 프리셋 검토",
|
||||
"render.lighting_samples_cpu": "영역 조명 샘플은 CPU 레이 트레이싱에 적용됩니다.",
|
||||
"render.lighting_samples_need_area": "영역 샘플을 설정하려면 CPU 영역 조명을 추가하세요.",
|
||||
"render.lighting_samples_reason": "영역 샘플은 1, 4, 16 또는 64여야 합니다.",
|
||||
"render.lighting_shadow_cpu": "그림자 스위치에는 CPU 레이 트레이싱이 필요합니다. GPU 경로 추적은 항상 그림자를 계산합니다.",
|
||||
"render.lighting_shadows": "그림자 투사",
|
||||
"render.lighting_shadows_section": "그림자 및 샘플링",
|
||||
"render.lighting_shape": "모양",
|
||||
"render.lighting_solo": "이 조명만 표시",
|
||||
"render.lighting_source": "광원",
|
||||
"render.lighting_source_section": "광원",
|
||||
"render.lighting_spot_preserved": "이 점 조명은 유형을 변경할 때까지 저장된 스폿 원뿔을 유지합니다.",
|
||||
"render.lighting_sun_distance": "태양 방향은 거리 및 조준점과 무관합니다.",
|
||||
"render.lighting_unsupported": "지원되지 않음",
|
||||
"render.lighting_used": "{used} / {limit}",
|
||||
"render.lighting_width": "너비 U",
|
||||
"render.lighting_world_position": "월드 X Y Z",
|
||||
"render.lighting_distance_unit": " × 크기"
|
||||
},
|
||||
"ar": {
|
||||
"render.lighting_aim_point": "نقطة التصويب",
|
||||
"render.lighting_apply": "تطبيق الإعداد المسبق",
|
||||
"render.lighting_area_samples": "عينات المساحة",
|
||||
"render.lighting_budget": "الميزانية",
|
||||
"render.lighting_budget_help": "الأعداد للقراءة فقط. أضف الأضواء أو كرّرها أو احذفها لتغييرها؛ والطريقة تحدد الحدود.",
|
||||
"render.lighting_colour": "اللون",
|
||||
"render.lighting_consent": "استبدل الأضواء الاتجاهية بهذا الإعداد المسبق",
|
||||
"render.lighting_custom": "أضواء مخصصة",
|
||||
"render.lighting_custom_help": "اختيار «مخصص» يحوّل الإعداد المسبق إلى أضواء قابلة للتعديل، صف لكل ضوء في الشجرة.",
|
||||
"render.lighting_direction": "الاتجاه X Y Z",
|
||||
"render.lighting_direction_help": "أو اكتب اتجاهًا نحو الضوء (X Y Z).",
|
||||
"render.lighting_edge_u": "متجه الضلع U",
|
||||
"render.lighting_edge_v": "متجه الضلع V",
|
||||
"render.lighting_falloff": "التضاؤل",
|
||||
"render.lighting_falloff_help": "الشدة محددة عند مسافة المرجع.",
|
||||
"render.lighting_height": "الارتفاع V",
|
||||
"render.lighting_minimum": "الحد الأدنى",
|
||||
"render.lighting_mute": "كتم هذا الضوء",
|
||||
"render.lighting_point": "نقطي",
|
||||
"render.lighting_preset": "إعداد الاستوديو المسبق",
|
||||
"render.lighting_preset_cpu": "إعدادات الاستوديو الاتجاهية تتطلب تتبّع الأشعة على المعالج. إضاءة بطاقة الرسومات تستخدم أضواء الشمس والمساحة الصريحة.",
|
||||
"render.lighting_preset_row": "الإعداد المسبق",
|
||||
"render.lighting_radiance": "الإشعاع",
|
||||
"render.lighting_reference": "المرجع",
|
||||
"render.lighting_review_help": "يستبدل قائمة الأضواء الاتجاهية. يُبقي الأضواء النقطية والمساحية والبيئة والظلال والكاميرا وكل إعدادات اللقطة الأخرى.",
|
||||
"render.lighting_review_title": "مراجعة إعداد الإضاءة المسبق",
|
||||
"render.lighting_samples_cpu": "عينات الأضواء المساحية تنطبق على تتبّع الأشعة على المعالج.",
|
||||
"render.lighting_samples_need_area": "أضف ضوء مساحة على المعالج لضبط عينات المساحة.",
|
||||
"render.lighting_samples_reason": "عينات المساحة يجب أن تكون 1 أو 4 أو 16 أو 64.",
|
||||
"render.lighting_shadow_cpu": "مفتاح الظلال يتطلب تتبّع الأشعة على المعالج. تتبّع المسار على بطاقة الرسومات يُلقي الظلال دائمًا.",
|
||||
"render.lighting_shadows": "إلقاء الظلال",
|
||||
"render.lighting_shadows_section": "الظلال وأخذ العينات",
|
||||
"render.lighting_shape": "الشكل",
|
||||
"render.lighting_solo": "عزل هذا الضوء",
|
||||
"render.lighting_source": "المصدر",
|
||||
"render.lighting_source_section": "مصدر الضوء",
|
||||
"render.lighting_spot_preserved": "يحتفظ هذا الضوء النقطي بمخروط الكشّاف المحفوظ إلى أن يتغيّر نوعه.",
|
||||
"render.lighting_sun_distance": "اتجاه الشمس مستقل عن المسافة ونقطة التصويب.",
|
||||
"render.lighting_unsupported": "غير مدعوم",
|
||||
"render.lighting_used": "{used} من {limit}",
|
||||
"render.lighting_width": "العرض U",
|
||||
"render.lighting_world_position": "العالم X Y Z",
|
||||
"render.lighting_distance_unit": " × الحجم"
|
||||
},
|
||||
"he": {
|
||||
"render.lighting_aim_point": "נקודת כיוון",
|
||||
"render.lighting_apply": "החל הגדרה מוכנה",
|
||||
"render.lighting_area_samples": "דגימות שטח",
|
||||
"render.lighting_budget": "תקציב",
|
||||
"render.lighting_budget_help": "הספירות לקריאה בלבד. הוסף, שכפל או מחק אורות כדי לשנות אותן; השיטה קובעת את הגבולות.",
|
||||
"render.lighting_colour": "צבע",
|
||||
"render.lighting_consent": "החלף את האורות הכיווניים בהגדרה זו",
|
||||
"render.lighting_custom": "אורות מותאמים",
|
||||
"render.lighting_custom_help": "בחירה במותאם הופכת את ההגדרה לאורות הניתנים לעריכה, שורה לכל אחד בעץ.",
|
||||
"render.lighting_direction": "כיוון X Y Z",
|
||||
"render.lighting_direction_help": "או הקלד כיוון אל האור (X Y Z).",
|
||||
"render.lighting_edge_u": "וקטור צלע U",
|
||||
"render.lighting_edge_v": "וקטור צלע V",
|
||||
"render.lighting_falloff": "דעיכה",
|
||||
"render.lighting_falloff_help": "העוצמה נקבעת במרחק הייחוס.",
|
||||
"render.lighting_height": "גובה V",
|
||||
"render.lighting_minimum": "מינימום",
|
||||
"render.lighting_mute": "השתק אור זה",
|
||||
"render.lighting_point": "נקודתי",
|
||||
"render.lighting_preset": "הגדרת סטודיו מוכנה",
|
||||
"render.lighting_preset_cpu": "הגדרות סטודיו כיווניות דורשות מעקב קרניים במעבד. תאורת GPU משתמשת באורות שמש ושטח מפורשים.",
|
||||
"render.lighting_preset_row": "הגדרה מוכנה",
|
||||
"render.lighting_radiance": "קרינה",
|
||||
"render.lighting_reference": "ייחוס",
|
||||
"render.lighting_review_help": "מחליף את רשימת האורות הכיווניים. שומר על אורות נקודתיים ואורות שטח, סביבה, צללים, מצלמה וכל שאר הגדרות הצילום.",
|
||||
"render.lighting_review_title": "סקירת הגדרת התאורה",
|
||||
"render.lighting_samples_cpu": "דגימות אור שטח חלות על מעקב קרניים במעבד.",
|
||||
"render.lighting_samples_need_area": "הוסף אור שטח במעבד כדי לקבוע דגימות שטח.",
|
||||
"render.lighting_samples_reason": "דגימות שטח חייבות להיות 1, 4, 16 או 64.",
|
||||
"render.lighting_shadow_cpu": "מתג הצללים דורש מעקב קרניים במעבד. מעקב נתיב ב-GPU תמיד מטיל צללים.",
|
||||
"render.lighting_shadows": "הטל צללים",
|
||||
"render.lighting_shadows_section": "צללים ודגימה",
|
||||
"render.lighting_shape": "צורה",
|
||||
"render.lighting_solo": "בודד אור זה",
|
||||
"render.lighting_source": "מקור",
|
||||
"render.lighting_source_section": "מקור אור",
|
||||
"render.lighting_spot_preserved": "אור נקודתי זה שומר על חרוט הזרקור השמור עד שסוגו משתנה.",
|
||||
"render.lighting_sun_distance": "כיוון השמש אינו תלוי במרחק ובנקודת הכוון.",
|
||||
"render.lighting_unsupported": "לא נתמך",
|
||||
"render.lighting_used": "{used} מתוך {limit}",
|
||||
"render.lighting_width": "רוחב U",
|
||||
"render.lighting_world_position": "עולם X Y Z",
|
||||
"render.lighting_distance_unit": " × גודל"
|
||||
},
|
||||
"vi": {
|
||||
"render.lighting_aim_point": "Điểm nhắm",
|
||||
"render.lighting_apply": "Áp dụng thiết lập sẵn",
|
||||
"render.lighting_area_samples": "Mẫu vùng sáng",
|
||||
"render.lighting_budget": "Ngân sách",
|
||||
"render.lighting_budget_help": "Các số chỉ để đọc. Thêm, nhân bản hoặc xóa đèn để đổi; phương pháp đặt giới hạn.",
|
||||
"render.lighting_colour": "Màu",
|
||||
"render.lighting_consent": "Thay các đèn định hướng bằng thiết lập sẵn này",
|
||||
"render.lighting_custom": "Đèn tùy chỉnh",
|
||||
"render.lighting_custom_help": "Chọn Tùy chỉnh sẽ biến thiết lập sẵn thành các đèn chỉnh được, mỗi đèn một hàng trong cây.",
|
||||
"render.lighting_direction": "Hướng X Y Z",
|
||||
"render.lighting_direction_help": "Hoặc nhập hướng tới đèn (X Y Z).",
|
||||
"render.lighting_edge_u": "Vectơ cạnh U",
|
||||
"render.lighting_edge_v": "Vectơ cạnh V",
|
||||
"render.lighting_falloff": "Suy giảm",
|
||||
"render.lighting_falloff_help": "Cường độ được tính tại khoảng cách tham chiếu.",
|
||||
"render.lighting_height": "Chiều cao V",
|
||||
"render.lighting_minimum": "Tối thiểu",
|
||||
"render.lighting_mute": "Tắt đèn này",
|
||||
"render.lighting_point": "Điểm",
|
||||
"render.lighting_preset": "Thiết lập studio sẵn",
|
||||
"render.lighting_preset_cpu": "Thiết lập studio định hướng cần dò tia bằng CPU. Chiếu sáng GPU dùng đèn Mặt trời và Vùng sáng tường minh.",
|
||||
"render.lighting_preset_row": "Thiết lập sẵn",
|
||||
"render.lighting_radiance": "Bức xạ",
|
||||
"render.lighting_reference": "Tham chiếu",
|
||||
"render.lighting_review_help": "Thay danh sách đèn định hướng. Giữ đèn điểm và đèn vùng sáng, môi trường, bóng đổ, máy ảnh và mọi cài đặt cảnh chụp khác.",
|
||||
"render.lighting_review_title": "Xem lại thiết lập chiếu sáng sẵn",
|
||||
"render.lighting_samples_cpu": "Mẫu đèn vùng sáng áp dụng cho dò tia bằng CPU.",
|
||||
"render.lighting_samples_need_area": "Thêm đèn vùng sáng CPU để đặt số mẫu vùng sáng.",
|
||||
"render.lighting_samples_reason": "Số mẫu vùng sáng phải là 1, 4, 16 hoặc 64.",
|
||||
"render.lighting_shadow_cpu": "Công tắc bóng đổ cần dò tia bằng CPU. Dò đường đi của tia bằng GPU luôn đổ bóng.",
|
||||
"render.lighting_shadows": "Đổ bóng",
|
||||
"render.lighting_shadows_section": "Bóng đổ và lấy mẫu",
|
||||
"render.lighting_shape": "Hình dạng",
|
||||
"render.lighting_solo": "Chỉ hiện đèn này",
|
||||
"render.lighting_source": "Nguồn",
|
||||
"render.lighting_source_section": "Nguồn sáng",
|
||||
"render.lighting_spot_preserved": "Đèn điểm này giữ chóp đèn rọi đã lưu cho đến khi đổi loại.",
|
||||
"render.lighting_sun_distance": "Hướng Mặt trời không phụ thuộc khoảng cách và điểm nhắm.",
|
||||
"render.lighting_unsupported": "không hỗ trợ",
|
||||
"render.lighting_used": "{used} / {limit}",
|
||||
"render.lighting_width": "Chiều rộng U",
|
||||
"render.lighting_world_position": "Thế giới X Y Z",
|
||||
"render.lighting_distance_unit": " × kích thước"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
{
|
||||
"en": {
|
||||
"cmd.render_lights_list": "List Render Lights",
|
||||
"render.light_default_key": "Key",
|
||||
"render.light_default_fill": "Fill",
|
||||
"render.light_default_rim": "Rim",
|
||||
"render.light_default_number": "Light {number}",
|
||||
"cmd.render_lights_remove": "Remove Render Light",
|
||||
"render.light_type_point": "Point",
|
||||
"render.light_hard_shadow": "This light has hard shadows; emitter softness is unavailable.",
|
||||
"render.light_azimuth": "Azimuth",
|
||||
"render.light_gpu_punctual": "Point and Spot lights are available with CPU ray tracing.",
|
||||
"cmd.render_lights_set": "Set Render Light",
|
||||
"render.light_missing": "This light no longer exists. Select a light in the Browser.",
|
||||
"render.light_behaviour": "BEHAVIOUR",
|
||||
"render.light_world_origin": "World origin",
|
||||
"render.light_type_area": "Area",
|
||||
"render.light_place_highlight": "Place by highlight",
|
||||
"render.light_elevation": "Elevation",
|
||||
"render.light_product_centre": "Product centre",
|
||||
"render.light_duplicate": "Duplicate",
|
||||
"render.light_size": "Size",
|
||||
"render.light_temperature_help": "Approximate blackbody tint; saved as linear RGB.",
|
||||
"render.light_preview_help": "Live view is unshadowed; Area lights use a centre-sample approximation. Render uses the complete light model.",
|
||||
"render.light_type_sun": "Sun",
|
||||
"render.light_place_pending": "Highlight placement needs viewport light picking and is not supported yet.",
|
||||
"render.light_type_spot": "Spot",
|
||||
"render.light_delete": "Delete",
|
||||
"render.light_backend_limit": "Choose CPU ray tracing or an explicit GPU studio to edit lights. Legacy GPU studio lights remain read-only.",
|
||||
"render.light_temperature": "Colour temperature",
|
||||
"render.light_view_only": "Solo and mute affect this view and its renders; they are never saved in the design.",
|
||||
"render.light_softness": "Softness",
|
||||
"render.light_intensity": "Intensity",
|
||||
"render.light_position": "POSITION",
|
||||
"cmd.render_lights_mute": "Mute Light",
|
||||
"render.light_type": "Type",
|
||||
"cmd.render_lights_duplicate": "Duplicate Render Light",
|
||||
"render.light_distance": "Distance",
|
||||
"render.light_aim": "Aim at"
|
||||
},
|
||||
"de": {
|
||||
"cmd.render_lights_list": "Render-Lichter auflisten",
|
||||
"render.light_default_key": "Führungslicht",
|
||||
"render.light_default_fill": "Fülllicht",
|
||||
"render.light_default_rim": "Kantenlicht",
|
||||
"render.light_default_number": "Licht {number}",
|
||||
"cmd.render_lights_remove": "Render-Licht entfernen",
|
||||
"render.light_type_point": "Punkt",
|
||||
"render.light_hard_shadow": "Dieses Licht wirft harte Schatten; Lichtquellenweichheit ist nicht verfügbar.",
|
||||
"render.light_azimuth": "Azimut",
|
||||
"render.light_gpu_punctual": "Punkt- und Spotlichter sind mit CPU-Raytracing verfügbar.",
|
||||
"cmd.render_lights_set": "Render-Licht einstellen",
|
||||
"render.light_missing": "Dieses Licht existiert nicht mehr. Ein Licht im Browser auswählen.",
|
||||
"render.light_behaviour": "VERHALTEN",
|
||||
"render.light_world_origin": "Weltursprung",
|
||||
"render.light_type_area": "Fläche",
|
||||
"render.light_place_highlight": "Nach Glanzlicht platzieren",
|
||||
"render.light_elevation": "Höhenwinkel",
|
||||
"render.light_product_centre": "Produktmitte",
|
||||
"render.light_duplicate": "Duplizieren",
|
||||
"render.light_size": "Größe",
|
||||
"render.light_temperature_help": "Angenäherte Schwarzkörperfarbe; als lineares RGB gespeichert.",
|
||||
"render.light_preview_help": "Die Live-Ansicht ist schattenfrei; Flächenlichter werden mit einer Mittelpunktprobe angenähert. Rendern nutzt das vollständige Lichtmodell.",
|
||||
"render.light_type_sun": "Sonne",
|
||||
"render.light_place_pending": "Die Platzierung nach Glanzlicht benötigt Lichtauswahl im Ansichtsfenster und wird noch nicht unterstützt.",
|
||||
"render.light_type_spot": "Spot",
|
||||
"render.light_delete": "Löschen",
|
||||
"render.light_backend_limit": "Zum Bearbeiten CPU-Raytracing oder ein explizites GPU-Studio wählen. Alte GPU-Studiolichter sind schreibgeschützt.",
|
||||
"render.light_temperature": "Farbtemperatur",
|
||||
"render.light_view_only": "Solo und Stumm gelten für diese Ansicht und ihre Renderbilder; sie werden nie im Design gespeichert.",
|
||||
"render.light_softness": "Weichheit",
|
||||
"render.light_intensity": "Intensität",
|
||||
"render.light_position": "POSITION",
|
||||
"cmd.render_lights_mute": "Licht stummschalten",
|
||||
"render.light_type": "Typ",
|
||||
"cmd.render_lights_duplicate": "Render-Licht duplizieren",
|
||||
"render.light_distance": "Abstand",
|
||||
"render.light_aim": "Ausrichten auf"
|
||||
},
|
||||
"ja": {
|
||||
"cmd.render_lights_list": "レンダーライトの一覧",
|
||||
"render.light_default_key": "キーライト",
|
||||
"render.light_default_fill": "フィルライト",
|
||||
"render.light_default_rim": "リムライト",
|
||||
"render.light_default_number": "ライト {number}",
|
||||
"cmd.render_lights_remove": "レンダーライトを削除",
|
||||
"render.light_type_point": "ポイント",
|
||||
"render.light_hard_shadow": "このライトは硬い影のみ対応しています。",
|
||||
"render.light_azimuth": "方位角",
|
||||
"render.light_gpu_punctual": "ポイントとスポットはCPUレイトレーシングで使用できます。",
|
||||
"cmd.render_lights_set": "レンダーライトを設定",
|
||||
"render.light_missing": "このライトは存在しません。ブラウザーでライトを選択してください。",
|
||||
"render.light_behaviour": "動作",
|
||||
"render.light_world_origin": "ワールド原点",
|
||||
"render.light_type_area": "エリア",
|
||||
"render.light_place_highlight": "ハイライトで配置",
|
||||
"render.light_elevation": "仰角",
|
||||
"render.light_product_centre": "製品の中心",
|
||||
"render.light_duplicate": "複製",
|
||||
"render.light_size": "サイズ",
|
||||
"render.light_temperature_help": "黒体色の近似。リニアRGBで保存されます。",
|
||||
"render.light_preview_help": "ライブ表示は影なしで、エリアライトは中心サンプルで近似されます。レンダーでは完全なライトモデルを使用します。",
|
||||
"render.light_type_sun": "太陽",
|
||||
"render.light_place_pending": "ハイライト配置にはビューポートのライト選択が必要で、現在は未対応です。",
|
||||
"render.light_type_spot": "スポット",
|
||||
"render.light_delete": "削除",
|
||||
"render.light_backend_limit": "編集するにはCPUレイトレーシングまたは明示的なGPUスタジオを選択してください。従来のGPUライトは読み取り専用です。",
|
||||
"render.light_temperature": "色温度",
|
||||
"render.light_view_only": "ソロとミュートはこのビューとレンダーのみに適用され、デザインには保存されません。",
|
||||
"render.light_softness": "柔らかさ",
|
||||
"render.light_intensity": "強度",
|
||||
"render.light_position": "位置",
|
||||
"cmd.render_lights_mute": "ライトをミュート",
|
||||
"render.light_type": "タイプ",
|
||||
"cmd.render_lights_duplicate": "レンダーライトを複製",
|
||||
"render.light_distance": "距離",
|
||||
"render.light_aim": "照射先"
|
||||
},
|
||||
"ko": {
|
||||
"cmd.render_lights_list": "렌더 조명 목록",
|
||||
"render.light_default_key": "키 라이트",
|
||||
"render.light_default_fill": "필 라이트",
|
||||
"render.light_default_rim": "림 라이트",
|
||||
"render.light_default_number": "조명 {number}",
|
||||
"cmd.render_lights_remove": "렌더 조명 제거",
|
||||
"render.light_type_point": "포인트",
|
||||
"render.light_hard_shadow": "이 조명은 단단한 그림자만 지원합니다.",
|
||||
"render.light_azimuth": "방위각",
|
||||
"render.light_gpu_punctual": "포인트와 스폿 조명은 CPU 레이 트레이싱에서 사용할 수 있습니다.",
|
||||
"cmd.render_lights_set": "렌더 조명 설정",
|
||||
"render.light_missing": "이 조명이 더 이상 없습니다. 브라우저에서 조명을 선택하세요.",
|
||||
"render.light_behaviour": "동작",
|
||||
"render.light_world_origin": "월드 원점",
|
||||
"render.light_type_area": "영역",
|
||||
"render.light_place_highlight": "하이라이트로 배치",
|
||||
"render.light_elevation": "고도각",
|
||||
"render.light_product_centre": "제품 중심",
|
||||
"render.light_duplicate": "복제",
|
||||
"render.light_size": "크기",
|
||||
"render.light_temperature_help": "흑체 색상 근사값이며 선형 RGB로 저장됩니다.",
|
||||
"render.light_preview_help": "라이브 뷰에는 그림자가 없으며 영역 조명은 중심 샘플로 근사됩니다. 렌더는 전체 조명 모델을 사용합니다.",
|
||||
"render.light_type_sun": "태양",
|
||||
"render.light_place_pending": "하이라이트 배치는 뷰포트 조명 선택이 필요하며 아직 지원되지 않습니다.",
|
||||
"render.light_type_spot": "스폿",
|
||||
"render.light_delete": "삭제",
|
||||
"render.light_backend_limit": "조명을 편집하려면 CPU 레이 트레이싱이나 명시적인 GPU 스튜디오를 선택하세요. 기존 GPU 스튜디오 조명은 읽기 전용입니다.",
|
||||
"render.light_temperature": "색온도",
|
||||
"render.light_view_only": "솔로와 음소거는 이 뷰와 렌더에만 적용되며 디자인에 저장되지 않습니다.",
|
||||
"render.light_softness": "부드러움",
|
||||
"render.light_intensity": "강도",
|
||||
"render.light_position": "위치",
|
||||
"cmd.render_lights_mute": "조명 음소거",
|
||||
"render.light_type": "유형",
|
||||
"cmd.render_lights_duplicate": "렌더 조명 복제",
|
||||
"render.light_distance": "거리",
|
||||
"render.light_aim": "조준 대상"
|
||||
},
|
||||
"zh": {
|
||||
"cmd.render_lights_list": "列出渲染灯光",
|
||||
"render.light_default_key": "主光",
|
||||
"render.light_default_fill": "补光",
|
||||
"render.light_default_rim": "轮廓光",
|
||||
"render.light_default_number": "灯光 {number}",
|
||||
"cmd.render_lights_remove": "移除渲染灯光",
|
||||
"render.light_type_point": "点光",
|
||||
"render.light_hard_shadow": "此灯光仅支持硬阴影,无法调整光源柔和度。",
|
||||
"render.light_azimuth": "方位角",
|
||||
"render.light_gpu_punctual": "点光和聚光可用于 CPU 光线追踪。",
|
||||
"cmd.render_lights_set": "设置渲染灯光",
|
||||
"render.light_missing": "此灯光已不存在。请在浏览器中选择灯光。",
|
||||
"render.light_behaviour": "行为",
|
||||
"render.light_world_origin": "世界原点",
|
||||
"render.light_type_area": "区域",
|
||||
"render.light_place_highlight": "按高光放置",
|
||||
"render.light_elevation": "仰角",
|
||||
"render.light_product_centre": "产品中心",
|
||||
"render.light_duplicate": "复制",
|
||||
"render.light_size": "尺寸",
|
||||
"render.light_temperature_help": "近似黑体色调,以线性 RGB 保存。",
|
||||
"render.light_preview_help": "实时视图不含阴影,区域光使用中心采样近似;渲染使用完整灯光模型。",
|
||||
"render.light_type_sun": "太阳",
|
||||
"render.light_place_pending": "按高光放置需要视口灯光拾取,目前尚不支持。",
|
||||
"render.light_type_spot": "聚光",
|
||||
"render.light_delete": "删除",
|
||||
"render.light_backend_limit": "请选择 CPU 光线追踪或明确的 GPU 灯光棚以编辑灯光。旧版 GPU 灯光棚为只读。",
|
||||
"render.light_temperature": "色温",
|
||||
"render.light_view_only": "独显和静音仅影响此视图及其渲染,不会保存到设计中。",
|
||||
"render.light_softness": "柔和度",
|
||||
"render.light_intensity": "强度",
|
||||
"render.light_position": "位置",
|
||||
"cmd.render_lights_mute": "关闭灯光",
|
||||
"render.light_type": "类型",
|
||||
"cmd.render_lights_duplicate": "复制渲染灯光",
|
||||
"render.light_distance": "距离",
|
||||
"render.light_aim": "瞄准"
|
||||
},
|
||||
"ar": {
|
||||
"cmd.render_lights_list": "سرد أضواء التصيير",
|
||||
"render.light_default_key": "رئيسي",
|
||||
"render.light_default_fill": "تعبئة",
|
||||
"render.light_default_rim": "حافة",
|
||||
"render.light_default_number": "ضوء {number}",
|
||||
"cmd.render_lights_remove": "إزالة ضوء التصيير",
|
||||
"render.light_type_point": "نقطي",
|
||||
"render.light_hard_shadow": "لهذا الضوء ظلال حادة؛ نعومة المصدر غير متاحة.",
|
||||
"render.light_azimuth": "السمت",
|
||||
"render.light_gpu_punctual": "الأضواء النقطية والكشّافة متاحة مع تتبّع الأشعة على المعالج.",
|
||||
"cmd.render_lights_set": "ضبط ضوء التصيير",
|
||||
"render.light_missing": "هذا الضوء لم يعد موجودًا. اختر ضوءًا في المتصفح.",
|
||||
"render.light_behaviour": "السلوك",
|
||||
"render.light_world_origin": "أصل العالم",
|
||||
"render.light_type_area": "مساحة",
|
||||
"render.light_place_highlight": "وضع بالتمييز",
|
||||
"render.light_elevation": "الارتفاع",
|
||||
"render.light_product_centre": "مركز المنتج",
|
||||
"render.light_duplicate": "تكرار",
|
||||
"render.light_size": "الحجم",
|
||||
"render.light_temperature_help": "لون جسم أسود تقريبي؛ يُحفظ كـ RGB خطي.",
|
||||
"render.light_preview_help": "العرض الحي بلا ظلال؛ الأضواء المساحية تستخدم تقريب عينة المركز. التصيير يستخدم نموذج الضوء الكامل.",
|
||||
"render.light_type_sun": "الشمس",
|
||||
"render.light_place_pending": "الوضع بالتمييز يتطلب اختيار الأضواء في منفذ العرض وهو غير مدعوم بعد.",
|
||||
"render.light_type_spot": "كشّاف",
|
||||
"render.light_delete": "حذف",
|
||||
"render.light_backend_limit": "اختر تتبّع الأشعة على المعالج أو استوديو GPU صريحًا لتعديل الأضواء. أضواء استوديو GPU القديمة للقراءة فقط.",
|
||||
"render.light_temperature": "درجة حرارة اللون",
|
||||
"render.light_view_only": "العزل والكتم يؤثران في هذا العرض وتصييراته؛ ولا يُحفظان في التصميم أبدًا.",
|
||||
"render.light_softness": "النعومة",
|
||||
"render.light_intensity": "الشدة",
|
||||
"render.light_position": "الموضع",
|
||||
"cmd.render_lights_mute": "كتم الضوء",
|
||||
"render.light_type": "النوع",
|
||||
"cmd.render_lights_duplicate": "تكرار ضوء التصيير",
|
||||
"render.light_distance": "المسافة",
|
||||
"render.light_aim": "التصويب نحو"
|
||||
},
|
||||
"he": {
|
||||
"cmd.render_lights_list": "הצג אורות רינדור",
|
||||
"render.light_default_key": "מפתח",
|
||||
"render.light_default_fill": "מילוי",
|
||||
"render.light_default_rim": "קונטור",
|
||||
"render.light_default_number": "אור {number}",
|
||||
"cmd.render_lights_remove": "הסר אור רינדור",
|
||||
"render.light_type_point": "נקודתי",
|
||||
"render.light_hard_shadow": "לאור זה צללים קשים; רכות הפולט אינה זמינה.",
|
||||
"render.light_azimuth": "זנית",
|
||||
"render.light_gpu_punctual": "אורות נקודתיים וזרקורים זמינים עם מעקב קרניים במעבד.",
|
||||
"cmd.render_lights_set": "הגדר אור רינדור",
|
||||
"render.light_missing": "האור הזה כבר לא קיים. בחר אור בדפדפן.",
|
||||
"render.light_behaviour": "התנהגות",
|
||||
"render.light_world_origin": "ראשית העולם",
|
||||
"render.light_type_area": "שטח",
|
||||
"render.light_place_highlight": "מקם לפי הדגשה",
|
||||
"render.light_elevation": "גובה",
|
||||
"render.light_product_centre": "מרכז המוצר",
|
||||
"render.light_duplicate": "שכפל",
|
||||
"render.light_size": "גודל",
|
||||
"render.light_temperature_help": "גוון גוף שחור משוער; נשמר כ-RGB לינארי.",
|
||||
"render.light_preview_help": "התצוגה החיה ללא צללים; אורות שטח משתמשים בקירוב דגימת מרכז. הרינדור משתמש במודל האור המלא.",
|
||||
"render.light_type_sun": "שמש",
|
||||
"render.light_place_pending": "מיקום לפי הדגשה דורש בחירת אורות בחלון התצוגה ואינו נתמך עדיין.",
|
||||
"render.light_type_spot": "זרקור",
|
||||
"render.light_delete": "מחק",
|
||||
"render.light_backend_limit": "בחר מעקב קרניים במעבד או סטודיו GPU מפורש כדי לערוך אורות. אורות סטודיו GPU ישנים הם לקריאה בלבד.",
|
||||
"render.light_temperature": "טמפרטורת צבע",
|
||||
"render.light_view_only": "בידוד והשתקה משפיעים על תצוגה זו ועל הרינדורים שלה; הם לעולם אינם נשמרים בתכנון.",
|
||||
"render.light_softness": "רכות",
|
||||
"render.light_intensity": "עוצמה",
|
||||
"render.light_position": "מיקום",
|
||||
"cmd.render_lights_mute": "השתק אור",
|
||||
"render.light_type": "סוג",
|
||||
"cmd.render_lights_duplicate": "שכפל אור רינדור",
|
||||
"render.light_distance": "מרחק",
|
||||
"render.light_aim": "כוון אל"
|
||||
},
|
||||
"vi": {
|
||||
"cmd.render_lights_list": "Liệt kê đèn kết xuất",
|
||||
"render.light_default_key": "Chính",
|
||||
"render.light_default_fill": "Bù",
|
||||
"render.light_default_rim": "Viền",
|
||||
"render.light_default_number": "Đèn {number}",
|
||||
"cmd.render_lights_remove": "Gỡ đèn kết xuất",
|
||||
"render.light_type_point": "Điểm",
|
||||
"render.light_hard_shadow": "Đèn này có bóng cứng; độ mềm của nguồn không khả dụng.",
|
||||
"render.light_azimuth": "Phương vị",
|
||||
"render.light_gpu_punctual": "Đèn điểm và đèn rọi khả dụng khi dò tia bằng CPU.",
|
||||
"cmd.render_lights_set": "Đặt đèn kết xuất",
|
||||
"render.light_missing": "Đèn này không còn tồn tại. Hãy chọn một đèn trong Trình duyệt.",
|
||||
"render.light_behaviour": "HÀNH VI",
|
||||
"render.light_world_origin": "Gốc thế giới",
|
||||
"render.light_type_area": "Vùng sáng",
|
||||
"render.light_place_highlight": "Đặt theo điểm sáng",
|
||||
"render.light_elevation": "Góc ngẩng",
|
||||
"render.light_product_centre": "Tâm sản phẩm",
|
||||
"render.light_duplicate": "Nhân bản",
|
||||
"render.light_size": "Kích thước",
|
||||
"render.light_temperature_help": "Sắc vật đen xấp xỉ; lưu dưới dạng RGB tuyến tính.",
|
||||
"render.light_preview_help": "Chế độ xem trực tiếp không có bóng; đèn vùng sáng dùng xấp xỉ lấy mẫu tại tâm. Kết xuất dùng mô hình ánh sáng đầy đủ.",
|
||||
"render.light_type_sun": "Mặt trời",
|
||||
"render.light_place_pending": "Đặt theo điểm sáng cần chọn đèn trong khung nhìn và chưa được hỗ trợ.",
|
||||
"render.light_type_spot": "Đèn rọi",
|
||||
"render.light_delete": "Xóa",
|
||||
"render.light_backend_limit": "Hãy chọn dò tia bằng CPU hoặc một studio GPU tường minh để chỉnh đèn. Đèn studio GPU cũ chỉ để đọc.",
|
||||
"render.light_temperature": "Nhiệt độ màu",
|
||||
"render.light_view_only": "Chỉ hiện một đèn và tắt đèn ảnh hưởng đến chế độ xem này và các lần kết xuất của nó; chúng không bao giờ được lưu trong thiết kế.",
|
||||
"render.light_softness": "Độ mềm",
|
||||
"render.light_intensity": "Cường độ",
|
||||
"render.light_position": "VỊ TRÍ",
|
||||
"cmd.render_lights_mute": "Tắt đèn",
|
||||
"render.light_type": "Loại",
|
||||
"cmd.render_lights_duplicate": "Nhân bản đèn kết xuất",
|
||||
"render.light_distance": "Khoảng cách",
|
||||
"render.light_aim": "Nhắm vào"
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ struct U {
|
||||
depth: vec4<f32>, // x = 1: reversed depth (1 near, 0 far); y, z: the faces' push (`FACE_BIAS`)
|
||||
tint: vec4<f32>, // xyz added to a whole hovered body's colour before lighting
|
||||
sel: vec4<f32>, // xyz a whole selected body's colour before lighting
|
||||
product_lights_meta: vec4<f32>, // explicit preview flag and bounded count
|
||||
product_lights: array<vec4<f32>,84>, // position/kind, radiance, axis/cone, attenuation
|
||||
};
|
||||
|
||||
fn reversed() -> bool {
|
||||
@@ -471,6 +473,36 @@ fn shade(i: TOut) -> vec4<f32> {
|
||||
return lit(i, 1.0);
|
||||
}
|
||||
|
||||
fn product_light_unit(v: vec3<f32>) -> vec3<f32> {
|
||||
let scale=max(max(abs(v.x),abs(v.y)),abs(v.z));
|
||||
if scale == 0.0 { return vec3<f32>(0.0,0.0,1.0); }
|
||||
return normalize(v/scale);
|
||||
}
|
||||
|
||||
// Direction and incident radiance for an unshadowed analytic preview sample.
|
||||
fn product_light_sample(k: u32, p: vec3<f32>) -> mat2x3<f32> {
|
||||
let source=u.product_lights[k*4u];
|
||||
let colour=u.product_lights[k*4u+1u];
|
||||
let axis=u.product_lights[k*4u+2u];
|
||||
let falloff=u.product_lights[k*4u+3u];
|
||||
var direction=product_light_unit(source.xyz);
|
||||
var weight=1.0;
|
||||
if source.w > 0.5 {
|
||||
let delta=source.xyz-p;
|
||||
let distance=max(length(delta),falloff.y);
|
||||
direction=product_light_unit(delta);
|
||||
weight=falloff.x/max(distance*distance,0.000001);
|
||||
if source.w == 2.0 {
|
||||
let cosine=dot(product_light_unit(axis.xyz),-direction);
|
||||
var cone=select(0.0,1.0,cosine>=colour.w);
|
||||
if axis.w-colour.w>0.000001 {cone=smoothstep(colour.w,axis.w,cosine);}
|
||||
weight *= cone;
|
||||
}
|
||||
if source.w == 3.0 {weight *= max(dot(product_light_unit(axis.xyz),-direction),0.0);}
|
||||
}
|
||||
return mat2x3<f32>(direction,colour.xyz*weight);
|
||||
}
|
||||
|
||||
fn lit(i: TOut, visibility: f32) -> vec4<f32> {
|
||||
return lit_color(i, visibility, i.c);
|
||||
}
|
||||
@@ -485,6 +517,17 @@ fn lit_color(i: TOut, visibility: f32, base: vec4<f32>) -> vec4<f32> {
|
||||
let v = normalize(u.back.xyz);
|
||||
var n = normalize(i.n);
|
||||
if (dot(n, v) < 0.0) { n = -n; }
|
||||
if u.product_lights_meta.x>0.0 {
|
||||
var radiance=vec3<f32>(0.0);
|
||||
for (var k=0u;k<min(u32(u.product_lights_meta.y),21u);k+=1u) {
|
||||
if u.product_lights[k*4u].w == 4.0 {radiance+=to_linear(base.rgb)*u.product_lights[k*4u+1u].xyz/3.141592653589793;continue;}
|
||||
let sample=product_light_sample(k,i.wp);
|
||||
radiance+=to_linear(base.rgb)*sample[1]*(max(dot(n,sample[0]),0.0)/3.141592653589793);
|
||||
}
|
||||
let mapped=radiance/(vec3<f32>(1.0)+radiance);
|
||||
let encoded=select(mapped*12.92,1.055*pow(mapped,vec3<f32>(1.0/2.4))-vec3<f32>(0.055),mapped>vec3<f32>(0.0031308));
|
||||
return out_color(vec4<f32>(encoded,base.a));
|
||||
}
|
||||
let key = normalize(v * 0.8 + vec3<f32>(-0.3, 0.2, 0.6));
|
||||
let diff = max(dot(n, key), 0.0);
|
||||
let fill = max(dot(n, v), 0.0);
|
||||
|
||||
@@ -18,6 +18,7 @@ mod library;
|
||||
mod library_data;
|
||||
#[cfg(test)]
|
||||
mod light_union_tests;
|
||||
mod lights;
|
||||
mod optical_bindings;
|
||||
mod physical_library;
|
||||
mod resources;
|
||||
@@ -33,6 +34,31 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.contract(&environment::CONTRACT)
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render::EnvironmentResult>)
|
||||
.params("name; set?: numerical setup patch; rotation_deg?: finite degrees within +/-1000000, wrapped to [-180,180); intensity?: finite linear intensity 0..64 CPU or 0..100 GPU. Edits the existing HDR, sky or constant environment in one undo, without selecting a source, moving the camera or starting a render. Absent environments and raster refuse."),
|
||||
CommandSpec::new("render.lights.set", "Set Render Light", crate::checked!("render.lights.set", lights::set))
|
||||
.icon("render_scene").doc_only()
|
||||
.contract(&crate::schema::TypedContract::<crate::schema::render_lights::EditParams>::new())
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_lights::EditResult>)
|
||||
.params("name; id except add; settings?: full unsaved RenderSetup; expected_revision?:u64; set for set/add: kind directional/point/spot/area, intensity_ev, temperature_k, softness, azimuth_deg, elevation_deg, distance_mm, size_mm, aim_at, width_mm, height_mm, position_mm, direction, edge_u_mm, edge_v_mm, radiance, colour, reference_distance_mm, minimum_distance_mm. Validated finite light edit in one undo. Existing family caps and backend support apply; refusal is atomic. Names remain defaults."),
|
||||
CommandSpec::new("render.lights.add", "Add Light", crate::checked!("render.lights.add", lights::add))
|
||||
.icon("render_scene").doc_only()
|
||||
.contract(&crate::schema::TypedContract::<crate::schema::render_lights::EditParams>::new())
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_lights::EditResult>)
|
||||
.params("name; id except add; settings?: full unsaved RenderSetup; expected_revision?:u64; set for set/add: kind directional/point/spot/area, intensity_ev, temperature_k, softness, azimuth_deg, elevation_deg, distance_mm, size_mm, aim_at, width_mm, height_mm, position_mm, direction, edge_u_mm, edge_v_mm, radiance, colour, reference_distance_mm, minimum_distance_mm. Validated finite light edit in one undo. Existing family caps and backend support apply; refusal is atomic. Names remain defaults."),
|
||||
CommandSpec::new("render.lights.duplicate", "Duplicate Render Light", crate::checked!("render.lights.duplicate", lights::duplicate))
|
||||
.icon("render_scene").doc_only()
|
||||
.contract(&crate::schema::TypedContract::<crate::schema::render_lights::EditParams>::new())
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_lights::EditResult>)
|
||||
.params("name; id except add; settings?: full unsaved RenderSetup; expected_revision?:u64; set for set/add: kind directional/point/spot/area, intensity_ev, temperature_k, softness, azimuth_deg, elevation_deg, distance_mm, size_mm, aim_at, width_mm, height_mm, position_mm, direction, edge_u_mm, edge_v_mm, radiance, colour, reference_distance_mm, minimum_distance_mm. Validated finite light edit in one undo. Existing family caps and backend support apply; refusal is atomic. Names remain defaults."),
|
||||
CommandSpec::new("render.lights.remove", "Remove Render Light", crate::checked!("render.lights.remove", lights::remove))
|
||||
.icon("render_scene").doc_only()
|
||||
.contract(&crate::schema::TypedContract::<crate::schema::render_lights::EditParams>::new())
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_lights::EditResult>)
|
||||
.params("name; id except add; settings?: full unsaved RenderSetup; expected_revision?:u64; set for set/add: kind directional/point/spot/area, intensity_ev, temperature_k, softness, azimuth_deg, elevation_deg, distance_mm, size_mm, aim_at, width_mm, height_mm, position_mm, direction, edge_u_mm, edge_v_mm, radiance, colour, reference_distance_mm, minimum_distance_mm. Validated finite light edit in one undo. Existing family caps and backend support apply; refusal is atomic. Names remain defaults."),
|
||||
CommandSpec::new("render.lights.list", "List Render Lights", crate::checked!("render.lights.list", lights::list))
|
||||
.icon("list").noundo().doc_only()
|
||||
.contract(&crate::schema::TypedContract::<crate::schema::render_lights::ListParams>::new())
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_lights::ListResult>)
|
||||
.params("setup?: saved setup name OR settings?: complete RenderSetup snapshot; neither uses defaults. Returns {lights:[{id,kind,name,name_key,number,implicit,intensity,colour,...spatial fields}]}. IDs are kind:zero-based-source-slot, stable across numerical edits but not family changes/reordering/removal/rig replacement; point and spot share punctual slots. Includes implicit default/preset lights. GPU RGB radiance is factored as colour * intensity; area edges are full world-mm vectors. Read-only, no host, camera change, save, render, model evaluation or undo. See docs/render-settings.md."),
|
||||
CommandSpec::new("render.aging.describe","Layered Surface Aging",effects::aging).icon("appearance").noundo().doc_only()
|
||||
.params("Empty object. Read-only original Rust/patina/dust/grime/scratch/chip/fading presets and exact GPU aging contract. UI activation opens the shared Aging tab; edits remain a saved render draft, never engineering geometry or material-property mutation."),
|
||||
CommandSpec::new("render.effects.describe","Lens and Creative Effects",effects::presentation).icon("camera").noundo().doc_only()
|
||||
@@ -98,7 +124,7 @@ CommandSpec::new("render.hdr.inspect", "Inspect HDR Source", resources::inspect)
|
||||
CommandSpec::new("render.settings.capture_hdr", "Save Render Settings with HDR", resources::capture_settings).icon("settings").doc_only()
|
||||
.params("name, set: typed CPU/GPU setup patch with hdr/environment unset; path: scoped HDR; expected_sha256?: digest returned by render.hdr.inspect (changed sources refuse); rotation_rad?:0, intensity?:1; samples?:1/4/16/64 for CPU only (default16); assume_linear_srgb?:false for GPU only. Captures immutable bytes and saves resource plus setup atomically in one undo, without a host; returns name/setup/resource metadata, never source bytes"),
|
||||
CommandSpec::new("render.preflight", "Check Render Request", jobs::preflight).icon("inspect").noundo().doc_only()
|
||||
.params("setup?: saved name OR settings?: full RenderSetup. A typed job selects raster/cpu_raytrace/gpu_path and its numerical options plus embedded HDR before dispatch; only replace may accompany it. Without job, the legacy runtime controls below remain available. See docs/render-settings.md. integrator?: raster (default) or raytrace; progressive?: false (registered GPU path, CPU integrator/LED options are mutually exclusive); samples?: 1..4096; max_depth?: 1..16; seed?: u32 for progressive; raytrace?: bounded runtime progressive/primary_samples/lights/punctual_lights/area_lights/area_samples/seed/exposure_ev/shadows/reflections/anisotropic_faces/emissions/surface_effects/dielectrics/environment options, only with raytrace. CPU raytrace.budget?: compact (legacy default), studio or workstation; see docs/render-cpu-resource-profiles.md for explicit image/geometry/memory/work limits. CPU raytrace.progressive?: {samples_per_pixel:1..profile limit, seed:u32}; requires primary_samples:1 and selected reflections.samples:1; no area/LED, anisotropy or dielectrics in this initial mode. See docs/render-cpu-progressive.md; environment?: {path: scoped HDR, expected_sha256?: inspected digest, rotation_radians: 0, intensity: 1, samples: 16} OR {resource: saved HDR digest, rotation_radians, intensity, samples}; embedded resources cannot combine with path/hash; explicit sRGB/D65 HDR primaries required. Opaque CPU preview with selected mirror/rough-specular reflections and certified planar anisotropy. HDR with rough reflections or anisotropy requires fully metallic selected bodies and all effective faces; unsupported combinations refuse. No MIS or GI. CPU runtime dielectrics support only certified thin_sheet/closed_box boundaries with explicit IOR and Beer absorption; see docs/render-raytrace-dielectrics.md. CPU emissions are visible radiance only; surface_effects change roughness/shading normals without geometry changes. led_strip?: continuous world-mm LED rectangle recipe; led_samples?: 1/4/16/64 for the whole strip, default16. At most8directional+8punctual+4rectangle/LED sources; shared area N. See docs/render-light-union.md. transparent_background?: false; replace?: false. With progressive:true, raytrace instead accepts GPU dielectrics/clear_coats/textures; environment instead accepts tagged hdr/embedded_hdr/sky with rotation_rad/intensity; file hdr supports expected_sha256, embedded_hdr uses a document resource digest. See docs/render-hdr-resources.md. GPU lens, studio lighting, tone_map, denoise, bounded finishing/backdrop and linear_exr retention are also available. GPU adaptive?: {pilot_samples:16..256,min_samples:16..samples,relative_error:0..1,absolute_error:0.000001..1000000,coverage_error:0.001..0.25} allocates independent production budgets; pilots are discarded, not a certified error guarantee. transmission_samples?:1|2|4 stratifies the first Fresnel branch with extra path cost. volume?:{min_mm:[x,y,z],max_mm:[x,y,z],extinction_per_mm:0..1000,scattering_albedo:[r,g,b],anisotropy:-0.95..0.95} is one finite homogeneous world-mm medium; active media require explicit lighting/environment and refuse glass, denoise and multiple transmission strata. These fields also persist in GPU job.options. See docs/render-materials/TRANSPORT-MASTER-BATCH-2026-10-23.md; see docs/render-transmission.md, render-environment.md, render-runtime-textures.md, render-thin-lens.md, render-studio-lighting.md and render-denoise.md. Optional CPU raytracing requires a raytrace-cpu build and native host, checked before scene capture. Stale geometry is rejected. See docs/render-jobs.md"),
|
||||
.params("setup?: saved name OR settings?: full RenderSetup. A typed job selects raster/cpu_raytrace/gpu_path and its numerical options plus embedded HDR before dispatch; only replace and transient studio_weights may accompany it. Without job, the legacy runtime controls below remain available. See docs/render-settings.md. studio_weights?: three finite 0..1 visibility weights for raster or implicit GPU studio sources only; never saved. integrator?: raster (default) or raytrace; progressive?: false (registered GPU path, CPU integrator/LED options are mutually exclusive); samples?: 1..4096; max_depth?: 1..16; seed?: u32 for progressive; raytrace?: bounded runtime progressive/primary_samples/lights/punctual_lights/area_lights/area_samples/seed/exposure_ev/shadows/reflections/anisotropic_faces/emissions/surface_effects/dielectrics/environment options, only with raytrace. CPU raytrace.budget?: compact (legacy default), studio or workstation; see docs/render-cpu-resource-profiles.md for explicit image/geometry/memory/work limits. CPU raytrace.progressive?: {samples_per_pixel:1..profile limit, seed:u32}; requires primary_samples:1 and selected reflections.samples:1; no area/LED, anisotropy or dielectrics in this initial mode. See docs/render-cpu-progressive.md; environment?: {path: scoped HDR, expected_sha256?: inspected digest, rotation_radians: 0, intensity: 1, samples: 16} OR {resource: saved HDR digest, rotation_radians, intensity, samples}; embedded resources cannot combine with path/hash; explicit sRGB/D65 HDR primaries required. Opaque CPU preview with selected mirror/rough-specular reflections and certified planar anisotropy. HDR with rough reflections or anisotropy requires fully metallic selected bodies and all effective faces; unsupported combinations refuse. No MIS or GI. CPU runtime dielectrics support only certified thin_sheet/closed_box boundaries with explicit IOR and Beer absorption; see docs/render-raytrace-dielectrics.md. CPU emissions are visible radiance only; surface_effects change roughness/shading normals without geometry changes. led_strip?: continuous world-mm LED rectangle recipe; led_samples?: 1/4/16/64 for the whole strip, default16. At most8directional+8punctual+4rectangle/LED sources; shared area N. See docs/render-light-union.md. transparent_background?: false; replace?: false. With progressive:true, raytrace instead accepts GPU dielectrics/clear_coats/textures; environment instead accepts tagged hdr/embedded_hdr/sky with rotation_rad/intensity; file hdr supports expected_sha256, embedded_hdr uses a document resource digest. See docs/render-hdr-resources.md. GPU lens, studio lighting, tone_map, denoise, bounded finishing/backdrop and linear_exr retention are also available. GPU adaptive?: {pilot_samples:16..256,min_samples:16..samples,relative_error:0..1,absolute_error:0.000001..1000000,coverage_error:0.001..0.25} allocates independent production budgets; pilots are discarded, not a certified error guarantee. transmission_samples?:1|2|4 stratifies the first Fresnel branch with extra path cost. volume?:{min_mm:[x,y,z],max_mm:[x,y,z],extinction_per_mm:0..1000,scattering_albedo:[r,g,b],anisotropy:-0.95..0.95} is one finite homogeneous world-mm medium; active media require explicit lighting/environment and refuse glass, denoise and multiple transmission strata. These fields also persist in GPU job.options. See docs/render-materials/TRANSPORT-MASTER-BATCH-2026-10-23.md; see docs/render-transmission.md, render-environment.md, render-runtime-textures.md, render-thin-lens.md, render-studio-lighting.md and render-denoise.md. Optional CPU raytracing requires a raytrace-cpu build and native host, checked before scene capture. Stale geometry is rejected. See docs/render-jobs.md"),
|
||||
CommandSpec::new("render.start", "Render Image", jobs::start).key("R").noundo().doc_only().at("RENDER", "IMAGE").icon("render_image")
|
||||
.params("Same request as render.preflight. Captures an immutable product scene and queues a bounded image job. Returns its session-scoped job identity, captured scene_generation and progress. Does not change the design. See docs/render-jobs.md"),
|
||||
CommandSpec::new("render.status", "Render Progress", jobs::status).icon("list").noundo().doc_only()
|
||||
|
||||
@@ -11,6 +11,7 @@ use solidcraft_render::{
|
||||
#[derive(Default, Deserialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
struct Start {
|
||||
studio_weights: Option<[f64; 3]>,
|
||||
progressive: bool,
|
||||
denoise: bool,
|
||||
samples: Option<u32>,
|
||||
@@ -46,6 +47,7 @@ impl Default for EnvironmentRequest {
|
||||
#[derive(Default, Deserialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
struct ProgressiveStart {
|
||||
studio_weights: Option<[f64; 3]>,
|
||||
aging: solidcraft_doc::render_aging::SavedAgingStack,
|
||||
#[serde(default)]
|
||||
nested_media: bool,
|
||||
@@ -159,7 +161,7 @@ fn normalize_saved_job(s: &Session, params: &Value, command: &str) -> Result<Opt
|
||||
} else {
|
||||
return Ok(None);
|
||||
};
|
||||
if let Some(key) = object.keys().find(|key| !matches!(key.as_str(), "setup" | "settings" | "replace")) {
|
||||
if let Some(key) = object.keys().find(|key| !matches!(key.as_str(), "setup" | "settings" | "replace" | "studio_weights")) {
|
||||
return Err(bad(
|
||||
command,
|
||||
format!(
|
||||
@@ -198,6 +200,9 @@ fn normalize_saved_job(s: &Session, params: &Value, command: &str) -> Result<Opt
|
||||
}
|
||||
};
|
||||
lowered["settings"] = serde_json::to_value(settings).map_err(|e| bad(command, e.to_string()))?;
|
||||
if let Some(weights) = object.get("studio_weights") {
|
||||
lowered["studio_weights"] = weights.clone();
|
||||
}
|
||||
if let Some(replace) = object.get("replace") {
|
||||
lowered["replace"] = replace.clone();
|
||||
}
|
||||
@@ -237,6 +242,10 @@ fn prepare(s: &Session, params: &Value, command: &str) -> Result<Prepared> {
|
||||
));
|
||||
}
|
||||
let mut input: Start = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
|
||||
validate_studio_weights(input.studio_weights, command)?;
|
||||
if input.integrator == Integrator::Raytrace && input.studio_weights.is_some() {
|
||||
return Err(bad(command, "studio_weights apply to raster or the implicit GPU studio; use explicit CPU light intensities"));
|
||||
}
|
||||
if input.progressive {
|
||||
return prepare_progressive(s, params, command, false, None, None, None);
|
||||
}
|
||||
@@ -399,6 +408,7 @@ fn prepare(s: &Session, params: &Value, command: &str) -> Result<Prepared> {
|
||||
return Err(bad(command, "resolved executor is not installed as an image job host"));
|
||||
}
|
||||
let request = ImageRequest {
|
||||
studio_weights: validate_studio_weights(input.studio_weights, command)?,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: input.integrator,
|
||||
@@ -455,6 +465,10 @@ fn prepare_progressive(
|
||||
return Err(bad(command, "progressive rendering does not accept CPU raytrace, environment or LED options"));
|
||||
}
|
||||
let mut input: ProgressiveStart = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
|
||||
validate_studio_weights(input.studio_weights, command)?;
|
||||
if input.studio_weights.is_some() && (input.lighting.is_some() || input.environment.is_some() || saved_hdr.is_some()) {
|
||||
return Err(bad(command, "studio_weights require the implicit GPU studio without environment lighting"));
|
||||
}
|
||||
if input.integrator != Integrator::Raster || !input.progressive {
|
||||
return Err(bad(command, "progressive rendering requires the registered GPU request method"));
|
||||
}
|
||||
@@ -601,6 +615,7 @@ fn prepare_progressive(
|
||||
return Err(bad(command, "image host is unavailable"));
|
||||
}
|
||||
let request = ImageRequest {
|
||||
studio_weights: validate_studio_weights(input.studio_weights, command)?,
|
||||
integrator: Default::default(),
|
||||
raytrace: None,
|
||||
environment,
|
||||
@@ -785,3 +800,10 @@ pub(super) fn export(s: &mut Session, params: &Value) -> Result<Value> {
|
||||
json!({"job":input.job,"path":input.path,"bytes":bytes.len(),"format":input.format.extension(),"encoding":if input.format==ExportFormat::Exr {"scene_linear_srgb_d65"} else {"srgb"},"alpha":if input.format==ExportFormat::Exr {"coverage_premultiplied"} else {"straight"},"frame":frame.info,"linear_master":frame.linear_master_info(),"presentation":frame.presentation()}),
|
||||
)
|
||||
}
|
||||
|
||||
fn validate_studio_weights(weights: Option<[f64; 3]>, command: &str) -> Result<Option<[f64; 3]>> {
|
||||
if weights.is_some_and(|weights| weights.iter().any(|value| !value.is_finite() || !(0.0..=1.0).contains(value))) {
|
||||
return Err(bad(command, "studio visibility weights must be finite in 0..1"));
|
||||
}
|
||||
Ok(weights)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
//! Read-only light inspection. No host, geometry evaluation, camera or design mutation.
|
||||
|
||||
use serde_json::Value;
|
||||
use solidcraft_doc::render_settings::{RenderSettings, RenderSetup};
|
||||
|
||||
use crate::params::bad;
|
||||
use crate::schema::render_lights::{EditParams, EditResult, Geometry, Light};
|
||||
use crate::schema::render_lights::{ListParams, ListResult};
|
||||
use crate::{Result, Session};
|
||||
|
||||
pub(super) fn list(s: &mut Session, params: &Value) -> Result<Value> {
|
||||
let cmd = "render.lights.list";
|
||||
if !params.is_object() {
|
||||
return Err(bad(cmd, "expected an object"));
|
||||
}
|
||||
let request: ListParams = serde_json::from_value(params.clone()).map_err(|e| bad(cmd, e.to_string()))?;
|
||||
if params.get("setup").is_some_and(Value::is_null) || params.get("settings").is_some_and(Value::is_null) {
|
||||
return Err(bad(cmd, "setup and settings cannot be null"));
|
||||
}
|
||||
let setup = match (request.setup, request.settings) {
|
||||
(Some(_), Some(_)) => return Err(bad(cmd, "choose setup or settings, not both")),
|
||||
(Some(name), None) => {
|
||||
RenderSettings::validate_name(&name).map_err(|e| bad(cmd, e.to_string()))?;
|
||||
s.doc.render.setups.get(&name).cloned().ok_or_else(|| bad(cmd, "no saved render setup with that name"))?
|
||||
}
|
||||
(None, Some(settings)) => {
|
||||
if !settings.is_object() {
|
||||
return Err(bad(cmd, "settings must be an object"));
|
||||
}
|
||||
serde_json::from_value(settings).map_err(|e| bad(cmd, e.to_string()))?
|
||||
}
|
||||
(None, None) => RenderSetup::default(),
|
||||
};
|
||||
setup.validate().map_err(|e| bad(cmd, e.to_string()))?;
|
||||
serde_json::to_value(ListResult { lights: crate::render_lights::inspect(&setup).map_err(|e| bad(cmd, e))? }).map_err(|e| bad(cmd, e.to_string()))
|
||||
}
|
||||
|
||||
fn change(s: &mut Session, params: &Value, operation: &str) -> Result<Value> {
|
||||
let command = format!("render.lights.{operation}");
|
||||
if !params.is_object() {
|
||||
return Err(bad(&command, "expected an object"));
|
||||
}
|
||||
let input: EditParams = serde_json::from_value(params.clone()).map_err(|e| bad(&command, e.to_string()))?;
|
||||
RenderSettings::validate_name(&input.name).map_err(|e| bad(&command, e.to_string()))?;
|
||||
if input.expected_revision.is_some_and(|revision| revision != s.revision) {
|
||||
return Err(bad(&command, "light settings changed; refresh before editing"));
|
||||
}
|
||||
let mut setup = match input.settings {
|
||||
Some(value) if value.is_object() => serde_json::from_value::<RenderSetup>(value).map_err(|e| bad(&command, e.to_string()))?,
|
||||
Some(_) => return Err(bad(&command, "settings must be an object")),
|
||||
None => s.doc.render.setups.get(&input.name).cloned().unwrap_or_default(),
|
||||
};
|
||||
let mut lights = crate::render_lights::inspect(&setup).map_err(|e| bad(&command, e))?;
|
||||
let target = [setup.camera.target.x, setup.camera.target.y, setup.camera.target.z];
|
||||
let mut selected = None;
|
||||
match operation {
|
||||
"add" => {
|
||||
if input.id.is_some() {
|
||||
return Err(bad(&command, "add does not accept an id"));
|
||||
}
|
||||
let mut patch = input.set.unwrap_or_default();
|
||||
if patch.kind.is_none() {
|
||||
patch.kind = Some("area".into());
|
||||
}
|
||||
let [x, y, z] = target;
|
||||
let mut light = Light {
|
||||
id: String::new(),
|
||||
name: String::new(),
|
||||
name_key: String::new(),
|
||||
number: 0,
|
||||
implicit: false,
|
||||
intensity: 1.0,
|
||||
colour: [1.0; 3],
|
||||
geometry: Geometry::Area { position_mm: [x, y - 100.0, z + 100.0], edge_u_mm: [10.0, 0.0, 0.0], edge_v_mm: [0.0, -10.0, 0.0] },
|
||||
};
|
||||
crate::render_lights::patch(&mut light, &patch, target, setup.camera.distance).map_err(|e| bad(&command, e))?;
|
||||
lights.push(light);
|
||||
selected = lights.len().checked_sub(1);
|
||||
}
|
||||
"set" | "duplicate" | "remove" => {
|
||||
let id = input.id.as_deref().ok_or_else(|| bad(&command, "id is required"))?;
|
||||
crate::render_lights::parse_id(id).map_err(|e| bad(&command, e))?;
|
||||
let index = lights.iter().position(|light| light.id == id).ok_or_else(|| bad(&command, "light no longer exists"))?;
|
||||
if operation == "remove" {
|
||||
if input.set.is_some() {
|
||||
return Err(bad(&command, "remove does not accept set"));
|
||||
}
|
||||
lights.retain(|light| light.id != id);
|
||||
} else if operation == "duplicate" {
|
||||
if input.set.is_some() {
|
||||
return Err(bad(&command, "duplicate does not accept set"));
|
||||
}
|
||||
let light = lights.get(index).cloned().ok_or_else(|| bad(&command, "missing light"))?;
|
||||
lights.push(light);
|
||||
selected = lights.len().checked_sub(1);
|
||||
} else {
|
||||
let patch = input.set.ok_or_else(|| bad(&command, "set is required"))?;
|
||||
let light = lights.get_mut(index).ok_or_else(|| bad(&command, "missing light"))?;
|
||||
if matches!(setup.job, Some(solidcraft_doc::render_settings::RenderJob::CpuRaytrace { .. }))
|
||||
&& light.geometry.kind() == "directional"
|
||||
&& patch.softness.is_some()
|
||||
{
|
||||
return Err(bad(&command, "CPU directional lights have hard shadows; softness is not supported"));
|
||||
}
|
||||
crate::render_lights::patch(light, &patch, target, setup.camera.distance).map_err(|e| bad(&command, e))?;
|
||||
selected = Some(index);
|
||||
}
|
||||
}
|
||||
_ => return Err(bad(&command, "unknown light operation")),
|
||||
}
|
||||
let id = selected.and_then(|index| {
|
||||
lights.get(index).map(|light| {
|
||||
let kind = light.geometry.kind();
|
||||
let slot = lights
|
||||
.iter()
|
||||
.take(index)
|
||||
.filter(|prior| {
|
||||
if matches!(kind, "point" | "spot") { matches!(prior.geometry.kind(), "point" | "spot") } else { prior.geometry.kind() == kind }
|
||||
})
|
||||
.count();
|
||||
format!("{kind}:{slot}")
|
||||
})
|
||||
});
|
||||
crate::render_lights::write(&mut setup, &lights).map_err(|e| bad(&command, e))?;
|
||||
let mut settings = (*s.doc.render).clone();
|
||||
settings.setups.insert(input.name.clone(), setup.clone());
|
||||
settings.validate().map_err(|e| bad(&command, e.to_string()))?;
|
||||
if *s.doc.render != settings {
|
||||
s.doc_mut().render = std::sync::Arc::new(settings);
|
||||
}
|
||||
serde_json::to_value(EditResult { id, name: input.name, setup: serde_json::to_value(setup).map_err(|e| bad(&command, e.to_string()))? })
|
||||
.map_err(|e| bad(&command, e.to_string()))
|
||||
}
|
||||
|
||||
pub(super) fn set(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
change(s, p, "set")
|
||||
}
|
||||
pub(super) fn add(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
change(s, p, "add")
|
||||
}
|
||||
pub(super) fn duplicate(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
change(s, p, "duplicate")
|
||||
}
|
||||
pub(super) fn remove(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
change(s, p, "remove")
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use solidcraft_doc::render_settings::RenderJob;
|
||||
|
||||
fn save(s: &mut Session, patch: Value) {
|
||||
s.execute("render.settings.set", &json!({"name":"Studio", "set":patch})).unwrap();
|
||||
@@ -128,6 +129,406 @@ fn shot_frame_edits_are_bounded_atomic_and_one_undo_per_edit() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_visibility_commands_validate_and_echo_without_document_or_history_changes() {
|
||||
let mut s = Session::default();
|
||||
save(&mut s, json!({"width":800}));
|
||||
save(&mut s, json!({"width":900}));
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
s.mark_saved();
|
||||
let document = s.doc.clone();
|
||||
let before = (s.undo.len(), s.redo.len(), s.revision, s.evaluations, s.is_dirty());
|
||||
for (command, input) in [
|
||||
("render.lights.solo", json!({"id":"directional:0","solo":true})),
|
||||
("render.lights.solo", json!({"solo":false})),
|
||||
("render.lights.mute", json!({"id":"area:3","mute":true})),
|
||||
("render.lights.mute", json!({"id":"spot:7","mute":false})),
|
||||
] {
|
||||
let reply = s.execute(command, &input).unwrap();
|
||||
for (key, value) in input.as_object().unwrap() {
|
||||
assert_eq!(reply.get(key), Some(value));
|
||||
}
|
||||
let spec = crate::find_command(command).unwrap();
|
||||
assert!(!spec.undoable && !spec.reads_model);
|
||||
let description = s.execute("engine.describe", &json!({"command":command})).unwrap();
|
||||
assert!(description["input"].is_object() && description["output"].is_object());
|
||||
}
|
||||
for (command, input) in [
|
||||
("render.lights.solo", json!({"solo":true})),
|
||||
("render.lights.solo", json!({"id":"point:8","solo":true})),
|
||||
("render.lights.solo", json!({"id":"point:00","solo":true})),
|
||||
("render.lights.solo", json!({"id":"directional:18446744073709551615","solo":true})),
|
||||
("render.lights.solo", json!(["area:0", true])),
|
||||
("render.lights.solo", json!({"id":"area:0","solo":"true"})),
|
||||
("render.lights.mute", json!({"id":"area:4","mute":true})),
|
||||
("render.lights.mute", json!({"id":"unknown:0","mute":true})),
|
||||
("render.lights.mute", json!({"id":"area:0","mute":true,"save":true})),
|
||||
("render.lights.mute", json!({"mute":true})),
|
||||
] {
|
||||
assert!(s.execute(command, &input).is_err(), "{command}: {input}");
|
||||
}
|
||||
assert!(Arc::ptr_eq(&document, &s.doc));
|
||||
assert_eq!(before, (s.undo.len(), s.redo.len(), s.revision, s.evaluations, s.is_dirty()));
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert_eq!(s.doc.render.setups["Studio"].width, 900);
|
||||
}
|
||||
|
||||
fn light_fixture(s: &mut Session, method: &str) {
|
||||
let options = if method == "gpu_path" { json!({"lighting":{}}) } else { json!({"lights":[],"punctual_lights":[],"area_lights":[]}) };
|
||||
save(s, json!({"job":{"method":method,"options":options}}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_small_area_pose_and_resize_preserve_aspect_and_emitting_side() {
|
||||
use crate::schema::render_lights::Geometry;
|
||||
use solidcraft_geom::Vec3;
|
||||
let mut s = Session::default();
|
||||
save(
|
||||
&mut s,
|
||||
json!({"job":{"method":"cpu_raytrace","options":{"lights":[],"area_lights":[{
|
||||
"center_mm":[0,0,10],"edge_u_mm":[0.000002,0,0],"edge_v_mm":[0,-0.000004,0],"color":[1,1,1],"intensity":1
|
||||
}]}}}),
|
||||
);
|
||||
s.execute("render.lights.set", &json!({"name":"Studio","id":"area:0","set":{"azimuth_deg":90,"elevation_deg":45}})).unwrap();
|
||||
let before = crate::render_lights::inspect(&s.doc.render.setups["Studio"]).unwrap();
|
||||
let Geometry::Area { edge_u_mm: [ux, uy, uz], edge_v_mm: [vx, vy, vz], .. } = before[0].geometry else { panic!("area") };
|
||||
let u = Vec3::new(ux, uy, uz);
|
||||
let v = Vec3::new(vx, vy, vz);
|
||||
assert!((u.len() - 0.000002).abs() < 1e-12);
|
||||
assert!((v.len() / u.len() - 2.0).abs() < 1e-12);
|
||||
s.execute("render.lights.set", &json!({"name":"Studio","id":"area:0","set":{"size_mm":20}})).unwrap();
|
||||
let after = crate::render_lights::inspect(&s.doc.render.setups["Studio"]).unwrap();
|
||||
let Geometry::Area { edge_u_mm: [ux, uy, uz], edge_v_mm: [vx, vy, vz], .. } = after[0].geometry else { panic!("area") };
|
||||
let resized_u = Vec3::new(ux, uy, uz);
|
||||
let resized_v = Vec3::new(vx, vy, vz);
|
||||
assert!((resized_u.len() - 20.0).abs() < 1e-10);
|
||||
assert!((resized_v.len() - 40.0).abs() < 1e-10);
|
||||
assert!(
|
||||
solidcraft_render::surface::unit_direction(u.cross(v))
|
||||
.unwrap()
|
||||
.dot(solidcraft_render::surface::unit_direction(resized_u.cross(resized_v)).unwrap())
|
||||
> 0.999999
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_edit_commands_publish_one_undo_and_preserve_other_settings() {
|
||||
let mut s = Session::default();
|
||||
light_fixture(&mut s, "cpu_raytrace");
|
||||
for (command, params) in [
|
||||
("render.lights.add", json!({"name":"Studio","set":{"kind":"point"}})),
|
||||
(
|
||||
"render.lights.set",
|
||||
json!({"name":"Studio","id":"point:0","set":{"intensity_ev":2,"temperature_k":3200,"azimuth_deg":35,"elevation_deg":45,"distance_mm":100}}),
|
||||
),
|
||||
("render.lights.duplicate", json!({"name":"Studio","id":"point:0"})),
|
||||
("render.lights.set", json!({"name":"Studio","id":"point:1","set":{"kind":"spot","aim_at":[0,0,0]}})),
|
||||
("render.lights.remove", json!({"name":"Studio","id":"point:0"})),
|
||||
] {
|
||||
let before = s.doc.clone();
|
||||
let undo = s.undo.len();
|
||||
let reply = s.execute(command, ¶ms).unwrap();
|
||||
assert_eq!(s.undo.len(), undo + 1, "{command}");
|
||||
assert_eq!(reply["setup"]["width"], 1024);
|
||||
let changed = s.doc.clone();
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(s.doc, before, "{command}");
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert_eq!(s.doc, changed, "{command}");
|
||||
}
|
||||
let list = s.execute("render.lights.list", &json!({"setup":"Studio"})).unwrap();
|
||||
assert_eq!(list["lights"].as_array().unwrap().len(), 1);
|
||||
assert_eq!(list["lights"][0]["kind"], "spot");
|
||||
assert_eq!(list["lights"][0]["intensity"], 4.0);
|
||||
assert_eq!(solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap(), *s.doc);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_edit_refusals_are_atomic_for_hostile_numbers_ids_stale_reviews_and_caps() {
|
||||
let mut s = Session::default();
|
||||
light_fixture(&mut s, "cpu_raytrace");
|
||||
s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":"point"}})).unwrap();
|
||||
for input in [
|
||||
json!({"name":"Studio","id":"point:0","set":{"intensity_ev":1e300}}),
|
||||
json!({"name":"Studio","id":"point:0","set":{"intensity_ev":7}}),
|
||||
json!({"name":"Studio","id":"point:0","set":{"temperature_k":999}}),
|
||||
json!({"name":"Studio","id":"point:0","set":{"softness":0.5}}),
|
||||
json!({"name":"Studio","id":"point:0","set":{"aim_at":[1e300,0,0]}}),
|
||||
json!({"name":"Studio","id":"point:0","set":{"distance_mm":-1}}),
|
||||
json!({"name":"Studio","id":"point:0","set":{"kind":"invalid"}}),
|
||||
json!({"name":"Studio","id":"area:0","set":{"intensity_ev":1}}),
|
||||
json!({"name":"Studio","id":"point:0","set":{"intensity_ev":1},"expected_revision":0}),
|
||||
json!({"name":"Studio","id":"point:0","set":{"save":true}}),
|
||||
] {
|
||||
let document = s.doc.clone();
|
||||
let before = (s.undo.len(), s.redo.len(), s.revision, s.evaluations);
|
||||
assert!(s.execute("render.lights.set", &input).is_err(), "{input}");
|
||||
assert!(Arc::ptr_eq(&document, &s.doc));
|
||||
assert_eq!(before, (s.undo.len(), s.redo.len(), s.revision, s.evaluations));
|
||||
}
|
||||
for (kind, cap) in [("directional", 8), ("point", 8), ("area", 4)] {
|
||||
light_fixture(&mut s, "cpu_raytrace");
|
||||
for _ in 0..cap {
|
||||
s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":kind}})).unwrap();
|
||||
}
|
||||
let document = s.doc.clone();
|
||||
let before = (s.undo.len(), s.revision);
|
||||
assert!(s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":kind}})).is_err());
|
||||
assert!(s.execute("render.lights.duplicate", &json!({"name":"Studio","id":format!("{kind}:0")})).is_err());
|
||||
assert!(Arc::ptr_eq(&document, &s.doc));
|
||||
assert_eq!(before, (s.undo.len(), s.revision));
|
||||
}
|
||||
light_fixture(&mut s, "gpu_path");
|
||||
s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":"directional"}})).unwrap();
|
||||
let document = s.doc.clone();
|
||||
for command in ["render.lights.add", "render.lights.duplicate"] {
|
||||
let params =
|
||||
if command.ends_with("add") { json!({"name":"Studio","set":{"kind":"point"}}) } else { json!({"name":"Studio","id":"directional:0"}) };
|
||||
assert!(s.execute(command, ¶ms).is_err());
|
||||
assert!(Arc::ptr_eq(&document, &s.doc));
|
||||
}
|
||||
for _ in 0..4 {
|
||||
s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":"area"}})).unwrap();
|
||||
}
|
||||
assert!(s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":"area"}})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_filter_copies_preserve_saved_settings_and_environment() {
|
||||
use crate::schema::render_lights::Visibility;
|
||||
let mut s = Session::default();
|
||||
light_fixture(&mut s, "gpu_path");
|
||||
s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":"area"}})).unwrap();
|
||||
s.execute("render.lights.duplicate", &json!({"name":"Studio","id":"area:0"})).unwrap();
|
||||
let original = s.doc.render.setups["Studio"].clone();
|
||||
let mut copy = original.clone();
|
||||
let mut visibility = Visibility { solo: Some("area:1".into()), ..Default::default() };
|
||||
assert_eq!(crate::render_lights::filter(&mut copy, &visibility).unwrap(), None);
|
||||
let lights = crate::render_lights::inspect(©).unwrap();
|
||||
assert_eq!(lights[0].intensity, 0.0);
|
||||
assert!(lights[1].intensity > 0.0);
|
||||
visibility.muted.insert("area:1".into());
|
||||
crate::render_lights::filter(&mut copy, &visibility).unwrap();
|
||||
assert!(crate::render_lights::inspect(©).unwrap().iter().all(|light| light.intensity == 0.0));
|
||||
assert_eq!(s.doc.render.setups["Studio"], original);
|
||||
let mut raster = RenderSetup::default();
|
||||
let unchanged = raster.clone();
|
||||
visibility.solo = Some("directional:1".into());
|
||||
visibility.muted.clear();
|
||||
assert_eq!(crate::render_lights::filter(&mut raster, &visibility).unwrap(), Some([0.0, 1.0, 0.0]));
|
||||
assert_eq!(raster, unchanged);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_list_unifies_cpu_families_and_keeps_source_slot_ids() {
|
||||
let mut s = Session::default();
|
||||
let directional = json!({"direction":[0,0,2],"color":[1,0.5,0.25],"intensity":3});
|
||||
let point = json!({"position_mm":[2,3,4],"color":[0.2,0.4,1],"intensity":2,"reference_distance_mm":10,"minimum_distance_mm":0.01});
|
||||
let mut spot = point.clone();
|
||||
spot["cone"] = json!({"emitted_axis":[0,0,-1],"inner_half_angle_radians":0.2,"outer_half_angle_radians":0.5});
|
||||
let area = json!({"center_mm":[0,0,10],"edge_u_mm":[4,0,0],"edge_v_mm":[0,-6,0],"color":[1,1,1],"intensity":4});
|
||||
save(
|
||||
&mut s,
|
||||
json!({"job":{"method":"cpu_raytrace","options":{
|
||||
"lights":[directional],"punctual_lights":[point,spot],"area_lights":[area]}}}),
|
||||
);
|
||||
let result = s.execute("render.lights.list", &json!({"setup":"Studio"})).unwrap();
|
||||
let lights = result["lights"].as_array().unwrap();
|
||||
assert_eq!(lights.len(), 4);
|
||||
for (light, (id, kind, name)) in lights.iter().zip([
|
||||
("directional:0", "directional", "Key"),
|
||||
("point:0", "point", "Fill"),
|
||||
("spot:1", "spot", "Rim"),
|
||||
("area:0", "area", "Light 4"),
|
||||
]) {
|
||||
assert_eq!(light["id"], id);
|
||||
assert_eq!(light["kind"], kind);
|
||||
assert_eq!(light["name"], name);
|
||||
assert_eq!(light["implicit"], false);
|
||||
}
|
||||
assert_eq!(lights[0]["direction"], json!([0.0, 0.0, 2.0]));
|
||||
assert_eq!(lights[0]["colour"], json!([1.0, 0.5, 0.25]));
|
||||
assert_eq!(lights[1]["minimum_distance_mm"], 0.01);
|
||||
assert_eq!(lights[2]["outer_half_angle_radians"], 0.5);
|
||||
assert_eq!(lights[3]["edge_v_mm"], json!([0.0, -6.0, 0.0]));
|
||||
assert_eq!(lights[3]["name_key"], "render.light_default_number");
|
||||
assert_eq!(lights[3]["number"], 4);
|
||||
let mut setup = serde_json::to_value(&s.doc.render.setups["Studio"]).unwrap();
|
||||
setup["job"]["options"]["lights"][0]["intensity"] = json!(6);
|
||||
let document = s.doc.clone();
|
||||
let edited = s.execute("render.lights.list", &json!({"settings":setup})).unwrap();
|
||||
assert_eq!(edited["lights"][0]["id"], lights[0]["id"]);
|
||||
assert_eq!(edited["lights"][0]["intensity"], 6.0);
|
||||
assert!(Arc::ptr_eq(&document, &s.doc));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_list_factors_gpu_radiance_and_converts_half_edges() {
|
||||
let mut s = Session::default();
|
||||
let result = s
|
||||
.execute(
|
||||
"render.lights.list",
|
||||
&json!({"settings":{"job":{"method":"gpu_path","options":{"lighting":{
|
||||
"sun":{"direction":[0,0,1],"angular_radius_rad":0.02,"radiance":[1000,500,250]},
|
||||
"area_lights":[{"center":[2,3,4],"u":[5,0,0],"v":[0,-6,0],"radiance":[8,4,2]},
|
||||
{"center":[0,0,10],"u":[1,0,0],"v":[0,1,0],"radiance":[0,0,0]}]
|
||||
}}}}}),
|
||||
)
|
||||
.unwrap();
|
||||
let lights = result["lights"].as_array().unwrap();
|
||||
assert_eq!(lights.len(), 3);
|
||||
assert_eq!(lights[0]["id"], "directional:0");
|
||||
assert_eq!(lights[0]["angular_radius_rad"], 0.02);
|
||||
assert_eq!(lights[0]["intensity"], 1000.0);
|
||||
assert_eq!(lights[0]["colour"], json!([1.0, 0.5, 0.25]));
|
||||
assert_eq!(lights[1]["id"], "area:0");
|
||||
assert_eq!(lights[1]["position_mm"], json!([2.0, 3.0, 4.0]));
|
||||
assert_eq!(lights[1]["edge_u_mm"], json!([10.0, 0.0, 0.0]));
|
||||
assert_eq!(lights[1]["edge_v_mm"], json!([0.0, -12.0, 0.0]));
|
||||
for (light, expected) in lights.iter().zip([[1000.0, 500.0, 250.0], [8.0, 4.0, 2.0], [0.0; 3]]) {
|
||||
let intensity = light["intensity"].as_f64().unwrap();
|
||||
for (colour, radiance) in light["colour"].as_array().unwrap().iter().zip(expected) {
|
||||
assert_eq!(colour.as_f64().unwrap() * intensity, radiance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_list_distinguishes_implicit_presets_empty_rigs_and_environments() {
|
||||
let mut s = Session::default();
|
||||
for (settings, count, implicit) in [
|
||||
(json!({}), 3, true),
|
||||
(json!({"job":{"method":"raster"}}), 3, true),
|
||||
(json!({"job":{"method":"cpu_raytrace"}}), 3, true),
|
||||
(json!({"job":{"method":"cpu_raytrace","options":{"preset":"warm_cool"}}}), 3, true),
|
||||
(json!({"job":{"method":"cpu_raytrace","options":{"preset":"key_rim"}}}), 2, true),
|
||||
(json!({"job":{"method":"cpu_raytrace","options":{"lights":[]}}}), 0, false),
|
||||
(json!({"job":{"method":"gpu_path"}}), 3, true),
|
||||
(json!({"job":{"method":"gpu_path","options":{"lighting":{}}}}), 0, false),
|
||||
(json!({"job":{"method":"gpu_path","options":{"environment":{"kind":"sky"}}}}), 0, false),
|
||||
] {
|
||||
let reply = s.execute("render.lights.list", &json!({"settings":settings})).unwrap();
|
||||
let lights = reply["lights"].as_array().unwrap();
|
||||
assert_eq!(lights.len(), count, "{settings}");
|
||||
assert!(lights.iter().all(|light| light["implicit"] == implicit));
|
||||
}
|
||||
let warm = s.execute("render.lights.list", &json!({"settings":{"job":{"method":"cpu_raytrace","options":{"preset":"warm_cool"}}}})).unwrap();
|
||||
assert_eq!(warm["lights"][0]["colour"], json!([1.0, 0.72, 0.48]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_list_accepts_all_twenty_cpu_slots_and_refuses_over_caps() {
|
||||
let mut s = Session::default();
|
||||
let directional = json!({"direction":[0,0,1],"color":[1,1,1],"intensity":1});
|
||||
let point = json!({"position_mm":[0,0,10],"color":[1,1,1],"intensity":1,"reference_distance_mm":10,"minimum_distance_mm":0.01});
|
||||
let area = json!({"center_mm":[0,0,10],"edge_u_mm":[4,0,0],"edge_v_mm":[0,6,0],"color":[1,1,1],"intensity":1});
|
||||
let mut settings = json!({"job":{"method":"cpu_raytrace","options":{
|
||||
"lights":vec![directional.clone();8],"punctual_lights":vec![point.clone();8],"area_lights":vec![area.clone();4]}}});
|
||||
let reply = s.execute("render.lights.list", &json!({"settings":settings})).unwrap();
|
||||
let lights = reply["lights"].as_array().unwrap();
|
||||
assert_eq!(lights.len(), 20);
|
||||
assert_eq!(lights.last().unwrap()["id"], "area:3");
|
||||
let ids: std::collections::BTreeSet<_> = lights.iter().map(|l| l["id"].as_str().unwrap()).collect();
|
||||
assert_eq!(ids.len(), 20);
|
||||
for (field, value) in [("lights", directional), ("punctual_lights", point), ("area_lights", area)] {
|
||||
settings["job"]["options"][field].as_array_mut().unwrap().push(value);
|
||||
assert!(s.execute("render.lights.list", &json!({"settings":settings})).is_err());
|
||||
settings["job"]["options"][field].as_array_mut().unwrap().pop();
|
||||
}
|
||||
let area = json!({"center":[0,0,10],"u":[1,0,0],"v":[0,1,0],"radiance":[1,1,1]});
|
||||
for count in [4, 5] {
|
||||
let result = s.execute(
|
||||
"render.lights.list",
|
||||
&json!({"settings":{"job":{"method":"gpu_path","options":{
|
||||
"lighting":{"area_lights":vec![area.clone();count]}}}}}),
|
||||
);
|
||||
if count == 4 {
|
||||
assert_eq!(result.unwrap()["lights"].as_array().unwrap().len(), 4);
|
||||
} else {
|
||||
assert!(result.is_err());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_list_hostile_calls_and_reads_preserve_document_history_and_dirty_state() {
|
||||
let mut s = Session::default();
|
||||
save(&mut s, json!({"width":800}));
|
||||
save(&mut s, json!({"width":900}));
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
s.mark_saved();
|
||||
let document = s.doc.clone();
|
||||
let before = (s.undo.len(), s.redo.len(), s.revision, s.evaluations, s.is_dirty());
|
||||
for params in [
|
||||
json!([]),
|
||||
json!([null, null]),
|
||||
json!(3),
|
||||
json!({"unknown":true}),
|
||||
json!({"setup":null}),
|
||||
json!({"settings":null}),
|
||||
json!({"setup":[]}),
|
||||
json!({"setup":"missing"}),
|
||||
json!({"setup":"Studio","settings":{}}),
|
||||
json!({"settings":[]}),
|
||||
json!({"settings":{"job":{"method":"cpu_raytrace","options":{"lights":[{
|
||||
"direction":[0,0,0],"color":[1,1,1],"intensity":1}]}}}}),
|
||||
json!({"settings":{"job":{"method":"gpu_path","options":{"lighting":{"sun":{
|
||||
"direction":[0,0,1],"angular_radius_rad":0.02,"radiance":[1e300,0,0]}}}}}}),
|
||||
] {
|
||||
assert!(s.execute("render.lights.list", ¶ms).is_err(), "{params}");
|
||||
assert!(Arc::ptr_eq(&document, &s.doc));
|
||||
assert_eq!(before, (s.undo.len(), s.redo.len(), s.revision, s.evaluations, s.is_dirty()));
|
||||
}
|
||||
// Session::execute normalizes a top-level null to the empty parameter object.
|
||||
for params in [Value::Null, json!({}), json!({"setup":"Studio"}), json!({"settings":{"job":{"method":"cpu_raytrace"}}})] {
|
||||
s.execute("render.lights.list", ¶ms).unwrap();
|
||||
assert!(Arc::ptr_eq(&document, &s.doc));
|
||||
assert_eq!(before, (s.undo.len(), s.redo.len(), s.revision, s.evaluations, s.is_dirty()));
|
||||
}
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert_eq!(s.doc.render.setups["Studio"].width, 900);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_list_publishes_and_checks_both_schemas() {
|
||||
let mut s = Session::default();
|
||||
let reply = s.execute("engine.describe", &json!({"command":"render.lights.list"})).unwrap();
|
||||
assert_eq!(reply["input"]["properties"].as_object().unwrap().keys().map(String::as_str).collect::<Vec<_>>(), ["settings", "setup"]);
|
||||
assert!(reply["input"]["properties"].get("setup").is_some());
|
||||
assert!(reply["input"]["properties"].get("settings").is_some());
|
||||
assert!(reply["output"]["properties"].get("lights").is_some());
|
||||
for mode in [crate::schema::ParamCheck::Off, crate::schema::ParamCheck::Warn, crate::schema::ParamCheck::Strict] {
|
||||
s.param_check = mode;
|
||||
assert!(s.execute("render.lights.list", &json!({"typo":true})).is_err());
|
||||
let reply = s.execute("render.lights.list", &json!({})).unwrap();
|
||||
assert_eq!(reply["lights"].as_array().unwrap().len(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_list_does_not_settle_a_stale_model() {
|
||||
let mut s = Session::default();
|
||||
for (command, params) in [
|
||||
("sketch.create", json!({"plane":"XY"})),
|
||||
("sketch.rectangle.two_point", json!({"p0":[5,5],"p1":[25,20]})),
|
||||
("sketch.finish", json!({})),
|
||||
("solid.extrude", json!({"distance":5})),
|
||||
("sketch.edit", json!({"sketch":"Sketch1"})),
|
||||
("sketch.drag", json!({"entity":"l1.start","from":[5,5],"to":[4,5],"live":true})),
|
||||
] {
|
||||
s.execute(command, ¶ms).unwrap();
|
||||
}
|
||||
assert!(s.model.is_stale());
|
||||
let document = s.doc.clone();
|
||||
let model = s.model.state();
|
||||
let before = (s.undo.len(), s.redo.len(), s.revision, s.evaluations);
|
||||
s.execute("render.lights.list", &json!({"settings":{"job":{"method":"cpu_raytrace"}}})).unwrap();
|
||||
assert!(s.model.is_stale());
|
||||
assert!(Arc::ptr_eq(&document, &s.doc));
|
||||
assert!(Arc::ptr_eq(&model, &s.model.state()));
|
||||
assert_eq!(before, (s.undo.len(), s.redo.len(), s.revision, s.evaluations));
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[test]
|
||||
fn embedded_hdr_capture_is_offline_atomic_deduplicated_and_undoable_after_source_removal() {
|
||||
@@ -461,3 +862,116 @@ fn settings_history_and_checkpoint_preserve_a_stale_live_drag() {
|
||||
assert!(!s.model.is_stale());
|
||||
assert!(s.evaluations > 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_shape_falloff_and_world_vectors_lower_to_existing_fields_with_undo() {
|
||||
use crate::schema::render_lights::Geometry;
|
||||
let mut s = Session::default();
|
||||
for method in ["cpu_raytrace", "gpu_path"] {
|
||||
light_fixture(&mut s, method);
|
||||
s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":"area"}})).unwrap();
|
||||
let before = s.doc.clone();
|
||||
s.execute(
|
||||
"render.lights.set",
|
||||
&json!({"name":"Studio","id":"area:0","set":{
|
||||
"position_mm":[2,3,40],"width_mm":60,"height_mm":40,"radiance":[8,4,2]
|
||||
}}),
|
||||
)
|
||||
.unwrap();
|
||||
let lights = crate::render_lights::inspect(&s.doc.render.setups["Studio"]).unwrap();
|
||||
assert_eq!(lights[0].colour.map(|c| c * lights[0].intensity), [8.0, 4.0, 2.0]);
|
||||
let Geometry::Area { position_mm, edge_u_mm: [ux, uy, uz], edge_v_mm: [vx, vy, vz] } = lights[0].geometry else { panic!("area") };
|
||||
assert_eq!(position_mm, [2.0, 3.0, 40.0]);
|
||||
assert!((ux.hypot(uy).hypot(uz) - 60.0).abs() < 1e-9);
|
||||
assert!((vx.hypot(vy).hypot(vz) - 40.0).abs() < 1e-9);
|
||||
let changed = s.doc.clone();
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(s.doc, before);
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert_eq!(s.doc, changed);
|
||||
// GPU stores half-edges, CPU full sides. Both inspect as the same full vectors.
|
||||
s.execute("render.lights.set", &json!({"name":"Studio","id":"area:0","set":{"edge_u_mm":[0,60,0],"edge_v_mm":[40,0,0]}})).unwrap();
|
||||
let roundtrip = solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap();
|
||||
assert_eq!(roundtrip, *s.doc);
|
||||
s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":"directional"}})).unwrap();
|
||||
s.execute("render.lights.set", &json!({"name":"Studio","id":"directional:0","set":{"direction":[-0.4,-0.6,0.7]}})).unwrap();
|
||||
let lights = crate::render_lights::inspect(&s.doc.render.setups["Studio"]).unwrap();
|
||||
let Geometry::Directional { direction, .. } = lights[0].geometry else { panic!("directional") };
|
||||
assert_eq!(direction, [-0.4, -0.6, 0.7]);
|
||||
}
|
||||
light_fixture(&mut s, "cpu_raytrace");
|
||||
s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":"point"}})).unwrap();
|
||||
s.execute(
|
||||
"render.lights.set",
|
||||
&json!({"name":"Studio","id":"point:0","set":{
|
||||
"position_mm":[5,10,20],"reference_distance_mm":1000,"minimum_distance_mm":10
|
||||
}}),
|
||||
)
|
||||
.unwrap();
|
||||
let lights = crate::render_lights::inspect(&s.doc.render.setups["Studio"]).unwrap();
|
||||
assert!(matches!(
|
||||
lights[0].geometry,
|
||||
Geometry::Point { position_mm: [5.0, 10.0, 20.0], reference_distance_mm: 1000.0, minimum_distance_mm: 10.0 }
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_new_numeric_fields_refuse_hostile_and_inapplicable_patches_atomically() {
|
||||
use crate::schema::render_lights::LightPatch;
|
||||
let mut s = Session::default();
|
||||
light_fixture(&mut s, "cpu_raytrace");
|
||||
for kind in ["area", "point", "directional"] {
|
||||
s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":kind}})).unwrap();
|
||||
}
|
||||
for (id, set) in [
|
||||
("area:0", json!({"width_mm":1e300})),
|
||||
("area:0", json!({"height_mm":-1})),
|
||||
("area:0", json!({"radiance":[1e300,0,0]})),
|
||||
("area:0", json!({"edge_u_mm":[0,0,0]})),
|
||||
("area:0", json!({"edge_v_mm":[1,0,0],"edge_u_mm":[1,0,0]})),
|
||||
("area:0", json!({"position_mm":[1e300,0,0]})),
|
||||
("area:0", json!({"minimum_distance_mm":1})),
|
||||
("point:0", json!({"width_mm":1})),
|
||||
("point:0", json!({"reference_distance_mm":1e300})),
|
||||
("point:0", json!({"reference_distance_mm":1,"minimum_distance_mm":2})),
|
||||
("point:0", json!({"minimum_distance_mm":0})),
|
||||
("directional:0", json!({"direction":[0,0,0]})),
|
||||
("directional:0", json!({"direction":[1e300,0,0]})),
|
||||
] {
|
||||
let before = s.doc.clone();
|
||||
let history = (s.undo.len(), s.revision);
|
||||
assert!(s.execute("render.lights.set", &json!({"name":"Studio","id":id,"set":set})).is_err());
|
||||
assert!(Arc::ptr_eq(&before, &s.doc));
|
||||
assert_eq!((s.undo.len(), s.revision), history);
|
||||
}
|
||||
for invalid in [f64::NAN, f64::INFINITY, f64::NEG_INFINITY] {
|
||||
for edit in [
|
||||
LightPatch { width_mm: Some(invalid), ..Default::default() },
|
||||
LightPatch { height_mm: Some(invalid), ..Default::default() },
|
||||
LightPatch { radiance: Some([invalid, 1.0, 1.0]), ..Default::default() },
|
||||
LightPatch { direction: Some([invalid, 0.0, 1.0]), ..Default::default() },
|
||||
LightPatch { position_mm: Some([invalid, 0.0, 1.0]), ..Default::default() },
|
||||
LightPatch { reference_distance_mm: Some(invalid), ..Default::default() },
|
||||
LightPatch { minimum_distance_mm: Some(invalid), ..Default::default() },
|
||||
] {
|
||||
let mut light = crate::render_lights::inspect(&s.doc.render.setups["Studio"]).unwrap().remove(0);
|
||||
assert!(crate::render_lights::patch(&mut light, &edit, [0.0; 3], 100.0).is_err());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_removing_last_area_clears_area_only_sampling_settings() {
|
||||
let mut s = Session::default();
|
||||
light_fixture(&mut s, "cpu_raytrace");
|
||||
s.execute("render.lights.add", &json!({"name":"Studio","set":{"kind":"area"}})).unwrap();
|
||||
let mut setup = s.doc.render.setups["Studio"].clone();
|
||||
if let Some(RenderJob::CpuRaytrace { options }) = &mut setup.job {
|
||||
options.area_samples = Some(64);
|
||||
options.seed = Some(123);
|
||||
}
|
||||
s.execute("render.lights.remove", &json!({"name":"Studio","id":"area:0","settings":setup})).unwrap();
|
||||
let Some(RenderJob::CpuRaytrace { options }) = &s.doc.render.setups["Studio"].job else { panic!("CPU") };
|
||||
assert!(options.area_samples.is_none() && options.seed.is_none());
|
||||
assert!(options.area_lights.as_ref().unwrap().is_empty());
|
||||
}
|
||||
|
||||
@@ -1,10 +1,39 @@
|
||||
//! Planned Render interactions, with explicit non-mutating refusals.
|
||||
use super::CommandSpec;
|
||||
use crate::schema::render_lights::{MuteParams, SoloParams};
|
||||
use crate::schema::{TypedContract, output_schema_for, render_ui::CheckReport};
|
||||
use crate::{Result, Session, params::bad};
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
const SOLO: crate::schema::TypedContract<SoloParams> = crate::schema::TypedContract::new();
|
||||
const MUTE: crate::schema::TypedContract<MuteParams> = crate::schema::TypedContract::new();
|
||||
|
||||
fn solo(_: &mut crate::Session, params: &serde_json::Value) -> crate::Result<serde_json::Value> {
|
||||
let command = "render.lights.solo";
|
||||
if !params.is_object() {
|
||||
return Err(crate::params::bad(command, "expected an object"));
|
||||
}
|
||||
let input: SoloParams = serde_json::from_value(params.clone()).map_err(|e| crate::params::bad(command, e.to_string()))?;
|
||||
if input.solo && input.id.is_none() {
|
||||
return Err(crate::params::bad(command, "solo requires a light id"));
|
||||
}
|
||||
if let Some(id) = &input.id {
|
||||
crate::render_lights::parse_id(id).map_err(|e| crate::params::bad(command, e))?;
|
||||
}
|
||||
serde_json::to_value(input).map_err(|e| crate::params::bad(command, e.to_string()))
|
||||
}
|
||||
|
||||
fn mute(_: &mut crate::Session, params: &serde_json::Value) -> crate::Result<serde_json::Value> {
|
||||
let command = "render.lights.mute";
|
||||
if !params.is_object() {
|
||||
return Err(crate::params::bad(command, "expected an object"));
|
||||
}
|
||||
let input: MuteParams = serde_json::from_value(params.clone()).map_err(|e| crate::params::bad(command, e.to_string()))?;
|
||||
crate::render_lights::parse_id(&input.id).map_err(|e| crate::params::bad(command, e))?;
|
||||
serde_json::to_value(input).map_err(|e| crate::params::bad(command, e.to_string()))
|
||||
}
|
||||
|
||||
macro_rules! waiting {
|
||||
($id:literal, $label:literal, $tab:literal, $panel:literal, $icon:literal, $reason:literal) => {
|
||||
CommandSpec::new($id, $label, |_, _| Err(crate::EngineError::Other(concat!("not supported yet: ", $reason).into())))
|
||||
@@ -44,7 +73,6 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.noundo()
|
||||
.doc_only()
|
||||
.params("No parameters. Return to Model Preview; headless echo only, never cancels a job."),
|
||||
waiting!("render.lights.add", "Add Light", "RENDER SCENE", "LIGHTS", "render_scene", "named light creation"),
|
||||
CommandSpec::new("appearance.paint", "Paint Appearance", super::inspect::appearance_gestures::paint)
|
||||
.icon("appearance").key("B").noundo()
|
||||
.params("appearance or color/name/opacity/pbr: appearance.assign look parameters; validates and returns look for ui.start paint. done?: true ends the UI tool. Programmatic calls never open UI."),
|
||||
@@ -52,7 +80,14 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.icon("select").key("I").noundo()
|
||||
.params("target?: appearance.chain target; returns its resolved look, or requests the UI sampling tool when omitted. Programmatic calls never open UI."),
|
||||
|
||||
waiting!("render.lights.solo", "Solo Light", "RENDER SCENE", "LIGHTS", "render_scene", "light visibility and solo controls"),
|
||||
CommandSpec::new("render.lights.solo","Solo Light",crate::checked!("render.lights.solo",solo))
|
||||
.noundo().doc_only().icon("render_scene").at("RENDER SCENE","LIGHTS")
|
||||
.contract(&SOLO).output(crate::schema::output_schema_for::<SoloParams>)
|
||||
.params("id?: kind:slot light address; solo:bool. Enabling requires an id; false clears solo. Validates and echoes per-document UI view state. Never saves settings, evaluates geometry, opens an editor or changes history."),
|
||||
CommandSpec::new("render.lights.mute","Mute Light",crate::checked!("render.lights.mute",mute))
|
||||
.noundo().doc_only().icon("render_scene").at("RENDER SCENE","LIGHTS")
|
||||
.contract(&MUTE).output(crate::schema::output_schema_for::<MuteParams>)
|
||||
.params("id: kind:slot light address; mute:bool. Validates and echoes per-document UI view state, applied to live preview and captured render copies only. Never changes saved settings or history."),
|
||||
waiting!("render.compare", "Compare Images", "RENDER", "RESULT", "compare", "retained image comparison"),
|
||||
waiting!("render.batch", "Render All Shots", "RENDER", "BATCH", "render_image", "the saved-shot render queue"),
|
||||
];
|
||||
@@ -67,7 +102,7 @@ fn copy_check(_: &mut Session, params: &Value) -> Result<Value> {
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn render_workspace_planned_commands_refuse_without_mutation() {
|
||||
fn render_lights_remaining_planned_commands_refuse_without_mutation() {
|
||||
use serde_json::{Value, json};
|
||||
assert!(super::find_command("appearance.replace").is_some_and(|command| command.planned.is_none()));
|
||||
let mut session = crate::Session::default();
|
||||
|
||||
@@ -69,7 +69,7 @@ CommandSpec::new("view.render_inspector", "Render Inspector", render_inspector)
|
||||
CommandSpec::new("view.render_select", "Render selection", crate::checked!("view.render_select", render_select))
|
||||
.contract(&RENDER_SELECT).output(output_schema_for::<RenderSelect>)
|
||||
.icon("select").noundo().doc_only()
|
||||
.params("kind: nothing|environment|light|shot|output|wear|sampling|effects|check; id?: bounded nonempty string for light/shot → validated transient Browser focus; never edits the design or opens a dialog"),
|
||||
.params("kind: nothing|environment|lighting|light|shot|output|wear|sampling|effects|check; id?: bounded nonempty string for light/shot → validated transient Browser focus; never edits the design or opens a dialog"),
|
||||
CommandSpec::new("view.render_stage", "Render Stage", render_stage)
|
||||
.icon("render_scene").noundo().doc_only()
|
||||
.params("stage: look|light|frame|output → {stage}; per-document UI state, never edits or evaluates the design; headless validation only"),
|
||||
@@ -1191,6 +1191,7 @@ fn render_browser_focus_validates_without_document_changes_or_evaluation() {
|
||||
json!({"kind":"nothing"}),
|
||||
json!({"kind":"environment"}),
|
||||
json!({"kind":"wear"}),
|
||||
json!({"kind":"lighting"}),
|
||||
json!({"kind":"light","id":"sun:0"}),
|
||||
json!({"kind":"shot","id":"Hero"}),
|
||||
json!({"kind":"output"}),
|
||||
@@ -1216,12 +1217,18 @@ fn render_browser_focus_validates_without_document_changes_or_evaluation() {
|
||||
json!({"kind":"sampling","id":"extra"}),
|
||||
json!({"kind":"effects","id":"extra"}),
|
||||
json!({"kind":"check","id":"extra"}),
|
||||
json!({"kind":"lighting","id":"extra"}),
|
||||
json!({"kind":"environment","extra":true}),
|
||||
] {
|
||||
assert!(session.execute("view.render_select", &request).is_err(), "{request}");
|
||||
}
|
||||
assert!(std::sync::Arc::ptr_eq(&doc, &session.doc));
|
||||
assert_eq!(before, (session.undo.len(), session.redo.len(), session.revision, session.evaluations, session.is_dirty()));
|
||||
let description = session.execute("engine.describe", &json!({"command":"view.render_select"})).unwrap();
|
||||
for key in ["input", "output"] {
|
||||
assert!(description[key].is_object());
|
||||
assert!(description[key].to_string().contains("\"lighting\""));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -25,6 +25,7 @@ pub mod params;
|
||||
pub mod product_scene;
|
||||
pub mod recovery;
|
||||
pub mod render_jobs;
|
||||
pub mod render_lights;
|
||||
pub mod sample;
|
||||
pub mod schema;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
||||
@@ -0,0 +1,486 @@
|
||||
//! Shared light inspection and numerical adapters; no document or view-state mutation.
|
||||
use crate::schema::render_lights::{Geometry, Light};
|
||||
use solidcraft_doc::render_settings::{RenderJob, RenderSetup};
|
||||
use solidcraft_geom::Vec3;
|
||||
use solidcraft_render::job::LightingPreset;
|
||||
use solidcraft_render::job::{AreaLight, AreaLights, DirectionalLightOptions, PunctualLightOptions, RectangleLightOptions, SpotConeOptions, Sun};
|
||||
|
||||
pub fn parse_id(id: &str) -> Result<(&str, usize), String> {
|
||||
if id.len() > 16 {
|
||||
return Err("invalid light id".into());
|
||||
}
|
||||
let (kind, slot) = id.split_once(':').ok_or("expected kind:slot light id")?;
|
||||
let limit = match kind {
|
||||
"directional" | "point" | "spot" => 8,
|
||||
"area" => 4,
|
||||
_ => return Err("unknown light kind".into()),
|
||||
};
|
||||
let index = slot.parse::<usize>().map_err(|_| "invalid light slot")?;
|
||||
if index >= limit || index.to_string() != slot {
|
||||
return Err("light slot is out of bounds or noncanonical".into());
|
||||
}
|
||||
Ok((kind, index))
|
||||
}
|
||||
|
||||
fn vector([x, y, z]: [f64; 3]) -> Vec3 {
|
||||
Vec3::new(x, y, z)
|
||||
}
|
||||
fn array(v: Vec3) -> [f64; 3] {
|
||||
[v.x, v.y, v.z]
|
||||
}
|
||||
|
||||
/// Original three-band Planck approximation, white-balanced at 6500 K. This is
|
||||
/// a tint control, not a calibrated spectral renderer. Only RGB is persisted.
|
||||
pub fn temperature_colour(kelvin: f64) -> [f64; 3] {
|
||||
let temperature = if kelvin.is_finite() { kelvin.clamp(1000.0, 40000.0) } else { 6500.0 };
|
||||
let rgb = [615e-9_f64, 535e-9, 445e-9]
|
||||
.map(|wavelength| ((0.01438776877 / (wavelength * 6500.0)).exp() - 1.0) / ((0.01438776877 / (wavelength * temperature)).exp() - 1.0));
|
||||
let maximum = rgb.into_iter().fold(0.0_f64, f64::max);
|
||||
rgb.map(|v| v / maximum)
|
||||
}
|
||||
|
||||
pub fn colour_temperature(colour: [f64; 3]) -> f64 {
|
||||
let [red, _, blue] = colour;
|
||||
let ratio = if red > 0.0 { blue / red } else { f64::MAX };
|
||||
let (mut low, mut high) = (1000.0, 40000.0);
|
||||
for _ in 0..24 {
|
||||
let middle = (low + high) * 0.5;
|
||||
let [r, _, b] = temperature_colour(middle);
|
||||
if b / r < ratio {
|
||||
low = middle;
|
||||
} else {
|
||||
high = middle;
|
||||
}
|
||||
}
|
||||
(low + high) * 0.5
|
||||
}
|
||||
|
||||
pub fn position(light: &Light, target: [f64; 3], default_distance: f64) -> (f64, f64, f64) {
|
||||
let delta = match light.geometry {
|
||||
Geometry::Directional { direction, .. } => {
|
||||
solidcraft_render::surface::unit_direction(vector(direction)).unwrap_or(Vec3::Z) * default_distance
|
||||
}
|
||||
Geometry::Point { position_mm, .. } | Geometry::Spot { position_mm, .. } | Geometry::Area { position_mm, .. } => {
|
||||
vector(position_mm) - vector(target)
|
||||
}
|
||||
};
|
||||
let distance = delta.len().max(0.001);
|
||||
(delta.y.atan2(delta.x).to_degrees(), (delta.z / distance).clamp(-1.0, 1.0).asin().to_degrees(), distance)
|
||||
}
|
||||
|
||||
pub fn patch(light: &mut Light, edit: &crate::schema::render_lights::LightPatch, target: [f64; 3], default_distance: f64) -> Result<(), String> {
|
||||
for (value, low, high) in [
|
||||
(edit.intensity_ev, -20.0, 27.0),
|
||||
(edit.temperature_k, 1000.0, 40000.0),
|
||||
(edit.softness, 0.0, 1.0),
|
||||
(edit.azimuth_deg, -360.0, 360.0),
|
||||
(edit.elevation_deg, -90.0, 90.0),
|
||||
(edit.distance_mm, 0.001, 1e6),
|
||||
(edit.size_mm, 0.0002, 2e6),
|
||||
(edit.width_mm, 0.000002, 2e6),
|
||||
(edit.height_mm, 0.000002, 2e6),
|
||||
(edit.reference_distance_mm, 0.001, 1e6),
|
||||
(edit.minimum_distance_mm, 0.001, 1e6),
|
||||
] {
|
||||
if value.is_some_and(|v| !v.is_finite() || !(low..=high).contains(&v)) {
|
||||
return Err("light edit exceeds finite numerical bounds".into());
|
||||
}
|
||||
}
|
||||
for (value, low, high) in [
|
||||
(edit.position_mm, -1e12, 1e12),
|
||||
(edit.direction, -1e6, 1e6),
|
||||
(edit.edge_u_mm, -2e6, 2e6),
|
||||
(edit.edge_v_mm, -2e6, 2e6),
|
||||
(edit.radiance, 0.0, 1e8),
|
||||
(edit.colour, 0.0, 1.0),
|
||||
] {
|
||||
if value.is_some_and(|v| v.iter().any(|v| !v.is_finite() || !(low..=high).contains(v))) {
|
||||
return Err("light vector exceeds finite numerical bounds".into());
|
||||
}
|
||||
}
|
||||
if edit.direction.is_some_and(|v| solidcraft_render::surface::unit_direction(vector(v)).is_err()) {
|
||||
return Err("light direction must be nonzero".into());
|
||||
}
|
||||
let aim = edit.aim_at.unwrap_or(target);
|
||||
if aim.iter().any(|v| !v.is_finite() || v.abs() > 1e9) {
|
||||
return Err("invalid light aim point".into());
|
||||
}
|
||||
let (azimuth, elevation, distance) = position(light, aim, default_distance);
|
||||
let azimuth = edit.azimuth_deg.unwrap_or(azimuth).to_radians();
|
||||
let elevation = edit.elevation_deg.unwrap_or(elevation).to_radians();
|
||||
let distance = edit.distance_mm.unwrap_or(distance);
|
||||
let direction = Vec3::new(elevation.cos() * azimuth.cos(), elevation.cos() * azimuth.sin(), elevation.sin());
|
||||
let point = vector(aim) + direction * distance;
|
||||
let old_size = match light.geometry {
|
||||
Geometry::Area { edge_u_mm, .. } => vector(edge_u_mm).len(),
|
||||
_ => 10.0,
|
||||
};
|
||||
let type_changed = edit.kind.as_ref().is_some_and(|kind| kind != light.geometry.kind());
|
||||
if let Some(kind) = edit.kind.as_ref().filter(|_| type_changed) {
|
||||
light.geometry = match kind.as_str() {
|
||||
"directional" => Geometry::Directional { direction: array(direction), angular_radius_rad: None },
|
||||
"point" => Geometry::Point { position_mm: array(point), reference_distance_mm: distance, minimum_distance_mm: 0.001 },
|
||||
"spot" => Geometry::Spot {
|
||||
position_mm: array(point),
|
||||
reference_distance_mm: distance,
|
||||
minimum_distance_mm: 0.001,
|
||||
emitted_axis: array(-direction),
|
||||
inner_half_angle_radians: 0.2,
|
||||
outer_half_angle_radians: 0.5,
|
||||
},
|
||||
"area" => Geometry::Area { position_mm: array(point), edge_u_mm: [old_size, 0.0, 0.0], edge_v_mm: [0.0, old_size, 0.0] },
|
||||
_ => return Err("unknown light type".into()),
|
||||
};
|
||||
}
|
||||
if let Some(ev) = edit.intensity_ev {
|
||||
light.intensity = ev.exp2();
|
||||
}
|
||||
if let Some(k) = edit.temperature_k {
|
||||
light.colour = temperature_colour(k);
|
||||
}
|
||||
if let Some(colour) = edit.colour {
|
||||
light.colour = colour;
|
||||
}
|
||||
if let Some(rgb) = edit.radiance {
|
||||
if !matches!(light.geometry, Geometry::Area { .. } | Geometry::Directional { angular_radius_rad: Some(_), .. }) {
|
||||
return Err("radiance requires an area light or GPU sun".into());
|
||||
}
|
||||
(light.intensity, light.colour) = radiance(rgb);
|
||||
}
|
||||
if !matches!(light.geometry, Geometry::Area { .. })
|
||||
&& (edit.width_mm.is_some() || edit.height_mm.is_some() || edit.edge_u_mm.is_some() || edit.edge_v_mm.is_some())
|
||||
{
|
||||
return Err("shape requires an area light".into());
|
||||
}
|
||||
if !matches!(light.geometry, Geometry::Point { .. } | Geometry::Spot { .. })
|
||||
&& (edit.reference_distance_mm.is_some() || edit.minimum_distance_mm.is_some())
|
||||
{
|
||||
return Err("falloff requires a point light".into());
|
||||
}
|
||||
if !matches!(light.geometry, Geometry::Directional { .. }) && edit.direction.is_some() {
|
||||
return Err("direction requires a directional light".into());
|
||||
}
|
||||
let moved = type_changed || edit.azimuth_deg.is_some() || edit.elevation_deg.is_some() || edit.distance_mm.is_some() || edit.aim_at.is_some();
|
||||
match &mut light.geometry {
|
||||
Geometry::Directional { direction: axis, angular_radius_rad } => {
|
||||
if edit.distance_mm.is_some() || edit.size_mm.is_some() || edit.aim_at.is_some() || edit.position_mm.is_some() {
|
||||
return Err("directional lights have no position, size or aim point".into());
|
||||
}
|
||||
if moved {
|
||||
*axis = array(direction);
|
||||
}
|
||||
if let Some(direction) = edit.direction {
|
||||
*axis = direction;
|
||||
}
|
||||
if let Some(softness) = edit.softness {
|
||||
*angular_radius_rad = Some(0.001 + softness * (std::f64::consts::FRAC_PI_2 - 0.001));
|
||||
}
|
||||
}
|
||||
Geometry::Point { position_mm, reference_distance_mm, minimum_distance_mm }
|
||||
| Geometry::Spot { position_mm, reference_distance_mm, minimum_distance_mm, .. } => {
|
||||
if edit.softness.is_some() || edit.size_mm.is_some() {
|
||||
return Err("point/spot lights have no finite emitter size or soft shadows".into());
|
||||
}
|
||||
if moved {
|
||||
*position_mm = array(point);
|
||||
}
|
||||
if let Some(position) = edit.position_mm {
|
||||
*position_mm = position;
|
||||
}
|
||||
if let Some(reference) = edit.reference_distance_mm {
|
||||
*reference_distance_mm = reference;
|
||||
}
|
||||
if let Some(minimum) = edit.minimum_distance_mm {
|
||||
*minimum_distance_mm = minimum;
|
||||
}
|
||||
if *minimum_distance_mm > *reference_distance_mm {
|
||||
return Err("minimum distance exceeds reference distance".into());
|
||||
}
|
||||
}
|
||||
Geometry::Area { position_mm, edge_u_mm, edge_v_mm } => {
|
||||
if moved {
|
||||
*position_mm = array(point);
|
||||
}
|
||||
let size = edit.size_mm.or_else(|| edit.softness.map(|s| 0.0002 + s * 1000.0)).unwrap_or(old_size);
|
||||
let ratio = vector(*edge_v_mm).len() / old_size.max(1e-6);
|
||||
if moved {
|
||||
let normal = solidcraft_render::surface::unit_direction(vector(aim) - vector(*position_mm)).unwrap_or(-Vec3::Z);
|
||||
let up = if normal.z.abs() > 0.99 { Vec3::Y } else { Vec3::Z };
|
||||
let u = solidcraft_render::surface::unit_direction(up.cross(normal)).unwrap_or(Vec3::X);
|
||||
*edge_u_mm = array(u * size);
|
||||
*edge_v_mm = array(normal.cross(u) * size * ratio);
|
||||
} else if edit.size_mm.is_some() || edit.softness.is_some() {
|
||||
*edge_u_mm = array(solidcraft_render::surface::unit_direction(vector(*edge_u_mm)).unwrap_or(Vec3::X) * size);
|
||||
*edge_v_mm = array(solidcraft_render::surface::unit_direction(vector(*edge_v_mm)).unwrap_or(Vec3::Y) * size * ratio);
|
||||
}
|
||||
if let Some(position) = edit.position_mm {
|
||||
*position_mm = position;
|
||||
}
|
||||
if let Some(u) = edit.edge_u_mm {
|
||||
*edge_u_mm = u;
|
||||
}
|
||||
if let Some(v) = edit.edge_v_mm {
|
||||
*edge_v_mm = v;
|
||||
}
|
||||
if let Some(width) = edit.width_mm {
|
||||
*edge_u_mm = array(solidcraft_render::surface::unit_direction(vector(*edge_u_mm)).unwrap_or(Vec3::X) * width);
|
||||
}
|
||||
if let Some(height) = edit.height_mm {
|
||||
*edge_v_mm = array(solidcraft_render::surface::unit_direction(vector(*edge_v_mm)).unwrap_or(Vec3::Y) * height);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Geometry::Spot { position_mm, emitted_axis, .. } = &mut light.geometry
|
||||
&& moved
|
||||
{
|
||||
*emitted_axis = array(solidcraft_render::surface::unit_direction(vector(aim) - vector(*position_mm)).unwrap_or(-Vec3::Z));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Materializes a canonical rig in a cloned setup. Caller validates and publishes
|
||||
/// atomically. Unsupported backend families are refused, never silently dropped.
|
||||
pub fn write(setup: &mut RenderSetup, lights: &[Light]) -> Result<(), String> {
|
||||
if lights.len() > 20 {
|
||||
return Err("at most twenty analytic lights".into());
|
||||
}
|
||||
let directional: Vec<_> = lights.iter().filter(|l| l.geometry.kind() == "directional").collect();
|
||||
let punctual: Vec<_> = lights.iter().filter(|l| matches!(l.geometry, Geometry::Point { .. } | Geometry::Spot { .. })).collect();
|
||||
let area: Vec<_> = lights.iter().filter(|l| l.geometry.kind() == "area").collect();
|
||||
if directional.len() > 8 || punctual.len() > 8 || area.len() > 4 {
|
||||
return Err("light family limit exceeded (8 directional, 8 punctual, 4 area)".into());
|
||||
}
|
||||
match setup.job.as_mut() {
|
||||
Some(RenderJob::CpuRaytrace { options }) => {
|
||||
if directional.iter().any(|light| matches!(light.geometry, Geometry::Directional { angular_radius_rad: Some(_), .. })) {
|
||||
return Err("CPU directional lights have hard shadows; softness is not supported".into());
|
||||
}
|
||||
options.preset = None;
|
||||
options.lights = Some(
|
||||
directional
|
||||
.into_iter()
|
||||
.map(|l| {
|
||||
let direction = match l.geometry {
|
||||
Geometry::Directional { direction, .. } => direction,
|
||||
_ => [0.0, 0.0, 1.0],
|
||||
};
|
||||
DirectionalLightOptions { direction, color: l.colour, intensity: l.intensity }
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
options.punctual_lights = Some(
|
||||
punctual
|
||||
.into_iter()
|
||||
.filter_map(|l| {
|
||||
let (position_mm, reference_distance_mm, minimum_distance_mm, cone) = match l.geometry {
|
||||
Geometry::Point { position_mm, reference_distance_mm, minimum_distance_mm } => {
|
||||
(position_mm, reference_distance_mm, minimum_distance_mm, None)
|
||||
}
|
||||
Geometry::Spot {
|
||||
position_mm,
|
||||
reference_distance_mm,
|
||||
minimum_distance_mm,
|
||||
emitted_axis,
|
||||
inner_half_angle_radians,
|
||||
outer_half_angle_radians,
|
||||
} => (
|
||||
position_mm,
|
||||
reference_distance_mm,
|
||||
minimum_distance_mm,
|
||||
Some(SpotConeOptions { emitted_axis, inner_half_angle_radians, outer_half_angle_radians }),
|
||||
),
|
||||
_ => return None,
|
||||
};
|
||||
Some(PunctualLightOptions {
|
||||
position_mm,
|
||||
reference_distance_mm,
|
||||
minimum_distance_mm,
|
||||
cone,
|
||||
color: l.colour,
|
||||
intensity: l.intensity,
|
||||
})
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
options.area_lights = Some(
|
||||
area.into_iter()
|
||||
.filter_map(|l| match l.geometry {
|
||||
Geometry::Area { position_mm, edge_u_mm, edge_v_mm } => {
|
||||
Some(RectangleLightOptions { center_mm: position_mm, edge_u_mm, edge_v_mm, color: l.colour, intensity: l.intensity })
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
if options.area_lights.as_ref().is_none_or(Vec::is_empty) {
|
||||
options.area_samples = None;
|
||||
options.seed = None;
|
||||
}
|
||||
}
|
||||
Some(RenderJob::GpuPath { options, .. }) => {
|
||||
if !punctual.is_empty() || directional.len() > 1 {
|
||||
return Err("GPU lighting supports one Sun and four Areas; choose an explicit studio before editing legacy default lights".into());
|
||||
}
|
||||
let mut lighting = options.lighting.unwrap_or_default();
|
||||
lighting.sun = directional.first().and_then(|l| match l.geometry {
|
||||
Geometry::Directional { direction, angular_radius_rad } => {
|
||||
Some(Sun { direction, angular_radius_rad: angular_radius_rad.unwrap_or(0.02), radiance: l.colour.map(|c| c * l.intensity) })
|
||||
}
|
||||
_ => None,
|
||||
});
|
||||
let areas: Vec<_> = area
|
||||
.into_iter()
|
||||
.filter_map(|l| match l.geometry {
|
||||
Geometry::Area { position_mm, edge_u_mm, edge_v_mm } => Some(AreaLight {
|
||||
center: position_mm,
|
||||
u: edge_u_mm.map(|v| v * 0.5),
|
||||
v: edge_v_mm.map(|v| v * 0.5),
|
||||
radiance: l.colour.map(|c| c * l.intensity),
|
||||
}),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
lighting.area_lights = AreaLights::new(&areas).map_err(|e| e.to_string())?;
|
||||
options.lighting = Some(lighting);
|
||||
}
|
||||
_ => return Err("choose CPU or GPU ray tracing before editing lights".into()),
|
||||
}
|
||||
setup.validate().map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Filters only a rendering copy; returns fixed-studio weights when the backend
|
||||
/// owns implicit lights that cannot be materialized in the saved light union.
|
||||
pub fn filter(setup: &mut RenderSetup, visibility: &crate::schema::render_lights::Visibility) -> Result<Option<[f64; 3]>, String> {
|
||||
if !visibility.active() {
|
||||
return Ok(None);
|
||||
}
|
||||
let mut lights = inspect(setup)?;
|
||||
if lights.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
if matches!(setup.job, None | Some(RenderJob::Raster { .. }))
|
||||
|| matches!(&setup.job,Some(RenderJob::GpuPath{options,..}) if options.lighting.is_none())
|
||||
{
|
||||
let mut weights = [0.0; 3];
|
||||
for (slot, light) in weights.iter_mut().zip(&lights) {
|
||||
*slot = if visibility.visible(&light.id) { 1.0 } else { 0.0 };
|
||||
}
|
||||
return Ok(Some(weights));
|
||||
}
|
||||
for light in &mut lights {
|
||||
if !visibility.visible(&light.id) {
|
||||
light.intensity = 0.0;
|
||||
}
|
||||
}
|
||||
write(setup, &lights)?;
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
pub fn inspect(setup: &RenderSetup) -> Result<Vec<Light>, String> {
|
||||
setup.validate().map_err(|e| e.to_string())?;
|
||||
let mut lights = Vec::new();
|
||||
match &setup.job {
|
||||
Some(RenderJob::CpuRaytrace { options }) => {
|
||||
let implicit = options.lights.is_none();
|
||||
let defaults;
|
||||
let directional = match &options.lights {
|
||||
Some(values) => values,
|
||||
None => {
|
||||
defaults = options.preset.unwrap_or(LightingPreset::Neutral).directional_lights();
|
||||
&defaults
|
||||
}
|
||||
};
|
||||
for (index, light) in directional.iter().enumerate() {
|
||||
push(
|
||||
&mut lights,
|
||||
index,
|
||||
implicit,
|
||||
light.intensity,
|
||||
light.color,
|
||||
Geometry::Directional { direction: light.direction, angular_radius_rad: None },
|
||||
);
|
||||
}
|
||||
for (index, light) in options.punctual_lights.iter().flatten().enumerate() {
|
||||
let geometry = match light.cone {
|
||||
Some(cone) => Geometry::Spot {
|
||||
position_mm: light.position_mm,
|
||||
reference_distance_mm: light.reference_distance_mm,
|
||||
minimum_distance_mm: light.minimum_distance_mm,
|
||||
emitted_axis: cone.emitted_axis,
|
||||
inner_half_angle_radians: cone.inner_half_angle_radians,
|
||||
outer_half_angle_radians: cone.outer_half_angle_radians,
|
||||
},
|
||||
None => Geometry::Point {
|
||||
position_mm: light.position_mm,
|
||||
reference_distance_mm: light.reference_distance_mm,
|
||||
minimum_distance_mm: light.minimum_distance_mm,
|
||||
},
|
||||
};
|
||||
push(&mut lights, index, false, light.intensity, light.color, geometry);
|
||||
}
|
||||
for (index, light) in options.area_lights.iter().flatten().enumerate() {
|
||||
push(
|
||||
&mut lights,
|
||||
index,
|
||||
false,
|
||||
light.intensity,
|
||||
light.color,
|
||||
Geometry::Area { position_mm: light.center_mm, edge_u_mm: light.edge_u_mm, edge_v_mm: light.edge_v_mm },
|
||||
);
|
||||
}
|
||||
}
|
||||
Some(RenderJob::GpuPath { options, .. }) => {
|
||||
if let Some(lighting) = options.lighting {
|
||||
if let Some(sun) = lighting.sun {
|
||||
let (intensity, colour) = radiance(sun.radiance);
|
||||
push(
|
||||
&mut lights,
|
||||
0,
|
||||
false,
|
||||
intensity,
|
||||
colour,
|
||||
Geometry::Directional { direction: sun.direction, angular_radius_rad: Some(sun.angular_radius_rad) },
|
||||
);
|
||||
}
|
||||
for (index, light) in lighting.area_lights.iter().enumerate() {
|
||||
let (intensity, colour) = radiance(light.radiance);
|
||||
push(
|
||||
&mut lights,
|
||||
index,
|
||||
false,
|
||||
intensity,
|
||||
colour,
|
||||
Geometry::Area { position_mm: light.center, edge_u_mm: light.u.map(|v| v * 2.0), edge_v_mm: light.v.map(|v| v * 2.0) },
|
||||
);
|
||||
}
|
||||
} else if options.environment.is_none() && options.hdr.is_none() {
|
||||
defaults(&mut lights);
|
||||
}
|
||||
}
|
||||
// Raster and the legacy setup use the fixed direct-light product preview.
|
||||
Some(RenderJob::Raster { .. }) | None => defaults(&mut lights),
|
||||
}
|
||||
Ok(lights)
|
||||
}
|
||||
|
||||
fn defaults(lights: &mut Vec<Light>) {
|
||||
for (index, light) in LightingPreset::Neutral.directional_lights().into_iter().enumerate() {
|
||||
push(lights, index, true, light.intensity, light.color, Geometry::Directional { direction: light.direction, angular_radius_rad: None });
|
||||
}
|
||||
}
|
||||
|
||||
fn radiance(rgb: [f64; 3]) -> (f64, [f64; 3]) {
|
||||
let intensity = rgb.into_iter().fold(0.0_f64, f64::max);
|
||||
(intensity, if intensity > 0.0 { rgb.map(|v| v / intensity) } else { [1.0; 3] })
|
||||
}
|
||||
|
||||
fn push(lights: &mut Vec<Light>, index: usize, implicit: bool, intensity: f64, colour: [f64; 3], geometry: Geometry) {
|
||||
let number = lights.len() + 1;
|
||||
let (name, name_key) = match number {
|
||||
1 => ("Key".into(), "render.light_default_key"),
|
||||
2 => ("Fill".into(), "render.light_default_fill"),
|
||||
3 => ("Rim".into(), "render.light_default_rim"),
|
||||
_ => (format!("Light {number}"), "render.light_default_number"),
|
||||
};
|
||||
lights.push(Light { id: format!("{}:{index}", geometry.kind()), name, name_key: name_key.into(), number, implicit, intensity, colour, geometry });
|
||||
}
|
||||
@@ -59,6 +59,7 @@ pub mod edit;
|
||||
pub mod features;
|
||||
pub mod inspect;
|
||||
pub mod render;
|
||||
pub mod render_lights;
|
||||
pub mod render_ui;
|
||||
pub mod sheet;
|
||||
pub mod sketch_constraints;
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
//! Portable read model for lights in a saved setup or an unsaved Render draft.
|
||||
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ListParams {
|
||||
/// Saved setup name. Mutually exclusive with settings. Neither selects the default setup.
|
||||
pub setup: Option<String>,
|
||||
/// Complete RenderSetup snapshot, including an optional typed job. Never saved or applied.
|
||||
#[schemars(with = "Option<std::collections::BTreeMap<String, Value>>")]
|
||||
pub settings: Option<Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, JsonSchema)]
|
||||
pub struct ListResult {
|
||||
pub lights: Vec<Light>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct Light {
|
||||
/// Family and zero-based source slot: directional:N, point:N, spot:N or area:N.
|
||||
/// Point and spot share their punctual-list index. Stable across numerical edits,
|
||||
/// not across family changes, list reordering, removal or rig replacement.
|
||||
pub id: String,
|
||||
/// English fallback for an unnamed light; clients translate name_key with number.
|
||||
pub name: String,
|
||||
pub name_key: String,
|
||||
/// One-based position in this list, for the Light {number} fallback.
|
||||
pub number: usize,
|
||||
/// Renderer-provided default/preset light, rather than an explicit saved source.
|
||||
pub implicit: bool,
|
||||
/// Relative linear intensity. For GPU radiance this is its largest RGB channel;
|
||||
/// colour * intensity reconstructs radiance. This is not a watts or Kelvin value.
|
||||
pub intensity: f64,
|
||||
/// Linear RGB, independent of display exposure and tone mapping.
|
||||
pub colour: [f64; 3],
|
||||
#[serde(flatten)]
|
||||
pub geometry: Geometry,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(tag = "kind", rename_all = "snake_case")]
|
||||
pub enum Geometry {
|
||||
Directional {
|
||||
/// World direction towards the source, as stored; need not be unit length.
|
||||
direction: [f64; 3],
|
||||
/// Present for the GPU finite-disk sun only, in radians.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
angular_radius_rad: Option<f64>,
|
||||
},
|
||||
Point {
|
||||
position_mm: [f64; 3],
|
||||
reference_distance_mm: f64,
|
||||
minimum_distance_mm: f64,
|
||||
},
|
||||
Spot {
|
||||
position_mm: [f64; 3],
|
||||
reference_distance_mm: f64,
|
||||
minimum_distance_mm: f64,
|
||||
/// World emission direction FROM the source.
|
||||
emitted_axis: [f64; 3],
|
||||
inner_half_angle_radians: f64,
|
||||
outer_half_angle_radians: f64,
|
||||
},
|
||||
Area {
|
||||
position_mm: [f64; 3],
|
||||
/// Full world-space side vectors; U cross V is the emitting side.
|
||||
edge_u_mm: [f64; 3],
|
||||
edge_v_mm: [f64; 3],
|
||||
},
|
||||
}
|
||||
|
||||
impl Geometry {
|
||||
pub fn kind(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Directional { .. } => "directional",
|
||||
Self::Point { .. } => "point",
|
||||
Self::Spot { .. } => "spot",
|
||||
Self::Area { .. } => "area",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Ephemeral per-document light visibility. Never part of RenderSetup or a design.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
pub struct Visibility {
|
||||
pub solo: Option<String>,
|
||||
pub muted: std::collections::BTreeSet<String>,
|
||||
}
|
||||
|
||||
impl Visibility {
|
||||
pub fn visible(&self, id: &str) -> bool {
|
||||
!self.muted.contains(id) && self.solo.as_ref().is_none_or(|solo| solo == id)
|
||||
}
|
||||
|
||||
pub fn active(&self) -> bool {
|
||||
self.solo.is_some() || !self.muted.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct SoloParams {
|
||||
pub id: Option<String>,
|
||||
pub solo: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct MuteParams {
|
||||
pub id: String,
|
||||
pub mute: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct LightPatch {
|
||||
pub kind: Option<String>,
|
||||
pub intensity_ev: Option<f64>,
|
||||
pub temperature_k: Option<f64>,
|
||||
pub softness: Option<f64>,
|
||||
pub azimuth_deg: Option<f64>,
|
||||
pub elevation_deg: Option<f64>,
|
||||
pub distance_mm: Option<f64>,
|
||||
pub size_mm: Option<f64>,
|
||||
pub aim_at: Option<[f64; 3]>,
|
||||
/// Full side lengths, preserving each existing edge's orientation.
|
||||
pub width_mm: Option<f64>,
|
||||
pub height_mm: Option<f64>,
|
||||
/// World-space fields, lowered to the existing renderer parameters.
|
||||
pub position_mm: Option<[f64; 3]>,
|
||||
pub direction: Option<[f64; 3]>,
|
||||
pub edge_u_mm: Option<[f64; 3]>,
|
||||
pub edge_v_mm: Option<[f64; 3]>,
|
||||
pub radiance: Option<[f64; 3]>,
|
||||
pub colour: Option<[f64; 3]>,
|
||||
pub reference_distance_mm: Option<f64>,
|
||||
pub minimum_distance_mm: Option<f64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct EditParams {
|
||||
pub name: String,
|
||||
pub id: Option<String>,
|
||||
/// Complete unsaved setup, used as the edit's starting point without losing other controls.
|
||||
#[schemars(with = "Option<std::collections::BTreeMap<String, Value>>")]
|
||||
pub settings: Option<Value>,
|
||||
pub set: Option<LightPatch>,
|
||||
pub expected_revision: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, JsonSchema)]
|
||||
pub struct EditResult {
|
||||
pub id: Option<String>,
|
||||
pub name: String,
|
||||
pub setup: Value,
|
||||
}
|
||||
@@ -104,8 +104,10 @@ impl<'de> Deserialize<'de> for RenderSelect {
|
||||
}
|
||||
let request = Request::deserialize(d)?;
|
||||
let identified = matches!(request.kind.as_str(), "light" | "shot");
|
||||
if !matches!(request.kind.as_str(), "nothing" | "environment" | "light" | "shot" | "output" | "wear" | "sampling" | "effects" | "check")
|
||||
|| identified != request.id.is_some()
|
||||
if !matches!(
|
||||
request.kind.as_str(),
|
||||
"nothing" | "environment" | "lighting" | "light" | "shot" | "output" | "wear" | "sampling" | "effects" | "check"
|
||||
) || identified != request.id.is_some()
|
||||
|| request.id.as_ref().is_some_and(|id| id.trim().is_empty() || id.len() > 1024)
|
||||
{
|
||||
return Err(serde::de::Error::custom("expected a Browser kind and an id only for light or shot"));
|
||||
@@ -124,7 +126,7 @@ impl JsonSchema for RenderSelect {
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"kind": {"type": "string", "enum": ["nothing", "environment", "output", "wear", "sampling", "effects", "check"]},
|
||||
"kind": {"type": "string", "enum": ["nothing", "environment", "lighting", "output", "wear", "sampling", "effects", "check"]},
|
||||
"id": {"type": "null"}
|
||||
},
|
||||
"required": ["kind"],
|
||||
|
||||
@@ -377,6 +377,7 @@ fn frame(scene: &Scene, cam: &Camera, [width, height]: [u32; 2], key: u64, acces
|
||||
let cap = scene.cap.unwrap_or(SECTION_CAP);
|
||||
let mode = scene.analysis.map(|a| a.mode);
|
||||
Frame {
|
||||
product_lights: None,
|
||||
product: false,
|
||||
key,
|
||||
slot: Arc::new(Mutex::new(Some(scene_geometry(scene)))),
|
||||
|
||||
@@ -157,6 +157,7 @@ fn request(size: u32) -> ImageRequest {
|
||||
let mut camera = Camera { distance: 4.0, ..Default::default() };
|
||||
camera.set_view(StandardView::Top);
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
integrator: Default::default(),
|
||||
raytrace: None,
|
||||
camera,
|
||||
|
||||
@@ -42,7 +42,7 @@ const SHADER: &str = concat!(
|
||||
include_str!("aging.wgsl")
|
||||
);
|
||||
const MAX_TRIANGLES: u64 = MAX_GPU_PATH_TRIANGLES;
|
||||
const PARAMETER_BYTES: usize = 1168;
|
||||
const PARAMETER_BYTES: usize = 1184;
|
||||
// Eight u32 words: count low, pixel, bounce, sample, code, count high, first-writer flag, spare.
|
||||
const FAILURE_BYTES: u64 = 32;
|
||||
// A path that cannot classify its glass medium ends there. Isolated paths at the
|
||||
@@ -319,6 +319,12 @@ fn admission(scene: &ProductScene, request: &ImageRequest, options: JobOptions)
|
||||
return Err(JobError::new(ErrorCode::InvalidRequest, "GPU path rendering does not accept CPU raytrace options"));
|
||||
}
|
||||
options.validate()?;
|
||||
if request.studio_weights.is_some_and(|weights| weights.iter().any(|value| !value.is_finite() || !(0.0..=1.0).contains(value))) {
|
||||
return Err(JobError::new(ErrorCode::InvalidRequest, "invalid studio visibility weights"));
|
||||
}
|
||||
if request.studio_weights.is_some() && (options.lighting.is_some() || request.environment.is_some()) {
|
||||
return Err(JobError::new(ErrorCode::InvalidRequest, "studio weights require implicit studio lighting"));
|
||||
}
|
||||
options.aging.validate_scene(scene)?;
|
||||
if options.finishing.photographic.active() && request.transparent_background {
|
||||
return Err(JobError::new(ErrorCode::InvalidRequest, "photographic effects require opaque output; choose it explicitly"));
|
||||
@@ -752,6 +758,10 @@ impl Task {
|
||||
bytes.extend_from_slice(&value.to_le_bytes());
|
||||
}
|
||||
}
|
||||
let weights = self.request.studio_weights.unwrap_or([1.0; 3]);
|
||||
for value in [weights[0] as f32, weights[1] as f32, weights[2] as f32, 0.0] {
|
||||
bytes.extend_from_slice(&value.to_le_bytes());
|
||||
}
|
||||
bytes
|
||||
}
|
||||
fn normalization_samples(&self) -> u32 {
|
||||
|
||||
@@ -31,6 +31,7 @@ struct Params {
|
||||
volume_max: vec4<f32>, // camera-relative bounds maximum, HG mean cosine
|
||||
volume_albedo: vec4<f32>, // RGB single-scattering albedo, reserved
|
||||
aging: array<AgingLayer,8>,
|
||||
studio_weights: vec4<f32>,
|
||||
|
||||
};
|
||||
@group(0) @binding(0) var<uniform> u: Params;
|
||||
@@ -953,7 +954,7 @@ fn sample_path_lane(pixel: u32, lane: u32) -> vec4<f32> {
|
||||
let light = lights[i];
|
||||
if u.lighting.z > 0.0 && dot(geometric,light.xyz)>0.0 && dot(n,light.xyz)>0.0 {
|
||||
let visibility=shadow_transmittance(o,light.xyz,FAR);
|
||||
radiance += visibility.transmittance * throughput * brdf(t,n,v,light.xyz) * ((1.0-t.base.w)*light.w*dot(n,light.xyz)*u.lighting.z);
|
||||
radiance += visibility.transmittance * throughput * brdf(t,n,v,light.xyz) * ((1.0-t.base.w)*light.w*dot(n,light.xyz)*u.lighting.z*u.studio_weights[i]);
|
||||
}
|
||||
}
|
||||
if t.base.w > 0.0 && random(&rng) < t.base.w {
|
||||
|
||||
@@ -21,6 +21,7 @@ fn request(size: u32) -> ImageRequest {
|
||||
let mut camera = Camera { distance: 4.0, ..Default::default() };
|
||||
camera.set_view(StandardView::Top);
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
integrator: Default::default(),
|
||||
raytrace: None,
|
||||
textures: None,
|
||||
@@ -429,6 +430,7 @@ fn glass_transport_evidence() {
|
||||
let bounds = meshes.iter().fold(Aabb3::EMPTY, |a, m| a.union(&m.mesh.bounds()));
|
||||
let camera = Camera { target: Vec3::new(0.0, 0.0, 1.0), yaw: -0.45, pitch: 0.5, distance: 13.0, fov: 0.65, ..Default::default() };
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
integrator: Default::default(),
|
||||
raytrace: None,
|
||||
textures: None,
|
||||
@@ -529,6 +531,13 @@ fn shader_validates_without_a_device() {
|
||||
naga::valid::Validator::new(naga::valid::ValidationFlags::all(), naga::valid::Capabilities::empty()).validate(&module).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_path_visibility_uniform_keeps_the_shader_contract() {
|
||||
shader_validates_without_a_device();
|
||||
let request = request(4);
|
||||
assert!(request.studio_weights.is_none());
|
||||
}
|
||||
|
||||
/// #3217: the path tracer opens Vulkan adapters only, and none where the platform has no
|
||||
/// Vulkan backend (macOS).
|
||||
#[test]
|
||||
@@ -674,30 +683,44 @@ fn gpu_brdf_matches_f64_surface_oracle() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The viewport embeds a separate WGSL translation. Exercise its actual function
|
||||
/// on the same native device as the path-tracer oracle, not a copied Rust formula.
|
||||
#[test]
|
||||
fn viewport_brdf_matches_f64_surface_oracle_at_index_match() {
|
||||
let Some(executor) = executor() else { return };
|
||||
let context = &executor.context;
|
||||
let source = format!(
|
||||
/// Assemble the same viewport declarations, lighting helpers and PBR implementation
|
||||
/// as production, plus a compute entry point that calls the actual BRDF.
|
||||
fn viewport_brdf_probe_source() -> String {
|
||||
format!(
|
||||
"{}\n{}\n{}",
|
||||
r#"
|
||||
struct ViewUniform { vp: mat4x4<f32>, back: vec4<f32>, eye: vec4<f32>, };
|
||||
@group(1) @binding(0) var<uniform> u: ViewUniform;
|
||||
struct Probe { base: vec4<f32>, parameters: vec4<f32>, view: vec4<f32>, light: vec4<f32>, };
|
||||
@group(0) @binding(0) var<uniform> probe: Probe;
|
||||
@group(0) @binding(1) var<storage, read_write> result: array<vec4<f32>>;
|
||||
"#,
|
||||
crate::view::SHADER,
|
||||
crate::pbr::SOURCE,
|
||||
r#"
|
||||
struct Probe { base: vec4<f32>, parameters: vec4<f32>, view: vec4<f32>, light: vec4<f32>, };
|
||||
// Bindings 0 and 1 belong to the production viewport uniform and palette.
|
||||
@group(0) @binding(2) var<uniform> probe: Probe;
|
||||
@group(0) @binding(3) var<storage, read_write> result: array<vec4<f32>>;
|
||||
@compute @workgroup_size(1)
|
||||
fn probe_pbr() {
|
||||
result[0] = vec4<f32>(pbr_brdf(probe.base.xyz, probe.parameters.xyz,
|
||||
vec3<f32>(0.0,0.0,1.0),probe.view.xyz,probe.light.xyz),1.0);
|
||||
}
|
||||
"#
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn viewport_brdf_probe_shader_is_valid() {
|
||||
let source = viewport_brdf_probe_source();
|
||||
let module = naga::front::wgsl::parse_str(&source).unwrap_or_else(|error| panic!("{}", error.emit_to_string(&source)));
|
||||
naga::valid::Validator::new(naga::valid::ValidationFlags::all(), naga::valid::Capabilities::empty())
|
||||
.validate(&module)
|
||||
.unwrap_or_else(|error| panic!("{}", error.emit_to_string(&source)));
|
||||
}
|
||||
|
||||
/// The viewport embeds a separate WGSL translation. Exercise its actual function
|
||||
/// on the same native device as the path-tracer oracle, not a copied Rust formula.
|
||||
#[test]
|
||||
fn viewport_brdf_matches_f64_surface_oracle_at_index_match() {
|
||||
let Some(executor) = executor() else { return };
|
||||
let context = &executor.context;
|
||||
let source = viewport_brdf_probe_source();
|
||||
let creation_scopes = scopes(&context.device);
|
||||
let shader = context.device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
label: Some("actual viewport PBR oracle"),
|
||||
source: wgpu::ShaderSource::Wgsl(source.into()),
|
||||
@@ -706,13 +729,13 @@ fn probe_pbr() {
|
||||
label: None,
|
||||
entries: &[
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
binding: 2,
|
||||
visibility: wgpu::ShaderStages::COMPUTE,
|
||||
ty: wgpu::BindingType::Buffer { ty: wgpu::BufferBindingType::Uniform, has_dynamic_offset: false, min_binding_size: None },
|
||||
count: None,
|
||||
},
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 1,
|
||||
binding: 3,
|
||||
visibility: wgpu::ShaderStages::COMPUTE,
|
||||
ty: wgpu::BindingType::Buffer {
|
||||
ty: wgpu::BufferBindingType::Storage { read_only: false },
|
||||
@@ -758,10 +781,11 @@ fn probe_pbr() {
|
||||
label: None,
|
||||
layout: &layout,
|
||||
entries: &[
|
||||
wgpu::BindGroupEntry { binding: 0, resource: uniform.as_entire_binding() },
|
||||
wgpu::BindGroupEntry { binding: 1, resource: values.as_entire_binding() },
|
||||
wgpu::BindGroupEntry { binding: 2, resource: uniform.as_entire_binding() },
|
||||
wgpu::BindGroupEntry { binding: 3, resource: values.as_entire_binding() },
|
||||
],
|
||||
});
|
||||
checked(creation_scopes).expect("viewport BRDF probe resource creation must validate");
|
||||
for metallic in [0.0, 0.5, 1.0] {
|
||||
for roughness in [0.045, 0.5, 1.0] {
|
||||
for ior in [1.0, 1.5, 3.0] {
|
||||
@@ -791,6 +815,7 @@ fn probe_pbr() {
|
||||
0.0,
|
||||
];
|
||||
let bytes: Vec<u8> = input.iter().flat_map(|value| value.to_le_bytes()).collect();
|
||||
let dispatch_scopes = scopes(&context.device);
|
||||
context.queue.write_buffer(&uniform, 0, &bytes);
|
||||
let mut encoder = context.device.create_command_encoder(&Default::default());
|
||||
{
|
||||
@@ -801,6 +826,7 @@ fn probe_pbr() {
|
||||
}
|
||||
encoder.copy_buffer_to_buffer(&values, 0, &readback, 0, 16);
|
||||
let submission = context.queue.submit([encoder.finish()]);
|
||||
checked(dispatch_scopes).expect("viewport BRDF probe dispatch must validate");
|
||||
let slice = readback.slice(..);
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
slice.map_async(wgpu::MapMode::Read, move |result| {
|
||||
|
||||
+13
-1
@@ -69,10 +69,22 @@ fn fs_pbr(i: PbrOut) -> @location(0) vec4<f32> {
|
||||
let v = pbr_unit(view);
|
||||
let lights = array<vec4<f32>, 3>(vec4<f32>(0.6, 0.0, 0.8, 3.0), vec4<f32>(-0.8, 0.0, 0.6, 1.0), vec4<f32>(0.0, -0.6, 0.8, 1.5));
|
||||
var radiance = vec3<f32>(0.0);
|
||||
for (var k = 0u; k < 3u; k += 1u) {
|
||||
for (var k = 0u; k < 3u && u.product_lights_meta.x == 0.0; k += 1u) {
|
||||
let light = lights[k];
|
||||
radiance += pbr_brdf(i.base, i.parameters, n, v, light.xyz) * (light.w * max(dot(n, light.xyz), 0.0));
|
||||
}
|
||||
for (var k = 0u; k < min(u32(u.product_lights_meta.y),21u) && u.product_lights_meta.x > 0.0; k += 1u) {
|
||||
let source=u.product_lights[k*4u];
|
||||
let colour=u.product_lights[k*4u+1u];
|
||||
let axis=u.product_lights[k*4u+2u];
|
||||
let falloff=u.product_lights[k*4u+3u];
|
||||
if source.w == 4.0 {
|
||||
radiance += i.base*colour.xyz*(1.0-i.parameters.x)/3.141592653589793;
|
||||
continue;
|
||||
}
|
||||
let sample=product_light_sample(k,i.wp);
|
||||
radiance += pbr_brdf(i.base,i.parameters,n,v,sample[0])*sample[1]*max(dot(n,sample[0]),0.0);
|
||||
}
|
||||
let mapped = radiance / (vec3<f32>(1.0) + radiance);
|
||||
if (u.back.w > 0.5) { return vec4<f32>(mapped, 1.0); }
|
||||
return vec4<f32>(pbr_encode(mapped), 1.0);
|
||||
|
||||
+35
-1
@@ -152,7 +152,7 @@ fn octahedral6(n: [f32; 3]) -> u32 {
|
||||
/// The shader's `U`: the view-projection matrix, 10 `vec4`s (the tenth carries the ambient
|
||||
/// occlusion radius), the 8 analysis colours, their flags, the depth direction and the two
|
||||
/// whole-body highlight colours (`uniform_bytes`).
|
||||
const UNIFORM_SIZE: u64 = 416;
|
||||
const UNIFORM_SIZE: u64 = 416 + 16 + 21 * 64;
|
||||
|
||||
/// A body drawn from its display plan, evaluated on the GPU: the plan, and a palette index per
|
||||
/// face (the plan's face numbering; faces past the end take the last index).
|
||||
@@ -955,6 +955,8 @@ pub const AO_SAMPLES_MOVING: u32 = 8;
|
||||
|
||||
/// Per-frame parameters.
|
||||
pub struct Frame {
|
||||
/// Bounded unshadowed product-light preview. None retains the fixed studio.
|
||||
pub product_lights: Option<Vec<[f32; 16]>>,
|
||||
/// Product preview uses its own batches, retaining the Design viewport's uploads.
|
||||
pub product: bool,
|
||||
pub key: u64,
|
||||
@@ -3229,6 +3231,7 @@ fn frame_key(cb: &Frame) -> u64 {
|
||||
use std::hash::Hash as _;
|
||||
let mut h = std::collections::hash_map::DefaultHasher::new();
|
||||
cb.product.hash(&mut h);
|
||||
cb.product_lights.as_ref().map(|lights| lights.iter().take(21).map(|light| light.map(f32::to_bits)).collect::<Vec<_>>()).hash(&mut h);
|
||||
cb.key.hash(&mut h);
|
||||
cb.sketch_key.hash(&mut h);
|
||||
cb.hl_key.hash(&mut h);
|
||||
@@ -4093,6 +4096,16 @@ pub fn uniform_bytes(cb: &Frame, w: f32, h: f32, linear: bool, reversed: bool) -
|
||||
v.extend([if reversed { 1.0 } else { 0.0 }, FACE_STEPS as f32, FACE_SLOPE, 0.0]);
|
||||
v.extend([cb.hover_tint[0], cb.hover_tint[1], cb.hover_tint[2], 0.0]);
|
||||
v.extend([cb.selection_tint[0], cb.selection_tint[1], cb.selection_tint[2], 0.0]);
|
||||
v.extend([
|
||||
if cb.product_lights.is_some() { 1.0 } else { 0.0 },
|
||||
cb.product_lights.as_ref().map_or(0, |lights| lights.len().min(21)) as f32,
|
||||
0.0,
|
||||
0.0,
|
||||
]);
|
||||
for index in 0..21 {
|
||||
let light = cb.product_lights.as_ref().and_then(|lights| lights.get(index)).copied().unwrap_or([0.0; 16]);
|
||||
v.extend(light.map(|value| if value.is_finite() { value } else { 0.0 }));
|
||||
}
|
||||
v.iter().flat_map(|x| x.to_le_bytes()).collect()
|
||||
}
|
||||
|
||||
@@ -4273,11 +4286,30 @@ mod tests {
|
||||
assert_eq!(samples_sent(1000), 32.0, "at most the shader's 32");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_preview_shader_uniform_and_frame_cache_include_light_state() {
|
||||
let source = format!("{}\n{}", super::SHADER, crate::pbr::SOURCE);
|
||||
let module = naga::front::wgsl::parse_str(&source).unwrap_or_else(|error| panic!("{}", error.emit_to_string(&source)));
|
||||
naga::valid::Validator::new(naga::valid::ValidationFlags::all(), naga::valid::Capabilities::empty()).validate(&module).unwrap();
|
||||
let uniform = module.types.iter().find(|(_, ty)| ty.name.as_deref() == Some("U")).unwrap().1;
|
||||
let naga::TypeInner::Struct { span, .. } = &uniform.inner else { panic!("U is a uniform struct") };
|
||||
assert_eq!(u64::from(*span), super::UNIFORM_SIZE);
|
||||
let mut frame = cached_frame();
|
||||
let previous = super::frame_key(&frame);
|
||||
frame.product_lights = Some(vec![[0.0; 16]]);
|
||||
assert_ne!(super::frame_key(&frame), previous);
|
||||
assert_eq!(super::uniform_bytes(&frame, 800.0, 600.0, false, false).len() as u64, super::UNIFORM_SIZE);
|
||||
let previous = super::frame_key(&frame);
|
||||
frame.product_lights = Some(Vec::new());
|
||||
assert_ne!(super::frame_key(&frame), previous);
|
||||
}
|
||||
|
||||
/// A frame with a fixed picture, and a key that names everything it shows.
|
||||
fn cached_frame() -> super::Frame {
|
||||
use std::sync::{Arc, Mutex};
|
||||
let slot = || Arc::new(Mutex::new(None));
|
||||
super::Frame {
|
||||
product_lights: None,
|
||||
product: false,
|
||||
key: 1,
|
||||
slot: slot(),
|
||||
@@ -4663,6 +4695,7 @@ mod glass_tests {
|
||||
}
|
||||
let none = || Arc::new(Mutex::new(None));
|
||||
let frame = Frame {
|
||||
product_lights: None,
|
||||
product: false,
|
||||
key: 1,
|
||||
slot: Arc::new(Mutex::new(Some(scene))),
|
||||
@@ -4836,6 +4869,7 @@ mod glass_tests {
|
||||
const SIZE: u32 = 64;
|
||||
let none = || Arc::new(Mutex::new(None));
|
||||
Frame {
|
||||
product_lights: None,
|
||||
product: false,
|
||||
key: 1,
|
||||
slot: Arc::new(Mutex::new(Some(scene))),
|
||||
|
||||
@@ -95,6 +95,7 @@ impl Renderer {
|
||||
}
|
||||
let slot = |scene| Arc::new(Mutex::new(scene));
|
||||
let frame = Frame {
|
||||
product_lights: None,
|
||||
product: false,
|
||||
key: 1,
|
||||
slot: slot(Some(model)),
|
||||
|
||||
@@ -31,6 +31,7 @@ fn request(width: u32, height: u32, budget: CpuBudget) -> ImageRequest {
|
||||
let mut camera = Camera { distance: 65.0, ..Default::default() };
|
||||
camera.set_view(StandardView::Top);
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: Integrator::Raytrace,
|
||||
|
||||
@@ -171,6 +171,7 @@ mod light_union_lease_tests {
|
||||
strip.append_to(&mut options, 64)?;
|
||||
}
|
||||
Ok(ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: Integrator::Raytrace,
|
||||
@@ -1404,6 +1405,7 @@ impl ImageHost {
|
||||
)
|
||||
.map_err(|e| JobError::new(ErrorCode::InvalidRequest, e.to_string()))?;
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
width: frame.info.width,
|
||||
height: frame.info.height,
|
||||
camera: source.0.request.camera,
|
||||
@@ -1627,6 +1629,7 @@ mod retained_request_tests {
|
||||
let mut lights = Vec::with_capacity(8);
|
||||
lights.push(super::super::DirectionalLightOptions { direction: [0.0, 0.0, 1.0], color: [1.0; 3], intensity: 1.0 });
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: Integrator::Raytrace,
|
||||
@@ -1696,6 +1699,7 @@ mod environment_metadata_lease_tests {
|
||||
let mut host = CpuHost::for_platform().unwrap();
|
||||
let budget = host.0.shared.budget.clone();
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: Integrator::Raytrace,
|
||||
@@ -1808,6 +1812,7 @@ mod surface_request_metadata_tests {
|
||||
|
||||
fn request() -> ImageRequest {
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: Default::default(),
|
||||
|
||||
@@ -47,6 +47,7 @@ fn fixture(raw: bool) -> (ImageHost, JobHandle, Arc<AtomicUsize>, Presentation)
|
||||
let begins = Arc::new(AtomicUsize::new(0));
|
||||
let host = ImageHost::cooperative_with(Arc::new(FixtureExecutor(begins.clone())));
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
width: 16,
|
||||
height: 16,
|
||||
background: [40, 80, 120],
|
||||
|
||||
@@ -144,6 +144,7 @@ mod progressive_checkpoints {
|
||||
|
||||
fn request() -> ImageRequest {
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
integrator: Default::default(),
|
||||
raytrace: None,
|
||||
textures: None,
|
||||
|
||||
@@ -165,6 +165,12 @@ fn admit_source_with_limits(
|
||||
if !request.camera.is_valid() {
|
||||
return Err(JobError::new(ErrorCode::InvalidRequest, "invalid image camera"));
|
||||
}
|
||||
if request.studio_weights.is_some_and(|weights| weights.iter().any(|value| !value.is_finite() || !(0.0..=1.0).contains(value))) {
|
||||
return Err(JobError::new(ErrorCode::InvalidRequest, "invalid studio visibility weights"));
|
||||
}
|
||||
if request.integrator == super::Integrator::Raytrace && request.studio_weights.is_some() {
|
||||
return Err(JobError::new(ErrorCode::InvalidRequest, "CPU ray tracing uses explicit lights rather than studio_weights"));
|
||||
}
|
||||
if scene.meshes.len() > max_bodies {
|
||||
return Err(limit("too many product bodies"));
|
||||
}
|
||||
@@ -658,7 +664,7 @@ impl ImageTask {
|
||||
}
|
||||
let triangle = self.triangle.as_mut().ok_or_else(|| invalid("missing raster triangle"))?;
|
||||
let eye = (self.request.camera.fov > 0.0).then(|| self.request.camera.eye());
|
||||
raster_pixel(triangle, self.sw, self.back, eye, &mut self.pixels, &mut self.depth)?;
|
||||
raster_pixel(triangle, self.sw, self.back, eye, self.request.studio_weights, &mut self.pixels, &mut self.depth)?;
|
||||
triangle.x += 1;
|
||||
if triangle.x > triangle.bounds[1] {
|
||||
triangle.x = triangle.bounds[0];
|
||||
@@ -717,7 +723,16 @@ impl ImageTask {
|
||||
}
|
||||
}
|
||||
|
||||
fn raster_pixel(t: &Triangle, width: usize, back: Vec3, eye: Option<Vec3>, pixels: &mut [[u8; 4]], depth: &mut [f32]) -> Result<()> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn raster_pixel(
|
||||
t: &Triangle,
|
||||
width: usize,
|
||||
back: Vec3,
|
||||
eye: Option<Vec3>,
|
||||
studio_weights: Option<[f64; 3]>,
|
||||
pixels: &mut [[u8; 4]],
|
||||
depth: &mut [f32],
|
||||
) -> Result<()> {
|
||||
let [a, b, c] = t.points;
|
||||
let (x, y) = (t.x as f64 + 0.5, t.y as f64 + 0.5);
|
||||
let w0 = ((b[0] - x) * (c[1] - y) - (b[1] - y) * (c[0] - x)) / t.area;
|
||||
@@ -753,7 +768,13 @@ fn raster_pixel(t: &Triangle, width: usize, back: Vec3, eye: Option<Vec3>, pixel
|
||||
let colour = if let Some(surface) = t.surface {
|
||||
let world = t.world.iter().zip(weights).fold(Vec3::ZERO, |p, (v, w)| p + *v * (w / sum));
|
||||
let view = eye.map_or(back, |eye| eye - world);
|
||||
let radiance = crate::studio::shade(surface, n, view).map_err(|e| invalid(&e.to_string()))?;
|
||||
let radiance = crate::studio::shade_weighted(surface, n, view, studio_weights.unwrap_or([1.0; 3])).map_err(|e| invalid(&e.to_string()))?;
|
||||
let mapped = crate::studio::tone_map(radiance).map_err(|e| invalid(&e.to_string()))?;
|
||||
[mapped.x, mapped.y, mapped.z]
|
||||
} else if let Some(weights) = studio_weights {
|
||||
let [r, g, b] = t.colour;
|
||||
let surface = crate::surface::OpaqueSurface::new(Vec3::new(r, g, b), 0.0, 1.0, 1.5).map_err(|e| invalid(&e.to_string()))?;
|
||||
let radiance = crate::studio::shade_weighted(surface, n, back, weights).map_err(|e| invalid(&e.to_string()))?;
|
||||
let mapped = crate::studio::tone_map(radiance).map_err(|e| invalid(&e.to_string()))?;
|
||||
[mapped.x, mapped.y, mapped.z]
|
||||
} else {
|
||||
|
||||
@@ -7,6 +7,7 @@ fn request() -> ImageRequest {
|
||||
let mut camera = Camera { distance: 50.0, ..Default::default() };
|
||||
camera.set_view(StandardView::Front);
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: Default::default(),
|
||||
@@ -19,6 +20,20 @@ fn request() -> ImageRequest {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_raster_mute_is_captured_in_request_and_darkens_only_the_product() {
|
||||
let part = scene(vec![square("part", [200, 180, 160], 1.0, Vec3::ZERO)]);
|
||||
let mut input = request();
|
||||
input.transparent_background = false;
|
||||
let normal = finish(ImageTask::new(part.clone(), input.clone(), super::CancelToken::default()).unwrap());
|
||||
input.studio_weights = Some([0.0; 3]);
|
||||
let dark = finish(ImageTask::new(part, input, super::CancelToken::default()).unwrap());
|
||||
assert_ne!(normal, dark);
|
||||
let image = image::load_from_memory(&dark).unwrap().to_rgba8();
|
||||
assert_eq!(image.get_pixel(32, 32).0, [0, 0, 0, 255]);
|
||||
assert_eq!(image.get_pixel(0, 0).0, [20, 40, 60, 255]);
|
||||
}
|
||||
|
||||
fn square(name: &str, colour: [u8; 3], opacity: f64, offset: Vec3) -> ProductMesh {
|
||||
let mesh = Mesh {
|
||||
positions: vec![
|
||||
|
||||
@@ -192,6 +192,7 @@ mod consumer {
|
||||
let mut camera = Camera { distance: 50.0, ..Default::default() };
|
||||
camera.set_view(StandardView::Top);
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: Integrator::Raytrace,
|
||||
|
||||
@@ -399,6 +399,22 @@ pub enum LightingPreset {
|
||||
KeyRim,
|
||||
}
|
||||
|
||||
impl LightingPreset {
|
||||
/// Portable source values shared by CPU transport and light inspection.
|
||||
pub fn directional_lights(self) -> Vec<DirectionalLightOptions> {
|
||||
let light = |direction, color, intensity| DirectionalLightOptions { direction, color, intensity };
|
||||
match self {
|
||||
Self::Neutral => crate::studio::LIGHTS.into_iter().map(|(d, intensity)| light([d.x, d.y, d.z], [1.0; 3], intensity)).collect(),
|
||||
Self::WarmCool => vec![
|
||||
light([0.6, 0.0, 0.8], [1.0, 0.72, 0.48], 3.0),
|
||||
light([-0.8, 0.0, 0.6], [0.45, 0.65, 1.0], 1.0),
|
||||
light([0.0, -0.6, 0.8], [1.0; 3], 1.5),
|
||||
],
|
||||
Self::KeyRim => vec![light([0.6, -0.4, 0.8], [1.0; 3], 3.0), light([-0.6, 0.4, 0.8], [0.6, 0.8, 1.0], 2.0)],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Full world-space side vectors; U cross V is the emitting side.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
@@ -1037,6 +1053,9 @@ impl RaytraceOptions {
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ImageRequest {
|
||||
/// Transient visibility of the three implicit studio lights; never saved in a design.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub studio_weights: Option<[f64; 3]>,
|
||||
/// Captured GPU resources stay in admitted work, never in status or saved data.
|
||||
#[serde(skip)]
|
||||
pub environment: Option<Arc<crate::lighting::environment::EnvironmentSource>>,
|
||||
|
||||
@@ -70,6 +70,7 @@ impl ImageWork for RegradeTask {
|
||||
return self.pending(done, total);
|
||||
}
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
width,
|
||||
height,
|
||||
camera: Default::default(),
|
||||
@@ -143,6 +144,7 @@ impl ImageWork for RegradeTask {
|
||||
}
|
||||
self.linear = None;
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
width,
|
||||
height,
|
||||
camera: Default::default(),
|
||||
|
||||
@@ -6,6 +6,7 @@ use solidcraft_geom::Aabb3;
|
||||
|
||||
fn request(integrator: Integrator) -> ImageRequest {
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator,
|
||||
|
||||
@@ -146,6 +146,7 @@ fn direct_response_respects_geometry_visibility_and_quarter_turn() {
|
||||
fn decoded_cpu_png_rotates_only_the_two_explicit_planar_targets() {
|
||||
fn render(scene: ProductScene, camera: Camera, options: RaytraceOptions) -> ::image::RgbaImage {
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: Integrator::Raytrace,
|
||||
|
||||
@@ -64,6 +64,7 @@ fn request(orientation: AnisotropicOrientation, reflect: bool) -> ImageRequest {
|
||||
..Default::default()
|
||||
};
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: job::Integrator::Raytrace,
|
||||
|
||||
@@ -64,6 +64,7 @@ fn task(samples: u8, selected: bool, face_override: bool, shadows: bool) -> Imag
|
||||
..Default::default()
|
||||
};
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: job::Integrator::Raytrace,
|
||||
@@ -228,6 +229,7 @@ fn spatial_reuse_fixture(s: u8, r: u8, selected: bool, face_override: bool, shad
|
||||
..Default::default()
|
||||
};
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: job::Integrator::Raytrace,
|
||||
|
||||
@@ -43,6 +43,7 @@ pub(in crate::raytrace) fn request(options: RaytraceOptions) -> ImageRequest {
|
||||
let mut camera = crate::Camera { distance: 50.0, ..Default::default() };
|
||||
camera.set_view(crate::StandardView::Top);
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: Integrator::Raytrace,
|
||||
|
||||
@@ -35,6 +35,7 @@ fn request() -> ImageRequest {
|
||||
let mut camera = crate::Camera { distance: 50.0, ..Default::default() };
|
||||
camera.set_view(crate::StandardView::Top);
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: job::Integrator::Raytrace,
|
||||
|
||||
@@ -40,6 +40,7 @@ fn request(mode: ReflectionMode) -> ImageRequest {
|
||||
let mut camera = crate::Camera { distance: 50.0, ..Default::default() };
|
||||
camera.set_view(crate::StandardView::Top);
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: job::Integrator::Raytrace,
|
||||
|
||||
@@ -176,6 +176,7 @@ fn thirty_two_emission_bindings_resume_with_four_work_units_and_cancel_without_p
|
||||
}
|
||||
fn request() -> ImageRequest {
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: job::Integrator::Raytrace,
|
||||
|
||||
@@ -86,18 +86,21 @@ impl Lighting {
|
||||
}
|
||||
|
||||
pub fn preset(preset: StudioPreset) -> Result<Self> {
|
||||
match preset {
|
||||
StudioPreset::Neutral => Ok(Self::studio_default()),
|
||||
StudioPreset::WarmCool => Self::new(vec![
|
||||
DirectionalLight::new(Vec3::new(0.6, 0.0, 0.8), Vec3::new(1.0, 0.72, 0.48), 3.0)?,
|
||||
DirectionalLight::new(Vec3::new(-0.8, 0.0, 0.6), Vec3::new(0.45, 0.65, 1.0), 1.0)?,
|
||||
DirectionalLight::new(Vec3::new(0.0, -0.6, 0.8), Vec3::new(1.0, 1.0, 1.0), 1.5)?,
|
||||
]),
|
||||
StudioPreset::KeyRim => Self::new(vec![
|
||||
DirectionalLight::new(Vec3::new(0.6, -0.4, 0.8), Vec3::new(1.0, 1.0, 1.0), 3.0)?,
|
||||
DirectionalLight::new(Vec3::new(-0.6, 0.4, 0.8), Vec3::new(0.6, 0.8, 1.0), 2.0)?,
|
||||
]),
|
||||
}
|
||||
let preset = match preset {
|
||||
StudioPreset::Neutral => return Ok(Self::studio_default()),
|
||||
StudioPreset::WarmCool => crate::job::LightingPreset::WarmCool,
|
||||
StudioPreset::KeyRim => crate::job::LightingPreset::KeyRim,
|
||||
};
|
||||
let lights = preset
|
||||
.directional_lights()
|
||||
.into_iter()
|
||||
.map(|light| {
|
||||
let [x, y, z] = light.direction;
|
||||
let [r, g, b] = light.color;
|
||||
DirectionalLight::new(Vec3::new(x, y, z), Vec3::new(r, g, b), light.intensity)
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
Self::new(lights)
|
||||
}
|
||||
|
||||
pub fn lights(&self) -> &[DirectionalLight] {
|
||||
|
||||
@@ -174,6 +174,7 @@ fn fixture(samples: u8, r: u8, left: Option<bool>) -> ImageTask {
|
||||
..Default::default()
|
||||
};
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: job::Integrator::Raytrace,
|
||||
|
||||
@@ -44,6 +44,7 @@ fn task(blocker: Option<(f64, f64)>, shadows: bool) -> ImageTask {
|
||||
..Default::default()
|
||||
};
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: job::Integrator::Raytrace,
|
||||
|
||||
@@ -183,6 +183,7 @@ fn request(reflections: Option<ReflectionOptions>) -> ImageRequest {
|
||||
let mut camera = crate::Camera { distance: 50.0, ..Default::default() };
|
||||
camera.set_view(crate::StandardView::Front);
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
integrator: job::Integrator::Raytrace,
|
||||
|
||||
@@ -12,10 +12,17 @@ pub const LIGHTS: [(Vec3, f64); 3] = [(Vec3::new(0.6, 0.0, 0.8), 3.0), (Vec3::ne
|
||||
/// Sum BRDF * incident radiance * light cosine, without display transfer.
|
||||
/// There are no cast shadows, indirect bounces, ambient term or emission.
|
||||
pub fn shade(surface: OpaqueSurface, normal: Vec3, view: Vec3) -> Result<Vec3, SurfaceError> {
|
||||
shade_weighted(surface, normal, view, [1.0; 3])
|
||||
}
|
||||
|
||||
pub fn shade_weighted(surface: OpaqueSurface, normal: Vec3, view: Vec3, weights: [f64; 3]) -> Result<Vec3, SurfaceError> {
|
||||
if weights.iter().any(|value| !value.is_finite() || !(0.0..=1.0).contains(value)) {
|
||||
return Err(SurfaceError::Radiance);
|
||||
}
|
||||
let n = unit_direction(normal)?;
|
||||
let mut radiance = Vec3::ZERO;
|
||||
for (light, intensity) in LIGHTS {
|
||||
radiance += surface.brdf(n, view, light)? * (intensity * n.dot(light).max(0.0));
|
||||
for ((light, intensity), weight) in LIGHTS.into_iter().zip(weights) {
|
||||
radiance += surface.brdf(n, view, light)? * (intensity * weight.clamp(0.0, 1.0) * n.dot(light).max(0.0));
|
||||
}
|
||||
Ok(radiance)
|
||||
}
|
||||
@@ -35,6 +42,16 @@ mod tests {
|
||||
use super::*;
|
||||
use std::f64::consts::PI;
|
||||
|
||||
#[test]
|
||||
fn render_lights_studio_visibility_preserves_default_and_zero_weights_remove_all_sources() {
|
||||
direct_white_conductor_matches_closed_form_and_is_tone_mapped_once();
|
||||
let surface = OpaqueSurface::new(Vec3::new(0.8, 0.5, 0.25), 0.0, 1.0, 1.5).unwrap();
|
||||
assert_eq!(shade(surface, Vec3::Z, Vec3::Z).unwrap(), shade_weighted(surface, Vec3::Z, Vec3::Z, [1.0; 3]).unwrap());
|
||||
assert_eq!(shade_weighted(surface, Vec3::Z, Vec3::Z, [0.0; 3]).unwrap(), Vec3::ZERO);
|
||||
assert!(shade_weighted(surface, Vec3::Z, Vec3::Z, [f64::NAN, 1.0, 1.0]).is_err());
|
||||
assert!(shade_weighted(surface, Vec3::Z, Vec3::Z, [2.0, 1.0, 1.0]).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn direct_white_conductor_matches_closed_form_and_is_tone_mapped_once() {
|
||||
let s = OpaqueSurface::new(Vec3::new(1.0, 1.0, 1.0), 1.0, 1.0, 1.5).unwrap();
|
||||
|
||||
@@ -410,6 +410,7 @@ fn offscreen(
|
||||
resources.insert(Renderer::new(&device, target, compute));
|
||||
let none = || Arc::new(Mutex::new(None));
|
||||
let cb = ViewportCallback(Frame {
|
||||
product_lights: None,
|
||||
product,
|
||||
key: 1,
|
||||
slot: Arc::new(Mutex::new(Some(scene))),
|
||||
|
||||
@@ -1036,6 +1036,10 @@ impl SolveApp {
|
||||
}
|
||||
let t0 = now_ms();
|
||||
let revision = self.session.revision;
|
||||
if matches!(id, "render.lights.solo" | "render.lights.mute") {
|
||||
render_workspace::light::validate_visibility(self, ¶ms)?;
|
||||
}
|
||||
let params = if matches!(id, "render.start" | "render.preflight") { render_workspace::light::filter_request(self, params)? } else { params };
|
||||
let selected_before = self.session.selection.clone();
|
||||
let r = self.session.execute(id, ¶ms).map_err(|e| e.to_string()).and_then(|reply| {
|
||||
render_workspace::apply_command(self, id, &reply)?;
|
||||
@@ -1066,6 +1070,14 @@ impl SolveApp {
|
||||
render_workspace::RenderSelection::Object(self.session.selection.clone())
|
||||
};
|
||||
}
|
||||
if let Ok(v) = &done {
|
||||
if matches!(id, "render.lights.solo" | "render.lights.mute") {
|
||||
render_workspace::light::apply_visibility(self, id, v);
|
||||
}
|
||||
if matches!(id, "render.lights.set" | "render.lights.add" | "render.lights.duplicate" | "render.lights.remove") {
|
||||
render_workspace::light::edited(self, ¶ms, v);
|
||||
}
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
@@ -1123,11 +1135,18 @@ impl SolveApp {
|
||||
let selected = match v.get("kind").and_then(Value::as_str) {
|
||||
Some("environment") => RenderSelection::Environment,
|
||||
Some("wear") => RenderSelection::Wear,
|
||||
Some("lighting") => {
|
||||
render_workspace::select_lighting(self);
|
||||
RenderSelection::Lighting
|
||||
}
|
||||
Some("output") => RenderSelection::Output,
|
||||
Some("sampling") => RenderSelection::Sampling,
|
||||
Some("effects") => RenderSelection::Effects,
|
||||
Some("check") => RenderSelection::Check,
|
||||
Some("light") => RenderSelection::Light(v.get("id").and_then(Value::as_str).unwrap_or_default().into()),
|
||||
Some("light") => {
|
||||
render_workspace::select_lighting(self);
|
||||
RenderSelection::Light(v.get("id").and_then(Value::as_str).unwrap_or_default().into())
|
||||
}
|
||||
Some("shot") => RenderSelection::Shot(v.get("id").and_then(Value::as_str).unwrap_or_default().into()),
|
||||
_ => RenderSelection::Nothing,
|
||||
};
|
||||
|
||||
@@ -70,12 +70,12 @@ fn section(app: &mut SolveApp, ui: &mut egui::Ui, key: &str) -> bool {
|
||||
let open = browser::is_open(app, &id, true);
|
||||
let label = app.tr(&format!("render.tree_{key}")).to_string();
|
||||
let add_label = app.tr(if key == "lights" { "render.tree_add_light" } else { "render.tree_add_shot" }).to_string();
|
||||
let pending = app.tr("render.tree_lights_pending").to_string();
|
||||
let pending = app.tr("render.light_backend_limit").to_string();
|
||||
let actions = [ui_kit::TreeAction {
|
||||
icon: "plus",
|
||||
hover_only: false,
|
||||
label: &add_label,
|
||||
reason: (key == "lights").then_some(pending.as_str()),
|
||||
reason: (key == "lights" && app.render_workspace.view.method == ImageMethod::Raster).then_some(pending.as_str()),
|
||||
target: if key == "lights" { "render:tree:lights:add" } else { "render:tree:shots:add" },
|
||||
}];
|
||||
let row = browser::draw_row(
|
||||
@@ -96,6 +96,7 @@ fn section(app: &mut SolveApp, ui: &mut egui::Ui, key: &str) -> bool {
|
||||
}
|
||||
.to_string(),
|
||||
fold: Some(open),
|
||||
selected: key == "lights" && app.render_workspace.view.selection == RenderSelection::Lighting,
|
||||
actions: if matches!(key, "lights" | "shots") { &actions } else { &[] },
|
||||
..Default::default()
|
||||
},
|
||||
@@ -105,9 +106,18 @@ fn section(app: &mut SolveApp, ui: &mut egui::Ui, key: &str) -> bool {
|
||||
}
|
||||
if row.actions.iter().any(|r| r.clicked()) {
|
||||
// The existing Shots manager owns naming and saving. This navigation never saves.
|
||||
app.start("render.settings.get");
|
||||
if key == "lights" {
|
||||
if let Err(error) = super::light::edit(app, "render.lights.add", None, Some(json!({"kind":"area"}))) {
|
||||
app.set_status(error, true);
|
||||
}
|
||||
} else {
|
||||
app.start("render.settings.get");
|
||||
}
|
||||
}
|
||||
if row.fold || row.clicked {
|
||||
if row.clicked && key == "lights" {
|
||||
select(app, "lighting", None);
|
||||
}
|
||||
if row.fold || (row.clicked && key != "lights") {
|
||||
browser::toggle(app, &id, true);
|
||||
}
|
||||
open
|
||||
@@ -119,28 +129,18 @@ fn select(app: &mut SolveApp, kind: &str, id: Option<&str>) {
|
||||
}
|
||||
|
||||
pub(crate) fn light_types(app: &SolveApp) -> Vec<&'static str> {
|
||||
let view = &app.render_workspace.view;
|
||||
let mut lights = Vec::new();
|
||||
match view.method {
|
||||
ImageMethod::Raster => {}
|
||||
ImageMethod::CpuRaytrace => {
|
||||
lights.extend(view.raytrace.lights.iter().flatten().map(|_| "render.tree_directional"));
|
||||
lights.extend(
|
||||
view.raytrace.punctual_lights.iter().flatten().map(|l| if l.cone.is_some() { "render.tree_spot" } else { "render.tree_point" }),
|
||||
);
|
||||
lights.extend(view.raytrace.area_lights.iter().flatten().map(|_| "render.tree_rectangle"));
|
||||
}
|
||||
ImageMethod::GpuRaytrace if view.studio.lighting_enabled => {
|
||||
if view.studio.sun_enabled {
|
||||
lights.push("render.tree_sun");
|
||||
}
|
||||
lights.extend(view.studio.area_lights.iter().map(|_| "render.tree_rectangle"));
|
||||
}
|
||||
ImageMethod::GpuRaytrace => {}
|
||||
}
|
||||
lights
|
||||
super::light::rows(app)
|
||||
.unwrap_or_default()
|
||||
.iter()
|
||||
.map(|light| match light.geometry {
|
||||
solidcraft_engine::schema::render_lights::Geometry::Directional { angular_radius_rad: Some(_), .. } => "render.tree_sun",
|
||||
solidcraft_engine::schema::render_lights::Geometry::Directional { .. } => "render.tree_directional",
|
||||
solidcraft_engine::schema::render_lights::Geometry::Point { .. } => "render.tree_point",
|
||||
solidcraft_engine::schema::render_lights::Geometry::Spot { .. } => "render.tree_spot",
|
||||
solidcraft_engine::schema::render_lights::Geometry::Area { .. } => "render.tree_rectangle",
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub(crate) fn environment(app: &SolveApp) -> (String, String) {
|
||||
let view = &app.render_workspace.view;
|
||||
let fixed = || (app.tr("render.tree_fixed_studio").to_string(), view.draft.environment_rotation, view.draft.environment_intensity);
|
||||
@@ -203,38 +203,24 @@ pub(crate) fn sections(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
app.render_workspace.view.inspector.page = inspector::Page::Environment;
|
||||
}
|
||||
if section(app, ui, "lights") {
|
||||
for (index, key) in light_types(app).iter().enumerate() {
|
||||
let label = app.tr(key).to_string();
|
||||
let id = format!("{}:{key}:{index}", app.render_workspace.view.method.label());
|
||||
for (index, light) in super::light::rows(app).unwrap_or_default().iter().enumerate() {
|
||||
let label = super::light::name(app, light);
|
||||
let id = &light.id;
|
||||
let visible = app.render_workspace.view.lights.visibility.visible(id);
|
||||
let solo = app.render_workspace.view.lights.visibility.solo.as_deref() == Some(id);
|
||||
let solo_target = format!("render:tree:light:{index}:solo");
|
||||
let mute_target = format!("render:tree:light:{index}:mute");
|
||||
let eye_target = format!("render:tree:light:{index}:visibility");
|
||||
let pending = app.tr("render.tree_lights_pending");
|
||||
let actions = [
|
||||
ui_kit::TreeAction {
|
||||
icon: "lookat",
|
||||
hover_only: true,
|
||||
label: app.tr("render.tree_solo"),
|
||||
reason: Some(pending),
|
||||
target: &solo_target,
|
||||
},
|
||||
ui_kit::TreeAction {
|
||||
icon: "suppress",
|
||||
hover_only: true,
|
||||
label: app.tr("render.tree_mute"),
|
||||
reason: Some(pending),
|
||||
target: &mute_target,
|
||||
},
|
||||
ui_kit::TreeAction { icon: "eye", hover_only: false, label: app.tr("ui.hide"), reason: Some(pending), target: &eye_target },
|
||||
];
|
||||
let solo_label = app.tr("render.tree_solo").to_string();
|
||||
let actions = [ui_kit::TreeAction { icon: "lookat", hover_only: true, label: &solo_label, reason: None, target: &solo_target }];
|
||||
let row = browser::draw_row(
|
||||
ui,
|
||||
ui.id().with(("render_light", &id)),
|
||||
ui.id().with(("render_light", id)),
|
||||
&Row {
|
||||
depth: 1,
|
||||
label: &label,
|
||||
name: true,
|
||||
icon: "render_scene",
|
||||
eye: Some(visible),
|
||||
dim: !visible,
|
||||
actions: &actions,
|
||||
selected: app.render_workspace.view.selection == RenderSelection::Light(id.clone()),
|
||||
..Default::default()
|
||||
@@ -243,8 +229,20 @@ pub(crate) fn sections(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
if let Some(rect) = row.rect {
|
||||
crate::scenario::publish_target(&format!("render:tree:light:{index}"), rect);
|
||||
}
|
||||
if let Some(rect) = row.eye_rect.filter(|rect| rect.is_positive()) {
|
||||
crate::scenario::publish_target(&format!("render:tree:light:{index}:mute"), rect);
|
||||
}
|
||||
if row.eye {
|
||||
if !visible && app.render_workspace.view.lights.visibility.solo.is_some() {
|
||||
let _ = app.run("render.lights.solo", json!({"solo":false}));
|
||||
}
|
||||
let _ = app.run("render.lights.mute", json!({"id":id,"mute":visible}));
|
||||
}
|
||||
if row.actions.iter().any(|response| response.clicked()) {
|
||||
let _ = app.run("render.lights.solo", json!({"id":id,"solo":!solo}));
|
||||
}
|
||||
if row.clicked {
|
||||
select(app, "light", Some(&id));
|
||||
select(app, "light", Some(id));
|
||||
app.render_workspace.view.inspector.page = inspector::Page::Lighting;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ use std::sync::{Arc, Mutex};
|
||||
use egui::{Color32, Sense};
|
||||
use serde_json::json;
|
||||
use solidcraft_engine::doc::render_settings::RenderSetup;
|
||||
use solidcraft_engine::render::job::{ImageHost, Integrator, LightingPreset, PreviewInfo, RaytraceOptions};
|
||||
#[cfg(test)]
|
||||
use solidcraft_engine::render::job::LightingPreset;
|
||||
use solidcraft_engine::render::job::{ImageHost, Integrator, PreviewInfo, RaytraceOptions};
|
||||
use solidcraft_engine::render::{
|
||||
Availability, Camera, ExecutorDescriptor, ExecutorId, ProductScene, RenderLimits, RenderMode, RenderOperation, RenderProfile, RenderRequest,
|
||||
ScratchLayout,
|
||||
@@ -41,6 +43,8 @@ mod library;
|
||||
|
||||
#[path = "render_ui/assign.rs"]
|
||||
pub(crate) mod assign;
|
||||
#[path = "render_workspace_light.rs"]
|
||||
pub(crate) mod light;
|
||||
|
||||
#[path = "render_workspace_materials.rs"]
|
||||
mod materials;
|
||||
@@ -271,6 +275,7 @@ pub enum RenderSelection {
|
||||
Object(Vec<solidcraft_engine::Sel>),
|
||||
Environment,
|
||||
Wear,
|
||||
Lighting,
|
||||
/// Method/type/index identity until named light commands provide persistent IDs.
|
||||
Light(String),
|
||||
Shot(String),
|
||||
@@ -290,11 +295,16 @@ pub(crate) fn selection_editor(app: &mut SolveApp, selection: &RenderSelection)
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) fn select_lighting(app: &mut SolveApp) {
|
||||
app.render_workspace.view.inspector.page = inspector::Page::Lighting;
|
||||
}
|
||||
|
||||
/// Small per-document editor state; GPU uploads and host capabilities stay outside tabs.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ViewState {
|
||||
pub(crate) assign: assign::State,
|
||||
pub(crate) frame: shot::Frame,
|
||||
lights: light::View,
|
||||
job_shot: Option<String>,
|
||||
save_shot_name: Option<String>,
|
||||
pub name: String,
|
||||
@@ -358,6 +368,7 @@ impl Default for ViewState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
assign: assign::State::default(),
|
||||
lights: Default::default(),
|
||||
job_shot: None,
|
||||
frame: Default::default(),
|
||||
save_shot_name: None,
|
||||
@@ -793,6 +804,10 @@ fn image_params(app: &SolveApp) -> Result<serde_json::Value, String> {
|
||||
|
||||
/// Pure request construction is shared with offline setup editing; host checks stay above.
|
||||
fn image_request(app: &SolveApp) -> Result<serde_json::Value, String> {
|
||||
light::filter_request(app, raw_image_request(app)?)
|
||||
}
|
||||
|
||||
fn raw_image_request(app: &SolveApp) -> Result<serde_json::Value, String> {
|
||||
cpu::validate_progressive_image(app)?;
|
||||
if !setups::has_runtime_inputs(app) {
|
||||
return Ok(json!({"settings":setups::snapshot(app)?}));
|
||||
@@ -897,6 +912,7 @@ fn cpu_sampling_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn cpu_lighting_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
ui.label(app.tr("render.cpu_lighting"));
|
||||
let presets = [
|
||||
@@ -1962,6 +1978,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
}
|
||||
let slot = app.render_workspace.slot.clone();
|
||||
let callback = ViewportCallback(Frame {
|
||||
product_lights: Some(light::preview(app)?),
|
||||
product: true,
|
||||
key,
|
||||
slot: slot.clone(),
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
//! Transient CPU image controls; engine commands own file capture and admission.
|
||||
use serde_json::{Value, json};
|
||||
use solidcraft_engine::render::job::{
|
||||
CpuBudget, DirectionalLightOptions, PunctualLightOptions, RaytraceEnvironmentOptions, ReflectionBody, ReflectionMode,
|
||||
};
|
||||
use solidcraft_engine::render::job::{CpuBudget, RaytraceEnvironmentOptions, ReflectionBody, ReflectionMode};
|
||||
|
||||
use super::hdr;
|
||||
use crate::{SolveApp, ui_kit};
|
||||
@@ -496,6 +494,7 @@ pub(super) fn environment_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
ui.small(app.tr("render.cpu_environment_background"));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn vector(ui: &mut egui::Ui, label: &str, value: &mut [f64; 3], range: std::ops::RangeInclusive<f64>, speed: f64, suffix: &str) {
|
||||
ui.label(label);
|
||||
ui.horizontal(|ui| {
|
||||
@@ -505,113 +504,9 @@ fn vector(ui: &mut egui::Ui, label: &str, value: &mut [f64; 3], range: std::ops:
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(super) fn light_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let mut custom = app.render_workspace.view.raytrace.lights.is_some();
|
||||
if ui_kit::checkbox(ui, app.tr("render.cpu_custom_directions"), &mut custom).changed() {
|
||||
let options = &mut app.render_workspace.view.raytrace;
|
||||
options.lights = custom.then(Vec::new);
|
||||
if custom {
|
||||
options.preset = None;
|
||||
}
|
||||
}
|
||||
ui.small(app.tr("render.cpu_light_help"));
|
||||
let title = app.tr("render.cpu_directional").to_string();
|
||||
let mut remove = None;
|
||||
let count = app.render_workspace.view.raytrace.lights.as_ref().map_or(0, Vec::len);
|
||||
for index in 0..count {
|
||||
ui_kit::section(ui, ("cpu_directional", index), &format!("{title} {}", index + 1), false, |ui| {
|
||||
let direction = app.tr("render.cpu_direction").to_string();
|
||||
let color = app.tr("render.cpu_linear_color").to_string();
|
||||
let intensity = app.tr("render.cpu_light_intensity").to_string();
|
||||
if let Some(light) = app.render_workspace.view.raytrace.lights.as_mut().and_then(|lights| lights.get_mut(index)) {
|
||||
vector(ui, &direction, &mut light.direction, -f64::MAX..=f64::MAX, 0.01, "");
|
||||
vector(ui, &color, &mut light.color, 0.0..=1.0, 0.01, "");
|
||||
ui.label(intensity);
|
||||
ui_kit::number_field(ui, &mut light.intensity, 0.0..=64.0, 0.1, "");
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("render.cpu_light_remove"), ui_kit::Button::Normal).clicked() {
|
||||
remove = Some(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
if let Some(index) = remove
|
||||
&& let Some(lights) = &mut app.render_workspace.view.raytrace.lights
|
||||
&& index < lights.len()
|
||||
{
|
||||
lights.remove(index);
|
||||
}
|
||||
if custom
|
||||
&& ui_kit::button(ui, app.tr("render.cpu_directional_add"), ui_kit::Button::Enabled(count < 8)).clicked()
|
||||
&& let Some(lights) = &mut app.render_workspace.view.raytrace.lights
|
||||
{
|
||||
lights.push(DirectionalLightOptions { direction: [0.0, 0.0, 1.0], color: [1.0; 3], intensity: 1.0 });
|
||||
}
|
||||
let title = app.tr("render.cpu_point").to_string();
|
||||
let mut remove = None;
|
||||
let count = app.render_workspace.view.raytrace.punctual_lights.as_ref().map_or(0, Vec::len);
|
||||
for index in 0..count {
|
||||
ui_kit::section(ui, ("cpu_point", index), &format!("{title} {}", index + 1), false, |ui| {
|
||||
let position = app.tr("render.cpu_light_position").to_string();
|
||||
let color = app.tr("render.cpu_linear_color").to_string();
|
||||
let intensity = app.tr("render.cpu_light_intensity").to_string();
|
||||
let reference = app.tr("render.cpu_light_reference").to_string();
|
||||
let minimum = app.tr("render.cpu_light_minimum").to_string();
|
||||
if let Some(light) = app.render_workspace.view.raytrace.punctual_lights.as_mut().and_then(|lights| lights.get_mut(index)) {
|
||||
vector(ui, &position, &mut light.position_mm, -1e12..=1e12, 1.0, " mm");
|
||||
vector(ui, &color, &mut light.color, 0.0..=1.0, 0.01, "");
|
||||
ui.label(intensity);
|
||||
ui_kit::number_field(ui, &mut light.intensity, 0.0..=64.0, 0.1, "");
|
||||
ui.label(reference);
|
||||
ui_kit::number_field(ui, &mut light.reference_distance_mm, 0.001..=1e6, 1.0, " mm");
|
||||
ui.label(minimum);
|
||||
ui_kit::number_field(ui, &mut light.minimum_distance_mm, 0.001..=1e6, 0.01, " mm");
|
||||
let mut spot = light.cone.is_some();
|
||||
if ui_kit::checkbox(ui, crate::i18n::tr("render.spot_cone"), &mut spot).changed() {
|
||||
light.cone = spot.then_some(solidcraft_engine::render::job::SpotConeOptions {
|
||||
emitted_axis: [0.0, 0.0, -1.0],
|
||||
inner_half_angle_radians: 0.2,
|
||||
outer_half_angle_radians: 0.5,
|
||||
});
|
||||
}
|
||||
if let Some(cone) = &mut light.cone {
|
||||
vector(ui, crate::i18n::tr("render.emitted_axis"), &mut cone.emitted_axis, -1e8..=1e8, 0.01, "");
|
||||
for (label, value) in [
|
||||
(crate::i18n::tr("render.inner_half_angle"), &mut cone.inner_half_angle_radians),
|
||||
(crate::i18n::tr("render.outer_half_angle"), &mut cone.outer_half_angle_radians),
|
||||
] {
|
||||
ui.label(label);
|
||||
let mut degrees = value.to_degrees();
|
||||
if ui_kit::number_field(ui, &mut degrees, 0.0..=90.0, 0.1, " deg").changed() {
|
||||
*value = degrees.to_radians();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("render.cpu_light_remove"), ui_kit::Button::Normal).clicked() {
|
||||
remove = Some(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
if let Some(index) = remove
|
||||
&& let Some(lights) = &mut app.render_workspace.view.raytrace.punctual_lights
|
||||
&& index < lights.len()
|
||||
{
|
||||
lights.remove(index);
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("render.cpu_point_add"), ui_kit::Button::Enabled(count < 8)).clicked() {
|
||||
let p = app.cam.target;
|
||||
let height = app.cam.distance.clamp(1.0, 1e6);
|
||||
app.render_workspace.view.raytrace.punctual_lights.get_or_insert_default().push(PunctualLightOptions {
|
||||
position_mm: [p.x, p.y, p.z + height],
|
||||
color: [1.0; 3],
|
||||
intensity: 1.0,
|
||||
reference_distance_mm: height,
|
||||
minimum_distance_mm: 0.001,
|
||||
cone: None,
|
||||
});
|
||||
}
|
||||
ui.small(app.tr("render.cpu_point_help"));
|
||||
area_controls(app, ui);
|
||||
super::light::lighting(app, ui);
|
||||
}
|
||||
|
||||
pub(super) fn record_checked(app: &mut SolveApp, params: &Value, reply: &Value) {
|
||||
@@ -664,66 +559,3 @@ pub(super) fn captured_status(app: &SolveApp, ui: &mut egui::Ui, status: &Value)
|
||||
ui_kit::section(ui, "cpu_captured_hdr", &title, false, |ui| metadata(app, ui, &status["environment"]));
|
||||
}
|
||||
}
|
||||
|
||||
fn area_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let title = app.tr("render.cpu_area_editor").to_string();
|
||||
ui_kit::section(ui, "render_cpu_areas", &title, false, |ui| {
|
||||
ui.small(app.tr("render.cpu_area_editor_help"));
|
||||
let count = app.render_workspace.view.raytrace.area_lights.as_ref().map_or(0, Vec::len);
|
||||
let mut remove = None;
|
||||
for index in 0..count {
|
||||
ui_kit::section(ui, ("render_cpu_area", index), &format!("{} {}", title, index + 1), false, |ui| {
|
||||
let position = app.tr("render.cpu_light_position").to_string();
|
||||
let u = app.tr("render.cpu_area_full_u").to_string();
|
||||
let v = app.tr("render.cpu_area_full_v").to_string();
|
||||
let color = app.tr("render.cpu_linear_color").to_string();
|
||||
let intensity = app.tr("render.cpu_light_intensity").to_string();
|
||||
if let Some(light) = app.render_workspace.view.raytrace.area_lights.as_mut().and_then(|lights| lights.get_mut(index)) {
|
||||
vector(ui, &position, &mut light.center_mm, -1e12..=1e12, 1.0, " mm");
|
||||
vector(ui, &u, &mut light.edge_u_mm, -1e6..=1e6, 1.0, " mm");
|
||||
vector(ui, &v, &mut light.edge_v_mm, -1e6..=1e6, 1.0, " mm");
|
||||
vector(ui, &color, &mut light.color, 0.0..=1.0, 0.01, "");
|
||||
ui.label(intensity);
|
||||
ui_kit::number_field(ui, &mut light.intensity, 0.0..=64.0, 0.1, "");
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("render.cpu_light_remove"), ui_kit::Button::Normal).clicked() {
|
||||
remove = Some(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
if let Some(index) = remove
|
||||
&& let Some(lights) = &mut app.render_workspace.view.raytrace.area_lights
|
||||
&& index < lights.len()
|
||||
{
|
||||
lights.remove(index);
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("render.cpu_area_add"), ui_kit::Button::Enabled(count < solidcraft_engine::render::job::MAX_AREA_LIGHTS))
|
||||
.clicked()
|
||||
{
|
||||
let center = app.cam.target;
|
||||
let size = app.cam.distance.clamp(1.0, 1e6) * 0.25;
|
||||
let options = &mut app.render_workspace.view.raytrace;
|
||||
options.area_lights.get_or_insert_default().push(solidcraft_engine::render::job::RectangleLightOptions {
|
||||
center_mm: [center.x, center.y, center.z + size * 3.0],
|
||||
edge_u_mm: [size, 0.0, 0.0],
|
||||
edge_v_mm: [0.0, -size, 0.0],
|
||||
color: [1.0; 3],
|
||||
intensity: 1.0,
|
||||
});
|
||||
options.area_samples.get_or_insert(16);
|
||||
options.seed.get_or_insert(0);
|
||||
}
|
||||
if app.render_workspace.view.raytrace.area_lights.as_ref().is_some_and(|v| !v.is_empty()) {
|
||||
let value = app.render_workspace.view.raytrace.area_samples.unwrap_or(16);
|
||||
ui.label(app.tr("render.cpu_area_samples"));
|
||||
ui_kit::dropdown_menu(ui, "cpu_area_samples", &value.to_string(), |ui| {
|
||||
for count in [1, 4, 16, 64] {
|
||||
if ui_kit::list_picker(ui, &count.to_string(), &count.to_string(), count == value).clicked() {
|
||||
app.render_workspace.view.raytrace.area_samples = Some(count);
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -459,6 +459,7 @@ fn perform_action(app: &mut SolveApp, action: PendingAction) -> Result<(), Strin
|
||||
fn confirmation(app: &mut SolveApp, ctx: &egui::Context) {
|
||||
super::shots::confirmation(app, ctx);
|
||||
materials::confirmation(app, ctx);
|
||||
super::light::confirmation(app, ctx);
|
||||
let Some(pending) = app.render_workspace.view.inspector.pending.clone() else { return };
|
||||
if pending.revision != app.session.revision || !Weak::ptr_eq(&pending.document, &Arc::downgrade(&app.session.doc)) {
|
||||
app.render_workspace.view.inspector.pending = None;
|
||||
@@ -663,18 +664,11 @@ fn advanced_appearance_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
super::effects::aging_controls(app, ui);
|
||||
}
|
||||
fn lighting_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
browse_button(app, ui, "rigs", "render.browse_rigs");
|
||||
|
||||
match app.render_workspace.view.method {
|
||||
ImageMethod::GpuRaytrace => studio::lighting_controls(app, ui),
|
||||
ImageMethod::CpuRaytrace => {
|
||||
super::cpu_lighting_controls(app, ui);
|
||||
cpu::light_controls(app, ui);
|
||||
}
|
||||
ImageMethod::Raster => {
|
||||
ui_kit::text(ui, app.tr("render.method_limit_raster"), ui_kit::Text::Note("render.method_limit_raster"));
|
||||
}
|
||||
if let super::RenderSelection::Light(id) = app.render_workspace.view.selection.clone() {
|
||||
super::light::editor(app, ui, &id);
|
||||
return;
|
||||
}
|
||||
super::light::lighting(app, ui);
|
||||
}
|
||||
fn vector(ui: &mut egui::Ui, label: &str, value: &mut [f64; 3], range: std::ops::RangeInclusive<f64>, speed: f64) {
|
||||
ui.label(label);
|
||||
|
||||
@@ -2350,6 +2350,17 @@ fn output_children_select_their_editor_with_all_sections_in_design_order() {
|
||||
),
|
||||
] {
|
||||
let handle = if kind == "output" { "render:tree:output".to_string() } else { format!("render:tree:output:{kind}") };
|
||||
// The capped Browser can publish rows below its clip after Lights adds more entries.
|
||||
// Reveal the Output group before exercising each real child-row click.
|
||||
h.frames(3);
|
||||
let browser = crate::scenario::rect_of("browser:card").unwrap();
|
||||
let header = crate::scenario::rect_of("render:browser:header").unwrap();
|
||||
h.call("ui.scroll", json!({"x":browser.center().x,"y":(header.bottom()+browser.bottom())/2.0,"delta":-2000}));
|
||||
h.frames(20);
|
||||
let browser = crate::scenario::rect_of("browser:card").unwrap();
|
||||
let header = crate::scenario::rect_of("render:browser:header").unwrap();
|
||||
let target = crate::scenario::handle_at(&handle).unwrap();
|
||||
assert!(browser.shrink(Tokens::get().space_8).contains(target) && target.y > header.bottom(), "{handle} is outside the visible Browser");
|
||||
h.step(&json!({"click":{"handle":handle}})).unwrap();
|
||||
h.frames(3);
|
||||
assert_eq!(h.app.render_workspace.view.selection, selection);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -234,6 +234,7 @@ pub(super) fn load(app: &mut SolveApp) {
|
||||
app.render_workspace.revision = app.session.revision;
|
||||
// Keep the existing explicit Restore Saved Camera action: loading options does not navigate.
|
||||
app.render_workspace.view.clean_setup = draft(app).ok();
|
||||
super::light::loaded(app);
|
||||
}
|
||||
|
||||
pub(super) fn refresh_dirty(app: &mut SolveApp) {
|
||||
|
||||
@@ -241,75 +241,9 @@ pub(super) fn environment_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(super) fn lighting_controls(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let label = app.tr("render.studio_lighting_enable").to_string();
|
||||
ui_kit::checkbox(ui, &label, &mut app.render_workspace.view.studio.lighting_enabled);
|
||||
if !app.render_workspace.view.studio.lighting_enabled {
|
||||
return;
|
||||
}
|
||||
let ambient = app.tr("render.studio_ambient_rgb").to_string();
|
||||
vector(ui, &ambient, &mut app.render_workspace.view.studio.ambient, 0.0..=1e6, 0.1);
|
||||
let label = app.tr("render.studio_sun").to_string();
|
||||
ui_kit::checkbox(ui, &label, &mut app.render_workspace.view.studio.sun_enabled);
|
||||
if app.render_workspace.view.studio.sun_enabled {
|
||||
let direction = app.tr("render.studio_direction").to_string();
|
||||
vector(ui, &direction, &mut app.render_workspace.view.studio.sun.direction, -1e8..=1e8, 0.01);
|
||||
let radiance = app.tr("render.studio_radiance").to_string();
|
||||
vector(ui, &radiance, &mut app.render_workspace.view.studio.sun.radiance, 0.0..=1e8, 1.0);
|
||||
ui.label(app.tr("render.studio_sun_radius"));
|
||||
let mut radius = app.render_workspace.view.studio.sun.angular_radius_rad.to_degrees();
|
||||
if ui_kit::number_field(ui, &mut radius, 0.001_f64.to_degrees()..=90.0, 0.05, "°").changed() {
|
||||
app.render_workspace.view.studio.sun.angular_radius_rad = radius.to_radians();
|
||||
}
|
||||
}
|
||||
let title = app.tr("render.studio_area").to_string();
|
||||
let mut remove = None;
|
||||
for index in 0..app.render_workspace.view.studio.area_lights.len() {
|
||||
ui_kit::section(ui, ("render_area", index), &format!("{title} {}", index + 1), false, |ui| {
|
||||
for (key, field) in [("render.studio_center", 0), ("render.studio_half_u", 1), ("render.studio_half_v", 2), ("render.studio_radiance", 3)]
|
||||
{
|
||||
let label = app.tr(key).to_string();
|
||||
let Some(light) = app.render_workspace.view.studio.area_lights.get_mut(index) else { continue };
|
||||
let value = match field {
|
||||
0 => &mut light.center,
|
||||
1 => &mut light.u,
|
||||
2 => &mut light.v,
|
||||
_ => &mut light.radiance,
|
||||
};
|
||||
vector(
|
||||
ui,
|
||||
&label,
|
||||
value,
|
||||
if field == 3 {
|
||||
0.0..=1e6
|
||||
} else if field == 0 {
|
||||
-1e12..=1e12
|
||||
} else {
|
||||
-1e6..=1e6
|
||||
},
|
||||
1.0,
|
||||
);
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("render.studio_remove_area"), ui_kit::Button::Normal).clicked() {
|
||||
remove = Some(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
if let Some(index) = remove {
|
||||
app.render_workspace.view.studio.area_lights.remove(index);
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("render.studio_add_area"), ui_kit::Button::Enabled(app.render_workspace.view.studio.area_lights.len() < 4)).clicked()
|
||||
{
|
||||
let target = app.cam.target;
|
||||
let size = (app.cam.distance * 0.25).clamp(1.0, 1e5);
|
||||
app.render_workspace.view.studio.area_lights.push(AreaLight {
|
||||
center: [target.x, target.y, target.z + size * 2.0],
|
||||
u: [size, 0.0, 0.0],
|
||||
v: [0.0, -size, 0.0],
|
||||
radiance: [8.0; 3],
|
||||
});
|
||||
}
|
||||
ui.small(app.tr("render.studio_area_help"));
|
||||
super::light::lighting(app, ui);
|
||||
}
|
||||
|
||||
/// Presentation is opt-in; raw radiance and engineering appearance stay untouched.
|
||||
|
||||
@@ -688,6 +688,142 @@ fn render_workspace_frame_shot_edits_revert_duplicate_and_rename_use_existing_co
|
||||
}
|
||||
}
|
||||
|
||||
fn render_lights_fixture() -> Harness {
|
||||
let mut h = Harness::new();
|
||||
h.call("ui.resize", json!({"width":1440,"height":1400}));
|
||||
h.app
|
||||
.run(
|
||||
"render.settings.set",
|
||||
json!({"name":"Studio","set":{"job":{"method":"cpu_raytrace","options":{"lights":[
|
||||
{"direction":[0.6,0,0.8],"color":[1,0.5,0.25],"intensity":3},
|
||||
{"direction":[-0.8,0,0.6],"color":[0.25,0.5,1],"intensity":2}
|
||||
]}}}}),
|
||||
)
|
||||
.unwrap();
|
||||
enter(&mut h.app, true).unwrap();
|
||||
setups::load(&mut h.app);
|
||||
h.app.pending_fit = None;
|
||||
h
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_solo_and_mute_filter_preview_and_render_copies_without_saving_or_history() {
|
||||
let mut h = render_lights_fixture();
|
||||
let original = setups::snapshot(&h.app).unwrap();
|
||||
let document = h.app.session.doc.clone();
|
||||
let json = document.to_json();
|
||||
let before = (h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision, h.app.session.is_dirty());
|
||||
h.app.run("render.lights.solo", json!({"id":"directional:1","solo":true})).unwrap();
|
||||
assert_eq!(light::preview(&h.app).unwrap().len(), 1);
|
||||
let request = image_request(&h.app).unwrap();
|
||||
assert_eq!(request["settings"]["job"]["options"]["lights"][0]["intensity"], 0.0);
|
||||
assert_eq!(request["settings"]["job"]["options"]["lights"][1]["intensity"], 2.0);
|
||||
h.app.run("render.lights.mute", json!({"id":"directional:1","mute":true})).unwrap();
|
||||
assert!(light::preview(&h.app).unwrap().is_empty());
|
||||
assert_eq!(image_request(&h.app).unwrap()["settings"]["job"]["options"]["lights"][1]["intensity"], 0.0);
|
||||
assert_eq!(setups::snapshot(&h.app).unwrap(), original);
|
||||
assert!(Arc::ptr_eq(&document, &h.app.session.doc));
|
||||
assert_eq!(h.app.session.doc.to_json(), json);
|
||||
assert_eq!(before, (h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision, h.app.session.is_dirty()));
|
||||
let visibility = h.app.render_workspace.view.lights.visibility.clone();
|
||||
assert!(h.app.run("render.lights.mute", json!({"id":"area:0","mute":true})).is_err());
|
||||
assert_eq!(h.app.render_workspace.view.lights.visibility, visibility);
|
||||
crate::documents::open_tab(&mut h.app, Session::default()).unwrap();
|
||||
assert!(!h.app.render_workspace.view.lights.visibility.active());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_editor_opening_and_disabled_gpu_types_never_edit_or_start_a_job() {
|
||||
let mut h = render_lights_fixture();
|
||||
h.app
|
||||
.run(
|
||||
"render.settings.set",
|
||||
json!({"name":"Studio","set":{"job":{"method":"gpu_path","options":{"lighting":{"area_lights":[
|
||||
{"center":[0,0,100],"u":[1000000,0,0],"v":[0,-1000000,0],"radiance":[0,0,0]}
|
||||
]}}}}}),
|
||||
)
|
||||
.unwrap();
|
||||
setups::load(&mut h.app);
|
||||
h.app.run("view.render_select", json!({"kind":"light","id":"area:0"})).unwrap();
|
||||
h.app.render_workspace.view.inspector.page = inspector::Page::Lighting;
|
||||
let document = h.app.session.doc.clone();
|
||||
let before = (h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision, h.app.session.is_dirty());
|
||||
h.frames(3);
|
||||
assert!(crate::scenario::rect_of("render:light:editor").is_some());
|
||||
h.step(&json!({"click":{"handle":"render:light:type:point"}})).unwrap();
|
||||
assert!(Arc::ptr_eq(&document, &h.app.session.doc));
|
||||
assert_eq!(before, (h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision, h.app.session.is_dirty()));
|
||||
assert!(h.app.render_workspace.view.job.is_none());
|
||||
assert!(h.app.dialog.is_none());
|
||||
assert_eq!(light::rows(&h.app).unwrap()[0].geometry.kind(), "area");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_edit_commands_refresh_selected_editor_and_keep_visibility_separate_from_undo() {
|
||||
let mut h = render_lights_fixture();
|
||||
h.app.run("render.lights.mute", json!({"id":"directional:0","mute":true})).unwrap();
|
||||
let document = h.app.session.doc.clone();
|
||||
let undo = h.app.session.undo.len();
|
||||
light::edit(&mut h.app, "render.lights.set", Some("directional:0"), Some(json!({"intensity_ev":2}))).unwrap();
|
||||
assert_eq!(h.app.session.undo.len(), undo + 1);
|
||||
assert_eq!(h.app.render_workspace.view.selection, RenderSelection::Light("directional:0".into()));
|
||||
assert_eq!(light::rows(&h.app).unwrap()[0].intensity, 4.0);
|
||||
assert!(!h.app.render_workspace.view.lights.visibility.visible("directional:0"));
|
||||
h.app.run("edit.undo", json!({})).unwrap();
|
||||
setups::load(&mut h.app);
|
||||
assert_eq!(h.app.session.doc, document);
|
||||
assert!(!h.app.render_workspace.view.lights.visibility.visible("directional:0"));
|
||||
assert_eq!(light::rows(&h.app).unwrap()[0].intensity, 3.0);
|
||||
light::edit(&mut h.app, "render.lights.duplicate", Some("directional:0"), None).unwrap();
|
||||
assert_eq!(h.app.render_workspace.view.selection, RenderSelection::Light("directional:2".into()));
|
||||
light::edit(&mut h.app, "render.lights.remove", Some("directional:2"), None).unwrap();
|
||||
assert_eq!(h.app.render_workspace.view.selection, RenderSelection::Nothing);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_fixed_studio_requests_carry_transient_weights_without_saving_them() {
|
||||
let mut h = Harness::new();
|
||||
enter(&mut h.app, true).unwrap();
|
||||
let document = h.app.session.doc.clone();
|
||||
let history = h.app.session.undo.len();
|
||||
h.app.run("render.lights.solo", json!({"id":"directional:1","solo":true})).unwrap();
|
||||
let raster = image_request(&h.app).unwrap();
|
||||
assert_eq!(raster["studio_weights"], json!([0.0, 1.0, 0.0]));
|
||||
h.app.render_workspace.view.method = ImageMethod::GpuRaytrace;
|
||||
assert_eq!(image_request(&h.app).unwrap()["studio_weights"], json!([0.0, 1.0, 0.0]));
|
||||
assert!(Arc::ptr_eq(&document, &h.app.session.doc));
|
||||
assert_eq!(h.app.session.undo.len(), history);
|
||||
assert!(serde_json::to_value(setups::snapshot(&h.app).unwrap()).unwrap().get("studio_weights").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_list_inspects_unsaved_ui_draft_without_applying_or_opening_anything() {
|
||||
let mut h = Harness::new();
|
||||
enter(&mut h.app, true).unwrap();
|
||||
h.app.render_workspace.view.method = ImageMethod::CpuRaytrace;
|
||||
h.app.render_workspace.view.raytrace.lights =
|
||||
Some(vec![solidcraft_engine::render::job::DirectionalLightOptions { direction: [0.0, 0.0, 1.0], color: [1.0, 0.5, 0.25], intensity: 7.0 }]);
|
||||
h.app.run("view.render_select", json!({"kind":"environment"})).unwrap();
|
||||
let document = h.app.session.doc.clone();
|
||||
let before = (h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision, h.app.session.is_dirty());
|
||||
let camera = h.app.cam;
|
||||
let page = h.app.render_workspace.view.inspector.page;
|
||||
let snapshot = setups::snapshot(&h.app).unwrap();
|
||||
let reply = h.app.run("render.lights.list", json!({"settings":snapshot})).unwrap();
|
||||
assert_eq!(reply["lights"].as_array().unwrap().len(), 1);
|
||||
assert_eq!(reply["lights"][0]["id"], "directional:0");
|
||||
assert_eq!(reply["lights"][0]["name"], "Key");
|
||||
assert_eq!(reply["lights"][0]["intensity"], 7.0);
|
||||
assert!(Arc::ptr_eq(&document, &h.app.session.doc));
|
||||
assert_eq!(before, (h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision, h.app.session.is_dirty()));
|
||||
assert_eq!(h.app.cam, camera);
|
||||
assert_eq!(h.app.render_workspace.view.selection, RenderSelection::Environment);
|
||||
assert_eq!(h.app.render_workspace.view.inspector.page, page);
|
||||
assert_eq!(setups::snapshot(&h.app).unwrap(), snapshot);
|
||||
assert!(h.app.render_workspace.view.job.is_none());
|
||||
assert!(h.app.dialog.is_none() && h.app.tool.is_none());
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod async_path_host {
|
||||
use super::*;
|
||||
@@ -967,6 +1103,7 @@ fn opaque_pbr_product_gpu_and_cpu_share_color_and_material_semantics() {
|
||||
let mut task = ImageTask::new(
|
||||
scene,
|
||||
ImageRequest {
|
||||
studio_weights: None,
|
||||
environment: None,
|
||||
textures: None,
|
||||
camera,
|
||||
@@ -2750,22 +2887,6 @@ fn clicked_setup_save_reload_and_switch_keep_gpu_numeric_intent_without_a_host()
|
||||
let completed = h.app.render_workspace.view.completed;
|
||||
let result_camera = h.app.render_workspace.view.result_camera;
|
||||
h.frames(3);
|
||||
// Open the real editors inside the bounded, scrolling floating card.
|
||||
let open_section = |h: &mut Harness, handle: String| {
|
||||
for _ in 0..4 {
|
||||
let at = crate::scenario::handle_at(&handle).unwrap();
|
||||
let inspector = crate::scenario::rect_of("render:inspector").unwrap();
|
||||
let top = crate::scenario::rect_of("render:inspector:header").unwrap().bottom() + Tokens::get().space_8;
|
||||
let bottom = crate::scenario::rect_of("render:job-footer").map_or(inspector.bottom(), |r| r.top()) - Tokens::get().space_8;
|
||||
if (top..=bottom).contains(&at.y) {
|
||||
break;
|
||||
}
|
||||
let x = crate::scenario::rect_of("render:inspector").unwrap().center().x;
|
||||
h.call("ui.scroll", json!({"x":x,"y":(top+bottom)/2.0,"delta":at.y.clamp(top,bottom)-at.y}));
|
||||
h.frames(20);
|
||||
}
|
||||
h.step(&json!({"click":{"handle":handle}})).unwrap();
|
||||
};
|
||||
h.app.run("view.render_select", json!({"kind":"sampling"})).unwrap();
|
||||
h.frames(3);
|
||||
h.app.run("view.render_select", json!({"kind":"effects"})).unwrap();
|
||||
@@ -2773,10 +2894,10 @@ fn clicked_setup_save_reload_and_switch_keep_gpu_numeric_intent_without_a_host()
|
||||
h.app.run("view.render_select", json!({"kind":"nothing"})).unwrap();
|
||||
h.app.run("view.render_stage", json!({"stage":"light"})).unwrap();
|
||||
h.frames(3);
|
||||
open_section(&mut h, format!("dialog:section:{} 1", crate::i18n::tr("render.studio_area")));
|
||||
h.app.start("render.hdr.inspect");
|
||||
h.app.run("view.render_select", json!({"kind":"lighting"})).unwrap();
|
||||
h.frames(3);
|
||||
h.app.run("view.render_stage", json!({"stage":"frame"})).unwrap();
|
||||
assert_eq!(setups::snapshot(&h.app).unwrap(), expected);
|
||||
h.app.run("view.render_select", json!({"kind":"light","id":"area:0"})).unwrap();
|
||||
h.frames(3);
|
||||
assert_eq!(setups::snapshot(&h.app).unwrap(), expected);
|
||||
assert!(!h.app.render_workspace.view.dirty);
|
||||
@@ -2840,10 +2961,10 @@ fn cpu_setup_reload_preserves_unedited_numeric_options_and_explicit_empty_values
|
||||
h.app.render_workspace.view.name = "CPU numeric".into();
|
||||
setups::load(&mut h.app);
|
||||
h.frames(3);
|
||||
for key in ["render.cpu_lights", "render.cpu_directional"] {
|
||||
let label = if key == "render.cpu_directional" { format!("{} 1", h.app.tr(key)) } else { h.app.tr(key).to_string() };
|
||||
h.step(&json!({"click":{"handle":format!("dialog:section:{label}")}})).unwrap();
|
||||
}
|
||||
h.app.run("view.render_select", json!({"kind":"lighting"})).unwrap();
|
||||
h.frames(3);
|
||||
assert_eq!(setups::snapshot(&h.app).unwrap(), expected);
|
||||
h.app.run("view.render_select", json!({"kind":"light","id":"directional:0"})).unwrap();
|
||||
h.frames(3);
|
||||
assert_eq!(setups::snapshot(&h.app).unwrap(), expected);
|
||||
assert_eq!(image_request(&h.app).unwrap(), json!({"settings":expected}));
|
||||
@@ -3264,6 +3385,7 @@ fn cpu_resource_profile_edits_preserve_resolution_samples_and_saved_intent() {
|
||||
fn large_image_display_uses_captured_profile_and_keeps_export_pixels_unchanged() {
|
||||
use solidcraft_engine::render::job::{CpuBudget, ImageRequest, RaytraceOptions};
|
||||
let request = ImageRequest {
|
||||
studio_weights: None,
|
||||
integrator: Integrator::Raytrace,
|
||||
raytrace: Some(RaytraceOptions { budget: CpuBudget::Studio, ..Default::default() }),
|
||||
camera: Camera::default(),
|
||||
@@ -4521,7 +4643,7 @@ fn navigation_bar_render_canvases_filter_slots_and_keep_product_fit() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_workspace_browser_sections_and_lights_describe_only_current_job_entries() {
|
||||
fn render_lights_browser_sections_and_lights_describe_current_job_entries() {
|
||||
let mut h = Harness::new();
|
||||
h.call("ui.resize", json!({"width":1440,"height":1100}));
|
||||
enter(&mut h.app, true).unwrap();
|
||||
@@ -4530,7 +4652,7 @@ fn render_workspace_browser_sections_and_lights_describe_only_current_job_entrie
|
||||
for section in ["Environment", "Lights", "Shots", "Objects"] {
|
||||
assert!(rows.iter().any(|label| label == section), "{section}: {rows:?}");
|
||||
}
|
||||
assert!(scene::light_types(&h.app).is_empty());
|
||||
assert_eq!(scene::light_types(&h.app), vec!["render.tree_directional"; 3]);
|
||||
assert_eq!(scene::environment(&h.app).0, "Fixed studio");
|
||||
h.app.render_workspace.view.method = ImageMethod::CpuRaytrace;
|
||||
h.app.render_workspace.view.raytrace = serde_json::from_value(json!({
|
||||
@@ -4551,7 +4673,7 @@ fn render_workspace_browser_sections_and_lights_describe_only_current_job_entrie
|
||||
h.app.render_workspace.view.method = ImageMethod::GpuRaytrace;
|
||||
let studio = &mut h.app.render_workspace.view.studio;
|
||||
studio.sun_enabled = true;
|
||||
assert!(scene::light_types(&h.app).is_empty(), "disabled rig must not expose editor defaults");
|
||||
assert_eq!(scene::light_types(&h.app), vec!["render.tree_directional"; 3], "implicit studio sources are listed");
|
||||
h.app.render_workspace.view.studio.lighting_enabled = true;
|
||||
h.app
|
||||
.render_workspace
|
||||
@@ -4567,7 +4689,7 @@ fn render_workspace_browser_sections_and_lights_describe_only_current_job_entrie
|
||||
h.frames(3);
|
||||
h.step(&json!({"click":{"handle":"render:tree:environment:current"}})).unwrap();
|
||||
assert_eq!(h.app.render_workspace.view.inspector.page, inspector::Page::Environment);
|
||||
h.step(&json!({"click":{"browser":"Sun"}})).unwrap();
|
||||
h.step(&json!({"click":{"browser":"Key"}})).unwrap();
|
||||
assert_eq!(h.app.render_workspace.view.inspector.page, inspector::Page::Lighting);
|
||||
}
|
||||
|
||||
@@ -4588,6 +4710,8 @@ fn render_workspace_browser_look_lens_counts_distinct_objects_and_selects_them()
|
||||
assert_eq!(groups[red].objects, ["A", "B", "C"]);
|
||||
assert_eq!(groups.len(), 2);
|
||||
h.app.render_workspace.view.by_look = true;
|
||||
// Keep the object rows inside the ten-row Browser viewport while testing their hover.
|
||||
crate::browser::toggle(&mut h.app, "render:tree:lights", true);
|
||||
h.frames(3);
|
||||
let at = crate::scenario::handle_at("row:A").unwrap();
|
||||
h.step(&json!({"move":[at.x,at.y]})).unwrap();
|
||||
@@ -4708,7 +4832,7 @@ fn render_workspace_browser_shot_switch_keeps_the_existing_dirty_confirmation()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_workspace_browser_focus_covers_each_kind_without_design_edits() {
|
||||
fn render_lights_browser_focus_covers_each_kind_without_design_edits() {
|
||||
use solidcraft_engine::Sel;
|
||||
let mut h = Harness::new();
|
||||
h.call("ui.resize", json!({"width":1440,"height":1400}));
|
||||
@@ -4734,11 +4858,24 @@ fn render_workspace_browser_focus_covers_each_kind_without_design_edits() {
|
||||
assert!(h.app.session.selection.is_empty());
|
||||
let focused_revision = h.app.session.revision;
|
||||
h.step(&json!({"click":{"handle":"render:tree:light:0"}})).unwrap();
|
||||
assert!(matches!(&h.app.render_workspace.view.selection, RenderSelection::Light(id) if id.contains("sun")));
|
||||
assert!(matches!(&h.app.render_workspace.view.selection, RenderSelection::Light(id) if id=="directional:0"));
|
||||
setups::load(&mut h.app);
|
||||
h.frames(3);
|
||||
h.step(&json!({"click":{"handle":"render:tree:shot:Shot"}})).unwrap();
|
||||
assert_eq!(h.app.render_workspace.view.selection, RenderSelection::Shot("Shot".into()));
|
||||
// The browser is height-capped even in a tall window. Output is its last row,
|
||||
// and published targets can lie below the scroll clip as more rows are added.
|
||||
let browser = crate::scenario::rect_of("browser:card").unwrap();
|
||||
let header = crate::scenario::rect_of("render:browser:header").unwrap();
|
||||
h.call("ui.scroll", json!({"x":browser.center().x,"y":(header.bottom()+browser.bottom())/2.0,"delta":-2000}));
|
||||
h.frames(20);
|
||||
let browser = crate::scenario::rect_of("browser:card").unwrap();
|
||||
let header = crate::scenario::rect_of("render:browser:header").unwrap();
|
||||
let output = crate::scenario::handle_at("render:tree:output").unwrap();
|
||||
assert!(
|
||||
browser.shrink(Tokens::get().space_8).contains(output) && output.y > header.bottom(),
|
||||
"Output click must be inside the visible browser body"
|
||||
);
|
||||
h.step(&json!({"click":{"handle":"render:tree:output"}})).unwrap();
|
||||
assert_eq!(h.app.render_workspace.view.selection, RenderSelection::Output);
|
||||
h.app.run("view.render_select", json!({"kind":"nothing"})).unwrap();
|
||||
@@ -4751,37 +4888,27 @@ fn render_workspace_browser_focus_covers_each_kind_without_design_edits() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_workspace_browser_add_and_light_actions_share_disabled_reasons_and_never_edit() {
|
||||
fn has_text(shape: &egui::Shape, needle: &str) -> bool {
|
||||
match shape {
|
||||
egui::Shape::Text(text) => text.galley.text().contains(needle),
|
||||
egui::Shape::Vec(shapes) => shapes.iter().any(|shape| has_text(shape, needle)),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
let mut h = Harness::new();
|
||||
h.call("ui.resize", json!({"width":1440,"height":1200}));
|
||||
enter(&mut h.app, true).unwrap();
|
||||
h.app.render_workspace.view.method = ImageMethod::GpuRaytrace;
|
||||
h.app.render_workspace.view.studio.lighting_enabled = true;
|
||||
h.app.render_workspace.view.studio.sun_enabled = true;
|
||||
fn render_lights_browser_eye_and_solo_are_view_state_and_editor_opening_is_read_only() {
|
||||
let mut h = render_lights_fixture();
|
||||
h.frames(3);
|
||||
let doc = h.app.session.doc.clone();
|
||||
let history = (h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision);
|
||||
for target in ["render:tree:lights:add", "render:tree:light:0:solo", "render:tree:light:0:mute", "render:tree:light:0:visibility"] {
|
||||
assert!(crate::scenario::handle_at(target).is_none(), "{target} must be disabled");
|
||||
let at = crate::scenario::rect_of(target).unwrap().center();
|
||||
h.step(&json!({"move":[at.x,at.y]})).unwrap();
|
||||
h.frames(120);
|
||||
assert!(h.shapes.iter().any(|s| has_text(&s.shape, h.app.tr("render.tree_lights_pending"))), "{target}: must show its disabled reason");
|
||||
h.step(&json!({"click":[at.x,at.y]})).unwrap();
|
||||
assert_eq!(h.app.render_workspace.view.selection, RenderSelection::Nothing);
|
||||
}
|
||||
assert!(crate::browser::drawn_rows().iter().any(|row| row.0 == "Key"));
|
||||
assert!(crate::browser::drawn_rows().iter().any(|row| row.0 == "Fill"));
|
||||
let document = h.app.session.doc.clone();
|
||||
let before = (h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision, h.app.session.is_dirty());
|
||||
h.step(&json!({"click":{"handle":"eye:Key"}})).unwrap();
|
||||
assert!(!h.app.render_workspace.view.lights.visibility.visible("directional:0"));
|
||||
h.step(&json!({"click":{"handle":"render:tree:light:1:solo"}})).unwrap();
|
||||
assert_eq!(h.app.render_workspace.view.lights.visibility.solo.as_deref(), Some("directional:1"));
|
||||
h.step(&json!({"click":{"handle":"render:tree:light:1"}})).unwrap();
|
||||
h.frames(3);
|
||||
assert_eq!(h.app.render_workspace.view.inspector.page, inspector::Page::Lighting);
|
||||
assert!(crate::scenario::rect_of("render:light:editor").is_some());
|
||||
assert!(crate::scenario::handle_at("render:tree:shots:add").is_some());
|
||||
h.step(&json!({"click":{"handle":"render:tree:shots:add"}})).unwrap();
|
||||
assert_eq!(h.app.render_workspace.view.inspector.page, inspector::Page::Scene);
|
||||
assert!(Arc::ptr_eq(&doc, &h.app.session.doc));
|
||||
assert_eq!(history, (h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision));
|
||||
assert!(Arc::ptr_eq(&document, &h.app.session.doc));
|
||||
assert_eq!(before, (h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision, h.app.session.is_dirty()));
|
||||
assert!(h.app.render_workspace.view.job.is_none());
|
||||
assert!(h.app.dialog.is_none());
|
||||
}
|
||||
|
||||
@@ -4818,6 +4945,7 @@ fn render_workspace_browser_semantic_focus_survives_clearing_object_picks() {
|
||||
let before = (h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.is_dirty());
|
||||
for (request, expected) in [
|
||||
(json!({"kind":"environment"}), RenderSelection::Environment),
|
||||
(json!({"kind":"lighting"}), RenderSelection::Lighting),
|
||||
(json!({"kind":"light","id":"sun"}), RenderSelection::Light("sun".into())),
|
||||
(json!({"kind":"shot","id":"Shot"}), RenderSelection::Shot("Shot".into())),
|
||||
(json!({"kind":"output"}), RenderSelection::Output),
|
||||
@@ -4845,6 +4973,7 @@ fn render_workspace_browser_focus_is_per_document_and_invalid_selection_is_atomi
|
||||
json!({"kind":"object"}),
|
||||
json!({"kind":"light"}),
|
||||
json!({"kind":"shot","id":""}),
|
||||
json!({"kind":"lighting","id":"extra"}),
|
||||
json!({"kind":"output","id":"x"}),
|
||||
json!({"kind":"shot","id":"x".repeat(1025)}),
|
||||
json!({"kind":"nothing","extra":1}),
|
||||
@@ -5584,7 +5713,7 @@ fn output_viewer_evidence() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn output_viewer_radial_defaults_keep_planned_actions_disabled() {
|
||||
fn output_viewer_radial_defaults_enable_lights_and_keep_planned_compare_disabled() {
|
||||
let h = output_viewer_fixture();
|
||||
let expected = [
|
||||
"render.start",
|
||||
@@ -5597,9 +5726,8 @@ fn output_viewer_radial_defaults_keep_planned_actions_disabled() {
|
||||
"undo",
|
||||
];
|
||||
assert_eq!(crate::mouse_gesture::Studio::Render.defaults(), expected);
|
||||
for id in ["render.lights.add", "render.compare"] {
|
||||
assert!(!crate::mouse_gesture::item(&h.app, id).unwrap().enabled);
|
||||
}
|
||||
assert!(crate::mouse_gesture::item(&h.app, "render.lights.add").unwrap().enabled);
|
||||
assert!(!crate::mouse_gesture::item(&h.app, "render.compare").unwrap().enabled);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -5887,6 +6015,64 @@ fn render_assign_gestures_labels_translate_in_all_five_catalogs() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lighting_group_selection_opens_ordered_editor_and_plus_still_adds() {
|
||||
let mut h = render_lights_fixture();
|
||||
h.call("ui.resize", json!({"width":1440,"height":2400}));
|
||||
let before = h.app.session.doc.clone();
|
||||
h.frames(3);
|
||||
h.step(&json!({"click":{"handle":"render:tree:lights"}})).unwrap();
|
||||
assert_eq!(h.app.render_workspace.view.selection, RenderSelection::Lighting);
|
||||
assert_eq!(h.app.render_workspace.view.inspector.page, inspector::Page::Lighting);
|
||||
assert!(crate::scenario::rect_of("render:lighting:editor").is_some());
|
||||
assert!(Arc::ptr_eq(&before, &h.app.session.doc));
|
||||
let sections: Vec<_> = ["render.lighting_source_section", "render.lighting_shadows_section", "render.lighting_budget"]
|
||||
.iter()
|
||||
.map(|key| crate::scenario::rect_of(&format!("dialog:section:{}", h.app.tr(key))).unwrap())
|
||||
.collect();
|
||||
assert!(sections.windows(2).all(|pair| pair[0].bottom() <= pair[1].top()));
|
||||
h.step(&json!({"click":{"handle":"render:tree:lights:add"}})).unwrap();
|
||||
assert!(light::rows(&h.app).unwrap().iter().any(|l| l.geometry.kind() == "area"));
|
||||
assert_eq!(h.app.render_workspace.view.selection, RenderSelection::Light("area:0".into()));
|
||||
assert!(crate::scenario::rect_of("render:light:editor").is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lighting_methods_show_reasons_and_budgets_without_changing_method_or_design() {
|
||||
for method in [ImageMethod::Raster, ImageMethod::CpuRaytrace, ImageMethod::GpuRaytrace] {
|
||||
let mut h = render_lights_fixture();
|
||||
h.call("ui.resize", json!({"width":1440,"height":2400}));
|
||||
if method == ImageMethod::GpuRaytrace {
|
||||
h.app.run("render.settings.set", json!({"name":"Studio","set":{"job":{"method":"gpu_path","options":{"lighting":{}}}}})).unwrap();
|
||||
setups::load(&mut h.app);
|
||||
} else {
|
||||
h.app.render_workspace.view.method = method;
|
||||
}
|
||||
h.app.run("view.render_select", json!({"kind":"lighting"})).unwrap();
|
||||
let before = h.app.session.doc.clone();
|
||||
let revision = h.app.session.revision;
|
||||
h.frames(3);
|
||||
for section in ["render.lighting_source_section", "render.lighting_shadows_section", "render.lighting_budget"] {
|
||||
assert!(crate::scenario::rect_of(&format!("dialog:section:{}", h.app.tr(section))).is_some());
|
||||
}
|
||||
let reason = match method {
|
||||
ImageMethod::Raster => "render.method_limit_raster",
|
||||
ImageMethod::CpuRaytrace => "render.lighting_samples_need_area",
|
||||
ImageMethod::GpuRaytrace => "render.light_gpu_punctual",
|
||||
};
|
||||
assert!(crate::scenario::rect_of(&format!("dialog:note:{reason}")).is_some());
|
||||
if method == ImageMethod::GpuRaytrace {
|
||||
assert!(crate::scenario::rect_of("dialog:note:render.lighting_shadow_cpu").is_some());
|
||||
assert!(crate::scenario::rect_of("dialog:note:render.lighting_samples_cpu").is_some());
|
||||
}
|
||||
assert!(h.widget(h.app.tr("render.lighting_budget_help")).is_some());
|
||||
assert_eq!(h.app.render_workspace.view.method, method);
|
||||
assert_eq!(h.app.session.revision, revision);
|
||||
assert!(Arc::ptr_eq(&before, &h.app.session.doc));
|
||||
assert!(h.app.dialog.is_none() && h.app.render_workspace.view.job.is_none());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_assign_gestures_stage_tools_and_selection_actions_use_commands() {
|
||||
let (mut h, _) = render_pick_sample();
|
||||
@@ -6011,3 +6197,116 @@ fn render_assign_gestures_geometry_and_theme_evidence() {
|
||||
}
|
||||
crate::theme::set_dark(previous);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lights_each_kind_contains_design_sections_and_real_parameter_fields_in_order() {
|
||||
for (method, kind) in
|
||||
[("cpu_raytrace", "area"), ("cpu_raytrace", "point"), ("cpu_raytrace", "directional"), ("gpu_path", "area"), ("gpu_path", "directional")]
|
||||
{
|
||||
let mut h = render_lights_fixture();
|
||||
h.call("ui.resize", json!({"width":1440,"height":3000}));
|
||||
let options = if method == "gpu_path" { json!({"lighting":{}}) } else { json!({"lights":[],"punctual_lights":[],"area_lights":[]}) };
|
||||
h.app.run("render.settings.set", json!({"name":"Studio","set":{"job":{"method":method,"options":options}}})).unwrap();
|
||||
setups::load(&mut h.app);
|
||||
light::edit(&mut h.app, "render.lights.add", None, Some(json!({"kind":kind}))).unwrap();
|
||||
h.app.render_workspace.view.inspector.page = inspector::Page::Lighting;
|
||||
let before = h.app.session.doc.clone();
|
||||
h.frames(3);
|
||||
assert!(crate::scenario::rect_of("render:light:editor").is_some());
|
||||
let mut sections = vec!["render.light_position"];
|
||||
if kind == "area" {
|
||||
sections.push("render.lighting_shape");
|
||||
}
|
||||
if kind == "point" {
|
||||
sections.push("render.lighting_falloff");
|
||||
}
|
||||
sections.push("render.light_behaviour");
|
||||
let rects: Vec<_> = sections.iter().map(|key| crate::scenario::rect_of(&format!("dialog:section:{}", h.app.tr(key))).unwrap()).collect();
|
||||
assert!(rects.windows(2).all(|pair| pair[0].bottom() <= pair[1].top()), "{method}/{kind}");
|
||||
let fields: &[&str] = match kind {
|
||||
"area" => &["width_mm", "height_mm", "radiance:0", "edge_u_mm:0", "edge_v_mm:0", "position_mm:0"],
|
||||
"point" => &["reference_distance_mm", "minimum_distance_mm", "position_mm:0"],
|
||||
_ => &["direction:0", "direction:1", "direction:2"],
|
||||
};
|
||||
for field in fields {
|
||||
assert!(crate::scenario::rect_of(&format!("render:light:{field}")).is_some(), "{method}/{kind}: {field}");
|
||||
}
|
||||
for key in ["render.lighting_solo", "render.lighting_mute", "render.light_duplicate", "render.light_delete"] {
|
||||
assert!(h.widget(h.app.tr(key)).is_some(), "{method}/{kind}: {key}");
|
||||
}
|
||||
assert!(crate::scenario::rect_of("dialog:note:render.light_place_pending").is_some());
|
||||
assert!(Arc::ptr_eq(&before, &h.app.session.doc));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lighting_preset_materialises_values_and_replacement_requires_review_consent() {
|
||||
let mut h = render_lights_fixture();
|
||||
h.call("ui.resize", json!({"width":1440,"height":2400}));
|
||||
h.app.run("view.render_select", json!({"kind":"lighting"})).unwrap();
|
||||
h.frames(3);
|
||||
let before = h.app.session.doc.clone();
|
||||
h.step(&json!({"click":{"handle":"render:lighting:preset"}})).unwrap();
|
||||
assert!(Arc::ptr_eq(&before, &h.app.session.doc));
|
||||
// Confirm's primary action is disabled until its explicit acknowledgement.
|
||||
h.step(&json!({"widget":h.app.tr("render.lighting_consent")})).unwrap();
|
||||
h.step(&json!({"widget":h.app.tr("render.lighting_apply")})).unwrap();
|
||||
assert!(h.app.render_workspace.view.raytrace.preset.is_some());
|
||||
assert!(h.app.render_workspace.view.raytrace.lights.is_none());
|
||||
let lights = light::rows(&h.app).unwrap();
|
||||
let undo = h.app.session.undo.len();
|
||||
h.step(&json!({"click":{"handle":"render:lighting:custom"}})).unwrap();
|
||||
assert!(h.app.render_workspace.view.raytrace.preset.is_none());
|
||||
assert_eq!(h.app.render_workspace.view.raytrace.lights.as_ref().unwrap().len(), lights.len());
|
||||
let materialised = light::rows(&h.app).unwrap();
|
||||
for (before, after) in lights.iter().zip(materialised) {
|
||||
assert_eq!(before.colour, after.colour);
|
||||
assert_eq!(before.intensity, after.intensity);
|
||||
}
|
||||
assert_eq!(h.app.session.undo.len(), undo + 1);
|
||||
assert_eq!(h.app.render_workspace.view.selection, RenderSelection::Lighting);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lighting_hostile_numeric_edits_refuse_without_panics_or_partial_state() {
|
||||
let mut h = render_lights_fixture();
|
||||
light::edit(&mut h.app, "render.lights.add", None, Some(json!({"kind":"point"}))).unwrap();
|
||||
let before = h.app.session.doc.clone();
|
||||
let history = h.app.session.undo.len();
|
||||
for set in
|
||||
[json!({"reference_distance_mm":1e300}), json!({"minimum_distance_mm":-1}), json!({"position_mm":[1e300,0,0]}), json!({"direction":[0,0,0]})]
|
||||
{
|
||||
assert!(light::edit(&mut h.app, "render.lights.set", Some("point:0"), Some(set)).is_err());
|
||||
assert!(Arc::ptr_eq(&before, &h.app.session.doc));
|
||||
assert_eq!(h.app.session.undo.len(), history);
|
||||
}
|
||||
h.app.render_workspace.view.inspector.page = inspector::Page::Lighting;
|
||||
h.frames(3);
|
||||
assert!(crate::scenario::rect_of("render:light:editor").is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_lighting_shadow_edits_are_undoable_and_preset_reviews_reject_changed_drafts() {
|
||||
let mut h = render_lights_fixture();
|
||||
h.call("ui.resize", json!({"width":1440,"height":2400}));
|
||||
h.app.run("view.render_select", json!({"kind":"lighting"})).unwrap();
|
||||
h.frames(3);
|
||||
let before = h.app.session.doc.clone();
|
||||
let undo = h.app.session.undo.len();
|
||||
h.step(&json!({"widget":h.app.tr("render.lighting_shadows")})).unwrap();
|
||||
assert!(!h.app.render_workspace.view.raytrace.shadows);
|
||||
assert_eq!(h.app.session.undo.len(), undo + 1);
|
||||
assert!(matches!(&h.app.session.doc.render.setups["Studio"].job,
|
||||
Some(solidcraft_engine::doc::render_settings::RenderJob::CpuRaytrace { options }) if !options.shadows));
|
||||
h.app.run("edit.undo", json!({})).unwrap();
|
||||
setups::load(&mut h.app);
|
||||
assert_eq!(h.app.session.doc, before);
|
||||
h.frames(3);
|
||||
h.step(&json!({"click":{"handle":"render:lighting:preset"}})).unwrap();
|
||||
assert!(h.widget(h.app.tr("render.lighting_consent")).is_some());
|
||||
h.app.render_workspace.view.draft.width = 1200;
|
||||
h.frames(3);
|
||||
assert!(h.widget(h.app.tr("render.lighting_consent")).is_none());
|
||||
assert_eq!(h.app.session.doc, before);
|
||||
assert_eq!(h.app.render_workspace.view.draft.width, 1200);
|
||||
}
|
||||
|
||||
@@ -138,6 +138,7 @@ pub(super) fn refresh(app: &mut SolveApp, ctx: &egui::Context) {
|
||||
let permit = WorkerPermit;
|
||||
let Some(setup) = app.session.doc.render.setups.get(&key.name) else { return };
|
||||
let request = solidcraft_engine::render::job::ImageRequest {
|
||||
studio_weights: None,
|
||||
camera: setup.camera,
|
||||
width: SIZE[0],
|
||||
height: SIZE[1],
|
||||
|
||||
@@ -266,6 +266,7 @@ pub(crate) fn view_frame(
|
||||
let none = || std::sync::Arc::new(std::sync::Mutex::new(None));
|
||||
crate::gpu::Frame {
|
||||
product: false,
|
||||
product_lights: None,
|
||||
key: model.0,
|
||||
slot: model.1.clone(),
|
||||
sketch_key: 0,
|
||||
|
||||
@@ -14,6 +14,8 @@ use egui::{Ui, vec2};
|
||||
pub(crate) struct Segments<'a> {
|
||||
/// Per-option availability; omitted entries are enabled. Unavailable options stay faded.
|
||||
pub enabled: &'a [bool],
|
||||
/// Optional per-option refusal reasons. Disabled options remain visible and explain why.
|
||||
pub disabled: &'a [Option<&'a str>],
|
||||
/// Optional stable scenario targets, independent of translated option labels.
|
||||
pub targets: &'a [&'a str],
|
||||
/// Optional leading icons retain the same text-segment geometry and accessibility.
|
||||
@@ -37,8 +39,21 @@ pub(crate) fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str], con
|
||||
if crate::prefs_search::querying(ui) && !crate::prefs_search::shows_all(ui) {
|
||||
crate::prefs_search::reveal(ui);
|
||||
}
|
||||
let Segments { enabled, targets, icons, workspace_accent, dense, small, states, disabled_reasons, compact, primary, intrinsic, proportional } =
|
||||
config;
|
||||
let Segments {
|
||||
enabled,
|
||||
disabled,
|
||||
targets,
|
||||
icons,
|
||||
workspace_accent,
|
||||
dense,
|
||||
small,
|
||||
states,
|
||||
disabled_reasons,
|
||||
compact,
|
||||
primary,
|
||||
intrinsic,
|
||||
proportional,
|
||||
} = config;
|
||||
let accent = crate::theme::TabAccent::current(ui.ctx());
|
||||
let t = Tokens::get();
|
||||
let catalog = super::layout::in_catalog(ui);
|
||||
@@ -61,6 +76,7 @@ pub(crate) fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str], con
|
||||
// Judged on the whole row, which is what a scrollbar narrows, not on one segment.
|
||||
let need = if intrinsic { total } else { (widest + 2.0 * t.space_8) * options.len() as f32 };
|
||||
if enabled.is_empty()
|
||||
&& disabled.is_empty()
|
||||
&& disabled_reasons.is_empty()
|
||||
&& !proportional
|
||||
&& !compact
|
||||
@@ -96,7 +112,7 @@ pub(crate) fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str], con
|
||||
if (intrinsic || proportional) && total > 0.0 { natural.get(index).copied().unwrap_or(0.0) * rect.width() / total } else { equal_width };
|
||||
let segment = egui::Rect::from_min_size(egui::pos2(x, rect.top()), vec2(width, rect.height()));
|
||||
x += width;
|
||||
let reason = disabled_reasons.get(index).copied().flatten();
|
||||
let reason = disabled_reasons.get(index).copied().flatten().or_else(|| disabled.get(index).copied().flatten());
|
||||
let id = ui.make_persistent_id(("segment", index));
|
||||
// The row is already allocated: a child scopes disabled painting and interaction
|
||||
// without advancing the parent's cursor once per segment.
|
||||
|
||||
@@ -76,6 +76,7 @@ pub(crate) struct RowResp {
|
||||
pub(crate) secondary: Option<Pos2>,
|
||||
pub(crate) fold: bool,
|
||||
pub(crate) eye: bool,
|
||||
pub(crate) eye_rect: Option<Rect>,
|
||||
pub(crate) radio: bool,
|
||||
/// The row's [`Row::action`] button was clicked.
|
||||
pub(crate) action: bool,
|
||||
@@ -200,6 +201,7 @@ pub(crate) fn tree_row(ui: &mut egui::Ui, id: egui::Id, row: &Row) -> RowResp {
|
||||
// Hidden or faded rows keep main's dimming, with the rounded suppression asset.
|
||||
icons::paint_icon(ui.painter(), er, if vis { "eye" } else { "suppress" }, if vis && !row.dim { 0.85 } else { DIM_ICON_OPACITY });
|
||||
out.eye = resp.clicked() && click_on == 2;
|
||||
out.eye_rect = Some(eye_r.intersect(ui.clip_rect()));
|
||||
crate::scenario::publish_handle(&format!("eye:{}", row.label), er.center());
|
||||
}
|
||||
if !row.compact {
|
||||
|
||||
@@ -4161,6 +4161,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let ssaa = supersampling(app, ui.ctx(), proj.vp.to_f32(), size_px);
|
||||
let ao_samples = ao_samples(app, ui.ctx(), proj.vp.to_f32(), size_px);
|
||||
let cb = ViewportCallback(Frame {
|
||||
product_lights: None,
|
||||
ssaa,
|
||||
ao_samples,
|
||||
product: false,
|
||||
@@ -7459,6 +7460,7 @@ mod tests {
|
||||
let proj = projection(&app, rect);
|
||||
let e = proj.cam.eye().to_f32();
|
||||
let frame = Frame {
|
||||
product_lights: None,
|
||||
product: false,
|
||||
key: 1,
|
||||
slot: slot.clone(),
|
||||
|
||||
+84
-1
@@ -28,6 +28,88 @@ or rename command in this slice.
|
||||
Named `get` returns `{name, setup}` or an error for a missing name. Without a name,
|
||||
it returns `{setups, defaults}`. Reads do not evaluate the model or change history.
|
||||
|
||||
`render.lights.list {setup: "Studio"}` returns a uniform `{lights: [...]}` read
|
||||
model without applying or saving anything. An unsaved client draft can instead
|
||||
pass `{settings: <complete RenderSetup>}`; `{}` inspects the default setup.
|
||||
Neither form selects a UI shot. Unknown parameters, null selectors, both selectors,
|
||||
missing setup names and invalid settings refuse without mutation or evaluation.
|
||||
CPU directional/point/spot/rectangle sources and GPU sun/rectangle sources expose
|
||||
`id`, `kind`, `name`, `name_key`, `number`, `implicit`, `intensity`, `colour` and
|
||||
their world-space geometry. Background and environment illumination are separate
|
||||
from this source list. Implicit fixed studios and CPU presets are expanded;
|
||||
explicit empty lists remain empty. GPU sky/HDR suppresses its implicit studio.
|
||||
|
||||
Light IDs use the kind and zero-based source slot (`directional:0`, `point:0`,
|
||||
`spot:1`, `area:0`); point and spot share indices in the punctual list. IDs survive
|
||||
numerical edits and repeated reads, but changing kind, reordering/removing lights
|
||||
or replacing a rig can change them. These are setup-local addresses, not durable
|
||||
document identities. Unnamed lights display Key, Fill, Rim, then Light 4, etc.;
|
||||
clients translate `name_key`, substituting `number` for later lights. Names are
|
||||
not persisted by this command.
|
||||
|
||||
Colour is linear RGB. CPU colour/intensity retain their saved values. GPU RGB
|
||||
radiance is factored into its largest channel as intensity and normalized colour
|
||||
(black uses intensity zero and white colour). Their product recovers radiance;
|
||||
no photometric equivalence between methods is implied. All rectangle edges are
|
||||
full side vectors in millimetres, including GPU half-edges multiplied by two.
|
||||
Directional vectors point towards a source; spot axes point from it. The optional
|
||||
directional `angular_radius_rad` identifies a finite GPU sun.
|
||||
|
||||
`render.lights.add`, `.set`, `.duplicate` and `.remove` edit a named setup in one
|
||||
undo step. They accept `name`, `id` except for add, optional complete `settings`
|
||||
as an unsaved starting point, and optional `expected_revision`. Add/set accept
|
||||
`set` with `kind`, `intensity_ev`, `temperature_k`, `softness`, `azimuth_deg`,
|
||||
`elevation_deg`, `distance_mm`, `size_mm`, `aim_at`, `width_mm`, `height_mm`,
|
||||
`position_mm`, `direction`, `edge_u_mm`, `edge_v_mm`, `radiance`, `colour`,
|
||||
`reference_distance_mm` and `minimum_distance_mm`. These lower into the existing
|
||||
light fields; there is no new saved light metadata. Temperature is an original
|
||||
three-band, 6500 K white-balanced Planck tint approximation stored as linear RGB.
|
||||
Area softness changes emitter size; GPU Sun softness changes angular radius.
|
||||
Hard CPU directional and point/spot sources refuse unsupported emitter softness.
|
||||
CPU admits 8 directional, 8 point/spot and 4 areas; GPU admits one Sun and four
|
||||
areas. GPU Point/Spot controls and the legacy three-directional GPU studio editor
|
||||
remain unavailable with reasons, rather than silently losing light sources.
|
||||
|
||||
`render.lights.solo {id?, solo}` and `render.lights.mute {id, mute}` validate and
|
||||
echo view requests. Enabling solo requires an id; disabling solo clears it.
|
||||
The UI also verifies that the address exists in its current lighting draft.
|
||||
`SolveApp::run` applies these replies to per-document `ViewState.lights`, never
|
||||
to a design or undo history. Shot changes clear this transient scope. Saving,
|
||||
undoing and reopening settings retain the unfiltered numerical setup.
|
||||
|
||||
`render_workspace_light::filter_request` filters copied settings at both
|
||||
`image_request` and `SolveApp::run`'s Check/Render boundary. Explicit sources keep
|
||||
their geometry and have zero intensity/radiance while off. Raster and the legacy
|
||||
GPU studio carry three optional `studio_weights` in the captured `ImageRequest`;
|
||||
they are finite 0..1 runtime values, never fields of `RenderSetup`. CPU raster
|
||||
uses them in `studio::shade_weighted`; the GPU path uses its captured uniform.
|
||||
CPU ray tracing and explicit GPU rigs refuse these fixed-studio weights.
|
||||
|
||||
The selectable Lights group runs `view.render_select {kind: "lighting"}` and opens
|
||||
Lighting: Light source, Shadows and sampling, then Budget. Its + still adds a
|
||||
light. CPU presets require review and consent before replacing directional lights;
|
||||
Custom materialises their existing values. GPU budgets show one Sun and four
|
||||
Areas; CPU eight directional and eight point/spot plus four Areas. Counts are
|
||||
read-only sliders. Unsupported controls stay faded with a reason. No rig identity
|
||||
is saved, so there is no Rig row.
|
||||
|
||||
Browser eyes and solo actions run the same view commands. A selected light mounts
|
||||
`render_workspace_light::editor` in the Inspector's Lighting page. Without a
|
||||
selected light, that page calls the same group editor. Light has a name/type
|
||||
header, Area/Point/Sun segments, intensity, temperature and softness; Position;
|
||||
Shape for areas; Falloff for points; and Behaviour (Solo, Mute, Duplicate, Delete).
|
||||
Distances displayed as subject-size multiples lower to millimetres. Width U and
|
||||
Height V are full side lengths (GPU storage uses half-edges). Independent vector
|
||||
edits preserve the other side. Radiance and temperature lower to existing linear
|
||||
RGB fields. Sun directions remain world vectors. Every edit is bounded and finite,
|
||||
with the renderer validating the complete candidate. Opening an editor
|
||||
does not apply or save anything. Edits run the four light commands; Place by
|
||||
highlight stays disabled with its viewport-picking reason. The live product view
|
||||
receives bounded analytic light samples in `Frame.product_lights`; both PBR and
|
||||
non-PBR/transparent batches use them. This is an unshadowed preview, with area
|
||||
emitters sampled at their centre and constant ambient illumination. HDR transport
|
||||
and full emitter sampling remain the image renderer's responsibility.
|
||||
|
||||
| Field | Default | Saved contract |
|
||||
|---|---|---|
|
||||
| `backend` | `builtin` | Valid R1 backend ID, at most 64 ASCII bytes; unavailable IDs survive reopen |
|
||||
@@ -138,7 +220,8 @@ The engine resolves the typed job **before** choosing CPU or GPU dispatch. A sav
|
||||
progressive sampling cannot replace it. A missing or unsupported host blocks
|
||||
Check/Start while leaving the saved intent intact.
|
||||
|
||||
For a complete job, the only additional request field is `replace`. Parallel
|
||||
For a complete job, additional request fields are `replace` and optional transient
|
||||
`studio_weights` for a fixed studio. Parallel
|
||||
runtime controls such as `progressive`, `integrator`, `raytrace`, `lens`,
|
||||
`environment` or `transparent_background` fail, including explicit null/false
|
||||
values. They cannot silently override a setup. For legacy `job` absent/null, the
|
||||
|
||||
Reference in New Issue
Block a user