How to make a Skybox Shader??


(shazmax) #1

Trying to create a custom shader for my sky…etc. I’ll add the clouds later but just wanted a standard shader that would show the image or whatever. Anyways after I load it up in gtkradiant I get this error:

Gtk-CRITICAL **: file gtktextbuffer.c: line 543 (gtk_text_buffer_emit_insert): assertion `g_utf8_validate (text, len, NULL)’ failed

Does this have to do with how I saved it or??? I’ve tried saving it both in Ansii and in UTF 8, in notepad and in wordpad…same thing. Here’s the sample code I’m trying to slowly work on:

textures/shaz_sky/height_up
{
qer_editorimage textures/shaz_sky/height_up.tga
q3map_lightimage textures/shaz_sky/low_01.tga

surfaceparm noimpact
surfaceparm nolightmap
surfaceparm nodlight
q3map_sun 1.0 0.8 0.6 130 220 50
q3map_surfacelight 100

}

My image is 128 x 128

Hope any of this helps ya out.

EDIT: Changed title for archives/search reasons. Sock


(Drakir) #2

A Quake3 sky is made from two components: a ‘skybox’ and a cloud layer. These components can be used together or individually.

Prerequisites
A sky shader should always contain several surface attributes. A sky shader without the skybox or cloud layers would look like this:

{
	surfaceParm nolightmap
	surfaceParm noimpact
	surfaceParm sky

	q3map_sun ? ? ? ? ? ? // optional
	q3map_surfaceLight ? // optional

	qer_editorimage textures/mysky.tga
}

The three surfaceParms make the sky surface behave like a sky. The optional q3maps add extra behaviour in the form of a sun and some surface lighting.

Skybox
A skybox simulates a sky by drawing a cube around the player with texture maps on the inside faces. The cube is drawn so that the player is always at the center of the cube, and the rest of the level is drawn in front of the cube faces. The skybox shows through surfaces with a surfaceParm sky. For a more detailed explanation see the skyParms attribute.

Note: the Quake2 sky was a skybox.

{
	surfaceParm nolightmap
	surfaceParm noimpact
	surfaceParm sky

	qer_editorimage textures/mysky.tga

	skyParms env/space - -
}

This shader is the same as the basic sky shader except for the new skyParms attribute.

Cloud Layer
A cloud layer simulates a sky by texturing a sort of squashed sphere around the player in a similar way to a skybox. The difference is that the parts of the sphere close to the ground plane are not drawn, giving a HOM effect if they are visible. Also, the apparent height of the cloud layer is adjustable.

Note: the Quake1 sky was a cloud layer.

This shader adds a scrolling cloud layer to the basic sky. The 512 in the skyParms attribute sets the height of the cloud layer.

{
surfaceParm nolightmap
surfaceParm noimpact
surfaceParm sky

qer_editorimage textures/mysky.tga

skyParms - 512 -

{
map textures/skies/inteldimclouds.tga
tcMod scroll 0.15 0.15
}
}

This shader adds an extra, transparent layer of clouds. It does this by using an additive (GL_ONE GL_ONE) blend. Note that if more than one stage is used the first map must have a depthWrite attribute.

{
surfaceParm nolightmap
surfaceParm noimpact
surfaceParm sky

qer_editorimage textures/mysky.tga

skyParms - 512 -

{
map textures/skies/inteldimclouds.tga
tcMod scroll 0.15 0.15
depthWrite
}
{
map textures/skies/intelredclouds.tga
tcMod scroll 0.05 0.05
blendFunc add
}
}

Combining Skyboxes And Cloud Layers
To combine cloud layers and skyboxes just make sure all the cloud layers are partly transparent. For example:

{
	surfaceParm nolightmap
	surfaceParm noimpact
	surfaceParm sky

	q3map_sun ? ? ? ? ? ? // optional
	q3map_surfaceLight ? // optional

	qer_editorimage textures/mysky.tga

	skyParms env/space 512 -

	{
		map textures/skies/intelredclouds.tga
		tcMod scroll 0.05 0.05
		blendFunc add
	}
}

(sock) #3

Drakir, with a reply like that this thread needs to be including in the top sticky thread for reference. Excellent reply. :drink:

Sock
:moo:


(shazmax) #4

I understand that - the website is:
http://www.sikstrom.nu/rikard/tuts/examples.html#i3.5

But what exactly does this error mean?

Gtk-CRITICAL **: file gtktextbuffer.c: line 543 (gtk_text_buffer_emit_insert): assertion `g_utf8_validate (text, len, NULL)’ failed


(ratty redemption) #5

you need to save your custom shader files in plain text, if your not already doing that.


(shazmax) #6

Hehehehe -
Quote from above:

“Does this have to do with how I saved it or??? I’ve tried saving it both in Ansii and in UTF 8, in notepad and in wordpad…same thing. Here’s the sample code I’m trying to slowly work on: …”

Ah I figured it out - I had one last thing in mind.

Make sure this darn box is checked under edit, preferences…


(shazmax) #7

The issue happened when I tried to shift + left click on the image texture in gtkradiant to bring up the shader window to make sure it was working correctly. So for those out there that get some freaky error like this when they do that -

Gtk-CRITICAL **: file gtktextbuffer.c: line 543 (gtk_text_buffer_emit_insert): assertion `g_utf8_validate (text, len, NULL)’ failed

Under the console - that’s why.

I’m gonna be like 60 when I figure all of this stuff out. Thnx though guyz - and thnx Drakir for the info. I stumbled acrossed the site and its been a great help for me for the shader information.


(ratty redemption) #8

not trying to confuse matters, but I have replaced the win98se notepad.exe with the more advanced notepadex.exe which I use for all my shader editing, but for some reason gtkradiant won`t load it up when that pref box is checked, so I have it running in the background and just switch between radiant and notepadex.

I dont like the default gtk shader editor as it shows some null characters in my shaders which dont show up in wordpad or notepadex.

and yeah, that is a good post by Drakir and I`d forgotten about sky shaders needing depthWrite on the first stage, if there are more layers blended… iirc it is something to do with some gfx cards having buggy optimizing code for drawing sky shaders, is that right?


(subimp25) #9

(subimp25) #10

(kamikazee) #11

What are you trying to do???


(FireFly) #12

I guess he’s checking if the ‘Quote’ button still works :smiley:


(subimp25) #13

(subimp25) #14

(Shaderman) #15

Or checking out the moderators patience…


(kamikazee) #16

/callvote hen_admin “removed posts”


(subimp25) #17

(subimp25) #18