Sidios Posted September 25, 2017 Share Posted September 25, 2017 Hi, I've been recently working on some map, I wanted to add some texture that is transparent and it's glowing at the same time. What kind of shader do I need for that? Link to comment
Jedi_Mediator Posted September 25, 2017 Share Posted September 25, 2017 It really depends on what texture you're using and the context you need to use it in. Can you show us the texture? Can you show us what parts need to glow? Can you specify what kind of transparency you want--is the whole thing going to be kind of translucent, or are there going to be certain sections that are completely transparent (like the holes in a vent or grate)? And do you need the texture to be affected by the lightmap? Link to comment
Sidios Posted September 25, 2017 Author Share Posted September 25, 2017 It really depends on what texture you're using and the context you need to use it in. Can you show us the texture? Can you show us what parts need to glow? Can you specify what kind of transparency you want--is the whole thing going to be kind of translucent, or are there going to be certain sections that are completely transparent (like the holes in a vent or grate)? And do you need the texture to be affected by the lightmap?Well lets say it's some kind of city. I want to put it in background to make fake perspective and make map feel more spacious. I wanted it to give some glow and it's not fully transparent, only small part at the top is transparent. I dont want that texture to be affected by map light.Texture itself looks like this: https://jkhub.org/images/yOH4JBY.png 512x128 Link to comment
Psyk0Sith Posted September 26, 2017 Share Posted September 26, 2017 You'll need a shader that combines a diffuse (with transparency) and glow map (paint on a pure black texture the parts that are glowing). Here's what i would use for a player model, swap with proper texture paths: models/players/yourmodel/diffuse_texture { q3map_nolightmap { map models/players/yourmodel/"diffuse_texture" blendFunc GL_ONE GL_ZERO rgbGen lightingDiffuse } { map models/players/yourmodel/"diffuse_texture" blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA rgbGen lightingDiffuse } { map models/players/yourmodel/"glow_texture" blendFunc GL_ONE GL_ONE detail rgbGen identity } }Stage 1 of "diffuse texture" is what your basic diffuse texture should display, in your case, a city skyline without glowing lights.Stage 2 Is the alpha channel transparency, the part your want to remove obviously. This is the same diffuse texture, only at this stage, the shader is using the alpha channel to know what is transparent.Stage 3 is adding glow on top. Link to comment
Sidios Posted September 26, 2017 Author Share Posted September 26, 2017 You'll need a shader that combines a diffuse (with transparency) and glow map (paint on a pure black texture the parts that are glowing). Here's what i would use for a player model, swap with proper texture paths: models/players/yourmodel/diffuse_texture { q3map_nolightmap { map models/players/yourmodel/"diffuse_texture" blendFunc GL_ONE GL_ZERO rgbGen lightingDiffuse } { map models/players/yourmodel/"diffuse_texture" blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA rgbGen lightingDiffuse } { map models/players/yourmodel/"glow_texture" blendFunc GL_ONE GL_ONE detail rgbGen identity } }Stage 1 of "diffuse texture" is what your basic diffuse texture should display, in your case, a city skyline without glowing lights.Stage 2 Is the alpha channel transparency, the part your want to remove obviously. This is the same diffuse texture, only at this stage, the shader is using the alpha channel to know what is transparent.Stage 3 is adding glow on top.Do I have to paint glow on purple and black texture? or it may be the same texture with alpha channel on it and more "bright" parts? Link to comment
Jedi_Mediator Posted September 26, 2017 Share Posted September 26, 2017 You'll need a shader that combines a diffuse (with transparency) and glow map (paint on a pure black texture the parts that are glowing). Here's what i would use for a player model, swap with proper texture paths: models/players/yourmodel/diffuse_texture { q3map_nolightmap { map models/players/yourmodel/"diffuse_texture" blendFunc GL_ONE GL_ZERO rgbGen lightingDiffuse } { map models/players/yourmodel/"diffuse_texture" blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA rgbGen lightingDiffuse } { map models/players/yourmodel/"glow_texture" blendFunc GL_ONE GL_ONE detail rgbGen identity } }Stage 1 of "diffuse texture" is what your basic diffuse texture should display, in your case, a city skyline without glowing lights.Stage 2 Is the alpha channel transparency, the part your want to remove obviously. This is the same diffuse texture, only at this stage, the shader is using the alpha channel to know what is transparent.Stage 3 is adding glow on top.Seems to me the shader would be fine without that first stage. Feel free to persuade me if I'm wrong. Do I have to paint glow on purple and black texture? or it may be the same texture with alpha channel on it and more "bright" parts?I think you could probably use the same texture for that third stage. The "GL_ONE GL_ONE" is an additive blend function, which basically means that black = transparent. So all the bright parts of the texture would stand out and seem to glow, without blotting out the other details in the image that don't glow. If using the same texture doesn't work, it would be easy enough to copy the image, fill in the alpha channel with black, rename it to "yourmodel_glow" or something like that, and use that for the glow stage. Probably not necessary, though. Oh, and if you want the glow stage to use the game's Dynamic Glow feature, include a new line at the end of the stage that says "glow." AshuraDX likes this Link to comment
Psyk0Sith Posted September 26, 2017 Share Posted September 26, 2017 Do I have to paint glow on purple and black texture? or it may be the same texture with alpha channel on it and more "bright" parts?Personally i would paint the texture with layers in photoshop (or app of choice), where you paint the top layer as the glowing lights, layer below would be city skyline. Once happy with the look, swap the skyline with a pure black color and save as your glow. So you only have glowing lights on a pure black background. Seems to me the shader would be fine without that first stage. Feel free to persuade me if I'm wrong. I think you could probably use the same texture for that third stage. The "GL_ONE GL_ONE" is an additive blend function, which basically means that black = transparent. So all the bright parts of the texture would stand out and seem to glow, without blotting out the other details in the image that don't glow. If using the same texture doesn't work, it would be easy enough to copy the image, fill in the alpha channel with black, rename it to "yourmodel_glow" or something like that, and use that for the glow stage. Probably not necessary, though. Oh, and if you want the glow stage to use the game's Dynamic Glow feature, include a new line at the end of the stage that says "glow." Oh it's possible the first stage is not mandatory, i took out a reflective stage when i copy pasted it so i probably messed up. What i posted is more of a road map, experimenting with shaderED will give you instant feedback. AshuraDX likes this Link to comment
Sidios Posted September 26, 2017 Author Share Posted September 26, 2017 I will do as you say and test it later on. Link to comment
Sidios Posted September 26, 2017 Author Share Posted September 26, 2017 You'll need a shader that combines a diffuse (with transparency) and glow map (paint on a pure black texture the parts that are glowing). Here's what i would use for a player model, swap with proper texture paths: models/players/yourmodel/diffuse_texture { q3map_nolightmap { map models/players/yourmodel/"diffuse_texture" blendFunc GL_ONE GL_ZERO rgbGen lightingDiffuse } { map models/players/yourmodel/"diffuse_texture" blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA rgbGen lightingDiffuse } { map models/players/yourmodel/"glow_texture" blendFunc GL_ONE GL_ONE detail rgbGen identity } }Stage 1 of "diffuse texture" is what your basic diffuse texture should display, in your case, a city skyline without glowing lights.Stage 2 Is the alpha channel transparency, the part your want to remove obviously. This is the same diffuse texture, only at this stage, the shader is using the alpha channel to know what is transparent.Stage 3 is adding glow on top.I did what you said and the diffuse texture is not transparent, shouldnt I add some qer_trans to the code? Link to comment
Solution Psyk0Sith Posted September 26, 2017 Solution Share Posted September 26, 2017 Did you paint the alpha channel of your .TGA where you want transparency (and saved as 32 bit?). Also try this code. models/players/yourmodel/"diffuse_texture" { q3map_nolightmap { map models/players/yourmodel/"diffuse_texture" alphaFunc GE128 blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA depthWrite rgbGen identity } { map models/players/yourmodel/"glow_texture" blendFunc GL_ONE GL_ONE detail rgbGen identity } } Link to comment
Sidios Posted September 26, 2017 Author Share Posted September 26, 2017 Did you paint the alpha channel of your .TGA where you want transparency (and saved as 32 bit?). Also try this code. models/players/yourmodel/"diffuse_texture" { q3map_nolightmap { map models/players/yourmodel/"diffuse_texture" alphaFunc GE128 blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA depthWrite rgbGen identity } { map models/players/yourmodel/"glow_texture" blendFunc GL_ONE GL_ONE detail rgbGen identity } }It look like this: https://jkhub.org/albums/cUaWV It's .PNG Didnt know it has to be 32 bit tho. Glow texture looks similar, just lights are more bright. Link to comment
Sidios Posted September 26, 2017 Author Share Posted September 26, 2017 Did you paint the alpha channel of your .TGA where you want transparency (and saved as 32 bit?). Also try this code. models/players/yourmodel/"diffuse_texture" { q3map_nolightmap { map models/players/yourmodel/"diffuse_texture" alphaFunc GE128 blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA depthWrite rgbGen identity } { map models/players/yourmodel/"glow_texture" blendFunc GL_ONE GL_ONE detail rgbGen identity } }It worked. Thanks for help Psyk0Sith likes this Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now