Re: カメラ角を修正したノーマル

投稿ツリー


このトピックの投稿一覧へ

通常 Re: カメラ角を修正したノーマル

msg# 1.2.1.1
depth:
3
前の投稿 - 次の投稿 | 親投稿 - 子投稿.1 .2 | 投稿日時 2008/5/20 19:15
ekakiya  半人前 居住地: 東京  投稿数: 38
2.46で pyNodeが入ったので、さっそく対応してみました。
以下のコードをDynamicノードに読み込んで、normalを入力すれば
カメラ角度を考慮したnormalに変換されます。

これで、フレネルやトゥーンの輪郭線が扱いやすくなりそうです!


from Blender import Node
import math

class MyNode(Node.Scripted):

	def __init__(self, sockets):
		normal = Node.Socket('Normal', val = [1.0, 1.0, 1.0, 1.0])
		sockets.input = [normal]
		sockets.output = [normal]

	def __call__(self):
		ocol = list(self.input.normal)
		ocol2 = list(self.input.normal)

		ocol2[0] = ocol[0] * math.cos(-self.s.surfaceViewVector[0]) - ocol[2] * math.sin(-self.s.surfaceViewVector[0])
		ocol2[1] = ocol[1]
		ocol2[2] = ocol[0] * math.sin(-self.s.surfaceViewVector[0]) + ocol[2] * math.cos(-self.s.surfaceViewVector[0])

		ocol[0] = ocol2[0]
		ocol[1] = ocol2[1] * math.cos(self.s.surfaceViewVector[1]) + ocol2[2] * math.sin(self.s.surfaceViewVector[1])
		ocol[2] = ocol2[2] * math.cos(self.s.surfaceViewVector[1]) - ocol2[1] * math.sin(self.s.surfaceViewVector[1])

		self.output.normal = ocol

__node__ = MyNode

投票数:0 平均点:0.00

  条件検索へ


ログイン

ユーザ名:

パスワード:



パスワード紛失

クイックリンク

2021/07/01版
●Blender.org
BlenderFoundation
- Blenderのダウンロード
- 公式チュート等
- 公式マニュアル(和訳)

●ニュース(英文)
BlenderNation

●Blenderコミュニティ
blenderartists.org

●Blender Q&A
- Blender Stack Exchange

●テストビルド
Buildbot(自動生成)


●開発関連
公式開発サイト
Blender開発blog
Blender Wiki