Dinamic Blob Shadows!
Moderator: Moderators
Re: Dinamic Blob Shadows!
lol that sepia filter is done using a a image editing program.
- very_bad_soldier
- Posts: 1397
- Joined: 20 Feb 2007, 01:10
Re: Dinamic Blob Shadows!
Hm, where do you got it from? In CA-SVN I can only find "unit_blobshadow.lua" which is not "dynamic blob shadows" AFAIK. Has this thingie ever been finished actually?Kixxe wrote:Yea i got it now but i don't see the widget when i load up 1944. Can't someone just upload it so it's avalible without downloading a full mod?
-
- Posts: 1176
- Joined: 23 Aug 2007, 19:46
- very_bad_soldier
- Posts: 1397
- Joined: 20 Feb 2007, 01:10
Re: Dinamic Blob Shadows!
I tell you if you tell me where to download. 

Re: Dinamic Blob Shadows!
Sorry, didn't realize that this was a source request, would have dropped this off earlier. Here's my current version of this Widget, I've had it in World Builder for quite some time.
I've been maintaining a version since User disappeared. That bug that was mentioned is fixed in this version.
I've been maintaining a version since User disappeared. That bug that was mentioned is fixed in this version.
Code: Select all
function widget:GetInfo()
return {
name = "Dynamic Blob Shadows",
desc = "Creates shadow projections from the sun position that wrap around the unit size",
author = "user, speedups by Argh",
date = "March 3, 2008",
license = "GNU GPL, v2",
layer = -1,
enabled = true
}
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local side = 0
local xmul = 0
local zmu = 0
local ShadowList = {}
local sunx,suny,sunz = gl.GetSun()
local shadowdens = gl.GetSun("shadowdensity","unit")
local SR, SG, SB = gl.GetSun("ambient","unit")
local noshadow = 0
local shadowsareon = 0
local sundist = 0
local realdist = 0
local greater = 0
local sunscale = 0
local sunangle = 0
local cangle = 0
local ShadowsOn = Spring.HaveShadows
local list
local UnitIDList
local height, diff, fx, fy, x, y, z, cx, cy, cz, id
local ShadowTex = 'LuaUI/Images/shadow.tga'
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- sun calculations,for projection----------------------------------------------
--------------------------------------------------------------------------------
sunangle = Spring.GetHeadingFromVector(sunx,sunz)/182.0444445 --exact number to convert a short integer to a 0 to 360 number.
sunangle = sunangle + (360+90) --when it is 65536, divide it by 182,0444445 you get 360.
if (sunangle > 360) then
sunangle = sunangle - 360
end
if (suny < 0 )then
noshadow = 1
else
sunscale = math.abs(suny + 0.1)* 200
sunscale = math.abs(sunscale - 200) * 100
end
sundist = math.pow(sunx,2) + math.pow(sunz,2)
sundist = math.sqrt(sundist)
realdist = sundist * 50
sunscale = sunscale / 1876
local glTexture = gl.Texture
local glDepthMask = gl.DepthMask
local glDepthTest = gl.DepthTest
local glColor = gl.Color
local SpringGetUnitDefID = Spring.GetUnitDefID
local SpringGetUnitViewPosition = Spring.GetUnitViewPosition
local SpringGetGroundHeight = Spring.GetGroundHeight
local glPushMatrix = gl.PushMatrix
local glDrawListAtUnit = gl.DrawListAtUnit
local glPopMatrix = gl.PopMatrix
local glCreateList = gl.CreateList
local glBeginEnd = gl.BeginEnd
local GLQUAD_STRIP = GL.QUAD_STRIP
local glTexCoord = gl.TexCoord
local glVertex = gl.Vertex
local SpringGetCameraPosition = Spring.GetCameraPosition
local SpringGetVisibleUnits = Spring.GetVisibleUnits
local cx,cy,cz = 0,0,0
if SR > 1.0 then SR = 0.5 end
if SG > 1.0 then SG = 0.5 end
if SB > 1.0 then SB = 0.5 end
if shadowdens == nil or shadowdens > 1.0 then shadowdens = 0.5 end
function widget:DrawWorldPreUnit()
cx,cy,cz = SpringGetCameraPosition()
glTexture(ShadowTex)
glDepthMask(false)
glDepthTest(false)
glColor(SR,SG,SB,shadowdens)
unitIDList = SpringGetVisibleUnits(-1,3000,false)
if unitIDList[1] == nil then
return false
else
if (ShadowsOn()) then
return false
else
if cy < 25 or cy > 4000 then
return false
else
for _,unitID in ipairs(unitIDList) do
id = SpringGetUnitDefID(unitID)
x,y,z = SpringGetUnitViewPosition(unitID)
height = SpringGetGroundHeight(x,z)
diff = height-y+5
if ShadowList[id] then
fx = UnitDefs[id].xsize
fy = UnitDefs[id].zsize
glPushMatrix()
glDrawListAtUnit(unitID,list,false,fx,1.0,fy,sunangle,0,1.0,0)
glPopMatrix()
end
end
end
end
end
glDepthMask(true)
glDepthTest(true)
glColor(1,1,1,1)
end
function widget:Initialize()
for ud,_ in pairs(UnitDefs) do
if UnitDefs[ud].customParams.draw_shadow == 'yes' then
table.insert(ShadowList,ud,1)
end
end
list = glCreateList(function()
glBeginEnd(GLQUAD_STRIP,function()
--point1
glTexCoord(0,0)
glVertex(-4,0,-4)
--point2
glTexCoord(0,1)
glVertex(4*sunscale,0,-4)
--point3
glTexCoord(1,0)
glVertex(-4,0,4)
--point4
glTexCoord(1,1)
glVertex(4*sunscale,0,4)
end)
end)
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
- very_bad_soldier
- Posts: 1397
- Joined: 20 Feb 2007, 01:10
Re: Dinamic Blob Shadows!
Thanks Argh! I will add it to SpringDownloader soon if you dont mind.
Re: Dinamic Blob Shadows!
No problem at all, please feel free to use it for whatever you'd like.
Just bear in mind that my version makes use of customParams, so you'd probably want to alter that before distribution, I deliberately made it that way to get along better with P.U.R.E. / World Builder.
Just bear in mind that my version makes use of customParams, so you'd probably want to alter that before distribution, I deliberately made it that way to get along better with P.U.R.E. / World Builder.
- very_bad_soldier
- Posts: 1397
- Joined: 20 Feb 2007, 01:10
Re: Dinamic Blob Shadows!
Great! Thanks again!
But one more request, I think "LuaUI/Images/shadow.tga" is missing too, would be great if you could provide it somewhere.
But one more request, I think "LuaUI/Images/shadow.tga" is missing too, would be great if you could provide it somewhere.
-
- Posts: 1176
- Joined: 23 Aug 2007, 19:46
Re: Dinamic Blob Shadows!
Well that's no problem - it's just the image user included in his version. I'll attach it to this posting...
- Attachments
-
- shadow.zip
- shadow.tga
- (8.5 KiB) Downloaded 22 times
Re: Dinamic Blob Shadows!
this new version still makes flying units shadows look bad, the shadow will stay exactly below the unit.
and the unit height transformation is still not good, both are things i have tried to fix.
and feature (rocks,plants,trees, these stuff) shadows, i remember that those are possible, but anyone wants it?
and the unit height transformation is still not good, both are things i have tried to fix.
and feature (rocks,plants,trees, these stuff) shadows, i remember that those are possible, but anyone wants it?
-
- Posts: 1176
- Joined: 23 Aug 2007, 19:46
Re: Dinamic Blob Shadows!
Well it's still better than no shadows at all...
I think I've also fixed the issue with the too narrow shadows with the new Spring versions. Maybe Argh can confirm it but I guess it was just about a one letter change (ysize turning into zsize or something like that)...
Maybe someone can try this too - it works for me now...

I think I've also fixed the issue with the too narrow shadows with the new Spring versions. Maybe Argh can confirm it but I guess it was just about a one letter change (ysize turning into zsize or something like that)...

Maybe someone can try this too - it works for me now...
- Attachments
-
- dynamic_blob_shadows.zip
- (1.36 KiB) Downloaded 457 times
- very_bad_soldier
- Posts: 1397
- Joined: 20 Feb 2007, 01:10
Re: Dinamic Blob Shadows!
Nice1! WidgetDownloader'd
Re: Dinamic Blob Shadows!
got a problem with the shadows
system:
amd64, ati 9700 (old driver, coz of compatibility)
system:
amd64, ati 9700 (old driver, coz of compatibility)
- Attachments
-
- screen008.jpg
- dumdidum
- (114.83 KiB) Downloaded 18 times
- very_bad_soldier
- Posts: 1397
- Joined: 20 Feb 2007, 01:10
Re: Dinamic Blob Shadows!
Missing shadow.tga? Oops, I forgot it in the downloader too...
EDIT: fixed
EDIT: fixed
Re: Dinamic Blob Shadows!
now its better, but not satisifying
- Attachments
-
- screen009.jpg
- (181.51 KiB) Downloaded 39 times
Re: Dinamic Blob Shadows!
Teamplatter: blob-y edition! 

-
- Posts: 1176
- Joined: 23 Aug 2007, 19:46
Re: Dinamic Blob Shadows!
It always depends on the map and where the sunlight was put. After my experience especially older maps suck at this point and you often have this "top-down" shadows right below the units. Still better than none at all imo...manolo_ wrote:now its better, but not satisifying
Re: Dinamic Blob Shadows!
Hmm. Hadn't noticed this thread before. My cheap little Intel onboard video can't render Spring shadows, so I'll have to give this a try.
Re: Dinamic Blob Shadows!
k, ru right, tested it on an other map and it worked, but i thought/hoped that it could do "real" shadows[Krogoth86] wrote:It always depends on the map and where the sunlight was put. After my experience especially older maps suck at this point and you often have this "top-down" shadows right below the units. Still better than none at all imo...manolo_ wrote:now its better, but not satisifying