Porting Mirko's Ravers Nature for ATi

Started by
85 comments, last by vincoof 21 years, 1 month ago
I still need to translate TSBM, but I think that all other register combiner code is translated.

I can not compile it because I don''t have VC.NET and when I try to compile it with VC6 it''s a real mess, so I gave up. But apart from syntax errors (errare humanun est!) this code should at least compile. Then it should work except you probably have to take care of fog and/or color sum stage. I don''t know if I''ve been clear about that point. Feel free to ask for explanations if I didn''t.

About initialization, first of all you should know that fragment shaders are not compiled into display list but can be bound like textures and created like display lists. That is, you should "compile" the shader once (just like you "compile" a display list once) and then "bind" it at every frame (just like you "bind" a texture every frame).

For instance, in the initialization part, there could be :

  fragmentshader = glGenFragmentShadersATI(1);glBindFragmentShaderATI(fragmentshader);glBeginFragmentShaderATI();/* write a shader here */glEndFragmentShaderATI();  


then each frame you just have to bind that shader :

  glBindFragmentShaderATI(fragmentshader);  


This idea is very simple.
However, I don''t know if your code is "ready" for that. I think it is, but obviously you know it better than me !
Advertisement
And I forgot the most important : enable or disable it with glEnable/Disable(GL_FRAGMENT_SHADER_ATI) just like you would do it with glEnable/Disable(GL_REGISTER_COMBINERS_NV).
OK, I understand it works like texture objects. That's nice (better then NV RC). As for fog. I don't actualy use gl fog. I do my own (so I can also have ground fog). I also added option do not use VAR for terrain geometry (works at about 40% of original speed if it's disabled, so I'll add VAO support when I get time = not right now). I should have working verison of mouantains scene by the end of the day. shader has been modified now I only have to write all the extension loading/ function binding (wglGetProcAddress)... and there is alot of it as I've seen extension documentation...

[edit] : I've have a question. I use glSetFragmentShaderConstantATI( GL_CON_1_ATI, sunColor.c ); and then "compile" the shader. That's OK if sunColor is always the same. But I need to change it each frame. So I need to compile fragment shader each frame. right?


You should never let your fears become the boundaries of your dreams.

[edited by - _DarkWIng_ on February 12, 2003 5:00:51 AM]
You should never let your fears become the boundaries of your dreams.
no, constants can be set without recompiling the shader..

can, or should?:D

btw, if you want, you can try out GL_ATI_text_fragment_shader instead of GL_ATI_fragment_shader. same hw support, but the usage similar to GL_ARB_fragment_program, and so, quite sweet.. and code is much simpler to write..

and then, there could be a GL_ARB_fragment_program implementation.. doing so much much more shading effects.. or so:D

i''m drifting off...

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

vincoof : Here 0.01 beta verison of demo with ATi fragment shaders. It''s only the first terrain scene.. just for test.. if this works I''ll fix the rest...

http://www2.arnes.si\~uteran\RaversNature_ATi.rar

look at log file to see what extensions were loaded. there should be a line "ATi code-path supported" or something like that if it works...

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
I''m sorry but I could have also posted the code that initializes function pointers. I already have it !

Fragment shader constants can either be local or global. The specification details it explicitly :
quote:
/* Paragraph describing SetFragmentShaderConstantATI */
Calls to this
function which occur inside a shader definition are automatically
bound when the shader is bound. This means that shader constants
have scope: if SetFragmentShaderConstantATI is called outside a
shader definition, it is bound globally. However, if that same
shader constant is set inside the shader, it overrides the global
definition when bound.

So, as davepermen wrote, you don''t need to compile the shader at each frame.

I''m sorry but I can''t uncompress recent rar files (at best I can see the file name and size!). Please zip it instead.

davepermen : I already thought of ATI_text_fragment_shader since it seemed the best solution IMO, but I have the most recent drivers and still the extension is not supported on my Radeon8500. So I think ATI_fragment_shader remains the only reasonable solution for fragment shading with Radeon 8000 series.

BTW, if anyone knows ever OpenGL shading capabilities for Radeon 7000 series, I''d be glad to know which one.
http://www2.arnes.si\~uteran\RaversNature_ATi.zip



You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Thanks, but... my system hanged ! The terrain was rendered (not sure if it was good, I've seen it 2-3 seconds) then black screen.
*reboot*

log file :

    File open at 15:44:04  02/12/03-----------------------------------------------------------------* Logging Class by Mirko Teran-Ravnikar* Created for Unity2 Engine----------------------------------------------------------------- - Initializing window - DirectInput initiation... - OpenGL system info :  - Renderer : Radeon 8500 DDR x86/SSE - Vendor : ATI Technologies Inc. - Verison : 1.3.3602 Win2000 Release - Extentions : GL_ARB_multitexture GL_EXT_texture_env_add GL_EXT_compiled_vertex_array GL_S3_s3tcGL_ARB_point_parameters GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_mapGL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3GL_ARB_texture_mirrored_repeat GL_ARB_transpose_matrix GL_ARB_vertex_blend GL_ARB_vertex_programGL_ARB_window_pos GL_ATI_element_array GL_ATI_envmap_bumpmap GL_ATI_fragment_shaderGL_ATI_map_object_buffer GL_ATI_pn_triangles GL_ATI_texture_env_combine3 GL_ATI_texture_mirror_onceGL_ATI_vertex_array_object GL_ATI_vertex_attrib_array_object GL_ATI_vertex_streamsGL_ATIX_texture_env_combine3 GL_ATIX_texture_env_route GL_ATIX_vertex_shader_output_point_sizeGL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_func_separate GL_EXT_blend_minmaxGL_EXT_blend_subtract GL_EXT_clip_volume_hint GL_EXT_draw_range_elements GL_EXT_fog_coordGL_EXT_multi_draw_arrays GL_EXT_packed_pixels GL_EXT_point_parameters GL_EXT_rescale_normalGL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_stencil_wrap GL_EXT_texgen_reflectionGL_EXT_texture3D GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clampGL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_EXT_texture_object GL_EXT_texture_rectangle GL_EXT_vertex_array GL_EXT_vertex_shaderGL_HP_occlusion_test GL_KTX_buffer_region GL_NV_texgen_reflection GL_NV_blend_square GL_NV_occlusion_queryGL_SGI_color_matrix GL_SGI_texture_edge_clamp GL_SGIS_texture_border_clamp GL_SGIS_texture_lodGL_SGIS_generate_mipmap GL_SGIS_multitexture GL_SUN_multi_draw_arrays GL_WIN_swap_hintWGL_EXT_extensions_string WGL_EXT_swap_control <!> Point Sprites NOT supported.<!> NV Register Combiners NOT supported.<!> NV VAR not supported : using system memory. - Loading TrueType fonts from Arial - ATi code-path supported - Loading ARB vertex program: VP\TerrainBasic.ARBVP - Cache allocated in system memory at address 0DAB0024 - Terrain heightmap generated in 407.792ms - Creating QuadTree structure...(depth = 6) - QuadTree build in 1.87842ms - Demo Maneger stats:   - 1) Sunrise   (19s)   - Total demo loop : 19s - Init sequence complete...    

ATi code path is supported.

I'll try to take a screenshot next time I run it (and hopefully quit before reboot).

[edit : cut the extensions string which was messing up the page]

[edited by - vincoof on February 12, 2003 10:49:26 AM]
Thanks. I''ll try to find out what could reboot yout system. That''s wierd. What OS are you using?

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Oops I've just seen a little mistake that *may* cause crashing. I wonder how you could compile, however.
The shader UShaderTerrain::InitRegComBasePass may be replaced by :

         glBeginFragmentShaderATI();     // Pass 1     glSampleMapATI(GL_REG_0_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI);     glSampleMapATI(GL_REG_1_ATI, GL_TEXTURE1_ARB, GL_SWIZZLE_STR_ATI);     // reg2 = TexBase*bias + TexSlope*(1-bias)     glColorFragmentOp3ATI(GL_LERP_ATI, GL_REG_2_ATI, GL_NONE, GL_NONE,                           GL_PRIMARY_COLOR_ARB, GL_ALPHA, GL_NONE,                           GL_REG_0_ATI, GL_NONE, GL_NONE,                           GL_REG_1_ATI, GL_NONE, GL_NONE);     // reg1 = fogFactor^2     glColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_1_ATI, GL_NONE, GL_SATURATE_BIT_ATI,                           GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_COMP_BIT_ATI,                           GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_COMP_BIT_ATI);     // reg0 = texture * sunColor     glColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                           GL_REG_2_ATI, GL_NONE, GL_NONE,                           GL_CON_1_ATI, GL_NONE, GL_NONE);     // reg0 = texture * sunColor * color = terrain     glColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                           GL_REG_0_ATI, GL_NONE, GL_NONE,                           GL_PRIMARY_COLOR_ARB, GL_NONE, GL_NONE);     // final color = fogColor * fog + terrain * (1-fog)     glColorFragmentOp3ATI(GL_LERP_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,                           GL_SECONDARY_INTERPOLATOR_ATI, GL_NONE, GL_NONE,                           GL_CON_0_ATI, GL_NONE, GL_NONE,                           GL_REG_0_ATI, GL_NONE, GL_NONE);     // alpha = fogFactor^2     glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,                           GL_REG_1_ATI, GL_BLUE, GL_NONE);     glEndFragmentShaderATI();      

You still have to send in constants, even though I've not written them this time.

I'm using a Radeon8500 (with latest drivers installed of course) and the OS is Win2000.
The black screen appears after 2/3 seconds only. That is, the start of the scene (fade from black) looks fine but instantly after that I get a black screen. Is there anything special you call when the scene "really starts" (ie after fading from black) ?

Also, I've tried to setup an invalid vertex program and the hang disappears, but I have no terrain obviously and everything else is fine (the sun and text) so I guess that terrain is the one who's causing hang/crash/freeze/whatever.

[edited by - vincoof on February 12, 2003 12:04:36 PM]

This topic is closed to new replies.

Advertisement