Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 507 508 [509] 510 511 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 908645 times)

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7620 on: July 27, 2015, 02:23:17 am »

Well I haven't actually tried to make a custom shader yet, I hadn't needed to until now since all the existing ones have failed for this task.

I have some simple example shaders I downloaded that are meant to do the job, but don't actually render the colors, and I have the code from the Unity shaders that do render the colors, but have tearing in my images, and they are a mass of gibberish that I can't read at all since I have no idea what all the assembly code is doing. So i don't really know where to start here.

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7621 on: July 27, 2015, 02:26:09 am »

This is the shader I'm using for custom colors:

Code: [Select]
Shader "Custom/ArmokStandardPBR" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "grey" {}
_BumpMap ("Normalmap (RGB) Occlusion (A)", 2D) = "bump" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200

CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard

// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0

sampler2D _MainTex;
sampler2D _Shapetex;
sampler2D _BumpMap;

struct Input {
float2 uv_MainTex;
float2 uv2_BumpMap;
float4 color: Color; // Vertex color
};

half _Glossiness;
fixed4 _Color;

void surf (Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
fixed4 b = tex2D (_BumpMap, IN.uv2_BumpMap);
//o.Albedo = c.rgb * IN.color.rgb;
o.Albedo = c.rgb < 0.5 ? (2.0 * c.rgb * IN.color.rgb) : (1.0 - 2.0 * (1.0 - c.rgb) * (1.0 - IN.color.rgb));
o.Metallic = 1.0 - IN.color.a;
o.Smoothness = b.b;
o.Occlusion = b.r;
o.Normal = UnpackNormal(b.ggga);
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}

It's very customized for my purposes, but it does work.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7622 on: July 27, 2015, 02:31:47 am »

My terrain is still brown when I use that. I can only get the colors appearing with a number of Unity's shaders.

Maybe I an doing something wrong when I am specifying the vertex colors somehow?

I'm creating a standard Mesh, then creating vertices, uv, triangles and color arrays, and linking them all to the mesh. Mind you I only started working on this at 1am last night.

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7623 on: July 27, 2015, 02:39:06 am »

Are you using your own mesh, or a unity terrain?

and I wasn't suggesting you use that shader specifically, I was just giving an example.

For this shader to work, you need the diffuse map to be close to grey, and the vertex color alpha channel changes metalness.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7624 on: July 27, 2015, 02:49:33 am »

I'm using a mesh I'm generating in code, then attaching this to the MeshFilter component. 99.9% of it is working fine except for the colors thing, which is only working for a select few Unity filters, which are glitchy. Every custom shader I've tried so far gives the same results: my terrain renders fine, with lighting etc, but no vertex colors appearing.

So, I'm using the colors32 structure since this was suggested as more efficient, and I know for a fact that the colors are getting into the pipeline, but I have no idea why it's not working for shaders that say it should work.

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7625 on: July 27, 2015, 02:57:58 am »

You mentioned that it's appearing brown. What texture is going into the diffuse slot?
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7626 on: July 27, 2015, 03:12:05 am »

Well that was a grainy light brown sand I was using as a sort of bump map.

But it seems I've found a shader I can use after clicking a lot of random links from other links.

"ColorMaterial AmbientAndDiffuse" was the bit the other examples were missing. After creating a simple shader with that as the only instruction, I now how the vertex colors appearing, no tearing or depth problems anymore. So that fixes one problem. Now I just need to add back in control of lighting and texture overlay and it's done.

EDIT: And because I found "ColorMaterial AmbientAndDiffuse" I can now google that term thank god, and it's linking me to the other stuff I need to know. It turns out that the whole shebang was in Unity under "ShaderLab: Legacy Lighting"

Ok, I'm done with the basic experiment now, i have vertex color, lighting and detail texture all combining. It's still kind of ugly, but here's the screenshot:
Spoiler (click to show/hide)
« Last Edit: July 27, 2015, 03:28:56 am by Reelya »
Logged

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7627 on: August 06, 2015, 08:53:51 am »

anyone here still playing screeps? I backed it but it turned out too braniac to play and I have a shortage of time, so first to pm me will get my cpu coupon kthnxby
Coupon gone!

oh, and I did my very first open source thingy! https://cdn.rawgit.com/lookcast/Glitter.js/master/index.html
« Last Edit: August 06, 2015, 10:21:10 pm by LoSboccacc »
Logged

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #7628 on: August 06, 2015, 09:26:04 pm »

I just spent about 15 minutes typing up a question to ask in this thread, stopping after every assertion I made in my description of the problem when I realized it might not be true, testing the assertion, narrowing down my idea of the problem as a result, and then deleting that part of the post. I deleted the entire post this way and answered my own question.

I think I'll add "write fake forum post" to my list of debug tools now.
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7629 on: August 06, 2015, 11:45:33 pm »

anyone here still playing screeps? I backed it but it turned out too braniac to play and I have a shortage of time, so first to pm me will get my cpu coupon kthnxby
Coupon gone!

oh, and I did my very first open source thingy! https://cdn.rawgit.com/lookcast/Glitter.js/master/index.html
Quote
The library supports tons of cool looping and timing options that user go crrrraaaazy for
"user" should be plural.

Other than that, that's some nice tech there.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #7630 on: August 07, 2015, 12:04:59 am »

I like the shiny green text.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7631 on: August 07, 2015, 12:08:09 am »

i like how it's not ugly as hell

seriously that's actually really impressive

i do not make sarcastic compliments

the previous statement was not sarcastic nor is this one

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #7632 on: August 07, 2015, 01:14:30 am »

$20 says Putnam's being sarcastic.

...

/s
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7633 on: August 07, 2015, 02:53:55 am »

anyone here still playing screeps? I backed it but it turned out too braniac to play and I have a shortage of time, so first to pm me will get my cpu coupon kthnxby
Coupon gone!

oh, and I did my very first open source thingy! https://cdn.rawgit.com/lookcast/Glitter.js/master/index.html
Quote
The library supports tons of cool looping and timing options that user go crrrraaaazy for
"user" should be plural.

Other than that, that's some nice tech there.

thanks! fixed typo it seems to drive all people crazy, also figured out how to support css transform and transitions so there is one more level of coolness:
https://cdn.rawgit.com/lookcast/Glitter.js/62641a5f346faa2894673ecef55dcf7714ba73a8/index.html
Logged

karhell

  • Bay Watcher
  • [IS_A_MOLPY]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7634 on: August 07, 2015, 03:55:25 am »

I just spent about 15 minutes typing up a question to ask in this thread, stopping after every assertion I made in my description of the problem when I realized it might not be true, testing the assertion, narrowing down my idea of the problem as a result, and then deleting that part of the post. I deleted the entire post this way and answered my own question.

I think I'll add "write fake forum post" to my list of debug tools now.
Explaining your code to an imaginary friend is another way to do that, and works pretty well too.
Glad you solved your problem ^^
Logged
Pages: 1 ... 507 508 [509] 510 511 ... 796