Rick Posted June 20, 2017 Posted June 20, 2017 Rephrasing the question: How can I make the texture background transparent so the only thing I see is my text? local shader = Shader:Load("Shaders/model/diffuse.shader") local currentBuff = Buffer:GetCurrent() local mat = Material:Create() mat:SetShader(shader) local sprite = Sprite:Create() sprite:SetViewMode(0) sprite:SetMaterial(mat) local buffer = Buffer:Create(20, 20, 1, 1) -- draw the text on the buffer Buffer:SetCurrent(buffer) self.context:SetBlendMode(Blend.Alpha) self.context:SetColor(Vec4(1, 0, 0, 1)) self.context:DrawText("Hello", 0, 0) local tex = buffer:GetColorTexture(0) mat:SetTexture(tex, 0) Buffer:SetCurrent(currentBuff) Quote
Ma-Shell Posted June 21, 2017 Posted June 21, 2017 The shader is the problem. Use "Shaders/model/diffuse+normal+alphamask.shader" instead of "diffuse.shader", then it should work. Quote
Rick Posted June 21, 2017 Author Posted June 21, 2017 So that kind of works. I see only the text but even though I changed color to red the text is black and can't really see it because of that. Quote
Ma-Shell Posted June 21, 2017 Posted June 21, 2017 For me the text is red (given, it's a very dark red...). You should be able to make it more visible by using "diffuse+normal+emission+alphamask.shader" and binding the texture to both, channels 0 (diffuse) and 4 (emission): i.e.: local shader = Shader:Load("Shaders/model/diffuse+normal+emission+alphamask.shader") local currentBuff = Buffer:GetCurrent() local mat = Material:Create() mat:SetShader(shader) local sprite = Sprite:Create() sprite:SetViewMode(0) sprite:SetMaterial(mat) local buffer = Buffer:Create(20, 20, 1, 1) -- draw the text on the buffer Buffer:SetCurrent(buffer) self.context:SetBlendMode(Blend.Alpha) self.context:SetColor(Vec4(1, 0, 0, 1)) self.context:DrawText("Hello", 0, 0) local tex = buffer:GetColorTexture(0) mat:SetTexture(tex, 0) mat:SetTexture(tex, 4) Buffer:SetCurrent(currentBuff) That should make it more crisp. 1 Quote
Rick Posted June 21, 2017 Author Posted June 21, 2017 That worked thank you much. Any ideas on how to fade out the text? I can change the alpha of SetColor() but currently I clear the buffer but that results in a white buffer it seems as the sprite goes all white when I call buffer:Clear(). It's like I need to clear it with no color. Currently I call Clear() then SetColor() where the alpha is going down from 1 to 0 and redrawing the text. However, as stated all I see is white. Quote
Recommended Posts
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.