Self illuminated shader


(duralisis) #1

I’m attempting to make a self-lit light-emitting shader using just a flat color (like a light bulb sort of). So I whip up a little test map and check, but it’s not illuminated, even though it casts light. I know I’m doing something wrong (I’m not too good at shaders), but what?

Here’s the code:

textures/radgallery/green
{
	qer_editorimage textures/gallery/green.tga
	q3map_surfacelight 1000
	q3map_lightsubdivide 32
	{
		map $lightmap
		rgbGen identity
	}
	{
		map textures/gallery/green.tga
	}
}

And here’s how it turns out:

(BTW, if you can’t see the images, use a filtering proxy like the Proxomitron - http://proxomitron.org - to block browser refer detects, then you’ll see 'em. Otherwise, copy and paste into the address bar).

Bad

http://duralisis.tripod.com/badshader.jpg

Here’s how I want it though (cheap mockup)

http://duralisis.tripod.com/mockup.jpg

And the texture itself

http://duralisis.tripod.com/green.jpg

So how I do make it work?


(chavo_one) #2

drop the lightmap stage. That’s what is darkening your cube.


(RabidCow) #3

You may be able to control that a little better by using q3map_backsplash x x (%of light that will light the texture, and distance in units that will be the equivalent distance of the lightsource from the texture). Correct me if I am wrong :slight_smile: I think the default is about .15 and 26 units or so.
RC


(chavo_one) #4

FWIW, here’s a shader I used to do exactly what you are trying to do:

textures/office_lights/red_light
{
	qer_editorimage textures/office_lights/red_b1.tga
	q3map_lightimage textures/office_lights/red_b1.tga
	q3map_surfacelight 500
	surfaceparm nomarks
	{
		map textures/office_lights/red_b1.tga
		blendFunc GL_ONE GL_ZERO
		rgbGen identity
	}			
}

(ydnar) #5

Don’t forget to add “surfaceparm nolightmap” if it doesn’t have/use a lightmap to reduce compile time and BSP size.

Note, the reason it’s not self-illuminating is because of the q3map_lightSubdivide. If you only plan to use it on small shapes like that, then you don’t need it.

y


(duralisis) #6

The mystery deepens…

I took chavo’s shader and just substituted my texture, recompiled and still, the same result, unlit. Then to make sure it’s not the texture, I create a fresh TGA from scratch, non-RLE encoded and non-origin specific only with a new shader and new map.

It compiles fine and I get the result of a completely white object this time. So thinking back to an earlier experiment with overbrightbits, I turn off both the regular OBB’s and the map OBB’s. WHAM! – It’s the green color I’ve been looking for!

Now this has got me wondering why it emits such little light in comparison to it’s surface (the surface is very very bright while the area around it is no more illuminated than a dim point light).

So, should the backsplash keyword allow me to keep it one color while emitting more light?

Edit: Added surfaceparm nolightmap and same results. I’m still able to turn off the main overbrightbits and get the desired result. There has to be a way to keep it a constant color while emitting a given amount of light.

Edit 2: Problem solved, ‘rgbGen identity’ was causing it to white out. Removing that causes it to look the same no matter what OBB’s are on.

:drink: Thanks for the help everyone. :drink:


(ydnar) #7

Nuke his blendFunc. Then it’ll draw the flat green color.

y


(Flash95) #8

How about posting the final script so the rest of us dont have to wonk around this one on our own. :drink:


(duralisis) #9

Here’s one I used:


textures/gallery/red_1k
{
	qer_editorimage textures/gallery/red.tga
	surfaceparm nolightmap
	surfaceparm nomarks
	q3map_backsplash 0 0
	q3map_lightimage textures/gallery/red.tga
	q3map_lightsubdivide 32
	q3map_surfacelight 1000
	{
		map textures/gallery/red.tga
	}         
}

I found that implicitly turning off backsplash entirely takes away that blotchy look (like another pt. light is in front of it) and that you need a very low subdivide value for anything other than skies, etc. Try this particular one on long neon lights for great effect.