Jump to content

Adding GodRays


metaldc4life
 Share

Recommended Posts

You can attach this to your directional light as a script to get the correct calculations :

 

function Script:Start()

 

self.world=World:GetCurrent()

if self.camera==nil then

for i=0,self.world:CountEntities()-1 do

if self.world:GetEntity(i):GetClass()==Object.CameraClass then

self.camera=self.world:GetEntity(i)

tolua.cast(self.camera,"Camera")

System:Print(self.world:GetEntity(i):GetClassName())

break

end

end

end

 

if self.camera then

local light=self.entity

self.dir = Vec3(light.mat.k.x,light.mat.k.y,light.mat.k.z):Normalize()

--sun raw position is then:

self.sunrawpos=Vec3(-self.dir.x,-self.dir.y,-self.dir.z)

self.camera:SetKeyValue("godray_pos",self.sunrawpos:ToString())

end

end

  • Upvote 2

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...