Hello guys,
so im working on an Entity which has a 3d2d Drawn Image on it.
TO get the image im using b-draw_lib, It fetches the Image from the interwebs and creates a Material with it.
B-Draw_Lib
file.CreateDir("downloaded_assets")
local exists = file.Exists
local write = file.Write
local fetch = http.Fetch
local white = Color( 255, 255, 255 )
local surface = surface
local crc = util.CRC
local _error = Material("error")
local math = math
local mats = {}
local fetchedavatars = {}
local function fetch_asset(url)
if not url then return _error end
if mats[url] then
return mats[url]
end
local crc = crc(url)
if exists("downloaded_assets/" .. crc .. ".png", "DATA") then
mats[url] = Material("data/downloaded_assets/" .. crc .. ".png")
return mats[url]
end
mats[url] = _error
fetch(url, function(data)
write("downloaded_assets/" .. crc .. ".png", data)
mats[url] = Material("data/downloaded_assets/" .. crc .. ".png")
end)
return mats[url]
end
local function fetchAvatarAsset( id64, size )
id64 = id64 or "BOT"
size = size == "medium" and "medium" or size == "small" and "" or size == "large" and "full" or ""
if fetchedavatars[ id64 .. " " .. size ] then
return fetchedavatars[ id64 .. " " .. size ]
end
fetchedavatars[ id64 .. " " .. size ] = id64 == "BOT" and "http://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/09/09962d76e5bd5b91a94ee76b07518ac6e240057a_full.jpg" or "http://i.imgur.com/uaYpdq7.png"
if id64 == "BOT" then return end
fetch("http://steamcommunity.com/profiles/" .. id64 .. "/?xml=1",function( body )
local link = body:match("http://cdn.akamai.steamstatic.com/steamcommunity/public/images/avatars/.-jpg")
if not link then return end
fetchedavatars[ id64 .. " " .. size ] = link:Replace( ".jpg", ( size ~= "" and "_" .. size or "") .. ".jpg")
end)
end
function draw.WebImage( url, x, y, width, height, color, angle, cornerorigin )
color = color or white
surface.SetDrawColor( color.r, color.g, color.b, color.a )
surface.SetMaterial( fetch_asset( url ) )
if not angle then
surface.DrawTexturedRect( x, y, width, height)
else
if not cornerorigin then
surface.DrawTexturedRectRotated( x, y, width, height, angle )
else
surface.DrawTexturedRectRotated( x + width / 2, y + height / 2, width, height, angle )
end
end
end
function draw.SeamlessWebImage( url, parentwidth, parentheight, xrep, yrep, color )
color = color or white
local xiwx, yihy = math.ceil( parentwidth/xrep ), math.ceil( parentheight/yrep )
for x = 0, xrep - 1 do
for y = 0, yrep - 1 do
draw.WebImage( url, x*xiwx, y*yihy, xiwx, yihy, color )
end
end
end
function draw.SteamAvatar( avatar, res, x, y, width, height, color, ang, corner )
draw.WebImage( fetchAvatarAsset( avatar, res ), x, y, width, height, color, ang, corner )
end
Now my problem is that the TExturedrect that it draws when i call the Function in my Entity and draw the Image(Which works fine), that his image is not Shaded.
It will glow bright white when its in an unshaded room and i just cant figure out how to add the shader.
I tried to use CreateMaterial instead of Material with the Path it uses for the Material function as the Basetexture, but i would simply get the errortexture.
Now i have absolutely no idea how i can get a Shader to work.
Any help is appreciated
Try to use a mesh.QuadEasy
And applying the material by doing a RenderTarget
Sorry, you need to Log In to post a reply to this thread.