User talk:Necolatis

From FlightGear wiki
Jump to navigation Jump to search

Model-combined shader issues

Hi, I've noticed that you've posted on the forums some issue with the model-combined* effects. Could you tell/show me what the desired effect was, what was the transparency setting for the glass material (in the .ac file)? (I'm the main author of those shaders)

The shader used is the same between the effects, the difference is how they are assigned to the various render-bins and the transparency hint, so that you don't get weird culling issues with objects behind the transparent ones, and so that it's properly handled by Rembrandt.

Using the non transparent variant will cause various issues across the board. (dissapearing bits of models behind the glass object, rainbow model in rembrandt, etc. )

I4dnf (talk) 09:23, 19 May 2014 (UTC)


Sure. First off, I did not test the transparency in Rembrandt yet. But it looks to work in normal and ALS.

I am not entirely satisfied yet, but getting this to work was a big step.

I have not discovered any issues with using it this way yet, but I did take the renderbin from the transparency effect, forgot to mention that in the forum-post.

MATERIAL "glassMat" rgb 0.8000 0.8000 0.8000 amb 0.0 0.0 0.0 emis 0.0000 0.0000 0.0000 spec 1.0000 1.0000 1.0000 shi 128 trans 0.5000

<!--ja37-glass-combined.eff-->
<PropertyList>
 <name>Effects/ja37-glass-combined</name>
 <inherits-from>Effects/model-combined-deferred</inherits-from>
 <parameters>
   <normalmap-enabled type="int">0</normalmap-enabled>
   <reflection-enabled type="int">1</reflection-enabled>
   <reflection-correction type="float">-0.5</reflection-correction><!-- -.5 -->
   <reflection-fresnel type="float">0</reflection-fresnel><!-- 0 -->
   <reflection-rainbow type="float">0.5</reflection-rainbow><!-- .25 -->
   <reflection-noise type="float">0.0</reflection-noise>
   <shade-model>smooth</shade-model>
   <texture n="2">
     <image>Aircraft/JA37/Models/Effects/ja37-glass-specular.png</image>
     <filter>linear</filter>
     <wrap-s>repeat</wrap-s>
     <wrap-t>repeat</wrap-t>
     <internal-format>normalized</internal-format>
   </texture>
   <texture n="5">
     <type>cubemap</type>
     <images>
       <positive-x>Aircraft/JA37/Models/Effects/ja37-glass-reflect.png</positive-x>
       <negative-x>Aircraft/JA37/Models/Effects/ja37-glass-reflect.png</negative-x>
       <positive-y>Aircraft/JA37/Models/Effects/ja37-glass-reflect.png</positive-y>
       <negative-y>Aircraft/JA37/Models/Effects/ja37-glass-reflect.png</negative-y>
       <positive-z>Aircraft/JA37/Models/Effects/ja37-glass-reflect.png</positive-z>
       <negative-z>Aircraft/JA37/Models/Effects/ja37-glass-reflect.png</negative-z>
     </images>
   </texture>
   <texture n="7">
     <image>Aircraft/Generic/Effects/Rainbow.png</image>
     <filter>linear-mipmap-linear</filter>
     <wrap-s>repeat</wrap-s>
     <wrap-t>repeat</wrap-t>
     <internal-format>normalized</internal-format>
   </texture>
   <!--WARNING: Do not edit below this line -->
    <!-- ####################
    ### TRANSPARENCY INCLUDE ###
    ######################### -->
      <rendering-hint>transparent</rendering-hint>
      <transparent>true</transparent>
      <render-bin>
        <bin-number>10</bin-number>
        <bin-name>DepthSortedBin</bin-name>
      </render-bin>
    <!-- ########################
    ### END TRANSPARENCY INCLUDE ###
    ############################# -->
 </parameters>
</PropertyList>

Necolatis (talk) 11:09, 19 May 2014 (UTC)


Just tested it in Rembrandt, it has a rainbow all over the screen.

:(

Necolatis (talk) 11:13, 19 May 2014 (UTC)


Yes, because you have only half-compatibility with rembrandt. Also, overriding texture n="7" is a bad idea. That is the old format, the new format has the fresnel and rainbow gradients in the same texture. In fact copying and duplicating the defaults in the local effect is a bad idea. Just copy those parameters you want to change from the defaults.
In the meantime try this:
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
    <name>ja37-glass-combined</name>
		<inherits-from>Effects/model-combined-transparent</inherits-from>
		<parameters>
			<normalmap-enabled type="int">0</normalmap-enabled>
			<lightmap-enabled type="int">0</lightmap-enabled>
			<reflection-enabled type="int">1</reflection-enabled>
			<reflection-correction type="float">-0.5</reflection-correction>
			<reflect-map-enabled type="int">0</reflect-map-enabled>
			<reflection-fresnel type="float">0.0</reflection-fresnel>
			<reflection-rainbow type="float">0.5</reflection-rainbow>
			<reflection-noise type="float">0.0</reflection-noise>
			<reflection-dynamic type="int">1</reflection-dynamic>
			<texture n="2">
				<image>Models/Effects/ja37-glass-specular.png</image>
				<filter>linear</filter>
				<wrap-s>repeat</wrap-s>
				<wrap-t>repeat</wrap-t>
				<internal-format>normalized</internal-format>
			</texture>
			<texture n="5">
				<type>cubemap</type>
				<images>
					<positive-x>Models/Effects/ja37-glass-reflect.png</positive-x>
					<negative-x>Models/Effects/ja37-glass-reflect.png</negative-x>
					<positive-y>Models/Effects/ja37-glass-reflect.png</positive-y>
					<negative-y>Models/Effects/ja37-glass-reflect.png</negative-y>
					<positive-z>Models/Effects/ja37-glass-reflect.png</positive-z>
					<negative-z>Models/Effects/ja37-glass-reflect.png</negative-z>
				</images>
			</texture>
			<rendering-hint>transparent</rendering-hint>
			<transparent>true</transparent>
			<render-bin>
				<bin-number>111</bin-number>
				<bin-name>DepthSortedBin</bin-name>
			</render-bin>
		</parameters>
</PropertyList>
BTW1: you'll notice that I've changed the paths so they are relative to the $aircraft folder. That way you are free to rename the aircraft folder without having to edit all the files containing hardcoded paths.
BTW2: shi of 128 is a bit high for glass/perspex. It gives you a very concentrated specular highlight. You might want to try values between 32 and 64.
I4dnf (talk) 11:47, 19 May 2014 (UTC)
Your suggestion works for ALS, but for Rembrandt and normal it just applies what looks to be the fixed pipeline. (I had same problem) I could solve it by using your suggestion for ALS, and combined-transparent for Rembrandt and model-reflect for the fixed.
I used to have the paths relative until a Linux user complained and then I changed all paths to be non-relative, but it probably works for shaders if you say it, so will keep it, thanks.
As for the shininess, I looked at pictures of the aircraft and the diameter of the specular spot, to make it match, it might be a little too high but not much I think, the cockpit glass of a fighter jet is highly polished and therefore give a small specular spot. But I will go back and check it.
Thank you for helping.
Necolatis (talk) 12:16, 19 May 2014 (UTC)
for Rembrandt and normal it just applies what looks to be the fixed pipeline
Ha, that's the issue. make sure you have the Model shader slider enabled. If you have it and still have the same issue, is there a way I can check the model myself ?
I4dnf (talk) 12:25, 19 May 2014 (UTC)
BTW:3 If the <texture n="2"> has a plain, uniform, full opaque alpha channel, then you don't need it. You only need that if you plan to change the amount of specular shown based on features in the texture. For a highly polished jet canopy most likely you don't want it.
I would also remove the <texture n="5"> and rely on the default cube-map, instead of using the same texture repeated 6 times. There are also a couple of other cube-maps to select from in Aircraft/Generic/Effects, but default should do just fine.
I.E. this simplified effect should do the job:
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
   <name>ja37-glass-combined</name>
   <inherits-from>Effects/model-combined-transparent</inherits-from>
   <parameters>
        <normalmap-enabled type="int">0</normalmap-enabled>
	<lightmap-enabled type="int">0</lightmap-enabled>
	<reflection-enabled type="int">1</reflection-enabled>
	<reflection-correction type="float">-0.5</reflection-correction>
	<reflect-map-enabled type="int">0</reflect-map-enabled>
	<reflection-fresnel type="float">0.0</reflection-fresnel>
	<reflection-rainbow type="float">0.5</reflection-rainbow>
	<reflection-noise type="float">0.0</reflection-noise>
	<reflection-dynamic type="int">1</reflection-dynamic>
	<rendering-hint>transparent</rendering-hint>
	<transparent>true</transparent>
	<render-bin>
		<bin-number>111</bin-number>
		<bin-name>DepthSortedBin</bin-name>
	</render-bin>
    </parameters>
</PropertyList>
I4dnf (talk) 12:32, 19 May 2014 (UTC)
The model sliders is on full when I test it, sorry. Yes, you can check it, Will post reply here when I have one uploaded that has the issue. Should be today.
Yes, my texture 2 is that, nice to know I can skip it. :)
I do not want the default texture 5, it has a different ground textures. Mine is blue/whitish sky color all around. So I don't reflect green ground when I am over white mountains etc.
Necolatis (talk) 19:34, 19 May 2014 (UTC)
I made a mistake when copying the file, I was again using model-transparent. When fixing it it works for normal pipeline also. In rembrandt it still has the rainbow though, but I can just apply a different shader for Rembrandt.
And btw. about the specular spot I remember now that the 128 value is adjusted for fixed pipeline without shader, since I think most is using that anyway, so that should dictate when the shininess should be, even though with shaders applied it might get a bit too small as you said. Maybe I can make a material animation that changes the value when a shader is applied, I will have to look into that.
Necolatis (talk) 19:51, 19 May 2014 (UTC)