Light compile ruins my terrain and need help with phonging


(-SSF-Sage) #1

I have a little problem, I’m not too good with shaders :lol:. I’ve been wresling tens of hours with this issue, but still my terrain gets messed up when I do light compile. I have read tutorials and tried to learn from shader manual. Everything else looks really awsome. Everything works (not light compile stuff ofc…) nicely with bsp only compile, but I want great lightning and shadows. There are three things:

  1. No shadows are cast on to the terrain. What part of the shader affects on this?

  2. Blending gets washed of with light compile. Foliage and some bushes starts looking awful. I can change the models, but I need help with this blend issue.

  3. Texture starts looking completely different. It get’s really ugly.

The problem is only with the terrain. Here is my shaders for terrain and skybox:


textures/duel_site/grass
{
	qer_editorimage textures/sage/duel_site.jpg
	q3map_lightImage textures/temperate_sd/master_grass_dirt3.tga 
	q3map_nonplanar
	q3map_shadeAngle 179
	q3map_tcGen ivector ( 512 0 0 ) ( 0 -512 0 )
	q3map_lightmapAxis x
	q3map_lightmapmergable
	q3map_alphaMod dotproduct2 ( 0 0 2 )
	surfaceparm gravelsteps
	surfaceparm landmine
   	q3map_foliage models/sage_grass/grassfoliage1a.md3 0.6 48 0.04 2 
   	q3map_foliage models/sage_grass/grassfoliage2a.md3 0.8 48 0.03 2 
      q3map_foliage models/sage_grass/grassfoliage3a.md3 1 48 0.02 2 //credit rayban for models
	{
		map textures/temperate_sd/grass_path1.tga 
		rgbGen identity
	}
	{
		map textures/temperate_sd/master_grass_dirt3.tga 
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		alphaGen vertex
		rgbGen identity
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen identity
	}
}


textures/duel_site/grass_rock
      {
	qer_editorimage textures/sage/duel_site5.jpg
	q3map_lightImage textures/temperate_sd/rock_grayvar.tga 
	q3map_nonplanar
	q3map_shadeAngle 179
	q3map_tcGen ivector ( 512 0 0 ) ( 0 -512 0 )
	q3map_lightmapAxis x
	q3map_lightmapmergable
	q3map_alphaMod dotproduct2 ( 0 0 2 )

	{
		map textures/temperate_sd/master_grass_dirt3.tga   
		rgbGen identity
	}
	{
		map textures/temperate_sd/rock_grayvar.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		alphaGen vertex
		rgbGen identity
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen identity
	}
}

textures/duel_site/grass_nofoliage //really no foliage...
{
	qer_editorimage textures/sage/duel_site2.jpg
	q3map_lightImage textures/temperate_sd/master_grass_dirt3.tga 
	q3map_nonplanar
	q3map_shadeAngle 179
	q3map_tcGen ivector ( 512 0 0 ) ( 0 -512 0 )
	q3map_lightmapAxis x
	q3map_lightmapmergable
	q3map_alphaMod dotproduct2 ( 0 0 2 )
	surfaceparm gravelsteps
	surfaceparm landmine

	{
		map textures/temperate_sd/grass_path1.tga 
		rgbGen identity
	}
	{
		map textures/temperate_sd/master_grass_dirt3.tga 
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		alphaGen vertex
		rgbGen identity
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen identity
	}
}


textures/duel_site/sky
{
	qer_editorimage textures/sage/sky.tga
	q3map_lightrgb 0.8 0.9 1.0
	q3map_skylight 85 3
	q3map_sun 1 .95 .9 200 145 30 
	skyparms - 200 -
	surfaceparm nodlight
	surfaceparm noimpact
	surfaceparm nolightmap
	surfaceparm sky
	{
		map textures/sage/sky.tga
		rgbGen identity
	}
	{
		map textures/sage/sky.tga
		blendfunc blend
		rgbGen identity
		tcMod scroll 0.0005 0.00
		tcMod scale 2 1
	}
}


There is also issue with phongshader. I have rocks with phong shaders but they look the same with and without phong. I really suck with shaders tbh. Shader:



textures/duel_site/rock
 {
 	q3map_nonplanar
	q3map_shadeangle 60 //the value have been also 179 but it made no difference.
 	qer_editorimage textures/temperate_sd/rock_grayvar.tga 
 	{
 		map $lightmap
 		rgbGen identity
 	}
 	{
		map textures/temperate_sd/rock_grayvar.tga 
 		blendFunc filter
	}
}


(Loffy) #2

Hep, hep, hep! I am the worst shader user here, if you do not mind. I’ve sent weeks with silly black dots all over the map. And, frankly, I have almost no idea what I do when I use shaders.

If I had you problem, I would take out these to lines
//q3map_nonplanar
//q3map_shadeAngle [some value here]

And recompile. Just to see what happens.

//Loffy

EDIT: Sent? I mean spent.


(-SSF-Sage) #3

Thx for the tip. I tried it for the rock which should use phong, I removed them both, then I tried both alone, with no difference. :x Is there some prob with my shader, or doesn’t this REALLY work? I never seen any difference on phong. :frowning: And I’ve used many shaders from many tutorial etc. Or is there a setting that disables it ingame? Btw is that correct you need to do the light phase for it to work (I do) or do I make that for no reason when testing? As I understood phong bases on shadows, and shadows needs light compile. Right? I thought phong bases on these 2 commands.

For the terrain, removing noplanar helped alot. It gave me my blend back. And made the foliage look nice again! But now it’s looks really wierd, some strange shadows showed up. Or atleast they looked like one.

Now let’s see how removing shadeangle affects to the terrain. I did not notice any changes. But my terrains shadow’s are awful. :frowning: And any trees, buildings etc. doesn’t cast shadows to the terrain. So my questions are. What makes some object cast shadows to something. What makes a plane to draw shadows (so you can see shadow on it)? Many things cast shadows to itself, but doesn’t make any shadows on other things. :frowning:


(stephanbay) #4

what are your compile switches?


(-SSF-Sage) #5

I’ve been trying many different options from the radiant. But for now on I think Bsp-meta -vis -light -fast -filter -samples 2 -bounce 8 is the best I guess.

I could really need help for shadowing this, so if anyone is interested to help me with compilation stuff, shaders and lightmapping etc. PLZ PLZ PLZ contact me! I’ll give credit of course…


(]UBC[ McNite) #6

First: dont compile with radiant. Get Q3map2build or any other nice frontend. (use search about q3map2build, there are some posts on it)

As for compile options:
BSP -meta -v
VIS -v
LIGHT -v -fast
are very sufficient for anything while you are in alpha and medium beta stages of your map.
If you want to save time, skip the VIS stage (this will break your FPS of course).

Use the logging options in Q3map2build to get a compile logfile. You can find amazing info in there, especially about things that break during compile.

The shadows come by themselves as soon as you use the light stage. If they dont, build a small boxmap, put in some brushes (floor, small walls around the edge) and give the skybox your skyshader, put in a tree and see whether you still have no shadows. Boxmaps are best to test shaders and stuff because they compile a lot faster than your whole map.

If things start looking awful with light, you might want to check on your light settings? Maybe some weird color settings in there? Use a stock ET skyshader too for a start?

Phong: AFAIK phong is only working well on objects that have slight edges that can get smoothed out, not on blocky objects, so i doubt u can get a smooth rock from a blocky brushwork just by using a phong shader.


(-SSF-Sage) #7

Thx for the post. Firstable why not to use radiant’s compiler? I do single bsp meta for testing, but as I’m now trying to get the shadows etc. look as I want. So I am doing the whole compilation to see the last look. This map is actually kinda box map. It’s a valley that is designed for duel (1on1).

Basicly there is no optimation made, cos it’s really not needed. Every brush is detail, except the skybox. There is very low tris count (highest about 10000) and there is no possibilities of really optimize a lot. There is 2 spawns (cottages) on each side, then 1 building in the middle. So vis wouldn’t been even needed, but doesn’t matter since my full compile times stays in less than 2 minutes. And the light features takes about 3/4 of it. To optimise the map you can do r_drawfoliage 0 lol.

There are shadows cast somewhere. I know they come with the light phase. But what comes to the terrain’s shadows. Firstable nothing else cast shadows to the terrain, except the terrain itself. Secondable all shadows the terrain gives itself looks really wierd and ugly. There are shadows that doesn’t get really caused by anything, so they appear from nowhere.

The buildings and stuff looks really nice and causes really nice shadows to their self, but no shadows to the terrain. Basicly I want this terrain to draw shadows of trees, rocks, buildings and bushes. And make it cast it’s own shadows nicely.

I’m building up a theme of kinda sunset. The sky and the light has littlebit orange color for purpose (the new versions of the shader, not needed to post though…). I’ve been trying tweaking the shadows by changing the sun angle etc. but couldn’t make it look really a lot more normal! I’ll post up some pics soon.


(kamikazee) #8

Radiant actually launches Q3Map2 for building, so any other external launcher works just as good.

What Q3Map2Build allows you to do, is to change any given parameter easily and retrieve log files in a simple click. It is not requirement, but certainly a great help.


(-SSF-Sage) #9

But I don’t really understood parameters. :lol: Using radiant’s is so much easier, and doesn’t need learning another program. Now I can see some shadows that could be from the trees etc. but they really look WIERD. The pics are really dark and bad, but hope you see something. The terrain looks wierd cos these are actually noclipped pics to see the shapes…

In first and second pic you can see the direction of the light, notice the shadows going different. In third pic look at the awful shadows! :frowning: The arrow really hits the spot in the pic. :stuck_out_tongue: It’s a scripted mover that bobs and rotates. :stuck_out_tongue: To show the axis side.


(-SSF-Sage) #10

Sorry for the double post! :evil: I did a little testing in a box map as ]UBC[ McNite said. What I found is when I used the same stuff as in my map, it produces nice shadows on a random material. However when I insert my duel_site/grass shader to it, the shadows disappeared. Now I need to find out what is causing this. Plz make my life easier and tell me straight away what is bugging out. :slight_smile: Well for so far, I start testing and will come back with the results.


(obsidian) #11

Wow, that’s a lot to read through so I’ll start at the beginning and just list things I find as I read my way down…

q3map_lightImage: your grass isn’t emitting any light so this isn’t needed.

q3map_tcGen iVector: Any reason why you have a negative value here?

q3map_lightmapAxis: this selects the axis in which lightmaps are projected. I don’t think you want a value of x since light is usually projected downwards from the z-axis if anything. You probably don’t need this at all.

Very sharp angles won’t get phong shaded no matter what you do… just a result of the fact that they are a sharp angle and it’s impossible to make it seem smooth. You may have to add more tessellations. Plus, it doesn’t work very well on surface where the textures are mapped along different axies.

It looks like you have sparklies (those little white specks in the screenshots - hard to tell). Sparklies are the result of bad building habits causing t-junctions.


(stephanbay) #12

can you post a screen of your gtk map. looks like that black shadow along hte left side is the skybox brush covering the terrain.


(-SSF-Sage) #13

Thx everyone for help. I’ve time to test these things up again at evening or at the weekend. Then I’ll see if any of it helped.

@Obsidian thx for pointing me out. You see I haven’t mastered shaders yet. Mostlikely these are copied and modified. There’s no reason for negative value as I don’t understand that much. The script had it so I didn’t change it since I didn’t know why. I get sometimes alot of these sparklies and I don’t know what is with my brushwork. Even the concrete floor which is from 1 brush had these! :lol: There’s no holes really… :smiley:

@stephanbay the skybox is just a hollow box. I’ll give you the screenshots when I have time to get back to this map. I’m now finishing up and soon (today 99%) to be releasing (gameplay test version, first alpha…) my and Erls’ map so I am being busy.

I’ve another question. When I do the whole compile my .prt and .srf files aren’t deleted. I assume they aren’t deleted autom. So can I just delete them, as I don’t need them after full compiling, right? Prt for -vis and srf for -light right?


(obsidian) #14

Get rid of t-junctions and sparklies should go away. Do a search here or elsewhere for “t-junctions” or “t-juncs” and you should see a lot of resources.

Your prt and srf files aren’t necessary, but they can be helpful when hinting or tracking down other issues. .prt is a portal file, .srf is a surface file.


(-SSF-Sage) #15

Ok here I am again. Now I shall give you my new shader and some screenshots from radiant. I made a box map and still the objects doesn’t draw shadows to my shader, but does draw to one with no shader.

So did I understand the basics about t-juncts. If I have a vertex “overlapping” a face, I get more t-juncts? So when I have a lot of them, does it give me sparklies, or do they get affected to each t-junct no matter what, even if I had only one? Plz plz tell me what is wrong with the shader.
:frowning:

textures/duel_site/grass //terrain
{
	qer_editorimage textures/sage/duel_site.jpg
	//q3map_lightImage textures/temperate_sd/master_grass_dirt3.tga 
	//q3map_nonplanar       
	//q3map_shadeAngle 179
	q3map_tcGen ivector ( 512 0 0 ) ( 0 512 0 )
	//q3map_lightmapAxis x
	//q3map_lightmapmergable
	q3map_alphaMod dotproduct2 ( 0 0 2 )
	surfaceparm gravelsteps
	surfaceparm landmine
   	q3map_foliage models/sage_grass/grassfoliagea.md3 0.6 48 0.04 2 
   	q3map_foliage models/sage_grass/grassfoliage2a.md3 0.8 48 0.03 2 
      q3map_foliage models/sage_grass/grassfoliage3a.md3 1 48 0.02 2 
	{
		map textures/temperate_sd/grass_path1.tga 
		rgbGen identity
	}
	{
		map textures/temperate_sd/master_grass_dirt3.tga 
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		alphaGen vertex
		rgbGen identity
	}
	{
	//	map $lightmap    tested with these on and off
	//	blendFunc GL_DST_COLOR GL_ZERO
	//	rgbGen identity
	}
}

[

Edit. for those who wonders why I have such a long alphas, it’s because it’s easier to track 'em down and modify 'em.

Edit2. Hmm!!! I thought I did try it without, I removed the // of the 3 lowest commands (lightmap block) and shadows casted. I’ll see if anything else was affecting to it. Mean while I want to be happy when I got it working, but then I want to be angry for the lightmap state! :lol:

Edit3. I got it working! Woohoo!! After all I removed three lines from the original and changed q3map_tcGen ivector to a positive value. Dunno which one of these made the difference, but now it works as it should. Removed lines are:

q3map_lightImage textures/temperate_sd/master_grass_dirt3.tga
q3map_lightmapAxis x
q3map_lightmapmergable


(obsidian) #16

It was almost certainly q3map_lightmapAxis. Terrain lightmaps should certainly not be projected from the X axis.

T-juncs are caused when a vertex intersects an edge, causing a errr… T-shaped junction. This intersecting vertex doesn’t actually split the edge in two as it should and therefore does not merge vertex points thus causing a microseam and you get the sparkle effect.

You simply get rid of these T’s by manually splitting the edge in two, probably with the clipper tool.


(-SSF-Sage) #17

Well thanks. I’ve been splitting all day, to get the vertexes meet another vertexes instead of an edge. But I’ve got a lot of these sparklies and in places where isn’t t-juncts for sure. They appears almost everywhere lol. But if I make the brushes overlap, shall it cause t-juncts? If we ignore ugly z-fighting. This map is on the shape and all put togethor, it’s ready when I get rid of the sparklies. But as I’ve got ruins there is a lot of them. :smiley: But sparklies gets drawn where the t-junct is, but not where isn’t any t-junct, right? For my map they seem to be drawed everywhere. :shock: Well thankfully it isn’t that bad ingame as it is in radiant.