Tree branches alpha transparency doesnt work on custom model


(TNR360) #1

I’ve tried many things already, I think the problem is in the shader, but here’s both the shader and texture in case-

//**************************************************************
// pine tree common winter (pine_tree_s.md3)
//**************************************************************

models/EF_nature/Trees/skin/WoodPineBark_c.tga
{
	q3map_clipmodel
	surfaceparm woodsteps
	surfaceparm nolightmap
	
	{
		map models/EF_nature/Trees/skin/WoodPineBark_c.tga
		rgbGen vertex
	}
}

models/EF_nature/Trees/skin/large_branch02_s
{
	qer_alphafunc greater 0.5
	
	cull disable
	surfaceparm trans
	surfaceparm nomarks
	surfaceparm alphashadow
	surfaceparm nolightmap
	
	//q3map_forcesunlight
	
        nomipmaps
        nopicmip
	
	deformVertexes wave 256 sin 0 1 0.25 0.1
        {
		map models/EF_nature/Trees/skin/large_branch02_s
		alphaFunc GE128
		rgbGen vertex
	}
}

Here’s the texture

http://files.filefront.com/large+branch02+stga/;11526307;/fileinfo.html

I have no idea what I’m doing wrong really

ps- yes the shader is added correctly because the wood texture shader does work


(IndyJones) #2
// name
textures/path/name
{
	qer_trans 0.85
	qer_editorimage textures/path/name.tga
	cull disable
	sort 6
	nomipmaps
	nopicmip
	surfaceparm nomarks
	surfaceparm alphashadow
	surfaceparm pointlight
	surfaceparm trans
	surfaceparm nonsolid

	implicitMask textures/path/name.tga
}

that’s a shader that i’m using.


(TNR360) #3

no luck at all, it didnt work :frowning:


(IndyJones) #4

maybe the texture have a invalid alpha channel?


(Berzerkr) #5

Indy is right. Opened the file with GIMP, seems like the alpha channel is invalid.


(TNR360) #6

http://rapidshare.com/files/138061995/large_branch02_s.tga.html

I had it fixed for me, at least I think its fixed, it still gives the same result


(Berzerkr) #7

Opened it with Gimp and IrfanView, seems to me the alpha channel is correct.
Maybe it’s the shader.

models/EF_nature/Trees/skin/large_branch02_s
{
	cull none
	implicitBlend -
	surfaceparm trans
	surfaceparm pointlight
	surfaceparm alphashadow
	{
		map models/EF_nature/Trees/skin/large_branch02_s.tga
		rgbGen lightingDiffuse
	}
}

I noticed you forgot to add the .tga in your shader

        {
		map models/EF_nature/Trees/skin/large_branch02_s
		alphaFunc GE128
		rgbGen vertex
	}

(TNR360) #8

nothing will work :frowning:


(-SSF-Sage) #9

Don’t you need to have a stage with blendfunc for it to work?


(kamikazee) #10

What’s the “fixed” shader? I see loads of variants here…


(TNR360) #11

I’ve tried every single one, including the ones on the ef forum xD


(Berzerkr) #12

Another thought.
Do you tried to replace the texture you made with, for example, the tree texture from fueldump to test if the alpha channel of the .tga really works correct?


(Fluffy_gIMp) #13

also, are you sure the shader path on the model is correct? (I’m assuming the base trunk and the branches are different shaders?)
Like berzerkr says the fuel dump tree shader would be a good one to test on the model.
oh and are there any errors in the console?


(TNR360) #14

I cant seem to get it working, I think I actually started with the ET tree

here’s the model/shader/textures

http://files.filefront.com/xgrar/;11548912;/fileinfo.html

Im completely stumped on how to fix this :frowning:


(murka) #15

A quick look and i got a few:

  1. Models had shader/material path to /blabla/blabla.tga , that .tga doesn’t go there mainly because we are using a shader, not a texture.
  2. Inside the shader, shader names end with a .tga… they should be /blabla/blabla (w/o any extension).
  3. That trunk could be converted to a .jpg to save some kilobytes.
  4. Whatever the issue, the model is using the textures, not the shader(try different shader/texture paths, like textures is /textures/blabla/file.tga and shader is /models/blabla/shadername).

Now to get some food.

Edit(after the eating):Yup, changed the shader/texture paths, one minor edit in the shader(because i changed the paths) and it works.

Edit2(after testing the model in-game and making some modifications for it to look better):
For some reason the branches looked slightly too dark, so I added a blendFunc add to it(also a alphaFunc GE128 because its an alpha texture).
The final shader:

// commented out, it doesnt ****ing work, trying new shader below
//**************************************************************
//Snowy Trees
//**************************************************************
models/EFx_alphatrees/Pine_snow/large_branch02_s	//Changed from textures/ to models/ and
//							removed .tga from the end
{
	qer_trans 0.85
	qer_editorimage textures/EFx_alphatrees/Pine_snow/1.tga		//Re-change the texture names,
//							 because it was a part of my debugging proccess
	nopicmip
	cull disable	//Just because "twosided" is longer xD
	surfaceparm alphashadow
	surfaceparm nomarks
	surfaceparm trans
	surfaceparm nonsolid
	implicitMask textures/EFx_alphatrees/Pine_snow/1.tga
	sort decal
	{
		map textures/EFx_alphatrees/Pine_snow/1.tga
		blendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
		rgbGen identity
	}
	{
		map textures/EFx_alphatrees/Pine_snow/1.tga
		alphaFunc GE128	//because it's an alpha texture
		blendFunc add	//Added this stage because the texture was seriously dark
	}
}
//**************************************************************
//NEW SHADER
//**************************************************************
// pine tree common winter (pine_tree_s.md3)
//**************************************************************
models/EFx_alphatrees/Pine_snow/WoodPineBark_c
{
	q3map_clipmodel
	surfaceparm woodsteps
	surfaceparm nolightmap
	q3map_nonplanar
	q3map_shadeangle 90		//Can't have a round surface w/o phong shading
	{
		map textures/EFx_alphatrees/Pine_snow/2.tga
		rgbGen identity		//rgbGen vertex gave me a bug with it, scrolling my 
//						console changed some colors on the texture.
	}
}

A side note: The texture looks too gray-ish from far away, it should be more white.


(TNR360) #16

thanks man it works great,
it’s just really bright, I can fix it up though :smiley:


(Fluffy_gIMp) #17

Hooray!

It will look gray at distance due to texture mip-mapping; the surrounding colour around the branch is the grey colour you’ll be seeing. The fix for this is to bleed the branch colours into (and over) the surrounding UV/Alphachannel borders.