Urban Terror Forums: How to parse shaders? - Urban Terror Forums

Jump to content

 Login | Register 
Advertisement
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to parse shaders? Rate Topic: -----

#1 User is offline   n4w4k Icon

  • Account: n4w4k
  • Main tag: chic.
  • Joined: 05-August 12
  • Posts: 24

Posted 28 February 2014 - 06:03 PM

Hello,

I'm creating a software with C# language for making pk3s and I can't find a way for parsing shaders. I've tried to use Regex but I think its kinda heavy, ANTLR for generating a complete parser but I can't find help for writing the grammar. Do you know a good evolutive way for doing it or any library?

#2 User is offline   NulL Icon

  •   former FS member   
    Level Designer
  • Account: null
  • Country:
  • Joined: 28-April 09
  • Posts: 2,606

Posted 28 February 2014 - 06:44 PM

Look in tr_shader.c of the quake3 engine source. ParseShader especially.

https://github.com/B...rer/tr_shader.c

#3 User is offline   n4w4k Icon

  • Account: n4w4k
  • Main tag: chic.
  • Joined: 05-August 12
  • Posts: 24

Posted 28 February 2014 - 07:54 PM

Oh nice! I'm not a C expert but I think I can translate it. Thx for your answer NulL.

#4 User is offline   n4w4k Icon

  • Account: n4w4k
  • Main tag: chic.
  • Joined: 05-August 12
  • Posts: 24

Posted 08 March 2014 - 07:10 AM

Hai!

I've finally explorated more ANTLR and now I'm able to parse shaders entirely. I've made some tests with some shaders and I got a problem with the deformVertexes normal directive. In the shader I have (for making flags), the directive is called with only 2 parameters instead of 5 like in the shader manual.

Is the manual wrong or not updated?

Here is the shader:

textures/test/flag
{
	qer_editorimage "textures/test/flag.tga"
	q3map_globaltexture
	deformVertexes wave 100 sin 4 3 0 0.3
	deformVertexes wave 30 sin 0 3 0 .8
	deformVertexes normal .3 .2
	surfaceparm alphashadow
	cull none
	{
		map "textures/test/flag.tga"
		blendfunc GL_ONE GL_ZERO
		alphafunc GE128
		rgbGen identity
		rgbGen const ( 1.0 1.0 1.0 )
		depthwrite
	}
	{
		map $lightmap
		rgbGen identity
		blendFunc GL_DST_COLOR GL_ZERO
		depthFunc equal
	}
}


Another question, in the manual there is no q3map_fancywater reference. Where can I find an full list of every directive?

#5 User is offline   NulL Icon

  •   former FS member   
    Level Designer
  • Account: null
  • Country:
  • Joined: 28-April 09
  • Posts: 2,606

Posted 08 March 2014 - 08:58 AM

I can only remember ever using deformvertexes normal once (many years ago), but in that shader it had two params.

bullet_loaderAdvertisement

#6 User is offline   n4w4k Icon

  • Account: n4w4k
  • Main tag: chic.
  • Joined: 05-August 12
  • Posts: 24

Posted 15 March 2014 - 08:40 PM

Finally I added the directive :)

I found an other one: light + int (or float?) in the azurea's script:

textures/azurea_a2_sfx/s128-01wc
{
	qer_editorimage textures/azurea_a2_trim/s128-01c.tga
	q3map_lightimage textures/azurea_a2_sfx/s128-01b.blend.tga
	light 1
	surfaceparm nomarks
	{
		map $lightmap
		rgbGen identity
	}
	{
		map textures/azurea_a2_trim/s128-01c.tga
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen identity
	}
	{
		map textures/azurea_a2_sfx/s128-01b.blend.tga
		blendfunc GL_ONE GL_ONE
		rgbGen wave sin .3 .1 0 0.5
	}
}


Does anyone have any information on it?

#7 User is offline   NulL Icon

  •   former FS member   
    Level Designer
  • Account: null
  • Country:
  • Joined: 28-April 09
  • Posts: 2,606

Posted 16 March 2014 - 08:33 AM

Just light on its own? I don't think that's valid shader keyword, at least not in quake3.

#8 User is offline   n4w4k Icon

  • Account: n4w4k
  • Main tag: chic.
  • Joined: 05-August 12
  • Posts: 24

Posted 16 March 2014 - 09:14 AM

Well, gsigms is a FS mapper and I read somewhere azurea was a map test for some new directives. Moreover, I found that parser where there are some directives that I didn't know. So I guess I should add them..

#9 User is offline   Fenix Icon

  •   former FS member   
  • Account: fenix
  • Country:
  • Joined: 06-December 10
  • Posts: 425

Posted 16 March 2014 - 11:27 AM

View Postn4w4k, on 16 March 2014 - 09:14 AM, said:

Moreover, I found that parser where there are some directives that I didn't know. So I guess I should add them..

That is from the 27's iobumpy engine so not all the stuff will work on a vanilla engine

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

Advertisement


Copyright © 1999-2024 Frozensand Games Limited  |  All rights reserved  |  Urban Terror™ and FrozenSand™ are trademarks of Frozensand Games Limited

Frozensand Games is a Limited company registered in England and Wales. Company Reg No: 10343942